- Notifications
You must be signed in to change notification settings - Fork2
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
setup validator schema
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit25ac1a38e6211ebfecb18f1df8208f36cd72d2de
There are no files selected for viewing
212 changes: 212 additions & 0 deletionssrc/utils/schema/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
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"], | ||
}; |
103 changes: 103 additions & 0 deletionssrc/utils/schema/meta.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
export default { | ||
$schema: "http://json-schema.org/draft-07/schema#", | ||
$id: "http://coderoad.io/tutorial_version.schema.json", | ||
title: "Tutorial Version", | ||
description: | ||
"A CodeRoad tutorial version. This JSON data is converted into a tutorial with the CodeRoad editor extension", | ||
definitions: { | ||
semantic_version: { | ||
type: "string", | ||
description: | ||
'A semantic version, such as "1.0.0". Learn more at https://semver.org/', | ||
pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$", | ||
minLength: 5, | ||
maxLength: 14, | ||
examples: ["0.1.0", "1.0.0"], | ||
}, | ||
sha1_hash: { | ||
type: "string", | ||
description: "A SHA1 hash created by Git", | ||
pattern: "^[0-9a-f]{5,40}$", | ||
minLength: 5, | ||
maxLength: 40, | ||
}, | ||
title: { | ||
type: "string", | ||
minLength: 1, | ||
maxLength: 40, | ||
}, | ||
file_path: { | ||
type: "string", | ||
description: "A path to a file", | ||
pattern: "(\\\\?([^\\/]*[\\/])*)([^\\/]+)$", | ||
minLength: 4, | ||
examples: ["src/file.js"], | ||
}, | ||
file_array: { | ||
type: "array", | ||
description: | ||
"An array of files which will be opened by the editor when entering the level or step", | ||
items: { | ||
$ref: "#/definitions/file_path", | ||
uniqueItems: true, | ||
}, | ||
}, | ||
command_array: { | ||
type: "array", | ||
description: | ||
"An array of command line commands that will be called when the user enters the level or step. Currently commands are limited for security purposes", | ||
items: { | ||
type: "string", | ||
enum: ["npm install"], | ||
}, | ||
}, | ||
commit_array: { | ||
type: "array", | ||
description: | ||
"An array of git commits which will be loaded when the level/step or solution is loaded", | ||
items: { | ||
$ref: "#/definitions/sha1_hash", | ||
uniqueItems: true, | ||
}, | ||
minItems: 1, | ||
}, | ||
setup_action: { | ||
type: "object", | ||
description: | ||
"A collection of files/commits/commands that run when a level/step or solution is loaded", | ||
properties: { | ||
files: { | ||
$ref: "#/definitions/file_array", | ||
}, | ||
commits: { | ||
$ref: "#/definitions/commit_array", | ||
}, | ||
commands: { | ||
$ref: "#/definitions/command_array", | ||
}, | ||
watchers: { | ||
type: "array", | ||
description: | ||
"An array file paths that, when updated, will trigger the test runner to run", | ||
items: { | ||
$ref: "#/definitions/file_path", | ||
uniqueItems: true, | ||
}, | ||
}, | ||
filter: { | ||
type: "string", | ||
description: | ||
"A regex pattern that will be passed to the test runner to limit the number of tests running", | ||
examples: ["^TestSuiteName"], | ||
}, | ||
subtasks: { | ||
type: "boolean", | ||
description: | ||
'A feature that shows subtasks: all active test names and the status of the tests (pass/fail). Use together with "filter"', | ||
examples: [true], | ||
}, | ||
}, | ||
additionalProperties: false, | ||
}, | ||
}, | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.