Skip to content

Commit

Permalink
Add process to validate the status.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
alrra committed Feb 28, 2017
1 parent 1f4c3c6 commit 3cb9b49
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 120 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# For more information about the configurations used
# in this file, please see the EditorConfig documentation:
# http://editorconfig.org

root = true

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

[*]

charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# For more information about the configurations used
# in this file, please see the Travis CI documentation:
# https://docs.travis-ci.com

language: node_js

node_js:
- "node"
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"devDependencies": {
"is-my-json-valid": "^2.15.0"
},
"private": true,
"scripts": {
"test": "node scripts/validate-status-json.js"
}
}
177 changes: 177 additions & 0 deletions scripts/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"$schema": "http://json-schema.org/schema#",
"definitions": {
"feature_categories": {
"enum": [
"Accessibility",
"CSS",
"DOM",
"Device",
"File APIs",
"Graphics",
"JavaScript",
"Misc",
"Multimedia",
"Network / Connectivity",
"Offline / Storage",
"Performance",
"Realtime / Communication",
"Security",
"User input",
"Web Components"
],
"type": "string"
},
"feature_priority": {
"enum": [
"High",
"Low",
"Medium"
],
"type": "string"
},
"implementation_statuses": {
"enum": [
"Behind a flag",
"Deprecated",
"Enabled by default",
"In Development",
"No active development",
"No public signals",
"Not currently planned",
"Not Supported",
"Prefixed",
"Preview Release",
"Removed",
"Shipped",
"Under Consideration"
],
"type": "string"
},
"standard_statuses": {
"enum": [
"De-facto standard",
"Established standard",
"Working draft or equivalent",
"Editor's draft",
"Public discussion",
"No public standards discussion"
],
"type": "string"
},
"url": {
"format": "uri",
"type": "string"
},
"vendor_views": {
"properties": {
"additionalProperties": false,
"text": {
"$ref": "#/definitions/implementation_statuses"
},
"value": {
"maximum": 12,
"minimum": 1,
"type": "number"
}
},
"required": [
"text"
],
"type": "object"
}
},
"description": "Schema for Microsoft Edge platform status JSON",
"items": {
"additionalProperties": false,
"type": "object",
"properties": {
"category": {
"$ref": "#/definitions/feature_categories"
},
"demo": {
"$ref": "#/definitions/url"
},
"ff_views": {
"$ref": "#/definitions/vendor_views"
},
"ff_views_link": {
"$ref": "#/definitions/url"
},
"id": {
"type": "number"
},
"ieStatus": {
"additionalProperties": false,
"properties": {
"flag": {
"type": "boolean"
},
"iePrefixed": {
"minLength": 1,
"type": "string"
},
"ieUnprefixed": {
"minLength": 1,
"type": "string"
},
"priority": {
"$ref": "#/definitions/feature_priority"
},
"text": {
"$ref": "#/definitions/ximplementation_statuses"
}
},
"required": [
"text"
]
},
"impl_status_chrome": {
"$ref": "#/definitions/implementation_statuses"
},
"link": {
"$ref": "#/definitions/url"
},
"msdn": {
"$ref": "#/definitions/url"
},
"name": {
"minLength": 1,
"type": "string"
},
"opera_views": {
"$ref": "#/definitions/vendor_views"
},
"shipped_opera_milestone": {
"type": "boolean"
},
"safari_views": {
"$ref": "#/definitions/vendor_views"
},
"safari_views_link": {
"$ref": "#/definitions/url"
},
"spec": {
"minLength": 1,
"type": "string"
},
"standardStatus": {
"$ref": "#/definitions/standard_statuses"
},
"summary": {
"minLength": 20,
"type": "string"
},
"uservoiceid": {
"type": "number"
}
}
},
"required": [
"category",
"ieStatus",
"name",
"summary"
],
"type": "array"
}
16 changes: 16 additions & 0 deletions scripts/validate-status-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const schema = require('./schema.json');
const statusData = require('./../status.json');
const validator = require('is-my-json-valid');
const validate = validator(schema, {
greedy: true,
verbose: true
});

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

if (!validate(statusData)) {
console.error(validate.errors);
process.exit(1);
} else {
process.exit(0);
}
Loading

0 comments on commit 3cb9b49

Please sign in to comment.