Skip to content

Commit 9974dd5

Browse files
committedSep 6, 2016
Updated to use webpack build of ASF
Updated the code to build with npm and webpack, still needs some gulp tasks removed, but most tasks can be run from npm. The webpack build embeds angular-schema-form, json-schema-form-core and objectpath.
1 parent 68c07af commit 9974dd5

16 files changed

+4269
-38
lines changed
 

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ bower_components
102102
node_modules
103103

104104
material-decorator.js
105-
material-decorator.min.js
105+
material-decorator.min.js

‎bower.json

+6-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Marcel Bennett <iamanthropic@gmail.com>"
66
],
77
"description": "Angular Material decorator for Angular Schema Form",
8-
"main": "material-decorator.js",
8+
"main": "dist/material-decorator.js",
99
"keywords": [
1010
"angular-schema-form-decorator",
1111
"angular material",
@@ -22,18 +22,14 @@
2222
"tests"
2323
],
2424
"dependencies": {
25-
"angular-schema-form": ">=0.8.13",
26-
"angular": "1.5.5",
27-
"angular-material": "1.0.7",
28-
"angular-animate": "1.4",
29-
"angular-sanitize": "1.4"
25+
"angular-schema-form": ">=0.8.13"
3026
},
3127
"devDependencies": {
28+
"angular": "1.5.5",
29+
"angular-animate": "1.4",
30+
"angular-material": "1.1.1",
31+
"angular-sanitize": "1.4",
3232
"angular-ui-ace": "~0.2.3",
3333
"moment": "~2.10.6"
34-
},
35-
"resolutions": {
36-
"angular-material": "^1.0.7",
37-
"angular": "^1.5.5"
3834
}
3935
}

‎dist/angular-schema-form-material.js

+4,087
Large diffs are not rendered by default.

‎dist/angular-schema-form-material.min.js

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/material-example.html

+2-6
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
.schema-form-radiobuttons md-input-container:last-child button {
4747
border-radius: 0 10px 10px 0;
4848
}
49-
50-
</style>
49+
</style>
5150
</head>
5251
<body ng-app="test" ng-controller="TestCtrl as ctrl" ng-cloak>
5352

@@ -59,7 +58,6 @@
5958
<a class="navbar-brand glyphicon glyphicon-home" href="/"></a>
6059
</div>
6160

62-
6361
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
6462
<form class="navbar-form navbar-left" role="search">
6563
<div class="form-group">
@@ -169,9 +167,7 @@ <h3>Schema</h3>
169167
<!-- <script type="text/javascript" src="../bower_components/angular-ui-sortable/sortable.js"></script>
170168
-->
171169
<script type="text/javascript" src="../bower_components/angular-ui-ace/ui-ace.js"></script>
172-
<script type="text/javascript" src="../bower_components/objectpath/lib/ObjectPath.js"></script>
173-
<script type="text/javascript" src="../bower_components/angular-schema-form/dist/schema-form.js"></script>
174-
<script type="text/javascript" src="../material-decorator.js"></script>
170+
<script type="text/javascript" src="../dist/angular-schema-form-material.js"></script>
175171

176172
<script type="text/javascript">
177173
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat

‎gulpfile.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,29 @@ gulp.task('build', function() {
3030
.pipe(rename('material-decorator.min.js'))
3131
.pipe(gulp.dest('./'));
3232

33+
});
34+
gulp.task('templates', function() {
35+
var stream = streamqueue({ objectMode: true });
36+
stream.queue(
37+
gulp.src('./src/**/*.html')
38+
.pipe(minifyHtml({
39+
empty: true,
40+
spare: true,
41+
quotes: true
42+
}))
43+
.pipe(templateCache({
44+
module: 'schemaForm',
45+
root: 'decorators/material/'
46+
}))
47+
);
48+
49+
stream.done()
50+
.pipe(concat('angular-schema-form-material-templates.js'))
51+
.pipe(gulp.dest('./src'))
52+
.pipe(uglify())
53+
.pipe(rename('angular-schema-form-material-templates.min.js'))
54+
.pipe(gulp.dest('./src'));
55+
3356
});
3457

