Skip to content

Commit ac117e2

Browse files
authored
Merge pull request #70 from coderoad/testRunner-setup
breaking - changes to testRunner.setup
2 parents a0daa57 + 2847cb3 commit ac117e2

11 files changed

+92
-48
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coderoad/cli",
3-
"version": "0.5.1",
3+
"version": "0.6.0",
44
"description": "A CLI to build the configuration file for Coderoad Tutorials",
55
"keywords": [
66
"coderoad",
@@ -15,8 +15,9 @@
1515
"url": "git+https://github.com/coderoad/coderoad-cli.git"
1616
},
1717
"license": "SEE LICENSE IN LICENSE.md",
18-
"author": "Argemiro Neto",
18+
"author": "Shawn McKay",
1919
"contributors": [
20+
"Argemiro Neto",
2021
"Shawn McKay"
2122
],
2223
"files": [

src/schema/meta.ts

+22
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ export default {
4747
type: "string",
4848
},
4949
},
50+
vscode_command_array: {
51+
type: "array",
52+
description:
53+
"An array of VSCode commands that can be called using the vscode commands API.",
54+
items: {
55+
anyOf: [
56+
{
57+
type: "string",
58+
description: "A VSCode command without params",
59+
},
60+
{
61+
type: "array",
62+
description: "A VSCode command with params",
63+
minLength: 2,
64+
maxLength: 2,
65+
},
66+
],
67+
},
68+
},
5069
commit_array: {
5170
type: "array",
5271
description:
@@ -105,6 +124,9 @@ export default {
105124
commands: {
106125
$ref: "#/definitions/command_array",
107126
},
127+
vscodeCommands: {
128+
$ref: "#/definitions/vscode_command_array",
129+
},
108130
watchers: {
109131
type: "array",
110132
items: {

src/schema/skeleton.ts

+21-9
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,25 @@ export default {
5252
description: "An optional folder for the test runner",
5353
examples: ["coderoad"],
5454
},
55-
setup: {
56-
$ref: "#/definitions/setup_action_without_commits",
57-
description:
58-
"Setup actions or commands used for setting up the test runner on tutorial launch",
59-
},
6055
},
6156
required: ["command", "args"],
6257
},
58+
setup: {
59+
type: "object",
60+
description:
61+
"Setup commits or commands used for setting up the test runner on tutorial launch",
62+
properties: {
63+
commits: {
64+
$ref: "#/definitions/commit_array",
65+
},
66+
commands: {
67+
$ref: "#/definitions/command_array",
68+
},
69+
vscodeCommands: {
70+
$ref: "#/definitions/vscode_command_array",
71+
},
72+
},
73+
},
6374
repo: {
6475
type: "object",
6576
description: "The repo holding the git commits for the tutorial",
@@ -84,10 +95,11 @@ export default {
8495
type: "object",
8596
description: "Configuration options for resetting a tutorial",
8697
properties: {
87-
command: {
88-
type: "string",
89-
description: "An optional command to run on reset",
90-
examples: ["npm install"],
98+
commands: {
99+
$ref: "#/definitions/command_array",
100+
},
101+
vscodeCommands: {
102+
$ref: "#/definitions/vscode_command_array",
91103
},
92104
},
93105
additionalProperties: false,

src/schema/tutorial.ts

+21-9
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,25 @@ export default {
7171
description: "An optional folder for the test runner",
7272
examples: ["coderoad"],
7373
},
74-
setup: {
75-
$ref: "#/definitions/setup_action",
76-
description:
77-
"Setup commits or commands used for setting up the test runner on tutorial launch",
78-
},
7974
},
8075
required: ["command", "args"],
8176
},
77+
setup: {
78+
type: "object",
79+
description:
80+
"Setup commits or commands used for setting up the test runner on tutorial launch",
81+
properties: {
82+
commits: {
83+
$ref: "#/definitions/commit_array",
84+
},
85+
commands: {
86+
$ref: "#/definitions/command_array",
87+
},
88+
vscodeCommands: {
89+
$ref: "#/definitions/vscode_command_array",
90+
},
91+
},
92+
},
8293
repo: {
8394
type: "object",
8495
description: "The repo holding the git commits for the tutorial",
@@ -103,10 +114,11 @@ export default {
103114
type: "object",
104115
description: "Configuration options for resetting a tutorial",
105116
properties: {
106-
command: {
107-
type: "string",
108-
description: "An optional command to run on reset",
109-
examples: ["npm install"],
117+
commands: {
118+
$ref: "#/definitions/command_array",
119+
},
120+
vscodeCommands: {
121+
$ref: "#/definitions/vscode_command_array",
110122
},
111123
},
112124
additionalProperties: false,

src/utils/parse.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ export function parse(params: ParseParams): any {
153153
// add init commits
154154
if (params.commits.INIT && params.commits.INIT.length) {
155155
// @ts-ignore
156-
parsed.config.testRunner.setup = {
157-
...(parsed.config?.testRunner?.setup || {}),
156+
parsed.config.setup = {
157+
...(parsed.config?.setup || {}),
158158
commits: params.commits.INIT,
159159
};
160160
}

src/validate.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,10 @@ async function validate(args: string[]) {
7474
await cherryPick(commits.INIT);
7575

7676
// run commands
77-
if (skeleton.config?.testRunner?.setup?.commands) {
77+
if (skeleton.config?.setup?.commands) {
7878
console.info("-- Running commands...");
7979

80-
await runCommands(
81-
skeleton.config?.testRunner?.setup?.commands,
82-
// add optional setup directory
83-
skeleton.config?.testRunner?.directory
84-
);
80+
await runCommands(skeleton.config?.setup?.commands);
8581
}
8682
}
8783

tests/parse.test.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -987,9 +987,9 @@ Description.
987987
tap: "--reporter=mocha-tap-reporter",
988988
},
989989
directory: "coderoad",
990-
setup: {
991-
commands: [],
992-
},
990+
},
991+
setup: {
992+
commands: [],
993993
},
994994
appVersions: {
995995
vscode: ">=0.7.0",
@@ -999,7 +999,7 @@ Description.
999999
branch: "aBranch",
10001000
},
10011001
reset: {
1002-
command: "some command",
1002+
commands: ["some command"],
10031003
},
10041004
dependencies: [
10051005
{
@@ -1026,16 +1026,16 @@ Description.
10261026
tap: "--reporter=mocha-tap-reporter",
10271027
},
10281028
directory: "coderoad",
1029-
setup: {
1030-
commands: [],
1031-
},
1029+
},
1030+
setup: {
1031+
commands: [],
10321032
},
10331033
repo: {
10341034
uri: "https://path.to/repo",
10351035
branch: "aBranch",
10361036
},
10371037
reset: {
1038-
command: "some command",
1038+
commands: ["some command"],
10391039
},
10401040
dependencies: [
10411041
{
@@ -1101,9 +1101,9 @@ Description.
11011101
tap: "--reporter=mocha-tap-reporter",
11021102
},
11031103
directory: "coderoad",
1104-
setup: {
1105-
commits: ["abcdef1", "123456789"],
1106-
},
1104+
},
1105+
setup: {
1106+
commits: ["abcdef1", "123456789"],
11071107
},
11081108
repo: {
11091109
uri: "https://path.to/repo",

tests/skeleton.test.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ const validJson = {
88
config: {
99
testRunner: {
1010
directory: "coderoad",
11-
setup: {
12-
commands: [],
13-
},
11+
1412
args: {
1513
filter: "--grep",
1614
tap: "--reporter=mocha-tap-reporter",
1715
},
1816
command: "./node_modules/.bin/mocha",
1917
},
18+
setup: {
19+
commands: [],
20+
},
2021
repo: {
2122
uri: "http://github.com/somePath/toRepo.git",
2223
branch: "codeBranch",

tests/tutorial.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ const validJson: Partial<T.Tutorial> = {
1313
tap: "tap",
1414
},
1515
directory: "coderoad",
16-
setup: {
17-
commits: ["abcdef1"],
18-
commands: ["npm install"],
19-
},
16+
},
17+
setup: {
18+
commits: ["abcdef1"],
19+
commands: ["npm install"],
2020
},
2121
repo: {
2222
uri: "https://github.com/some-repo.git",

typings/tutorial.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type TutorialConfig = {
1010
repo: TutorialRepo;
1111
dependencies?: TutorialDependency[];
1212
reset?: ConfigReset;
13+
setup?: StepActions;
1314
};
1415

1516
/** Logical groupings of tasks */
@@ -69,7 +70,6 @@ export interface TestRunnerConfig {
6970
command: string;
7071
args: TestRunnerArgs;
7172
directory?: string;
72-
setup?: StepActions;
7373
}
7474

7575
export interface TutorialRepo {

0 commit comments

Comments
 (0)