Skip to content

Commit 0fcc18e

Browse files
committed
this is the beginning of a beautiful tool
0 parents  commit 0fcc18e

18 files changed

+521
-0
lines changed

Diff for: .babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

Diff for: .editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
root = true;
4+
5+
[*]
6+
# Ensure there's no lingering whitespace
7+
trim_trailing_whitespace = true
8+
# Ensure a newline at the end of each file
9+
insert_final_newline = true
10+
11+
[*.js]
12+
# Unix-style newlines
13+
end_of_line = lf
14+
charset = utf-8
15+
indent_style = space
16+
indent_size = 2

Diff for: .eslintrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 6,
4+
"sourceType": "module"
5+
},
6+
"rules": {},
7+
"env": {
8+
"browser": true,
9+
"node": true
10+
}
11+
}

Diff for: .gitignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# Compiled binary addons (http://nodejs.org/api/addons.html)
20+
build/Release
21+
22+
# Dependency directory
23+
# Commenting this out is preferred by some people, see
24+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
25+
node_modules
26+
bower_components
27+
coverage
28+
tmp
29+
30+
# Users Environment Variables
31+
.lock-wscript
32+
.idea

Diff for: .travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
node_js:
3+
- "4"
4+
- "5"
5+
- "stable"
6+
sudo: false
7+
script: "gulp coverage"
8+
after_success:
9+
- npm install -g codeclimate-test-reporter
10+
- codeclimate-test-reporter < coverage/lcov.info

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### [0.0.1](https://github.com/json-schema-form/json-schema-form-generator/releases/tag/v0.0.1)
2+
3+
- The first release

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Raphael Owino <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# json-schema-form-generator
2+
3+
A tool to generate json schema forms
4+
5+
[![Travis build status](http://img.shields.io/travis/json-schema-form/json-schema-form-generator.svg?style=flat)](https://travis-ci.org/json-schema-form/json-schema-form-generator)
6+
[![Code Climate](https://codeclimate.com/github/json-schema-form/json-schema-form-generator/badges/gpa.svg)](https://codeclimate.com/github/json-schema-form/json-schema-form-generator)
7+
[![Test Coverage](https://codeclimate.com/github/json-schema-form/json-schema-form-generator/badges/coverage.svg)](https://codeclimate.com/github/json-schema-form/json-schema-form-generator)
8+
[![Dependency Status](https://david-dm.org/json-schema-form/json-schema-form-generator.svg)](https://david-dm.org/json-schema-form/json-schema-form-generator)
9+
[![devDependency Status](https://david-dm.org/json-schema-form/json-schema-form-generator/dev-status.svg)](https://david-dm.org/json-schema-form/json-schema-form-generator#info=devDependencies)
10+
11+
## Objective
12+
13+
The goal for this libary is to provide a generator that will allow users of json-schema-form to generate form definitions through various means. This is the base package and will provide translations of simple data into json-schema-form syntax. It will also import json-schema-form definitions and return it in a format that can be used with the GUI.
14+
15+
## Installation
16+
17+
npm install json-schema-generator
18+
19+
## Components
20+
21+
### Definitions Generator
22+
23+
24+
25+
26+
### Definitions Importer
27+
28+
29+
## Roadmap
30+
31+
32+
## Contributions
33+
34+
35+

Diff for: gulpfile.js

+200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
const gulp = require('gulp');
2+
const loadPlugins = require('gulp-load-plugins');
3+
const del = require('del');
4+
const glob = require('glob');
5+
const path = require('path');
6+
const isparta = require('isparta');
7+
const webpack = require('webpack');
8+
const webpackStream = require('webpack-stream');
9+
const source = require('vinyl-source-stream');
10+
11+
const Instrumenter = isparta.Instrumenter;
12+
const mochaGlobals = require('./test/setup/.globals');
13+
const manifest = require('./package.json');
14+
15+
// Load all of our Gulp plugins
16+
const $ = loadPlugins();
17+
18+
// Gather the library data from `package.json`
19+
const config = manifest.babelBoilerplateOptions;
20+
const mainFile = manifest.main;
21+
const destinationFolder = path.dirname(mainFile);
22+
const exportFileName = path.basename(mainFile, path.extname(mainFile));
23+
24+
function cleanDist(done) {
25+
del([destinationFolder]).then(() => done());
26+
}
27+
28+
function cleanTmp(done) {
29+
del(['tmp']).then(() => done());
30+
}
31+
32+
// Lint a set of files
33+
function lint(files) {
34+
return gulp.src(files)
35+
.pipe($.eslint())
36+
.pipe($.eslint.format())
37+
.pipe($.eslint.failAfterError());
38+
}
39+
40+
function lintSrc() {
41+
return lint('src/**/*.js');
42+
}
43+
44+
function lintTest() {
45+
return lint('test/**/*.js');
46+
}
47+
48+
function lintGulpfile() {
49+
return lint('gulpfile.js');
50+
}
51+
52+
function build() {
53+
return gulp.src(path.join('src', config.entryFileName))
54+
.pipe(webpackStream({
55+
output: {
56+
filename: exportFileName + '.js',
57+
libraryTarget: 'umd',
58+
library: config.mainVarName
59+
},
60+
// Add your own externals here. For instance,
61+
// {
62+
// jquery: true
63+
// }
64+
// would externalize the `jquery` module.
65+
externals: {},
66+
module: {
67+
loaders: [
68+
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
69+
]
70+
},
71+
devtool: 'source-map'
72+
}))
73+
.pipe(gulp.dest(destinationFolder))
74+
.pipe($.filter(['**', '!**/*.js.map']))
75+
.pipe($.rename(exportFileName + '.min.js'))
76+
.pipe($.sourcemaps.init({ loadMaps: true }))
77+
.pipe($.uglify())
78+
.pipe($.sourcemaps.write('./'))
79+
.pipe(gulp.dest(destinationFolder));
80+
}
81+
82+
function _mocha() {
83+
return gulp.src(['test/setup/node.js', 'test/unit/**/*.js'], {read: false})
84+
.pipe($.mocha({
85+
reporter: 'dot',
86+
globals: Object.keys(mochaGlobals.globals),
87+
ignoreLeaks: false
88+
}));
89+
}
90+
91+
function _registerBabel() {
92+
require('babel-register');
93+
}
94+
95+
function test() {
96+
_registerBabel();
97+
return _mocha();
98+
}
99+
100+
function coverage(done) {
101+
_registerBabel();
102+
gulp.src(['src/**/*.js'])
103+
.pipe($.istanbul({ instrumenter: Instrumenter }))
104+
.pipe($.istanbul.hookRequire())
105+
.on('finish', () => {
106+
return test()
107+
.pipe($.istanbul.writeReports())
108+
.on('end', done);
109+
});
110+
}
111+
112+
const watchFiles = ['src/**/*', 'test/**/*', 'package.json', '**/.eslintrc', '.jscsrc'];
113+
114+
// Run the headless unit tests as you make changes.
115+
function watch() {
116+
gulp.watch(watchFiles, ['test']);
117+
}
118+
119+
function testBrowser() {
120+
// Our testing bundle is made up of our unit tests, which
121+
// should individually load up pieces of our application.
122+
// We also include the browser setup file.
123+
const testFiles = glob.sync('./test/unit/**/*.js');
124+
const allFiles = ['./test/setup/browser.js'].concat(testFiles);
125+
126+
// Lets us differentiate between the first build and subsequent builds
127+
var firstBuild = true;
128+
129+
// This empty stream might seem like a hack, but we need to specify all of our files through
130+
// the `entry` option of webpack. Otherwise, it ignores whatever file(s) are placed in here.
131+
return gulp.src('')
132+
.pipe($.plumber())
133+
.pipe(webpackStream({
134+
watch: true,
135+
entry: allFiles,
136+
output: {
137+
filename: '__spec-build.js'
138+
},
139+
// Externals isn't necessary here since these are for tests.
140+
module: {
141+
loaders: [
142+
// This is what allows us to author in future JavaScript
143+
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
144+
// This allows the test setup scripts to load `package.json`
145+
{ test: /\.json$/, exclude: /node_modules/, loader: 'json-loader' }
146+
]
147+
},
148+
plugins: [
149+
// By default, webpack does `n=>n` compilation with entry files. This concatenates
150+
// them into a single chunk.
151+
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })
152+
],
153+
devtool: 'inline-source-map'
154+
}, null, function() {
155+
if (firstBuild) {
156+
$.livereload.listen({port: 35729, host: 'localhost', start: true});
157+
var watcher = gulp.watch(watchFiles, ['lint']);
158+
} else {
159+
$.livereload.reload('./tmp/__spec-build.js');
160+
}
161+
firstBuild = false;
162+
}))
163+
.pipe(gulp.dest('./tmp'));
164+
}
165+
166+
// Remove the built files
167+
gulp.task('clean', cleanDist);
168+
169+
// Remove our temporary files
170+
gulp.task('clean-tmp', cleanTmp);
171+
172+
// Lint our source code
173+
gulp.task('lint-src', lintSrc);
174+
175+
// Lint our test code
176+
gulp.task('lint-test', lintTest);
177+
178+
// Lint this file
179+
gulp.task('lint-gulpfile', lintGulpfile);
180+
181+
// Lint everything
182+
gulp.task('lint', ['lint-src', 'lint-test', 'lint-gulpfile']);
183+
184+
// Build two versions of the library
185+
gulp.task('build', ['lint', 'clean'], build);
186+
187+
// Lint and run our tests
188+
gulp.task('test', ['lint'], test);
189+
190+
// Set up coverage and run tests
191+
gulp.task('coverage', ['lint'], coverage);
192+
193+
// Set up a livereload environment for our spec runner `test/runner.html`
194+
gulp.task('test-browser', ['lint', 'clean-tmp'], testBrowser);
195+
196+
// Run the headless unit tests as you make changes.
197+
gulp.task('watch', watch);
198+
199+
// An alias of test
200+
gulp.task('default', ['test']);

Diff for: package.json

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "json-schema-form-generator",
3+
"version": "0.0.1",
4+
"description": "A tool to generate json schema forms",
5+
"main": "dist/json-schema-form-generator.js",
6+
"scripts": {
7+
"test": "gulp",
8+
"lint": "gulp lint",
9+
"test-browser": "gulp test-browser",
10+
"watch": "gulp watch",
11+
"build": "gulp build",
12+
"coverage": "gulp coverage"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/json-schema-form/json-schema-form-generator.git"
17+
},
18+
"keywords": [],
19+
"author": "Raphael Owino <[email protected]>",
20+
"license": "MIT",
21+
"bugs": {
22+
"url": "https://github.com/json-schema-form/json-schema-form-generator/issues"
23+
},
24+
"homepage": "https://github.com/json-schema-form/json-schema-form-generator",
25+
"devDependencies": {
26+
"babel-core": "^6.3.26",
27+
"babel-loader": "^6.2.0",
28+
"babel-polyfill": "^6.3.14",
29+
"babel-preset-es2015": "^6.3.13",
30+
"babel-register": "^6.3.13",
31+
"chai": "^3.4.1",
32+
"del": "^2.2.0",
33+
"glob": "^7.0.3",
34+
"gulp": "^3.9.0",
35+
"gulp-eslint": "^2.0.0",
36+
"gulp-filter": "^4.0.0",
37+
"gulp-istanbul": "^0.10.3",
38+
"gulp-livereload": "^3.8.1",
39+
"gulp-load-plugins": "^1.1.0",
40+
"gulp-mocha": "^2.2.0",
41+
"gulp-plumber": "^1.0.1",
42+
"gulp-rename": "^1.2.2",
43+
"gulp-sourcemaps": "^1.6.0",
44+
"gulp-uglify": "^1.5.1",
45+
"isparta": "^4.0.0",
46+
"json-loader": "^0.5.3",
47+
"mocha": "^2.3.4",
48+
"sinon": "^1.17.2",
49+
"sinon-chai": "^2.8.0",
50+
"vinyl-source-stream": "^1.1.0",
51+
"webpack": "^1.12.9",
52+
"webpack-stream": "^3.1.0"
53+
},
54+
"babelBoilerplateOptions": {
55+
"entryFileName": "json-schema-form-generator.js",
56+
"mainVarName": "jsonSchemaFormGenerator"
57+
}
58+
}

0 commit comments

Comments
 (0)