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

Commit7a66cb7

Browse files
committed
setup validate
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent2b2ddd6 commit7a66cb7

File tree

5 files changed

+78
-14
lines changed

5 files changed

+78
-14
lines changed

‎src/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as util from "util";
66
import{parse}from"./utils/parse";
77
import{getArg}from"./utils/args";
88
import{getCommits,CommitLogObject}from"./utils/commits";
9-
import{validateSchema}from"./utils/validate";
9+
import{validateSchema}from"./utils/validateSchema";
1010
import*asTfrom"../typings/tutorial";
1111

1212
constwrite=util.promisify(fs.writeFile);

‎src/cli.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import"./utils/logs";
22
importbuildfrom"./build";
33
importcreatefrom"./create";
4-
import{help,createascreateHelp,buildasbuildHelp}from"./help";
4+
importvalidatefrom"./validate";
5+
import*ashelpfrom"./help";
56

67
exportasyncfunctioncli(rawArgs:string[]):Promise<void>{
78
constcommand:string=rawArgs[2];
@@ -16,23 +17,31 @@ export async function cli(rawArgs: string[]): Promise<void> {
1617

1718
case"build":
1819
if(args.length&&["--help","-h"].includes(args[0])){
19-
buildHelp();
20+
help.build();
2021
return;
2122
}
2223
build(args);
2324
break;
2425

2526
case"create":
2627
if(args.length&&["--help","-h"].includes(args[0])){
27-
createHelp();
28+
help.create();
2829
return;
2930
}
3031
create(args);
3132
break;
3233

34+
case"validate":
35+
if(args.length&&["--help","-h"].includes(args[0])){
36+
help.validate();
37+
return;
38+
}
39+
validate(args);
40+
break;
41+
3342
case"--help":
3443
case"-h":
3544
default:
36-
help();
45+
help.main();
3746
}
3847
}

‎src/help.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
exportfunctionhelp(){
1+
exportfunctionmain(){
22
console.log(`
3+
CodeRoad CLI
34
Usage: coderoad [options]
45
56
Options:
67
--help (-h) display these help docs
78
--version (-v) show coderoad cli version
89
create start a new tutorial from a template
910
build generate a coderoad.json file from markdown and yaml
11+
validate run a variety of tests to ensure a tutorial works as intended
1012
11-
More docs at https://github.com/coderoad/coderoad-cli
12-
`);
13+
More docs at https://github.com/coderoad/coderoad-cli`);
1314
}
1415

1516
exportfunctioncreate(){
16-
console.log(`
17+
console.log(`Create a new CodeRoad tutorial project from a template.
18+
1719
Usage: coderoad create [path] [options]
1820
1921
Options:
2022
--help (-h) display these help docs
2123
--lang (-l) programming language for template
2224
--testRunner (-t) test runner module for template
2325
24-
More docs at https://github.com/coderoad/coderoad-cli
25-
`);
26+
More docs at https://github.com/coderoad/coderoad-cli`);
2627
}
2728

2829
exportfunctionbuild(){
29-
console.log(`
30+
console.log(`Compile a coderoad.json file from markdown & yaml.
31+
3032
Usage: coderoad build [path] [options]
3133
3234
Options:
@@ -35,6 +37,16 @@ Options:
3537
--yaml (-y) custom path to the tutorial yaml file (coderoad.yaml)
3638
--output (-o) custom path to tutorial json config file (coderoad.json)
3739
38-
More docs at https://github.com/coderoad/coderoad-cli
39-
`);
40+
More docs at https://github.com/coderoad/coderoad-cli`);
41+
}
42+
43+
exportfunctionvalidate(){
44+
console.log(`Validates commits and tests across a tutorial.
45+
46+
Usage: coderoad validate [path] [options]
47+
48+
Options:
49+
--help (-h) display these help docs
50+
51+
More docs at https://github.com/coderoad/coderoad-cli`);
4052
}
File renamed without changes.

‎src/validate.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
asyncfunctionvalidate(args:string[]){
2+
// dir - default .
3+
constdir=!args.length||args[0].match(/^-/) ?"." :args[0];
4+
console.warn("Not yet implemented. Coming soon");
5+
return;
6+
7+
// setup .tmp directory
8+
// git clone branch
9+
10+
// VALIDATE SKELETON WITH COMMITS
11+
// parse tutorial skeleton for order and commands
12+
13+
// on error, warn missing level/step
14+
15+
// VALIDATE COMMIT ORDER
16+
// list all commits in order
17+
// validate that a level number doesn't come before another level
18+
// validate that a step falls within a level
19+
// validate that steps are in order
20+
21+
// on error, show level/step out of order
22+
23+
// VALIDATE TUTORIAL TESTS
24+
// load INIT commit(s)
25+
// run test runner setup command(s)
26+
// loop over commits:
27+
// - load level commit
28+
// - run level setup command(s)
29+
// - load step setup commit(s)
30+
// - run step setup command(s)
31+
// - if next solution:
32+
// - run test - expect fail
33+
// - if solution
34+
// - run test - expect pass
35+
36+
// log level/step
37+
// on error, show level/step & error message
38+
39+
// CLEANUP
40+
// finally: remove .tmp directory
41+
}
42+
43+
exportdefaultvalidate;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp