Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit25ac1a3

Browse files
committed
setup validator schema
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent8490cec commit25ac1a3

File tree

2 files changed

+315
-0
lines changed

2 files changed

+315
-0
lines changed

‎src/utils/schema/index.ts

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
importmetafrom"./meta";
2+
3+
exportdefault{
4+
...meta,
5+
type:"object",
6+
properties:{
7+
version:{
8+
$ref:"#/definitions/semantic_version",
9+
description:"The tutorial version. Must be unique for the tutorial.",
10+
examples:["0.1.0","1.0.0"],
11+
},
12+
13+
// summary
14+
summary:{
15+
type:"object",
16+
properties:{
17+
title:{
18+
$ref:"#/definitions/title",
19+
description:"The title of tutorial",
20+
},
21+
description:{
22+
type:"string",
23+
description:"A summary of the the tutorial",
24+
minLength:10,
25+
maxLength:400,
26+
},
27+
},
28+
additionalProperties:false,
29+
required:["title","description"],
30+
},
31+
32+
// config
33+
config:{
34+
type:"object",
35+
properties:{
36+
testRunner:{
37+
type:"object",
38+
description:"The test runner configuration",
39+
properties:{
40+
command:{
41+
type:"string",
42+
description:"Command line to start the test runner",
43+
examples:["./node_modules/.bin/mocha"],
44+
},
45+
args:{
46+
type:"object",
47+
description:
48+
"A configuration of command line args for your test runner",
49+
properties:{
50+
filter:{
51+
type:"string",
52+
description:
53+
"the command line arg for filtering tests with a regex pattern",
54+
examples:["--grep"],
55+
},
56+
tap:{
57+
type:"string",
58+
description:
59+
"The command line arg for configuring a TAP reporter. See https://github.com/sindresorhus/awesome-tap for examples.",
60+
examples:["--reporter=mocha-tap-reporter"],
61+
},
62+
},
63+
additionalProperties:false,
64+
required:["tap"],
65+
},
66+
directory:{
67+
type:"string",
68+
description:"An optional folder for the test runner",
69+
examples:["coderoad"],
70+
},
71+
setup:{
72+
type:"object",
73+
$ref:"#/definitions/setup_action",
74+
description:
75+
"Setup commits or commands used for setting up the test runner on tutorial launch",
76+
},
77+
},
78+
required:["command","args"],
79+
},
80+
repo:{
81+
type:"object",
82+
description:"The repo holding the git commits for the tutorial",
83+
properties:{
84+
uri:{
85+
type:"string",
86+
description:"The uri source of the tutorial",
87+
format:"uri",
88+
examples:["https://github.com/name/tutorial-name.git"],
89+
},
90+
branch:{
91+
description:
92+
"The branch of the repo where the tutorial config file exists",
93+
type:"string",
94+
examples:["master"],
95+
},
96+
},
97+
additionalProperties:false,
98+
required:["uri","branch"],
99+
},
100+
},
101+
dependencies:{
102+
type:"array",
103+
description:"A list of tutorial dependencies",
104+
items:{
105+
type:"object",
106+
properties:{
107+
name:{
108+
type:"string",
109+
description:
110+
"The command line process name of the dependency. It will be checked by running `name --version`",
111+
examples:["node","python"],
112+
},
113+
version:{
114+
type:"string",
115+
description:
116+
"The version requirement. See https://github.com/npm/node-semver for options",
117+
examples:[">=10"],
118+
},
119+
},
120+
required:["name","version"],
121+
},
122+
},
123+
appVersions:{
124+
type:"object",
125+
description:
126+
"A list of compatable coderoad versions. Currently only a VSCode extension.",
127+
properties:{
128+
vscode:{
129+
type:"string",
130+
description:
131+
"The version range for coderoad-vscode that this tutorial is compatable with",
132+
examples:[">=0.7.0"],
133+
},
134+
},
135+
},
136+
additionalProperties:false,
137+
required:["testRunner","repo"],
138+
},
139+
140+
// levels
141+
levels:{
142+
type:"array",
143+
description:
144+
'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',
145+
items:{
146+
type:"object",
147+
properties:{
148+
title:{
149+
$ref:"#/definitions/title",
150+
description:"A title for the level",
151+
},
152+
summary:{
153+
type:"string",
154+
description:"A high-level summary of the level",
155+
maxLength:250,
156+
},
157+
content:{
158+
type:"string",
159+
description:"Content for a tutorial written as Markdown",
160+
},
161+
setup:{
162+
$ref:"#/definitions/setup_action",
163+
description:
164+
"An optional point for loading commits, running commands or opening files",
165+
},
166+
steps:{
167+
type:"array",
168+
items:{
169+
type:"object",
170+
properties:{
171+
content:{
172+
type:"string",
173+
description:
174+
"The text displayed explaining information about the current task, written as markdown",
175+
},
176+
setup:{
177+
allOf:[
178+
{
179+
$ref:"#/definitions/setup_action",
180+
description:
181+
"A point for loading commits. It can also run commands and/or open files",
182+
},
183+
{
184+
required:["commits"],
185+
},
186+
],
187+
},
188+
solution:{
189+
allOf:[
190+
{
191+
$ref:"#/definitions/setup_action",
192+
description:
193+
"The solution commits that can be loaded if the user gets stuck. It can also run commands and/or open files",
194+
},
195+
{
196+
required:["commits"],
197+
},
198+
],
199+
},
200+
},
201+
required:["content","setup","solution"],
202+
},
203+
},
204+
},
205+
required:["title","description","content"],
206+
},
207+
minItems:1,
208+
},
209+
},
210+
additionalProperties:false,
211+
required:["version","summary","config","levels"],
212+
};

