@@ -15,16 +15,11 @@ required_tool() {
15
15
die " $1 is required but not installed. Please install it and make sure it's in your PATH."
16
16
}
17
17
required_tool jq
18
- required_tool curl
19
18
20
19
[[ -f ./bin/fetch-configlet ]] || die " run this script from the repo's root directory."
21
20
22
21
slug=" ${1} "
23
22
24
- # transform slug 'resistor-color-duo' to name 'Resistor Color Duo'
25
- IFS=- read -ra words <<< " ${slug}"
26
- name=${words[*]^}
27
-
28
23
it_exists=$(
29
24
jq --arg slug " ${slug} " '
30
25
.exercises.practice
@@ -34,54 +29,17 @@ it_exists=$(
34
29
)
35
30
[[ ${it_exists} == false ]] || die " ${slug} already exists in config.json"
36
31
37
- # Add entry for exercise in config.json
38
- ./bin/fetch-configlet
39
- jq --arg slug " ${slug} " \
40
- --arg uuid " $( ./bin/configlet uuid) " \
41
- --arg name " ${name} " \
42
- '
43
- .exercises.practice += [
44
- {
45
- slug: $slug,
46
- name: $name,
47
- uuid: $uuid,
48
- practices: [],
49
- prerequisites: [],
50
- difficulty: 1
51
- }
52
- ]
53
- ' config.json > config.json.tmp \
54
- && mv config.json.tmp config.json
55
-
56
- # Sync the exercise
57
- ./bin/configlet sync --update --yes \
58
- --tests include \
59
- --metadata \
60
- --docs \
61
- --exercise " ${slug} "
62
-
63
- touch " exercises/practice/${slug} /.meta/example.jq"
64
-
65
- echo ' "Remove this line and implement your solution" | halt_error' > " exercises/practice/${slug} /${slug} .jq"
32
+ ./bin/fetch-configlet || die " cannot fetch configlet"
66
33
67
- echo
68
34
read -rp ' Your github username: ' author
69
- conf=" exercises/practice/${slug} /.meta/config.json"
70
- jq --arg slug " ${slug} " \
71
- --arg author " ${author} " \
72
- '
73
- .authors = [$author] |
74
- .files = {
75
- solution: [$slug + ".jq"],
76
- test: ["test-\($slug).bats"],
77
- example: [".meta/example.jq"]
78
- }
79
- ' " ${conf} " > " ${conf} .tmp" \
80
- && mv " ${conf} .tmp" " ${conf} "
35
+
36
+ ./bin/configlet create --practice-exercise " ${slug} " --author " ${author} "
37
+
38
+ echo ' "Remove this line and implement your solution" | halt_error' > " exercises/practice/${slug} /${slug} .jq"
81
39
82
40
cp -pt exercises/practice/" ${slug} " lib/bats-* .bash
83
41
84
- ./bin/generate_tests " ${slug} "
42
+ ./bin/generate_tests " ${slug} " || true
85
43
86
44
echo
87
45
find " exercises/practice/${slug} " -type f -ls
0 commit comments