3558
gulp.task('jscs', function() {
@@ -41,4 +64,4 @@ gulp.task('watch', function() {
4164
gulp.watch('./src/**/*', [ 'default' ]);
4265
});
4366

44-
gulp.task('default', [ 'build' ]);
67+
gulp.task('default', [ 'templates' ]);

‎material-decorator.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ $templateCache.put("decorators/material/textarea.html","<md-input-container clas
4444
var sfField = sfBuilderProvider.builders.sfField;
4545
var condition = sfBuilderProvider.builders.condition;
4646
var array = sfBuilderProvider.builders.array;
47+
var numeric = sfBuilderProvider.builders.numeric;
4748

4849
var sfLayout = sfLayout;
4950
var sfMessagesNode = sfMessagesNodeHandler();
@@ -73,7 +74,7 @@ $templateCache.put("decorators/material/textarea.html","<md-input-container clas
7374
'default': { template: base + 'default.html', builder: defaults },
7475
fieldset: { template: base + 'fieldset.html', builder: [ sfField, simpleTransclusion, condition ] },
7576
help: { template: base + 'help.html', builder: defaults },
76-
number: { template: base + 'default.html', builder: defaults },
77+
number: { template: base + 'default.html', builder: defaults.concat(numeric) },
7778
password: { template: base + 'default.html', builder: defaults },
7879
radios: { template: base + 'radios.html', builder: defaults },
7980
'radios-inline': { template: base + 'radios-inline.html', builder: defaults },
@@ -141,15 +142,15 @@ $templateCache.put("decorators/material/textarea.html","<md-input-container clas
141142
if (title) {
142143
mdAutocompleteFrag.setAttribute('md-floating-label', title);
143144
};
144-
}
145+
};
145146
};
146147

147148
function mdSwitchBuilder(args) {
148149
var mdSwitchFrag = args.fieldFrag.querySelector('md-switch');
149150
if (args.form.schema.titleMap) {
150151
mdSwitchFrag.setAttribute('ng-true-value', args.form.schema.titleMap.true);
151152
mdSwitchFrag.setAttribute('ng-false-value', args.form.schema.titleMap.false);
152-
}
153+
};
153154
};
154155

155156
function sfOptionsBuilder(args) {
@@ -331,6 +332,10 @@ $templateCache.put("decorators/material/textarea.html","<md-input-container clas
331332
})
332333
*/
333334

335+
require('../material-decorator-templates.js');
336+
require('./type-parser.js');
337+
require('./material-decorator.js');
338+
334339
/**
335340
* It might be a bug, but currently input[type=number] does not add
336341
* a parser, so the model gets populated with a string. It does however stop non numbers so it

‎material-decorator.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+38-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,35 @@
22
"name": "angular-schema-form-material",
33
"version": "1.0.0-alpha.1",
44
"description": "Angular Material decorator for Angular Schema Form",
5-
"main": "material-decorator.js",
5+
"main": "dist/material-decorator.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"templates": "gulp templates",
8+
"dist": "npm run build && npm run minify",
9+
"build": "webpack",
10+
"watch": "webpack --watch",
11+
"minify": "uglifyjs dist/angular-schema-form-material.js --comments --output=dist/angular-schema-form-material.min.js",
12+
"test": "echo \"Error: no test specified\" && exit 1",
13+
"test-not-yet-done": "karma start --single-run --browsers PhantomJS karma.conf.js --log-level info"
814
},
915
"keywords": [
1016
"angular-schema-form-decorator"
1117
],
1218
"author": "Marcel Bennett <iamanthropic@gmail.com>",
1319
"license": "MIT",
20+
"dependencies": {
21+
"angular": ">= 1.2",
22+
"angular-messages": "^1.5.0",
23+
"angular-sanitize": ">= 1.2",
24+
"angular-schema-form": "git://github.com/json-schema-form/angular-schema-form.git#feature/webpack-babel",
25+
"tv4": "~1.0.15"
26+
},
1427
"devDependencies": {
28+
"babel-core": "^6.10.4",
29+
"babel-loader": "^6.2.4",
30+
"babel-polyfill": "^6.9.1",
31+
"babel-preset-es2015": "^6.9.0",
32+
"chai": "^3.5.0",
33+
"coveralls": "^2.11.0",
1534
"gulp": "^3.9.0",
1635
"gulp-angular-templatecache": "^1.6.0",
1736
"gulp-concat": "^2.5.2",
@@ -20,9 +39,22 @@
2039
"gulp-rename": "^1.2.2",
2140
"gulp-uglify": "^1.2.0",
2241
"gulp-watch": "^4.2.4",
23-
"streamqueue": "^0.1.3"
24-
},
25-
"dependencies": {
26-
"angular-messages": "^1.5.0"
42+
"karma": "^0.13.22",
43+
"karma-chai-sinon": "^0.1.5",
44+
"karma-coverage": "^1.0.0",
45+
"karma-growler-reporter": "0.0.1",
46+
"karma-mocha": "^1.0.1",
47+
"karma-phantomjs-launcher": "^0.1.4",
48+
"karma-webpack": "^1.7.0",
49+
"mocha": "^2.5.3",
50+
"mocha-lcov-reporter": "0.0.1",
51+
"ng-cache-loader": "0.0.16",
52+
"protractor": "^2.5.1",
53+
"sinon": "^1.17.4",
54+
"sinon-chai": "^2.8.0",
55+
"streamqueue": "^0.1.3",
56+
"uglify-js": "^2.6.2",
57+
"webpack": "^1.13.1",
58+
"webpack-dev-server": "^1.14.1"
2759
}
2860
}

‎src/angular-schema-form-material-templates.js

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/angular-schema-form-material-templates.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/material-decorator.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
var sfField = sfBuilderProvider.builders.sfField;
2020
var condition = sfBuilderProvider.builders.condition;
2121
var array = sfBuilderProvider.builders.array;
22+
var numeric = sfBuilderProvider.builders.numeric;
2223

2324
var sfLayout = sfLayout;
2425
var sfMessagesNode = sfMessagesNodeHandler();
@@ -48,7 +49,7 @@
4849
'default': { template: base + 'default.html', builder: defaults },
4950
fieldset: { template: base + 'fieldset.html', builder: [ sfField, simpleTransclusion, condition ] },
5051
help: { template: base + 'help.html', builder: defaults },
51-
number: { template: base + 'default.html', builder: defaults },
52+
number: { template: base + 'default.html', builder: defaults.concat(numeric) },
5253
password: { template: base + 'default.html', builder: defaults },
5354
radios: { template: base + 'radios.html', builder: defaults },
5455
'radios-inline': { template: base + 'radios-inline.html', builder: defaults },
@@ -116,15 +117,15 @@
116117
if (title) {
117118
mdAutocompleteFrag.setAttribute('md-floating-label', title);
118119
};
119-
}
120+
};
120121
};
121122

122123
function mdSwitchBuilder(args) {
123124
var mdSwitchFrag = args.fieldFrag.querySelector('md-switch');
124125
if (args.form.schema.titleMap) {
125126
mdSwitchFrag.setAttribute('ng-true-value', args.form.schema.titleMap.true);
126127
mdSwitchFrag.setAttribute('ng-false-value', args.form.schema.titleMap.false);
127-
}
128+
};
128129
};
129130

130131
function sfOptionsBuilder(args) {

‎src/module.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
require('../bower_components/angular-schema-form/dist/schema-form.js');
2+
require('./angular-schema-form-material-templates.js');
3+
require('./type-parser.js');
4+
require('./material-decorator.js');

‎src/template-webpack-module.js

Whitespace-only changes.

‎test/protractor/conf.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
exports.config = {
2-
specs: ['specs/*.js'],
3-
baseUrl: 'http://localhost:63342/',
4-
multiCapabilities: [
5-
{'browserName': 'firefox'},
6-
{'browserName': 'chrome'}
7-
]
8-
};
2+
specs: [ 'specs/*.js' ],
3+
baseUrl: 'http://localhost:63342/',
4+
multiCapabilities: [
5+
{ 'browserName': 'firefox' },
6+
{ 'browserName': 'chrome' }
7+
]
8+
};

‎webpack.config.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* global __dirname */
2+
var webpack = require('webpack');
3+
var path = require('path');
4+
var pjson = require('./package.json');
5+
console.log('Angular Schema Form v' + pjson.version);
6+
7+
module.exports = {
8+
entry: './src/module.js',
9+
output: {
10+
path: path.join(__dirname, 'dist'),
11+
filename: 'angular-schema-form-material.js',
12+
libraryTarget: 'umd'
13+
},
14+
resolve: { extensions: [ '', '.js', '.html' ] },
15+
module: {
16+
loaders: [
17+
{
18+
test: /\.js$/,
19+
include: [ path.join(__dirname, 'src') ],
20+
loader: 'babel',
21+
},
22+
{ test: /\.html$/, loader: "ng-cache?prefix=decorators/material" }
23+
]
24+
},
25+
externals: {
26+
'angular': 'var angular',
27+
'tv4': 'var tv4',
28+
},
29+
plugins: [
30+
new webpack.BannerPlugin(
31+
'angular-schema-form-material\n' +
32+
'@version ' +
33+
pjson.version + '\n' +
34+
'@link https://github.com/json-schema-form/angular-schema-form-material\n' +
35+
'@license MIT\n' +
36+
'Copyright (c) 2016 JSON Schema Form')
37+
]
38+
};

0 commit comments

Comments
 (0)
Please sign in to comment.