Skip to content

Validate/schema #9

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
May 31, 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
23 changes: 13 additions & 10 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"author": "Argemiro Neto",
"license": "ISC",
"dependencies": {
"ajv": "^6.12.2",
"arg": "^4.1.3",
"esm": "^3.2.25",
"inquirer": "^7.1.0",
Expand All @@ -31,6 +32,7 @@
},
"devDependencies": {
"@babel/preset-typescript": "^7.10.1",
"@types/ajv": "^1.0.0",
"@types/inquirer": "^6.5.0",
"@types/jest": "^25.2.3",
"@types/js-yaml": "^3.12.4",
Expand Down
2 changes: 1 addition & 1 deletion src/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ncp from "ncp";
import ncp from "ncp";
import * as path from "path";
import { promisify } from "util";

Expand Down
212 changes: 212 additions & 0 deletions src/utils/schema/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
import meta from "./meta";

export default {
...meta,
type: "object",
properties: {
version: {
$ref: "#/definitions/semantic_version",
description: "The tutorial version. Must be unique for the tutorial.",
examples: ["0.1.0", "1.0.0"],
},

// summary
summary: {
type: "object",
properties: {
title: {
$ref: "#/definitions/title",
description: "The title of tutorial",
},
description: {
type: "string",
description: "A summary of the the tutorial",
minLength: 10,
maxLength: 400,
},
},
additionalProperties: false,
required: ["title", "description"],
},

// config
config: {
type: "object",
properties: {
testRunner: {
type: "object",
description: "The test runner configuration",
properties: {
command: {
type: "string",
description: "Command line to start the test runner",
examples: ["./node_modules/.bin/mocha"],
},
args: {
type: "object",
description:
"A configuration of command line args for your test runner",
properties: {
filter: {
type: "string",
description:
"the command line arg for filtering tests with a regex pattern",
examples: ["--grep"],
},
tap: {
type: "string",
description:
"The command line arg for configuring a TAP reporter. See https://github.com/sindresorhus/awesome-tap for examples.",
examples: ["--reporter=mocha-tap-reporter"],
},
},
additionalProperties: false,
required: ["tap"],
},
directory: {
type: "string",
description: "An optional folder for the test runner",
examples: ["coderoad"],
},
setup: {
type: "object",
$ref: "#/definitions/setup_action",
description:
"Setup commits or commands used for setting up the test runner on tutorial launch",
},
},
required: ["command", "args"],
},
repo: {
type: "object",
description: "The repo holding the git commits for the tutorial",
properties: {
uri: {
type: "string",
description: "The uri source of the tutorial",
format: "uri",
examples: ["https://github.com/name/tutorial-name.git"],
},
branch: {
description:
"The branch of the repo where the tutorial config file exists",
type: "string",
examples: ["master"],
},
},
additionalProperties: false,
required: ["uri", "branch"],
},
},
dependencies: {
type: "array",
description: "A list of tutorial dependencies",
items: {
type: "object",
properties: {
name: {
type: "string",
description:
"The command line process name of the dependency. It will be checked by running `name --version`",
examples: ["node", "python"],
},
version: {
type: "string",
description:
"The version requirement. See https://github.com/npm/node-semver for options",
examples: [">=10"],
},
},
required: ["name", "version"],
},
},
appVersions: {
type: "object",
description:
"A list of compatable coderoad versions. Currently only a VSCode extension.",
properties: {
vscode: {
type: "string",
description:
"The version range for coderoad-vscode that this tutorial is compatable with",
examples: [">=0.7.0"],
},
},
},
additionalProperties: false,
required: ["testRunner", "repo"],
},

// levels
levels: {
type: "array",
description:
'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',
items: {
type: "object",
properties: {
title: {
$ref: "#/definitions/title",
description: "A title for the level",
},
summary: {
type: "string",
description: "A high-level summary of the level",
maxLength: 250,
},
content: {
type: "string",
description: "Content for a tutorial written as Markdown",
},
setup: {
$ref: "#/definitions/setup_action",
description:
"An optional point for loading commits, running commands or opening files",
},
steps: {
type: "array",
items: {
type: "object",
properties: {
content: {
type: "string",
description:
"The text displayed explaining information about the current task, written as markdown",
},
setup: {
allOf: [
{
$ref: "#/definitions/setup_action",
description:
"A point for loading commits. It can also run commands and/or open files",
},
{
required: ["commits"],
},
],
},
solution: {
allOf: [
{
$ref: "#/definitions/setup_action",
description:
"The solution commits that can be loaded if the user gets stuck. It can also run commands and/or open files",
},
{
required: ["commits"],
},
],
},
},
required: ["content", "setup", "solution"],
},
},
},
required: ["title", "description", "content"],
},
minItems: 1,
},
},
additionalProperties: false,
required: ["version", "summary", "config", "levels"],
};
Loading