Skip to content

breaking - changes to testRunner.setup #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coderoad/cli",
"version": "0.5.1",
"version": "0.6.0",
"description": "A CLI to build the configuration file for Coderoad Tutorials",
"keywords": [
"coderoad",
Expand All @@ -15,8 +15,9 @@
"url": "git+https://github.com/coderoad/coderoad-cli.git"
},
"license": "SEE LICENSE IN LICENSE.md",
"author": "Argemiro Neto",
"author": "Shawn McKay",
"contributors": [
"Argemiro Neto",
"Shawn McKay"
],
"files": [
Expand Down
22 changes: 22 additions & 0 deletions src/schema/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ export default {
type: "string",
},
},
vscode_command_array: {
type: "array",
description:
"An array of VSCode commands that can be called using the vscode commands API.",
items: {
anyOf: [
{
type: "string",
description: "A VSCode command without params",
},
{
type: "array",
description: "A VSCode command with params",
minLength: 2,
maxLength: 2,
},
],
},
},
commit_array: {
type: "array",
description:
Expand Down Expand Up @@ -105,6 +124,9 @@ export default {
commands: {
$ref: "#/definitions/command_array",
},
vscodeCommands: {
$ref: "#/definitions/vscode_command_array",
},
watchers: {
type: "array",
items: {
Expand Down
30 changes: 21 additions & 9 deletions src/schema/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,25 @@ export default {
description: "An optional folder for the test runner",
examples: ["coderoad"],
},
setup: {
$ref: "#/definitions/setup_action_without_commits",
description:
"Setup actions or commands used for setting up the test runner on tutorial launch",
},
},
required: ["command", "args"],
},
setup: {
type: "object",
description:
"Setup commits or commands used for setting up the test runner on tutorial launch",
properties: {
commits: {
$ref: "#/definitions/commit_array",
},
commands: {
$ref: "#/definitions/command_array",
},
vscodeCommands: {
$ref: "#/definitions/vscode_command_array",
},
},
},
repo: {
type: "object",
description: "The repo holding the git commits for the tutorial",
Expand All @@ -84,10 +95,11 @@ export default {
type: "object",
description: "Configuration options for resetting a tutorial",
properties: {
command: {
type: "string",
description: "An optional command to run on reset",
examples: ["npm install"],
commands: {
$ref: "#/definitions/command_array",
},
vscodeCommands: {
$ref: "#/definitions/vscode_command_array",
},
},
additionalProperties: false,
Expand Down
30 changes: 21 additions & 9 deletions src/schema/tutorial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,25 @@ export default {
description: "An optional folder for the test runner",
examples: ["coderoad"],
},
setup: {
$ref: "#/definitions/setup_action",
description:
"Setup commits or commands used for setting up the test runner on tutorial launch",
},
},
required: ["command", "args"],
},
setup: {
type: "object",
description:
"Setup commits or commands used for setting up the test runner on tutorial launch",
properties: {
commits: {
$ref: "#/definitions/commit_array",
},
commands: {
$ref: "#/definitions/command_array",
},
vscodeCommands: {
$ref: "#/definitions/vscode_command_array",
},
},
},
repo: {
type: "object",
description: "The repo holding the git commits for the tutorial",
Expand All @@ -103,10 +114,11 @@ export default {
type: "object",
description: "Configuration options for resetting a tutorial",
properties: {
command: {
type: "string",
description: "An optional command to run on reset",
examples: ["npm install"],
commands: {
$ref: "#/definitions/command_array",
},
vscodeCommands: {
$ref: "#/definitions/vscode_command_array",
},
},
additionalProperties: false,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export function parse(params: ParseParams): any {
// add init commits
if (params.commits.INIT && params.commits.INIT.length) {
// @ts-ignore
parsed.config.testRunner.setup = {
...(parsed.config?.testRunner?.setup || {}),
parsed.config.setup = {
...(parsed.config?.setup || {}),
commits: params.commits.INIT,
};
}
Expand Down
8 changes: 2 additions & 6 deletions src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,10 @@ async function validate(args: string[]) {
await cherryPick(commits.INIT);

// run commands
if (skeleton.config?.testRunner?.setup?.commands) {
if (skeleton.config?.setup?.commands) {
console.info("-- Running commands...");

await runCommands(
skeleton.config?.testRunner?.setup?.commands,
// add optional setup directory
skeleton.config?.testRunner?.directory
);
await runCommands(skeleton.config?.setup?.commands);
}
}

Expand Down
22 changes: 11 additions & 11 deletions tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,9 @@ Description.
tap: "--reporter=mocha-tap-reporter",
},
directory: "coderoad",
setup: {
commands: [],
},
},
setup: {
commands: [],
},
appVersions: {
vscode: ">=0.7.0",
Expand All @@ -999,7 +999,7 @@ Description.
branch: "aBranch",
},
reset: {
command: "some command",
commands: ["some command"],
},
dependencies: [
{
Expand All @@ -1026,16 +1026,16 @@ Description.
tap: "--reporter=mocha-tap-reporter",
},
directory: "coderoad",
setup: {
commands: [],
},
},
setup: {
commands: [],
},
repo: {
uri: "https://path.to/repo",
branch: "aBranch",
},
reset: {
command: "some command",
commands: ["some command"],
},
dependencies: [
{
Expand Down Expand Up @@ -1101,9 +1101,9 @@ Description.
tap: "--reporter=mocha-tap-reporter",
},
directory: "coderoad",
setup: {
commits: ["abcdef1", "123456789"],
},
},
setup: {
commits: ["abcdef1", "123456789"],
},
repo: {
uri: "https://path.to/repo",
Expand Down
7 changes: 4 additions & 3 deletions tests/skeleton.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ const validJson = {
config: {
testRunner: {
directory: "coderoad",
setup: {
commands: [],
},

args: {
filter: "--grep",
tap: "--reporter=mocha-tap-reporter",
},
command: "./node_modules/.bin/mocha",
},
setup: {
commands: [],
},
repo: {
uri: "http://github.com/somePath/toRepo.git",
branch: "codeBranch",
Expand Down
8 changes: 4 additions & 4 deletions tests/tutorial.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const validJson: Partial<T.Tutorial> = {
tap: "tap",
},
directory: "coderoad",
setup: {
commits: ["abcdef1"],
commands: ["npm install"],
},
},
setup: {
commits: ["abcdef1"],
commands: ["npm install"],
},
repo: {
uri: "https://github.com/some-repo.git",
Expand Down
2 changes: 1 addition & 1 deletion typings/tutorial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type TutorialConfig = {
repo: TutorialRepo;
dependencies?: TutorialDependency[];
reset?: ConfigReset;
setup?: StepActions;
};

/** Logical groupings of tasks */
Expand Down Expand Up @@ -69,7 +70,6 @@ export interface TestRunnerConfig {
command: string;
args: TestRunnerArgs;
directory?: string;
setup?: StepActions;
}

export interface TutorialRepo {
Expand Down