-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made changes in name and fixed bug in AIM build
- Loading branch information
1 parent
eced02b
commit 94eb4b6
Showing
6 changed files
with
167 additions
and
165 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -16,6 +16,8 @@ class Aim extends Task { | |
basedir, | ||
"aim.md", | ||
"index.html", | ||
[], | ||
[], | ||
lu_label | ||
); | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
206 changes: 103 additions & 103 deletions
206
labDescSchema.json → validation/schemas/labDescSchema.json
This file contains 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 |
---|---|---|
@@ -1,104 +1,104 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"type": "object", | ||
"required": ["lab", "lab_display_name", "broadArea", "phase", "collegeName", | ||
"baseUrl", "introduction", "objective", | ||
"targetAudience", "courseAlignment"], | ||
"properties": { | ||
"lab": {"type": "string"}, | ||
"lab_display_name": {"type": "string"}, | ||
"broadArea": { | ||
"type": "object", | ||
"properties": { | ||
"name": {"type": "string"}, | ||
"link": {"type": "string", "format": "uri"} | ||
} | ||
}, | ||
"phase": {"type": "number"}, | ||
"collegeName": {"type": "string"}, | ||
"baseUrl": { | ||
"type": "string", | ||
"format": "hostname" | ||
}, | ||
"introduction": {"type": "string"}, | ||
"objective": {"type": "string"}, | ||
"experiments": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"type": "object", | ||
"required": ["name", "short-name", | ||
"repo", "tag", "deploy"], | ||
"properties": { | ||
"name": {"type": "string"}, | ||
"short-name": {"type": "string"}, | ||
"repo": {"type": "string", "format": "uri"}, | ||
"tag": { | ||
"type": "string", | ||
"minLength": 6, | ||
"maxLength": 6, | ||
"pattern": "^v([0-9]{1,2}\\.){2}[0-9]$" | ||
}, | ||
"deploy": {"type": "boolean"} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"experiment-sections": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"required": ["sect-name", "experiments"], | ||
"properties": { | ||
"sect-name": {"type": "string"}, | ||
"experiments": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"type": "object", | ||
"required": ["name", "short-name", | ||
"repo", "tag", "deploy"], | ||
"properties": { | ||
"name": {"type": "string"}, | ||
"short-name": {"type": "string"}, | ||
"repo": {"type": "string", "format": "uri"}, | ||
"tag": { | ||
"type": "string", | ||
"minLength": 6, | ||
"maxLength": 6, | ||
"pattern": "^v([0-9]{1,2}\\.){2}[0-9]$" | ||
}, | ||
"deploy": {"type": "boolean"} | ||
}, | ||
"additionalProperties": false | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"targetAudience": { | ||
"type": "object", | ||
"properties": { | ||
"UG": { | ||
"type": "array", | ||
"items": {"type": "string"} | ||
}, | ||
"PG": { | ||
"type": "array", | ||
"items": {"type": "string"} | ||
} | ||
} | ||
}, | ||
"courseAlignment": { | ||
"type": "object", | ||
"properties": { | ||
"description": {"type": "string"}, | ||
"universities": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": {"type": "string"} | ||
} | ||
} | ||
} | ||
} | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"type": "object", | ||
"required": ["lab", "lab_display_name", "broadArea", "phase", "collegeName", | ||
"baseUrl", "introduction", "objective", | ||
"targetAudience", "courseAlignment"], | ||
"properties": { | ||
"lab": {"type": "string"}, | ||
"lab_display_name": {"type": "string"}, | ||
"broadArea": { | ||
"type": "object", | ||
"properties": { | ||
"name": {"type": "string"}, | ||
"link": {"type": "string", "format": "uri"} | ||
} | ||
}, | ||
"phase": {"type": "number"}, | ||
"collegeName": {"type": "string"}, | ||
"baseUrl": { | ||
"type": "string", | ||
"format": "hostname" | ||
}, | ||
"introduction": {"type": "string"}, | ||
"objective": {"type": "string"}, | ||
"experiments": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"type": "object", | ||
"required": ["name", "short-name", | ||
"repo", "tag", "deploy"], | ||
"properties": { | ||
"name": {"type": "string"}, | ||
"short-name": {"type": "string"}, | ||
"repo": {"type": "string", "format": "uri"}, | ||
"tag": { | ||
"type": "string", | ||
"minLength": 6, | ||
"maxLength": 6, | ||
"pattern": "^v([0-9]{1,2}\\.){2}[0-9]$" | ||
}, | ||
"deploy": {"type": "boolean"} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"experiment-sections": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"required": ["sect-name", "experiments"], | ||
"properties": { | ||
"sect-name": {"type": "string"}, | ||
"experiments": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"type": "object", | ||
"required": ["name", "short-name", | ||
"repo", "tag", "deploy"], | ||
"properties": { | ||
"name": {"type": "string"}, | ||
"short-name": {"type": "string"}, | ||
"repo": {"type": "string", "format": "uri"}, | ||
"tag": { | ||
"type": "string", | ||
"minLength": 6, | ||
"maxLength": 6, | ||
"pattern": "^v([0-9]{1,2}\\.){2}[0-9]$" | ||
}, | ||
"deploy": {"type": "boolean"} | ||
}, | ||
"additionalProperties": false | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"targetAudience": { | ||
"type": "object", | ||
"properties": { | ||
"UG": { | ||
"type": "array", | ||
"items": {"type": "string"} | ||
}, | ||
"PG": { | ||
"type": "array", | ||
"items": {"type": "string"} | ||
} | ||
} | ||
}, | ||
"courseAlignment": { | ||
"type": "object", | ||
"properties": { | ||
"description": {"type": "string"}, | ||
"universities": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": {"type": "string"} | ||
} | ||
} | ||
} | ||
} | ||
} |
108 changes: 55 additions & 53 deletions
108
validateDescriptor.js → validation/validateDescriptor.js
This file contains 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 |
---|---|---|
@@ -1,53 +1,55 @@ | ||
const Ajv = require('ajv'); | ||
const addFormats = require("ajv-formats") | ||
const figures = require('figures'); | ||
const chalk = require('chalk'); | ||
const path = require('path'); | ||
|
||
function reportJSONError(error) { | ||
const heading = | ||
chalk`Error detected in {blue {italic lab-descriptor.json}}`; | ||
console.log(chalk`${heading}`); | ||
|
||
if (error.keyword === 'additionalProperties') { | ||
const msg = `please remove: ${error.params.additionalProperty}`; | ||
logError(error.dataPath, msg); | ||
} | ||
else { | ||
logError(error.dataPath, error.message); | ||
} | ||
} | ||
|
||
function logError(dataPath, textMsg) { | ||
let delim =chalk` {yellow ${figures.pointerSmall}} `; | ||
let msg = chalk` {yellow ${textMsg}}`; | ||
dp = dataPath.replace(/\./g, delim); | ||
console.log(`\n${dp}\n${msg}\n`); | ||
} | ||
|
||
|
||
function validateLabDescriptor(lab_descriptor_path){ | ||
const validator = new Ajv(); | ||
addFormats(validator); | ||
const validate = validator.compile(require('./labDescSchema.json')); | ||
const valid = validate(require(lab_descriptor_path)); | ||
|
||
if (!valid) { | ||
if (validate.errors) { | ||
reportJSONError(validate.errors[0]); | ||
} | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
|
||
module.exports.validateLabDescriptor = validateLabDescriptor; | ||
|
||
|
||
/* | ||
node validateDescriptor.js <path/to/lab> | ||
*/ | ||
if (require.main === module) { | ||
validateLabDescriptor(path.resolve(process.argv[2], "lab-descriptor.json")); | ||
} | ||
const Ajv = require('ajv'); | ||
const addFormats = require("ajv-formats") | ||
const figures = require('figures'); | ||
const chalk = require('chalk'); | ||
const path = require('path'); | ||
|
||
function reportJSONError(error) { | ||
const heading = | ||
chalk`Error detected in {blue {italic lab-descriptor.json}}`; | ||
console.log(chalk`${heading}`); | ||
|
||
if (error.keyword === 'additionalProperties') { | ||
const msg = `please remove: ${error.params.additionalProperty}`; | ||
logError(error.dataPath, msg); | ||
} | ||
else { | ||
logError(error.dataPath, error.message); | ||
} | ||
} | ||
|
||
function logError(dataPath, textMsg) { | ||
let delim =chalk` {yellow ${figures.pointerSmall}} `; | ||
let msg = chalk` {yellow ${textMsg}}`; | ||
dp = dataPath.replace(/\./g, delim); | ||
console.log(`\n${dp}\n${msg}\n`); | ||
} | ||
|
||
|
||
function validateLabDescriptor(lab_descriptor_path){ | ||
const validator = new Ajv(); | ||
addFormats(validator); | ||
const validate = validator.compile(require("./schemas/labDescSchema.json")); | ||
const valid = validate(require(lab_descriptor_path)); | ||
|
||
if (!valid) { | ||
if (validate.errors) { | ||
reportJSONError(validate.errors[0]); | ||
} | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
|
||
module.exports = { | ||
validateLabDescriptor, | ||
} | ||
|
||
|
||
/* | ||
node validateDescriptor.js <path/to/lab> | ||
*/ | ||
if (require.main === module) { | ||
validateLabDescriptor(path.resolve(process.argv[2], "lab-descriptor.json")); | ||
} |