From c3a9be4c73e47f2e8197de775f41d981701407fb Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Fri, 4 Jun 2021 20:07:56 -0500 Subject: [PATCH] feat: add json specification (#21) --- index.json | 1 + index.spec.js | 9 +++++++++ index.spec.json | 27 +++++++++++++++++++++++++++ package-lock.json | 32 ++++++++++++++++++++++++++++++++ package.json | 4 ++-- 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 index.spec.js create mode 100644 index.spec.json create mode 100644 package-lock.json diff --git a/index.json b/index.json index 8bc4c79..ffa95e8 100644 --- a/index.json +++ b/index.json @@ -1,4 +1,5 @@ { + "$schema": "./index.spec.json", "types": { "feat": { "description": "A new feature", diff --git a/index.spec.js b/index.spec.js new file mode 100644 index 0000000..4b4eaa5 --- /dev/null +++ b/index.spec.js @@ -0,0 +1,9 @@ +var jsonschema = require("jsonschema"); +var fs = require("fs"); + +var data = fs.readFileSync("./index.json"); +var schema = fs.readFileSync("./index.spec.json"); + +jsonschema.validate(JSON.parse(data), JSON.parse(schema), { + throwAll: true, +}); diff --git a/index.spec.json b/index.spec.json new file mode 100644 index 0000000..7079138 --- /dev/null +++ b/index.spec.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Conventional Commit Types Data Schema", + "additionalProperties": true, + "definitions": { + "commitType": { + "type": "object", + "additionalProperties": false, + "properties": { + "description": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": ["description", "title"] + } + }, + "properties": { + "types": { + "type": "object", + "additionalProperties": { "$ref": "#/definitions/commitType" } + } + }, + "required": ["types"] +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..9c4cd86 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,32 @@ +{ + "name": "conventional-commit-types", + "version": "3.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "version": "3.0.0", + "license": "ISC", + "devDependencies": { + "jsonschema": "^1.4.0" + } + }, + "node_modules/jsonschema": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.4.0.tgz", + "integrity": "sha512-/YgW6pRMr6M7C+4o8kS+B/2myEpHCrxO4PEWnqJNBFMjn7EWXqlQ4tGwL6xTHeRplwuZmcAncdvfOad1nT2yMw==", + "dev": true, + "engines": { + "node": "*" + } + } + }, + "dependencies": { + "jsonschema": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.4.0.tgz", + "integrity": "sha512-/YgW6pRMr6M7C+4o8kS+B/2myEpHCrxO4PEWnqJNBFMjn7EWXqlQ4tGwL6xTHeRplwuZmcAncdvfOad1nT2yMw==", + "dev": true + } + } +} diff --git a/package.json b/package.json index 985dc7e..bea43f9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "List of conventional commit types.", "main": "index.json", "scripts": { - "test": "json -f index.json" + "test": "node index.spec" }, "keywords": [], "author": "Anders D. Johnson", @@ -14,6 +14,6 @@ "url": "https://github.com/commitizen/conventional-commit-types.git" }, "devDependencies": { - "json": "^9.0.4" + "jsonschema": "^1.4.0" } }