Skip to content

Commit 85a8d12

Browse files
authored
Merge pull request #85 from coderoad/feat/webhook
Support webhook in the coderoad cli
2 parents 93d6938 + dec2296 commit 85a8d12

File tree

5 files changed

+389
-226
lines changed

5 files changed

+389
-226
lines changed

Diff for: src/schema/skeleton.ts

+152-103
Original file line numberDiff line numberDiff line change
@@ -1,208 +1,257 @@
1-
import meta from './meta'
1+
import meta from "./meta";
22

33
export default {
4-
title: 'Skeleton Schema',
4+
title: "Skeleton Schema",
55
description:
6-
'A CodeRoad tutorial config schema. This data is paired up with the markdown to create a tutorial',
6+
"A CodeRoad tutorial config schema. This data is paired up with the markdown to create a tutorial",
77
...meta,
8-
type: 'object',
8+
type: "object",
99
properties: {
1010
version: {
11-
$ref: '#/definitions/semantic_version',
12-
description: 'The tutorial version. Must be unique for the tutorial.',
13-
examples: ['0.1.0', '1.0.0']
11+
$ref: "#/definitions/semantic_version",
12+
description: "The tutorial version. Must be unique for the tutorial.",
13+
examples: ["0.1.0", "1.0.0"],
1414
},
1515

1616
// config
1717
config: {
18-
type: 'object',
18+
type: "object",
1919
properties: {
2020
testRunner: {
21-
type: 'object',
22-
description: 'The test runner configuration',
21+
type: "object",
22+
description: "The test runner configuration",
2323
properties: {
2424
command: {
25-
type: 'string',
26-
description: 'Command line to start the test runner',
27-
examples: ['./node_modules/.bin/mocha']
25+
type: "string",
26+
description: "Command line to start the test runner",
27+
examples: ["./node_modules/.bin/mocha"],
2828
},
2929
args: {
30-
type: 'object',
30+
type: "object",
3131
description:
32-
'A configuration of command line args for your test runner',
32+
"A configuration of command line args for your test runner",
3333
properties: {
3434
filter: {
35-
type: 'string',
35+
type: "string",
3636
description:
37-
'the command line arg for filtering tests with a regex pattern',
38-
examples: ['--grep']
37+
"the command line arg for filtering tests with a regex pattern",
38+
examples: ["--grep"],
3939
},
4040
tap: {
41-
type: 'string',
41+
type: "string",
4242
description:
43-
'The command line arg for configuring a TAP reporter. See https://github.com/sindresorhus/awesome-tap for examples.',
44-
examples: ['--reporter=mocha-tap-reporter']
45-
}
43+
"The command line arg for configuring a TAP reporter. See https://github.com/sindresorhus/awesome-tap for examples.",
44+
examples: ["--reporter=mocha-tap-reporter"],
45+
},
4646
},
4747
additionalProperties: false,
48-
required: ['tap']
48+
required: ["tap"],
4949
},
5050
directory: {
51-
type: 'string',
52-
description: 'An optional folder for the test runner',
53-
examples: ['coderoad']
54-
}
51+
type: "string",
52+
description: "An optional folder for the test runner",
53+
examples: ["coderoad"],
54+
},
5555
},
56-
required: ['command', 'args']
56+
required: ["command", "args"],
5757
},
5858
setup: {
59-
type: 'object',
59+
type: "object",
6060
description:
61-
'Setup commits or commands used for setting up the test runner on tutorial launch',
61+
"Setup commits or commands used for setting up the test runner on tutorial launch",
6262
properties: {
6363
commits: {
64-
$ref: '#/definitions/commit_array'
64+
$ref: "#/definitions/commit_array",
6565
},
6666
commands: {
67-
$ref: '#/definitions/command_array'
67+
$ref: "#/definitions/command_array",
6868
},
6969
vscodeCommands: {
70-
$ref: '#/definitions/vscode_command_array'
71-
}
72-
}
70+
$ref: "#/definitions/vscode_command_array",
71+
},
72+
},
7373
},
7474
repo: {
75-
type: 'object',
76-
description: 'The repo holding the git commits for the tutorial',
75+
type: "object",
76+
description: "The repo holding the git commits for the tutorial",
7777
properties: {
7878
uri: {
79-
type: 'string',
80-
description: 'The uri source of the tutorial',
81-
format: 'uri',
82-
examples: ['https://github.com/name/tutorial-name.git']
79+
type: "string",
80+
description: "The uri source of the tutorial",
81+
format: "uri",
82+
examples: ["https://github.com/name/tutorial-name.git"],
8383
},
8484
branch: {
8585
description:
86-
'The branch of the repo where the tutorial config file exists',
87-
type: 'string',
88-
examples: ['master']
89-
}
86+
"The branch of the repo where the tutorial config file exists",
87+
type: "string",
88+
examples: ["master"],
89+
},
9090
},
9191
additionalProperties: false,
92-
required: ['uri', 'branch']
92+
required: ["uri", "branch"],
9393
},
9494
reset: {
95-
type: 'object',
96-
description: 'Configuration options for resetting a tutorial',
95+
type: "object",
96+
description: "Configuration options for resetting a tutorial",
9797
properties: {
9898
commands: {
99-
$ref: '#/definitions/command_array'
99+
$ref: "#/definitions/command_array",
100100
},
101101
vscodeCommands: {
102-
$ref: '#/definitions/vscode_command_array'
103-
}
102+
$ref: "#/definitions/vscode_command_array",
103+
},
104104
},
105-
additionalProperties: false
105+
additionalProperties: false,
106106
},
107107
dependencies: {
108-
type: 'array',
109-
description: 'A list of tutorial dependencies',
108+
type: "array",
109+
description: "A list of tutorial dependencies",
110110
items: {
111-
type: 'object',
111+
type: "object",
112112
properties: {
113113
name: {
114-
type: 'string',
114+
type: "string",
115115
description:
116-
'The command line process name of the dependency. It will be checked by running `name --version`',
117-
examples: ['node', 'python']
116+
"The command line process name of the dependency. It will be checked by running `name --version`",
117+
examples: ["node", "python"],
118118
},
119119
version: {
120-
type: 'string',
120+
type: "string",
121121
description:
122-
'The version requirement. See https://github.com/npm/node-semver for options',
123-
examples: ['>=10']
124-
}
122+
"The version requirement. See https://github.com/npm/node-semver for options",
123+
examples: [">=10"],
124+
},
125125
},
126-
required: ['name', 'version']
127-
}
126+
required: ["name", "version"],
127+
},
128128
},
129129
appVersions: {
130-
type: 'object',
130+
type: "object",
131131
description:
132-
'A list of compatable coderoad versions. Currently only a VSCode extension.',
132+
"A list of compatable coderoad versions. Currently only a VSCode extension.",
133133
properties: {
134134
vscode: {
135-
type: 'string',
135+
type: "string",
136136
description:
137-
'The version range for coderoad-vscode that this tutorial is compatable with',
138-
examples: ['>=0.7.0']
139-
}
140-
}
141-
}
137+
"The version range for coderoad-vscode that this tutorial is compatable with",
138+
examples: [">=0.7.0"],
139+
},
140+
},
141+
},
142+
webhook: {
143+
type: "object",
144+
description:
145+
"An optional configuration for webhooks triggered by events such as init, step/level/tutorial complete",
146+
properties: {
147+
url: {
148+
type: "string",
149+
description: "URL for POST restful webhook request",
150+
examples: ["https://example.com/webhook"],
151+
},
152+
events: {
153+
type: "object",
154+
description: "An object of events to trigger on",
155+
properties: {
156+
init: {
157+
type: "boolean",
158+
description:
159+
"An event triggered on tutorial startup. Sends tutorialId",
160+
},
161+
reset: {
162+
type: "boolean",
163+
description:
164+
"An event triggered on reset of a tutorial. Sends tutorialId",
165+
},
166+
step_complete: {
167+
type: "boolean",
168+
description:
169+
"An event triggered on completion of a step. Sends tutorialId, levelId & stepId",
170+
},
171+
level_complete: {
172+
step_complete: {
173+
type: "boolean",
174+
description:
175+
"An event triggered on completion of a level. Sends tutorialId & levelId",
176+
},
177+
},
178+
tutorial_complete: {
179+
step_complete: {
180+
type: "boolean",
181+
description:
182+
"An event triggered on completion of a tutorial. Sends tutorialId",
183+
},
184+
},
185+
},
186+
additionalProperties: false,
187+
},
188+
},
189+
required: ["url", "events"],
190+
},
142191
},
143192
additionalProperties: false,
144-
required: ['testRunner', 'repo']
193+
required: ["testRunner", "repo"],
145194
},
146195

