Skip to content
Snippets Groups Projects
Commit 2b8ebf78 authored by Tomasz Ducin's avatar Tomasz Ducin
Browse files

including distribution files; closes #90

parent 88583c60
No related branches found
No related tags found
No related merge requests found
/*!
* <%= pkg.name %> library v<%= pkg.version %>
* <%= pkg.homepage %>
*
* Copyright (c) 2014-2016 Alvaro Cabrera & Tomasz Ducin
* Released under the <%= pkg.license %> license
*
* Date: <%= now %>
*/
v0.2.6:
date: 2015-12-30
changes:
- dependency update
v0.2.5:
date: 2015-11-26
changes:
- mixins should be arrays
v0.2.4:
date: 2015-11-25
changes:
- Call reduce() on each resolved reference
v0.2.3:
date: 2015-11-25
changes:
- references fixes
- minor fixes
v0.2.2:
date: 2015-10-09
changes:
- linting
- dereferencing update
v0.2.1:
date: 2015-09-12
changes:
- docs update
- logo added
- underscores allowed
- straight approach to sub-schema containers
- inferred types update
v0.2.0:
date: 2015-07-15
changes:
- docs update
v0.1.13:
date: 2015-06-25
changes:
- extending chance.js
v0.1.12:
date: 2015-06-11
changes:
- max issues solved
v0.1.11:
date: 2015-06-08
changes:
- docs update
- test specs
- contributing guidelines
- inferred types
v0.1.10: v0.1.10:
date: 2015-05-21 date: 2015-05-21
changes: changes:
......
module.exports = function(grunt) { module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-parts'); require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: grunt.file.read('.banner.txt'),
now: (new Date()).toISOString().replace('T', ' '),
browserify: {
options: {
watch: "on",
banner: "<%= banner %>",
browserifyOptions: {
detectGlobals: "off",
noBuiltins: "on"
}
},
dist: {
files: {
'dist/jsf.js': ['lib/index.js']
}
},
min: {
options: {
transform: ['uglifyify']
},
files: {
'dist/jsf-min.js': ['lib/index.js']
}
}
}
});
grunt.registerTask('build', [
'browserify'
]);
grunt.registerTask('default', [
'spec',
'build'
]);
}; };
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
[![Dependency Status](https://david-dm.org/json-schema-faker/json-schema-faker/status.svg)](https://david-dm.org/json-schema-faker/json-schema-faker) [![Dependency Status](https://david-dm.org/json-schema-faker/json-schema-faker/status.svg)](https://david-dm.org/json-schema-faker/json-schema-faker)
[![devDependency Status](https://david-dm.org/json-schema-faker/json-schema-faker/dev-status.svg)](https://david-dm.org/json-schema-faker/json-schema-faker#info=devDependencies) [![devDependency Status](https://david-dm.org/json-schema-faker/json-schema-faker/dev-status.svg)](https://david-dm.org/json-schema-faker/json-schema-faker#info=devDependencies)
Use [JSON Schema](http://json-schema.org/) along with fake generators to provide consistent fake data for your system. Note that `json-schema-faker` supports (currently) the JSON-Schema specification **draft-04** only. Use [JSON Schema](http://json-schema.org/) along with fake generators to provide consistent fake data for your system.
***Want to support `jsf`?*** We are looking for a free database hosting, please see the [call for providers](https://github.com/json-schema-faker/json-schema-faker/issues/89). ***Want to support `jsf`?*** We are looking for a free database hosting, please see the [call for providers](https://github.com/json-schema-faker/json-schema-faker/issues/89).
...@@ -27,6 +27,7 @@ Use [JSON Schema](http://json-schema.org/) along with fake generators to provide ...@@ -27,6 +27,7 @@ Use [JSON Schema](http://json-schema.org/) along with fake generators to provide
- [Custom formats](#custom-formats) - [Custom formats](#custom-formats)
- [Extending dependencies](#extending-dependencies) - [Extending dependencies](#extending-dependencies)
- [Inferred Types](#inferred-types) - [Inferred Types](#inferred-types)
- [Bundling](#bundling)
- [Automation](#automation) - [Automation](#automation)
- [Grunt plugin](#grunt-plugin) - [Grunt plugin](#grunt-plugin)
- Misc - Misc
...@@ -46,7 +47,7 @@ Install `json-schema-faker` with npm: ...@@ -46,7 +47,7 @@ Install `json-schema-faker` with npm:
## Overview ## Overview
JSON-schema-faker (or `jsf` for short) combines two things: JSON-Schema-faker (or `jsf` for short) combines two things:
* The [JSON-schema specification](http://json-schema.org/), that defines what is the allowed content of a JSON document * The [JSON-schema specification](http://json-schema.org/), that defines what is the allowed content of a JSON document
* Fake data generators, that are used to generate basic or complex data, conforming to the schema. Following libraries come bundled with jsf: * Fake data generators, that are used to generate basic or complex data, conforming to the schema. Following libraries come bundled with jsf:
...@@ -106,6 +107,8 @@ Clone these gists and execute them locally (each gist has its own readme with in ...@@ -106,6 +107,8 @@ Clone these gists and execute them locally (each gist has its own readme with in
## Supported keywords ## Supported keywords
Note that `jsf` supports (currently) the JSON-Schema specification **draft-04** only. Below is the list of supported keywords:
- **$ref** &mdash; Resolve internal references only, and/or external if provided. - **$ref** &mdash; Resolve internal references only, and/or external if provided.
- **required** &mdash; All required properties are guaranteed, if not can be omitted. - **required** &mdash; All required properties are guaranteed, if not can be omitted.
- **pattern** &mdash; Generate samples based on RegExp values. - **pattern** &mdash; Generate samples based on RegExp values.
...@@ -129,7 +132,7 @@ Clone these gists and execute them locally (each gist has its own readme with in ...@@ -129,7 +132,7 @@ Clone these gists and execute them locally (each gist has its own readme with in
## Using references ## Using references
Inline references are fully supported (json-pointers) but external can't be resolved by `json-schema-faker`. Inline references are fully supported (json-pointers) but external can't be resolved by `jsf`.
In order to achieve that you can use [refaker](https://github.com/json-schema-faker/refaker) and then use the resolved schemas: In order to achieve that you can use [refaker](https://github.com/json-schema-faker/refaker) and then use the resolved schemas:
...@@ -158,7 +161,7 @@ console.log(sample.someValue); ...@@ -158,7 +161,7 @@ console.log(sample.someValue);
## Faking values ## Faking values
`json-schema-faker` has built-in generators for core-formats, [Faker.js](http://marak.com/faker.js/) and [Chance.js](http://chancejs.com/) are also supported. `jsf` has built-in generators for core-formats, [Faker.js](http://marak.com/faker.js/) and [Chance.js](http://chancejs.com/) are also supported.
You can use **faker** or **chance** properties but they are optional: You can use **faker** or **chance** properties but they are optional:
...@@ -319,7 +322,7 @@ JSON Schema does not require you to provide the `type` property for your JSON Sc ...@@ -319,7 +322,7 @@ JSON Schema does not require you to provide the `type` property for your JSON Sc
But since `jsf` uses the `type` property to create the proper fake data, we attempt to infer the type whenever it is not provided. We do this based on the JSON Schema validation properties you use. But since `jsf` uses the `type` property to create the proper fake data, we attempt to infer the type whenever it is not provided. We do this based on the JSON Schema validation properties you use.
> Now this means that if you do not use any of the JSON Schema validation properties, json-schema-faker will not be able to infer the type for you and you will need to **explicitly** set your `type` manually.) > Now this means that if you do not use any of the JSON Schema validation properties, jsf will not be able to infer the type for you and you will need to **explicitly** set your `type` manually.)
Below is the list of JSON Schema validation properties and the inferred type based on the property: Below is the list of JSON Schema validation properties and the inferred type based on the property:
...@@ -355,6 +358,17 @@ Below is the list of JSON Schema validation properties and the inferred type bas ...@@ -355,6 +358,17 @@ Below is the list of JSON Schema validation properties and the inferred type bas
* `minLength` * `minLength`
* `pattern` * `pattern`
## Bundling
JSON-Schema-faker might be used in Node.js as well as in the browser. In order to execute `jsf` in a browser, you should include the distribution file from [`dist`](dist) directory. Each new version of `jsf` is bundled using []browserify](http://browserify.org/) and stored by the library maintainers. The bundle includes full versions of all dependencies.
However, you may want to bundle a smaller package of `jsf`, because:
* you want to reduce the bundle file size
* you don't need all languages from faker.js
* you wish to use chance.js only and get rid of other dependencies
* or for any other reason...
In that case you may bundle the distribution yourself manually. It's easily achievable: just modify the [`lib/util/container.js`](lib/util/container.js) file and either remove o rmodify the `require` calls (they're directly used by browserify to include dependencies). Automation of this feature is expected in near future.
## Automation ## Automation
### Grunt plugin ### Grunt plugin
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
dist/jsf.js 0 → 100644
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -2,15 +2,16 @@ ...@@ -2,15 +2,16 @@
"name": "json-schema-faker", "name": "json-schema-faker",
"version": "0.2.6", "version": "0.2.6",
"description": "JSON-Schema + Faker", "description": "JSON-Schema + Faker",
"homepage": "http://json-schema-faker.js.org",
"main": "lib/index.js", "main": "lib/index.js",
"author": {
"name": "Alvaro Cabrera",
"email": "pateketrueke@gmail.com"
},
"contributors": [ "contributors": [
{
"name": "Alvaro Cabrera",
"email": "pateketrueke@gmail.com"
},
{ {
"name": "Tomasz Ducin", "name": "Tomasz Ducin",
"email": "tomasz.ducin@gmail.com", "email": "tomasz@ducin.it",
"url": "http://ducin.it" "url": "http://ducin.it"
} }
], ],
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
"type": "git", "type": "git",
"url": "https://github.com/json-schema-faker/json-schema-faker" "url": "https://github.com/json-schema-faker/json-schema-faker"
}, },
"bugs": "https://github.com/json-schema-faker/json-schema-faker/issues",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"chance": "^0.8.0", "chance": "^0.8.0",
...@@ -26,13 +28,17 @@ ...@@ -26,13 +28,17 @@
"randexp": "^0.4.2" "randexp": "^0.4.2"
}, },
"devDependencies": { "devDependencies": {
"browserify": "^13.0.0",
"clone": "^1.0.2", "clone": "^1.0.2",
"glob": "^6.0.3", "glob": "^6.0.3",
"grunt": "^0.4.5", "grunt": "^0.4.5",
"grunt-browserify": "^4.0.1",
"grunt-parts": "^0.5.7", "grunt-parts": "^0.5.7",
"jayschema": "^0.3.1", "jayschema": "^0.3.1",
"load-grunt-tasks": "^3.4.0",
"semver": "^5.1.0", "semver": "^5.1.0",
"tv4": "^1.2.7", "tv4": "^1.2.7",
"uglifyify": "^3.0.1",
"z-schema": "^3.16.1" "z-schema": "^3.16.1"
}, },
"keywords": [ "keywords": [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment