From 316b0354dc51aef70d1e2aca5af47a0e7fe21873 Mon Sep 17 00:00:00 2001 From: shmck Date: Thu, 25 Jun 2020 08:50:42 -0700 Subject: [PATCH 1/3] no-validate Signed-off-by: shmck --- src/build.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/build.ts b/src/build.ts index cd7dbc2..c243713 100644 --- a/src/build.ts +++ b/src/build.ts @@ -25,6 +25,7 @@ type BuildArgs = { markdown: string; yaml: string; output: string; + noValidate: boolean; }; async function build(args: string[]) { @@ -41,6 +42,8 @@ async function build(args: string[]) { // -o --output - default coderoad.json const output = getArg(args, { name: "output", alias: "o" }) || "tutorial.json"; + const noValidate = + getArg(args, { name: "no-validate", alias: "nv" }) !== "false"; console.log(`Building CodeRoad ${output}...`); @@ -49,6 +52,7 @@ async function build(args: string[]) { output, markdown, yaml, + noValidate, }; } catch (e) { console.error("Error parsing build logs"); @@ -139,10 +143,14 @@ async function build(args: string[]) { // validate tutorial based on tutorial json schema try { - const valid = validateSchema(tutorialSchema, tutorial); - if (!valid) { - console.error("Tutorial validation failed. See above to see what to fix"); - return; + if (!options.noValidate) { + const valid = validateSchema(tutorialSchema, tutorial); + if (!valid) { + console.error( + "Tutorial validation failed. See above to see what to fix" + ); + return; + } } } catch (e) { console.error("Error validating tutorial schema:"); From c965ff438a16578a286d2ca7077b49030b46fbe6 Mon Sep 17 00:00:00 2001 From: shmck Date: Fri, 26 Jun 2020 19:31:14 -0700 Subject: [PATCH 2/3] block tutorial validation Signed-off-by: shmck --- src/build.ts | 13 +++++++------ src/help.ts | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/build.ts b/src/build.ts index c243713..988f1ec 100644 --- a/src/build.ts +++ b/src/build.ts @@ -25,7 +25,7 @@ type BuildArgs = { markdown: string; yaml: string; output: string; - noValidate: boolean; + validate: boolean; }; async function build(args: string[]) { @@ -42,8 +42,9 @@ async function build(args: string[]) { // -o --output - default coderoad.json const output = getArg(args, { name: "output", alias: "o" }) || "tutorial.json"; - const noValidate = - getArg(args, { name: "no-validate", alias: "nv" }) !== "false"; + const validate = getArg(args, { name: "validate", alias: "v" }) !== "false"; + + console.log("validate", validate); console.log(`Building CodeRoad ${output}...`); @@ -52,7 +53,7 @@ async function build(args: string[]) { output, markdown, yaml, - noValidate, + validate, }; } catch (e) { console.error("Error parsing build logs"); @@ -143,13 +144,13 @@ async function build(args: string[]) { // validate tutorial based on tutorial json schema try { - if (!options.noValidate) { + if (options.validate) { const valid = validateSchema(tutorialSchema, tutorial); if (!valid) { console.error( "Tutorial validation failed. See above to see what to fix" ); - return; + // continue rather than exiting early } } } catch (e) { diff --git a/src/help.ts b/src/help.ts index f61a301..5b9523b 100644 --- a/src/help.ts +++ b/src/help.ts @@ -47,6 +47,7 @@ Usage: coderoad validate [path] [options] Options: --help (-h) display these help docs +--validate (-v) run tutorial schema validation. Default is true, set to false to block validation. --clean (-c) set to false to preserve .tmp folder. Helpful for debugging More docs at https://github.com/coderoad/coderoad-cli`); From 62de1ba0c8dc0e2f94234316a4e0c45cea69e953 Mon Sep 17 00:00:00 2001 From: shmck Date: Fri, 26 Jun 2020 19:33:39 -0700 Subject: [PATCH 3/3] show defaults in help Signed-off-by: shmck --- src/help.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/help.ts b/src/help.ts index 5b9523b..5cbc637 100644 --- a/src/help.ts +++ b/src/help.ts @@ -32,10 +32,10 @@ export function build() { Usage: coderoad build [path] [options] Options: ---help (-h) display these help docs ---markdown (-m) custom path to the tutorial markdown file (TUTORIAL.md) ---yaml (-y) custom path to the tutorial yaml file (coderoad.yaml) ---output (-o) custom path to tutorial json config file (coderoad.json) +--help (-h) display these help docs +--markdown (-m) (TUTORIAL.md) custom path to the tutorial markdown file +--yaml (-y) (coderoad.yaml) custom path to the tutorial yaml file +--output (-o) (coderoad.json) custom path to tutorial json config file More docs at https://github.com/coderoad/coderoad-cli`); } @@ -46,9 +46,9 @@ export function validate() { Usage: coderoad validate [path] [options] Options: ---help (-h) display these help docs ---validate (-v) run tutorial schema validation. Default is true, set to false to block validation. ---clean (-c) set to false to preserve .tmp folder. Helpful for debugging +--help (-h) display these help docs +--validate (-v) (true) run tutorial schema validation. Set to false to block validation. +--clean (-c) (false) set to false to preserve .tmp folder. Helpful for debugging More docs at https://github.com/coderoad/coderoad-cli`); }