Merge branch 'master' into 5.0.0

master
Evgeny Poberezkin 2017-03-12 17:38:27 +00:00
commit 02f9a15eff
8 changed files with 88 additions and 56 deletions

View File

@ -43,7 +43,7 @@ Please make sure to include the following information in the issue:
#### <a name="changes"></a>Change proposals
[Create a proposal](https://github.com/epoberezkin/ajv/issues/new?body=**What%20version%20of%20Ajv%20you%20are%20you%20using%3F**%0A%0A**What%20problem%20do%20you%20want%20to%20solve%3F**%0A%0A**What%20do%20you%20think%20is%20the%20correct%20solution%20to%20problem?**%0A%0A**Will%20you%20be%20able%20to%20implement%20it%3F**%0A%0A) for a new feature, option or some other improvement.
[Create a proposal](https://github.com/epoberezkin/ajv/issues/new?labels=suggestion&body=**What%20version%20of%20Ajv%20you%20are%20you%20using%3F**%0A%0A**What%20problem%20do%20you%20want%20to%20solve%3F**%0A%0A**What%20do%20you%20think%20is%20the%20correct%20solution%20to%20problem?**%0A%0A**Will%20you%20be%20able%20to%20implement%20it%3F**%0A%0A) for a new feature, option or some other improvement.
Please include this information:
@ -63,7 +63,7 @@ Please include as much details as possible.
#### <a name="compatibility"></a>Browser and compatibility issues
[Create an issue](https://github.com/epoberezkin/ajv/issues/new?body=**The version of Ajv you are using**%0A%0A**The environment you have the problem with.**%0A%0A**Your code (please make it as small as possible to reproduce the issue).**%0A%0A**If your issue is in the browser, please list the other packages loaded in the page in the order they are loaded. Please check if the issue gets resolved (or results change) if you move Ajv bundle closer to the top.**%0A%0A**Results in node.js v4.**%0A%0A**Results and error messages in your platform.**%0A%0A) to report a compatibility problem that only happens in a particular environemnt (when your code works correctly in node.js v4 in linux systems but fails in some other environment).
[Create an issue](https://github.com/epoberezkin/ajv/issues/new?labels=compatibility&body=**The%20version%20of%20Ajv%20you%20are%20using**%0A%0A**The%20environment%20you%20have%20the%20problem%20with.**%0A%0A**Your%20code%20(please%20make%20it%20as%20small%20as%20possible%20to%20reproduce%20the%20issue).**%0A%0A**If%20your%20issue%20is%20in%20the%20browser,%20please%20list%20the%20other%20packages%20loaded%20in%20the%20page%20in%20the%20order%20they%20are%20loaded.%20Please%20check%20if%20the%20issue%20gets%20resolved%20(or%20results%20change)%20if%20you%20move%20Ajv%20bundle%20closer%20to%20the%20top.**%0A%0A**Results%20in%20node.js%20v4.**%0A%0A**Results%20and%20error%20messages%20in%20your%20platform.**%0A%0A) to report a compatibility problem that only happens in a particular environemnt (when your code works correctly in node.js v4 in linux systems but fails in some other environment).
Please include this information:

View File

@ -11,9 +11,9 @@ The fastest JSON Schema validator for node.js and browser with draft 6 support.
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
__Please note__: You can start using NEW beta version 5.0.2 ([migration guide](https://github.com/epoberezkin/ajv/releases/tag/5.0.1-beta.0)) with the support of draft 6 (not officially published yet): `npm install ajv@^5.0.2-beta`.
__Please note__: You can start using NEW beta version [5.0.3](https://github.com/epoberezkin/ajv/releases/tag/5.0.3-beta.0) (see [migration guide from 4.x.x](https://github.com/epoberezkin/ajv/releases/tag/5.0.1-beta.0)) with the support of JSON-Schema draft-06 (not officially published yet): `npm install ajv@^5.0.3-beta`.
Also see [docs](https://github.com/epoberezkin/ajv/tree/5.0.2-beta.0) for 5.0.2.
Also see [docs](https://github.com/epoberezkin/ajv/tree/5.0.3-beta.0) for 5.0.3.
## Contents
@ -95,10 +95,10 @@ Currently Ajv is the only validator that passes all the tests from [JSON Schema
npm install ajv
```
To install a stable beta version 5.0.2 (see [migration guide](https://github.com/epoberezkin/ajv/releases/tag/5.0.1-beta.0)):
To install a stable beta version [5.0.3](https://github.com/epoberezkin/ajv/releases/tag/5.0.3-beta.0) (see [migration guide from 4.x.x](https://github.com/epoberezkin/ajv/releases/tag/5.0.1-beta.0)):
```
npm install ajv@^5.0.2-beta
npm install ajv@^5.0.3-beta
```
@ -1178,20 +1178,24 @@ Properties of `params` object in errors depend on the keyword that failed valida
## Some packages using Ajv
- [webpack](https://github.com/webpack/webpack) - a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser
- [jsonscript-js](https://github.com/JSONScript/jsonscript-js) - the interpreter for [JSONScript](http://www.jsonscript.org) - scripted processing of existing endpoints and services
- [osprey-method-handler](https://github.com/mulesoft-labs/osprey-method-handler) - Express middleware for validating requests and responses based on a RAML method object, used in [osprey](https://github.com/mulesoft/osprey) - validating API proxy generated from a RAML definition
- [jsoneditor](https://github.com/josdejong/jsoneditor) - A web-based tool to view, edit, format, and validate JSON http://jsoneditoronline.org
- [JSON Schema Lint](https://github.com/nickcmaynard/jsonschemalint) - A web tool to validate JSON/YAML document against a single JSON-schema http://jsonschemalint.com
- [har-validator](https://github.com/ahmadnassri/har-validator) - HTTP Archive (HAR) validator
- [jsoneditor](https://github.com/josdejong/jsoneditor) - a web-based tool to view, edit, format, and validate JSON http://jsoneditoronline.org
- [JSON Schema Lint](https://github.com/nickcmaynard/jsonschemalint) - a web tool to validate JSON/YAML document against a single JSON-schema http://jsonschemalint.com
- [objection](https://github.com/vincit/objection.js) - SQL-friendly ORM for node.js
- [table](https://github.com/gajus/table) - formats data into a string table
- [ripple-lib](https://github.com/ripple/ripple-lib) - A JavaScript API for interacting with [Ripple](https://ripple.com) in Node.js and the browser
- [restbase](https://github.com/wikimedia/restbase) - Distributed storage with REST API & dispatcher for backend services built to provide a low-latency & high-throughput API for Wikipedia / Wikimedia content
- [ripple-lib](https://github.com/ripple/ripple-lib) - a JavaScript API for interacting with [Ripple](https://ripple.com) in Node.js and the browser
- [restbase](https://github.com/wikimedia/restbase) - distributed storage with REST API & dispatcher for backend services built to provide a low-latency & high-throughput API for Wikipedia / Wikimedia content
- [hippie-swagger](https://github.com/CacheControl/hippie-swagger) - [Hippie](https://github.com/vesln/hippie) wrapper that provides end to end API testing with swagger validation
- [react-form-controlled](https://github.com/seeden/react-form-controlled) - React controlled form components with validation
- [rabbitmq-schema](https://github.com/tjmehta/rabbitmq-schema) - A schema definition module for RabbitMQ graphs and messages
- [rabbitmq-schema](https://github.com/tjmehta/rabbitmq-schema) - a schema definition module for RabbitMQ graphs and messages
- [@query/schema](https://www.npmjs.com/package/@query/schema) - stream filtering with a URI-safe query syntax parsing to JSON Schema
- [chai-ajv-json-schema](https://github.com/peon374/chai-ajv-json-schema) - chai plugin to us JSON-schema with expect in mocha tests
- [grunt-jsonschema-ajv](https://github.com/SignpostMarv/grunt-jsonschema-ajv) - Grunt plugin for validating files against JSON-Schema
- [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) - extract text from bundle into a file
- [electron-builder](https://github.com/electron-userland/electron-builder) - a solution to package and build a ready for distribution Electron app
- [addons-linter](https://github.com/mozilla/addons-linter) - Mozilla Add-ons Linter
- [gh-pages-generator](https://github.com/epoberezkin/gh-pages-generator) - multi-page site generator converting markdown files to GitHub pages

View File

@ -12,20 +12,20 @@
".tonic_example.js"
],
"scripts": {
"eslint": "if-node-version '>=4' eslint lib/*.js lib/compile/*.js spec",
"eslint": "if-node-version \">=4\" eslint lib/*.js lib/compile/*.js spec scripts",
"test-spec": "mocha spec/*.spec.js -R spec $(if-node-version 7 echo --harmony-async-await)",
"test-fast": "AJV_FAST_TEST=true npm run test-spec",
"test-debug": "mocha spec/*.spec.js --debug-brk -R spec",
"test-cov": "nyc npm run test-spec",
"test-ts": "tsc --target ES5 --noImplicitAny lib/ajv.d.ts",
"bundle": "./scripts/bundle . Ajv pure_getters",
"bundle-regenerator": "./scripts/bundle regenerator",
"bundle-nodent": "./scripts/bundle nodent",
"bundle-all": "rm -rf dist && npm run bundle && npm run bundle-regenerator && npm run bundle-nodent",
"bundle-beautify": "./scripts/bundle js-beautify",
"build": "rm -f lib/dotjs/*.js && node scripts/compile-dots.js",
"bundle": "node ./scripts/bundle.js . Ajv pure_getters",
"bundle-regenerator": "node ./scripts/bundle.js regenerator",
"bundle-nodent": "node ./scripts/bundle.js nodent",
"bundle-all": "del-cli dist && npm run bundle && npm run bundle-regenerator && npm run bundle-nodent",
"bundle-beautify": "node ./scripts/bundle.js js-beautify",
"build": "del-cli lib/dotjs/*.js && node scripts/compile-dots.js",
"test-karma": "karma start --single-run --browsers PhantomJS",
"test-browser": "rm -rf .browser && npm run bundle-all && scripts/prepare-tests && npm run test-karma",
"test-browser": "del-cli .browser && npm run bundle-all && scripts/prepare-tests && npm run test-karma",
"test": "npm run eslint && npm run test-ts && npm run build && npm run test-cov && npm run test-browser",
"prepublish": "npm run build && npm run bundle-all",
"watch": "watch 'npm run build' ./lib/dot"
@ -72,6 +72,7 @@
"browserify": "^14.1.0",
"chai": "^3.5.0",
"coveralls": "^2.11.4",
"del-cli": "^0.2.1",
"dot": "^1.0.3",
"eslint": "^3.2.2",
"gh-pages-generator": "^0.2.0",
@ -89,7 +90,7 @@
"nyc": "^10.0.0",
"phantomjs-prebuilt": "^2.1.4",
"pre-commit": "^1.1.1",
"regenerator": "0.9.5",
"regenerator": "0.9.7",
"require-globify": "^1.3.0",
"typescript": "^2.0.3",
"uglify-js": "2.6.1",

3
scripts/.eslintrc.yml Normal file
View File

@ -0,0 +1,3 @@
rules:
no-console: 0
no-empty: [2, allowEmptyCatch: true]

View File

@ -1,33 +0,0 @@
#!/usr/bin/env bash
set -e
package=$1
standalone=$2
compress=$3
name=$(./scripts/info $package name)
main=$(./scripts/info $package main)
version=$(./scripts/info $package version)
description=$(./scripts/info $package description)
if [ "$package" != "." ]; then
package="./node_modules/$package"
fi
mkdir -p dist
browserify -r "$package/$main:$name" \
-o "dist/$name.bundle.js" \
$([ -n "$standalone" ] && echo "-s $standalone")
uglifyjs dist/$name.bundle.js \
-o dist/$name.min.js \
-c $compress \
-m \
$([ -n "$standalone" ] && echo "--source-map dist/$name.min.js.map -r $standalone") \
--preamble "/* $name $version: $description */"
if [ -z "$standalone" ]; then
rm dist/$name.bundle.js
fi

54
scripts/bundle.js Normal file
View File

@ -0,0 +1,54 @@
'use strict';
var fs = require('fs')
, path = require('path')
, browserify = require('browserify')
, uglify = require('uglify-js');
var pkg = process.argv[2]
, standalone = process.argv[3]
, compress = process.argv[4];
var packageDir = path.join(__dirname, '..');
if (pkg != '.') packageDir = path.join(packageDir, 'node_modules', pkg);
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) {
if (err) {
console.error('browserify error:', err);
process.exit(1);
}
var outputFile = path.join(distDir, json.name);
var outputBundle = outputFile + '.bundle.js';
fs.writeFileSync(outputBundle, buf);
var uglifyOpts = {
warnings: true,
compress: {},
output: {
preamble: '/* ' + json.name + ' ' + json.version + ': ' + json.description + ' */'
}
};
if (compress) {
var compressOpts = compress.split(',');
for (var i=0; i<compressOpts.length; ++i) {
var pair = compressOpts[i].split('=');
uglifyOpts.compress[pair[0]] = pair.length < 1 || pair[1] != 'false';
}
}
if (standalone) uglifyOpts.outSourceMap = json.name + '.min.js.map';
var result = uglify.minify(outputBundle, uglifyOpts);
fs.writeFileSync(outputFile + '.min.js', result.code);
if (result.map) fs.writeFileSync(outputFile + '.min.js.map', result.map);
if (!standalone) fs.unlinkSync(outputBundle);
});

View File

@ -1,4 +1,5 @@
//compile doT templates to js functions
'use strict';
var glob = require('glob')
, fs = require('fs')
@ -26,8 +27,10 @@ console.log('\n\nCompiling:');
var FUNCTION_NAME = /function\s+anonymous\s*\(it[^)]*\)\s*{/;
var OUT_EMPTY_STRING = /out\s*\+=\s*'\s*';/g;
var ISTANBUL = /\'(istanbul[^']+)\';/g;
var VARS = ['$errs', '$valid', '$lvl', '$data', '$dataLvl',
'$errorKeyword', '$closingBraces', '$schemaPath'];
var VARS = [
'$errs', '$valid', '$lvl', '$data', '$dataLvl',
'$errorKeyword', '$closingBraces', '$schemaPath'
];
files.forEach(function (f) {
var keyword = path.basename(f, '.jst');

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
set -e