‎src/utils/schema/meta.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
exportdefault{
2+
$schema:"http://json-schema.org/draft-07/schema#",
3+
$id:"http://coderoad.io/tutorial_version.schema.json",
4+
title:"Tutorial Version",
5+
description:
6+
"A CodeRoad tutorial version. This JSON data is converted into a tutorial with the CodeRoad editor extension",
7+
definitions:{
8+
semantic_version:{
9+
type:"string",
10+
description:
11+
'A semantic version, such as "1.0.0". Learn more at https://semver.org/',
12+
pattern:"^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$",
13+
minLength:5,
14+
maxLength:14,
15+
examples:["0.1.0","1.0.0"],
16+
},
17+
sha1_hash:{
18+
type:"string",
19+
description:"A SHA1 hash created by Git",
20+
pattern:"^[0-9a-f]{5,40}$",
21+
minLength:5,
22+
maxLength:40,
23+
},
24+
title:{
25+
type:"string",
26+
minLength:1,
27+
maxLength:40,
28+
},
29+
file_path:{
30+
type:"string",
31+
description:"A path to a file",
32+
pattern:"(\\\\?([^\\/]*[\\/])*)([^\\/]+)$",
33+
minLength:4,
34+
examples:["src/file.js"],
35+
},
36+
file_array:{
37+
type:"array",
38+
description:
39+
"An array of files which will be opened by the editor when entering the level or step",
40+
items:{
41+
$ref:"#/definitions/file_path",
42+
uniqueItems:true,
43+
},
44+
},
45+
command_array:{
46+
type:"array",
47+
description:
48+
"An array of command line commands that will be called when the user enters the level or step. Currently commands are limited for security purposes",
49+
items:{
50+
type:"string",
51+
enum:["npm install"],
52+
},
53+
},
54+
commit_array:{
55+
type:"array",
56+
description:
57+
"An array of git commits which will be loaded when the level/step or solution is loaded",
58+
items:{
59+
$ref:"#/definitions/sha1_hash",
60+
uniqueItems:true,
61+
},
62+
minItems:1,
63+
},
64+
setup_action:{
65+
type:"object",
66+
description:
67+
"A collection of files/commits/commands that run when a level/step or solution is loaded",
68+
properties:{
69+
files:{
70+
$ref:"#/definitions/file_array",
71+
},
72+
commits:{
73+
$ref:"#/definitions/commit_array",
74+
},
75+
commands:{
76+
$ref:"#/definitions/command_array",
77+
},
78+
watchers:{
79+
type:"array",
80+
description:
81+
"An array file paths that, when updated, will trigger the test runner to run",
82+
items:{
83+
$ref:"#/definitions/file_path",
84+
uniqueItems:true,
85+
},
86+
},
87+
filter:{
88+
type:"string",
89+
description:
90+
"A regex pattern that will be passed to the test runner to limit the number of tests running",
91+
examples:["^TestSuiteName"],
92+
},
93+
subtasks:{
94+
type:"boolean",
95+
description:
96+
'A feature that shows subtasks: all active test names and the status of the tests (pass/fail). Use together with "filter"',
97+
examples:[true],
98+
},
99+
},
100+
additionalProperties:false,
101+
},
102+
},
103+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp