Comparing version 6.12.5 to 7.0.0-alpha.0
@@ -1,20 +0,20 @@ | ||
var Ajv = require('ajv'); | ||
var ajv = new Ajv({allErrors: true}); | ||
var Ajv = require("ajv") | ||
var ajv = new Ajv({allErrors: true}) | ||
var schema = { | ||
"properties": { | ||
"foo": { "type": "string" }, | ||
"bar": { "type": "number", "maximum": 3 } | ||
} | ||
}; | ||
properties: { | ||
foo: {type: "string"}, | ||
bar: {type: "number", maximum: 3}, | ||
}, | ||
} | ||
var validate = ajv.compile(schema); | ||
var validate = ajv.compile(schema) | ||
test({"foo": "abc", "bar": 2}); | ||
test({"foo": 2, "bar": 4}); | ||
test({foo: "abc", bar: 2}) | ||
test({foo: 2, bar: 4}) | ||
function test(data) { | ||
var valid = validate(data); | ||
if (valid) console.log('Valid!'); | ||
else console.log('Invalid: ' + ajv.errorsText(validate.errors)); | ||
} | ||
var valid = validate(data) | ||
if (valid) console.log("Valid!") | ||
else console.log("Invalid: " + ajv.errorsText(validate.errors)) | ||
} |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
// do NOT remove this file - it would break pre-compiled schemas | ||
// https://github.com/ajv-validator/ajv/issues/889 | ||
module.exports = require('fast-deep-equal'); | ||
module.exports = require("fast-deep-equal") |
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#", | ||
"description": "Meta-schema for $data reference (JSON Schema extension proposal)", | ||
"type": "object", | ||
"required": [ "$data" ], | ||
"properties": { | ||
"$data": { | ||
"type": "string", | ||
"anyOf": [ | ||
{ "format": "relative-json-pointer" }, | ||
{ "format": "json-pointer" } | ||
] | ||
} | ||
}, | ||
"additionalProperties": false | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#", | ||
"description": "Meta-schema for $data reference (JSON Schema extension proposal)", | ||
"type": "object", | ||
"required": ["$data"], | ||
"properties": { | ||
"$data": { | ||
"type": "string", | ||
"anyOf": [{"format": "relative-json-pointer"}, {"format": "json-pointer"}] | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
{ | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"$id": "http://json-schema.org/draft-06/schema#", | ||
"title": "Core schema meta-schema", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"$id": "http://json-schema.org/draft-06/schema#", | ||
"title": "Core schema meta-schema", | ||
"definitions": { | ||
"schemaArray": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": {"$ref": "#"} | ||
}, | ||
"nonNegativeInteger": { | ||
"type": "integer", | ||
"minimum": 0 | ||
}, | ||
"nonNegativeIntegerDefault0": { | ||
"allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}] | ||
}, | ||
"simpleTypes": { | ||
"enum": [ | ||
"array", | ||
"boolean", | ||
"integer", | ||
"null", | ||
"number", | ||
"object", | ||
"string" | ||
] | ||
}, | ||
"stringArray": { | ||
"type": "array", | ||
"items": {"type": "string"}, | ||
"uniqueItems": true, | ||
"default": [] | ||
} | ||
}, | ||
"type": ["object", "boolean"], | ||
"properties": { | ||
"$id": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"$schema": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"$ref": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"title": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"default": {}, | ||
"examples": { | ||
"type": "array", | ||
"items": {} | ||
}, | ||
"multipleOf": { | ||
"type": "number", | ||
"exclusiveMinimum": 0 | ||
}, | ||
"maximum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMaximum": { | ||
"type": "number" | ||
}, | ||
"minimum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMinimum": { | ||
"type": "number" | ||
}, | ||
"maxLength": {"$ref": "#/definitions/nonNegativeInteger"}, | ||
"minLength": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, | ||
"pattern": { | ||
"type": "string", | ||
"format": "regex" | ||
}, | ||
"additionalItems": {"$ref": "#"}, | ||
"items": { | ||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}], | ||
"default": {} | ||
}, | ||
"maxItems": {"$ref": "#/definitions/nonNegativeInteger"}, | ||
"minItems": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, | ||
"uniqueItems": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"contains": {"$ref": "#"}, | ||
"maxProperties": {"$ref": "#/definitions/nonNegativeInteger"}, | ||
"minProperties": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, | ||
"required": {"$ref": "#/definitions/stringArray"}, | ||
"additionalProperties": {"$ref": "#"}, | ||
"definitions": { | ||
"schemaArray": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { "$ref": "#" } | ||
}, | ||
"nonNegativeInteger": { | ||
"type": "integer", | ||
"minimum": 0 | ||
}, | ||
"nonNegativeIntegerDefault0": { | ||
"allOf": [ | ||
{ "$ref": "#/definitions/nonNegativeInteger" }, | ||
{ "default": 0 } | ||
] | ||
}, | ||
"simpleTypes": { | ||
"enum": [ | ||
"array", | ||
"boolean", | ||
"integer", | ||
"null", | ||
"number", | ||
"object", | ||
"string" | ||
] | ||
}, | ||
"stringArray": { | ||
"type": "array", | ||
"items": { "type": "string" }, | ||
"uniqueItems": true, | ||
"default": [] | ||
} | ||
"type": "object", | ||
"additionalProperties": {"$ref": "#"}, | ||
"default": {} | ||
}, | ||
"type": ["object", "boolean"], | ||
"properties": { | ||
"$id": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"$schema": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"$ref": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"title": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"default": {}, | ||
"examples": { | ||
"type": "array", | ||
"items": {} | ||
}, | ||
"multipleOf": { | ||
"type": "number", | ||
"exclusiveMinimum": 0 | ||
}, | ||
"maximum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMaximum": { | ||
"type": "number" | ||
}, | ||
"minimum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMinimum": { | ||
"type": "number" | ||
}, | ||
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" }, | ||
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, | ||
"pattern": { | ||
"type": "string", | ||
"format": "regex" | ||
}, | ||
"additionalItems": { "$ref": "#" }, | ||
"items": { | ||
"anyOf": [ | ||
{ "$ref": "#" }, | ||
{ "$ref": "#/definitions/schemaArray" } | ||
], | ||
"default": {} | ||
}, | ||
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, | ||
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, | ||
"uniqueItems": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"contains": { "$ref": "#" }, | ||
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, | ||
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, | ||
"required": { "$ref": "#/definitions/stringArray" }, | ||
"additionalProperties": { "$ref": "#" }, | ||
"definitions": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"default": {} | ||
}, | ||
"properties": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"default": {} | ||
}, | ||
"patternProperties": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"default": {} | ||
}, | ||
"dependencies": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"anyOf": [ | ||
{ "$ref": "#" }, | ||
{ "$ref": "#/definitions/stringArray" } | ||
] | ||
} | ||
}, | ||
"propertyNames": { "$ref": "#" }, | ||
"const": {}, | ||
"enum": { | ||
"type": "array", | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"type": { | ||
"anyOf": [ | ||
{ "$ref": "#/definitions/simpleTypes" }, | ||
{ | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/simpleTypes" }, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
] | ||
}, | ||
"format": { "type": "string" }, | ||
"allOf": { "$ref": "#/definitions/schemaArray" }, | ||
"anyOf": { "$ref": "#/definitions/schemaArray" }, | ||
"oneOf": { "$ref": "#/definitions/schemaArray" }, | ||
"not": { "$ref": "#" } | ||
"type": "object", | ||
"additionalProperties": {"$ref": "#"}, | ||
"default": {} | ||
}, | ||
"default": {} | ||
"patternProperties": { | ||
"type": "object", | ||
"additionalProperties": {"$ref": "#"}, | ||
"default": {} | ||
}, | ||
"dependencies": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}] | ||
} | ||
}, | ||
"propertyNames": {"$ref": "#"}, | ||
"const": {}, | ||
"enum": { | ||
"type": "array", | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"type": { | ||
"anyOf": [ | ||
{"$ref": "#/definitions/simpleTypes"}, | ||
{ | ||
"type": "array", | ||
"items": {"$ref": "#/definitions/simpleTypes"}, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
] | ||
}, | ||
"format": {"type": "string"}, | ||
"allOf": {"$ref": "#/definitions/schemaArray"}, | ||
"anyOf": {"$ref": "#/definitions/schemaArray"}, | ||
"oneOf": {"$ref": "#/definitions/schemaArray"}, | ||
"not": {"$ref": "#"} | ||
}, | ||
"default": {} | ||
} |
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "http://json-schema.org/draft-07/schema#", | ||
"title": "Core schema meta-schema", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "http://json-schema.org/draft-07/schema#", | ||
"title": "Core schema meta-schema", | ||
"definitions": { | ||
"schemaArray": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": {"$ref": "#"} | ||
}, | ||
"nonNegativeInteger": { | ||
"type": "integer", | ||
"minimum": 0 | ||
}, | ||
"nonNegativeIntegerDefault0": { | ||
"allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}] | ||
}, | ||
"simpleTypes": { | ||
"enum": [ | ||
"array", | ||
"boolean", | ||
"integer", | ||
"null", | ||
"number", | ||
"object", | ||
"string" | ||
] | ||
}, | ||
"stringArray": { | ||
"type": "array", | ||
"items": {"type": "string"}, | ||
"uniqueItems": true, | ||
"default": [] | ||
} | ||
}, | ||
"type": ["object", "boolean"], | ||
"properties": { | ||
"$id": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"$schema": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"$ref": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"$comment": { | ||
"type": "string" | ||
}, | ||
"title": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"default": true, | ||
"readOnly": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"examples": { | ||
"type": "array", | ||
"items": true | ||
}, | ||
"multipleOf": { | ||
"type": "number", | ||
"exclusiveMinimum": 0 | ||
}, | ||
"maximum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMaximum": { | ||
"type": "number" | ||
}, | ||
"minimum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMinimum": { | ||
"type": "number" | ||
}, | ||
"maxLength": {"$ref": "#/definitions/nonNegativeInteger"}, | ||
"minLength": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, | ||
"pattern": { | ||
"type": "string", | ||
"format": "regex" | ||
}, | ||
"additionalItems": {"$ref": "#"}, | ||
"items": { | ||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}], | ||
"default": true | ||
}, | ||
"maxItems": {"$ref": "#/definitions/nonNegativeInteger"}, | ||
"minItems": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, | ||
"uniqueItems": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"contains": {"$ref": "#"}, | ||
"maxProperties": {"$ref": "#/definitions/nonNegativeInteger"}, | ||
"minProperties": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, | ||
"required": {"$ref": "#/definitions/stringArray"}, | ||
"additionalProperties": {"$ref": "#"}, | ||
"definitions": { | ||
"schemaArray": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { "$ref": "#" } | ||
}, | ||
"nonNegativeInteger": { | ||
"type": "integer", | ||
"minimum": 0 | ||
}, | ||
"nonNegativeIntegerDefault0": { | ||
"allOf": [ | ||
{ "$ref": "#/definitions/nonNegativeInteger" }, | ||
{ "default": 0 } | ||
] | ||
}, | ||
"simpleTypes": { | ||
"enum": [ | ||
"array", | ||
"boolean", | ||
"integer", | ||
"null", | ||
"number", | ||
"object", | ||
"string" | ||
] | ||
}, | ||
"stringArray": { | ||
"type": "array", | ||
"items": { "type": "string" }, | ||
"uniqueItems": true, | ||
"default": [] | ||
} | ||
"type": "object", | ||
"additionalProperties": {"$ref": "#"}, | ||
"default": {} | ||
}, | ||
"type": ["object", "boolean"], | ||
"properties": { | ||
"$id": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"$schema": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"$ref": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"$comment": { | ||
"type": "string" | ||
}, | ||
"title": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"default": true, | ||
"readOnly": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"examples": { | ||
"type": "array", | ||
"items": true | ||
}, | ||
"multipleOf": { | ||
"type": "number", | ||
"exclusiveMinimum": 0 | ||
}, | ||
"maximum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMaximum": { | ||
"type": "number" | ||
}, | ||
"minimum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMinimum": { | ||
"type": "number" | ||
}, | ||
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" }, | ||
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, | ||
"pattern": { | ||
"type": "string", | ||
"format": "regex" | ||
}, | ||
"additionalItems": { "$ref": "#" }, | ||
"items": { | ||
"anyOf": [ | ||
{ "$ref": "#" }, | ||
{ "$ref": "#/definitions/schemaArray" } | ||
], | ||
"default": true | ||
}, | ||
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, | ||
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, | ||
"uniqueItems": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"contains": { "$ref": "#" }, | ||
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, | ||
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, | ||
"required": { "$ref": "#/definitions/stringArray" }, | ||
"additionalProperties": { "$ref": "#" }, | ||
"definitions": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"default": {} | ||
}, | ||
"properties": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"default": {} | ||
}, | ||
"patternProperties": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"propertyNames": { "format": "regex" }, | ||
"default": {} | ||
}, | ||
"dependencies": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"anyOf": [ | ||
{ "$ref": "#" }, | ||
{ "$ref": "#/definitions/stringArray" } | ||
] | ||
} | ||
}, | ||
"propertyNames": { "$ref": "#" }, | ||
"const": true, | ||
"enum": { | ||
"type": "array", | ||
"items": true, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"type": { | ||
"anyOf": [ | ||
{ "$ref": "#/definitions/simpleTypes" }, | ||
{ | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/simpleTypes" }, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
] | ||
}, | ||
"format": { "type": "string" }, | ||
"contentMediaType": { "type": "string" }, | ||
"contentEncoding": { "type": "string" }, | ||
"if": {"$ref": "#"}, | ||
"then": {"$ref": "#"}, | ||
"else": {"$ref": "#"}, | ||
"allOf": { "$ref": "#/definitions/schemaArray" }, | ||
"anyOf": { "$ref": "#/definitions/schemaArray" }, | ||
"oneOf": { "$ref": "#/definitions/schemaArray" }, | ||
"not": { "$ref": "#" } | ||
"type": "object", | ||
"additionalProperties": {"$ref": "#"}, | ||
"default": {} | ||
}, | ||
"default": true | ||
"patternProperties": { | ||
"type": "object", | ||
"additionalProperties": {"$ref": "#"}, | ||
"propertyNames": {"format": "regex"}, | ||
"default": {} | ||
}, | ||
"dependencies": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}] | ||
} | ||
}, | ||
"propertyNames": {"$ref": "#"}, | ||
"const": true, | ||
"enum": { | ||
"type": "array", | ||
"items": true, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"type": { | ||
"anyOf": [ | ||
{"$ref": "#/definitions/simpleTypes"}, | ||
{ | ||
"type": "array", | ||
"items": {"$ref": "#/definitions/simpleTypes"}, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
] | ||
}, | ||
"format": {"type": "string"}, | ||
"contentMediaType": {"type": "string"}, | ||
"contentEncoding": {"type": "string"}, | ||
"if": {"$ref": "#"}, | ||
"then": {"$ref": "#"}, | ||
"else": {"$ref": "#"}, | ||
"allOf": {"$ref": "#/definitions/schemaArray"}, | ||
"anyOf": {"$ref": "#/definitions/schemaArray"}, | ||
"oneOf": {"$ref": "#/definitions/schemaArray"}, | ||
"not": {"$ref": "#"} | ||
}, | ||
"default": true | ||
} |
@@ -63,13 +63,7 @@ { | ||
"additionalProperties": { | ||
"anyOf": [ | ||
{"type": "array"}, | ||
{"$ref": "#"} | ||
] | ||
"anyOf": [{"type": "array"}, {"$ref": "#"}] | ||
} | ||
}, | ||
"items": { | ||
"anyOf": [ | ||
{"$ref": "#"}, | ||
{"$ref": "#/definitions/schemaArray"} | ||
] | ||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}] | ||
}, | ||
@@ -76,0 +70,0 @@ "definitions": { |
{ | ||
"name": "ajv", | ||
"version": "6.12.5", | ||
"version": "7.0.0-alpha.0", | ||
"description": "Another JSON Schema Validator", | ||
"main": "lib/ajv.js", | ||
"main": "dist/ajv.js", | ||
"typings": "lib/ajv.d.ts", | ||
@@ -15,19 +15,18 @@ "files": [ | ||
"scripts": { | ||
"eslint": "eslint lib/{compile/,}*.js spec/{**/,}*.js scripts --ignore-pattern spec/JSON-Schema-Test-Suite", | ||
"jshint": "jshint lib/{compile/,}*.js", | ||
"lint": "npm run jshint && npm run eslint", | ||
"test-spec": "mocha spec/{**/,}*.spec.js -R spec", | ||
"test-fast": "AJV_FAST_TEST=true npm run test-spec", | ||
"eslint": "eslint 'lib/**/*.ts' 'spec/**/*.*s' scripts --ignore-pattern spec/JSON-Schema-Test-Suite", | ||
"prettier:write": "prettier --write './**/*.{md,json,yaml,js,ts}'", | ||
"prettier:check": "prettier --list-different './**/*.{md,json,yaml,js,ts}'", | ||
"test-spec": "cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register 'spec/**/*.spec.ts' -R dot", | ||
"test-debug": "npm run test-spec -- --inspect-brk", | ||
"test-cov": "nyc npm run test-spec", | ||
"test-ts": "tsc --target ES5 --noImplicitAny --noEmit spec/typescript/index.ts", | ||
"bundle": "del-cli dist && node ./scripts/bundle.js . Ajv pure_getters", | ||
"bundle-beautify": "node ./scripts/bundle.js js-beautify", | ||
"build": "del-cli lib/dotjs/*.js \"!lib/dotjs/index.js\" && node scripts/compile-dots.js", | ||
"bundle": "rm -rf bundle && node ./scripts/bundle.js", | ||
"build": "rm -rf dist && tsc && cp -r lib/refs dist", | ||
"json-tests": "rm -rf spec/_json/*.js && node scripts/jsontests", | ||
"test-karma": "karma start", | ||
"test-browser": "del-cli .browser && npm run bundle && scripts/prepare-tests && npm run test-karma", | ||
"test-all": "npm run test-cov && if-node-version 10 npm run test-browser", | ||
"test": "npm run lint && npm run build && npm run test-all", | ||
"prepublish": "npm run build && npm run bundle", | ||
"watch": "watch \"npm run build\" ./lib/dot" | ||
"test-browser": "rm -rf .browser && npm run bundle && scripts/prepare-tests && karma start", | ||
"test-all": "npm run test-cov && if-node-version 12 npm run test-browser", | ||
"test": "npm run build && npm run json-tests && npm run eslint && npm run test-cov", | ||
"test-ci": "AJV_FULL_TEST=true npm test", | ||
"prepublish": "npm run build", | ||
"watch": "watch \"npm run build\" ./lib" | ||
}, | ||
@@ -68,20 +67,24 @@ "nyc": { | ||
"fast-json-stable-stringify": "^2.0.0", | ||
"json-schema-traverse": "^0.4.1", | ||
"json-schema-traverse": "^0.5.0", | ||
"uri-js": "^4.2.2" | ||
}, | ||
"devDependencies": { | ||
"ajv-async": "^1.0.0", | ||
"bluebird": "^3.5.3", | ||
"brfs": "^2.0.0", | ||
"@ajv-validator/config": "^0.2.2", | ||
"@types/chai": "^4.2.12", | ||
"@types/mocha": "^8.0.3", | ||
"@types/node": "^14.0.27", | ||
"@typescript-eslint/eslint-plugin": "^3.8.0", | ||
"@typescript-eslint/parser": "^3.8.0", | ||
"ajv-formats": "^0.2.0", | ||
"browserify": "^16.2.0", | ||
"chai": "^4.0.1", | ||
"coveralls": "^3.0.1", | ||
"del-cli": "^3.0.0", | ||
"dot": "^1.0.3", | ||
"eslint": "^7.3.1", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^7.8.1", | ||
"eslint-config-prettier": "^6.11.0", | ||
"gh-pages-generator": "^0.2.3", | ||
"glob": "^7.0.0", | ||
"husky": "^4.2.5", | ||
"if-node-version": "^1.0.0", | ||
"js-beautify": "^1.7.3", | ||
"jshint": "^2.10.2", | ||
"json-schema-test": "^2.0.0", | ||
@@ -91,9 +94,10 @@ "karma": "^5.0.0", | ||
"karma-mocha": "^2.0.0", | ||
"karma-sauce-launcher": "^4.1.3", | ||
"lint-staged": "^10.2.11", | ||
"mocha": "^8.0.1", | ||
"nyc": "^15.0.0", | ||
"pre-commit": "^1.1.1", | ||
"require-globify": "^1.3.0", | ||
"typescript": "^3.9.5", | ||
"uglify-js": "^3.6.9", | ||
"prettier": "^2.0.5", | ||
"terser": "^5.2.1", | ||
"ts-node": "^9.0.0", | ||
"tsify": "^5.0.2", | ||
"typescript": "^4.0.0", | ||
"watch": "^1.0.0" | ||
@@ -108,3 +112,12 @@ }, | ||
"url": "https://github.com/sponsors/epoberezkin" | ||
}, | ||
"prettier": "@ajv-validator/config/prettierrc.json", | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged && npm test" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{md,json,yaml,js,ts}": "prettier --write" | ||
} | ||
} |
@@ -1,61 +0,46 @@ | ||
'use strict'; | ||
"use strict" | ||
var fs = require('fs') | ||
, path = require('path') | ||
, browserify = require('browserify') | ||
, uglify = require('uglify-js'); | ||
const fs = require("fs") | ||
const path = require("path") | ||
const browserify = require("browserify") | ||
const {minify} = require("terser") | ||
var pkg = process.argv[2] | ||
, standalone = process.argv[3] | ||
, compress = process.argv[4]; | ||
const json = require(path.join(__dirname, "..", "package.json")) | ||
const bundleDir = path.join(__dirname, "..", "bundle") | ||
if (!fs.existsSync(bundleDir)) fs.mkdirSync(bundleDir) | ||
var packageDir = path.join(__dirname, '..'); | ||
if (pkg != '.') packageDir = path.join(packageDir, 'node_modules', pkg); | ||
browserify({standalone: "Ajv"}) | ||
.require(path.join(__dirname, "..", json.main), {expose: json.name}) | ||
.bundle(saveAndMinify) | ||
var json = require(path.join(packageDir, 'package.json')); | ||
var distDir = path.join(__dirname, '..', 'dist'); | ||
if (!fs.existsSync(distDir)) fs.mkdirSync(distDir); | ||
var bOpts = {}; | ||
if (standalone) bOpts.standalone = standalone; | ||
browserify(bOpts) | ||
.require(path.join(packageDir, json.main), {expose: json.name}) | ||
.bundle(function (err, buf) { | ||
async function saveAndMinify(err, buf) { | ||
if (err) { | ||
console.error('browserify error:', err); | ||
process.exit(1); | ||
console.error("browserify error:", err) | ||
process.exit(1) | ||
} | ||
var outputFile = path.join(distDir, json.name); | ||
var uglifyOpts = { | ||
const bundlePath = path.join(bundleDir, json.name) | ||
const opts = { | ||
ecma: 2018, | ||
warnings: true, | ||
compress: {}, | ||
output: { | ||
preamble: '/* ' + json.name + ' ' + json.version + ': ' + json.description + ' */' | ||
} | ||
}; | ||
if (compress) { | ||
var compressOpts = compress.split(','); | ||
for (var i=0, il = compressOpts.length; i<il; ++i) { | ||
var pair = compressOpts[i].split('='); | ||
uglifyOpts.compress[pair[0]] = pair.length < 1 || pair[1] != 'false'; | ||
} | ||
compress: { | ||
pure_getters: true, | ||
keep_infinity: true, | ||
unsafe_methods: true, | ||
}, | ||
format: { | ||
preamble: `/* ${json.name} ${json.version}: ${json.description} */`, | ||
}, | ||
sourceMap: { | ||
filename: json.name + ".min.js", | ||
url: json.name + ".min.js.map", | ||
}, | ||
} | ||
if (standalone) { | ||
uglifyOpts.sourceMap = { | ||
filename: json.name + '.min.js', | ||
url: json.name + '.min.js.map' | ||
}; | ||
} | ||
var result = uglify.minify(buf.toString(), uglifyOpts); | ||
fs.writeFileSync(outputFile + '.min.js', result.code); | ||
if (result.map) fs.writeFileSync(outputFile + '.min.js.map', result.map); | ||
if (standalone) fs.writeFileSync(outputFile + '.bundle.js', buf); | ||
if (result.warnings) { | ||
for (var j=0, jl = result.warnings.length; j<jl; ++j) | ||
console.warn('UglifyJS warning:', result.warnings[j]); | ||
} | ||
}); | ||
const result = await minify(buf.toString(), opts) | ||
fs.writeFileSync(bundlePath + ".bundle.js", buf) | ||
fs.writeFileSync(bundlePath + ".min.js", result.code) | ||
fs.writeFileSync(bundlePath + ".min.js.map", result.map) | ||
if (result.warnings) result.warnings.forEach((msg) => console.warn("terser.minify warning:", msg)) | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
250
3
2
594593
31
10094
1433
+ Addedjson-schema-traverse@0.5.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
Updatedjson-schema-traverse@^0.5.0