147196
// levels
148197
levels: {
149-
type: 'array',
198+
type: "array",
150199
description:
151200
'Levels are the stages a user goes through in the tutorial. A level may contain a group of tasks called "steps" that must be completed to proceed',
152201
items: {
153-
type: 'object',
202+
type: "object",
154203
properties: {
155204
id: {
156-
type: 'string',
157-
description: 'A level id',
158-
examples: ['1', '11']
205+
type: "string",
206+
description: "A level id",
207+
examples: ["1", "11"],
159208
},
160209
setup: {
161-
$ref: '#/definitions/setup_action_without_commits',
210+
$ref: "#/definitions/setup_action_without_commits",
162211
description:
163-
'An optional point for running actions, commands or opening files'
212+
"An optional point for running actions, commands or opening files",
164213
},
165214
steps: {
166-
type: 'array',
215+
type: "array",
167216
items: {
168-
type: 'object',
217+
type: "object",
169218
properties: {
170219
id: {
171-
type: 'string',
172-
description: 'A level id',
173-
examples: ['1.1', '11.12']
220+
type: "string",
221+
description: "A level id",
222+
examples: ["1.1", "11.12"],
174223
},
175224
setup: {
176225
allOf: [
177226
{
178-
$ref: '#/definitions/setup_action_without_commits',
227+
$ref: "#/definitions/setup_action_without_commits",
179228
description:
180-
'A point for running actions, commands and/or opening files'
181-
}
182-
]
229+
"A point for running actions, commands and/or opening files",
230+
},
231+
],
183232
},
184233
solution: {
185234
allOf: [
186235
{
187-
$ref: '#/definitions/setup_action_without_commits',
236+
$ref: "#/definitions/setup_action_without_commits",
188237
description:
189-
'The solution can be loaded if the user gets stuck. It can run actions, commands and/or open files'
238+
"The solution can be loaded if the user gets stuck. It can run actions, commands and/or open files",
190239
},
191240
{
192-
required: []
193-
}
194-
]
195-
}
241+
required: [],
242+
},
243+
],
244+
},
196245
},
197-
required: ['id']
198-
}
199-
}
246+
required: ["id"],
247+
},
248+
},
200249
},
201-
required: ['id']
250+
required: ["id"],
202251
},
203-
minItems: 1
204-
}
252+
minItems: 1,
253+
},
205254
},
206255
additionalProperties: false,
207-
required: ['version', 'config', 'levels']
208-
}
256+
required: ["version", "config", "levels"],
257+
};

0 commit comments

Comments
 (0)