Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #215: Improve grunt build tasks and add grunt dist #225

Merged
merged 1 commit into from
Feb 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build/min/
build/
node_modules/
lib/*/*
npm-debug.log
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ before_install:
install: npm install

before_script:
- rm -r dist
- grunt build:all
- grunt dist
136 changes: 85 additions & 51 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
'use strict';

var _ = require('lodash');

module.exports = function(grunt) {

require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);

var banner = '/*! <%= pkg.title %> v<%= pkg.version %> - <%= pkg.description %> <%= grunt.template.today("yyyy-mm-dd") %> \n\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n */\n';
var pkg = grunt.file.readJSON('package.json');
var banner = _.template('/*! <%= pkg.title %> v<%= pkg.version %> - <%= pkg.description %> <%= grunt.template.today("yyyy-mm-dd") %> \n\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n */\n')({ pkg: pkg, grunt: grunt });

// Ignore webpack in node v5, until webpack is fixed for that version.
var ignoreWebpack = process.version.substr(0, 'v5'.length) === 'v5';
Expand Down Expand Up @@ -103,16 +108,16 @@ module.exports = function(grunt) {

var config = {

pkg: grunt.file.readJSON('package.json'),
pkg: pkg,

webpack: {
joint: {
files: {
'./dist/joint.webpack-bundle.js' : './dist/joint.min.js'
'./build/joint.webpack-bundle.js' : './build/joint.min.js'
},
entry: './dist/joint.min.js',
entry: './build/joint.min.js',
output: {
path: './dist/',
path: './build/',
filename: 'joint.webpack-bundle.js',
library: 'joint'
},
Expand All @@ -127,7 +132,7 @@ module.exports = function(grunt) {
browserify: {
joint: {
files: {
'dist/joint.browserify-bundle.js': 'dist/joint.min.js'
'build/joint.browserify-bundle.js': 'build/joint.min.js'
},
options: {
browserifyOptions: {
Expand All @@ -136,94 +141,91 @@ module.exports = function(grunt) {
}
}
},
clean: {
dist: ['dist']
},
concat: {
options: {
banner: banner,
process: {
delimiters: 'square'
}
},
geometry: {
files: {
'dist/geometry.js': [].concat(
['build/wrappers/geometry.head.js'],
'build/geometry.js': [].concat(
['wrappers/geometry.head.js'],
js.geometry,
['build/wrappers/geometry.foot.js']
['wrappers/geometry.foot.js']
),
'dist/geometry.min.js': [].concat(
['build/wrappers/geometry.head.js'],
'build/geometry.min.js': [].concat(
['wrappers/geometry.head.js'],
['build/min/geometry.min.js'],
['build/wrappers/geometry.foot.js']
['wrappers/geometry.foot.js']
)
}
},
vectorizer: {
files: {
'dist/vectorizer.js': [].concat(
['build/wrappers/vectorizer.head.js'],
'build/vectorizer.js': [].concat(
['wrappers/vectorizer.head.js'],
js.vectorizer,
['build/wrappers/vectorizer.foot.js']
['wrappers/vectorizer.foot.js']
),
'dist/vectorizer.min.js': [].concat(
['build/wrappers/vectorizer.head.js'],
'build/vectorizer.min.js': [].concat(
['wrappers/vectorizer.head.js'],
['build/min/vectorizer.min.js'],
['build/wrappers/vectorizer.foot.js']
['wrappers/vectorizer.foot.js']
)
}
},
joint: {
files: {
'dist/joint.core.js': [].concat(
['build/wrappers/joint.head.js'],
'build/joint.core.js': [].concat(
['wrappers/joint.head.js'],
js.geometry,
js.vectorizer,
js.core,
['build/wrappers/joint.foot.js']
['wrappers/joint.foot.js']
),
'dist/joint.core.min.js': [].concat(
['build/wrappers/joint.head.js'],
'build/joint.core.min.js': [].concat(
['wrappers/joint.head.js'],
['build/min/geometry.min.js'],
['build/min/vectorizer.min.js'],
['build/min/joint.min.js'],
['build/wrappers/joint.foot.js']
['wrappers/joint.foot.js']
),
'dist/joint.core.css': [].concat(
'build/joint.core.css': [].concat(
css.core
),
'dist/joint.core.min.css': [].concat(
'build/joint.core.min.css': [].concat(
['build/min/joint.min.css']
),
'dist/joint.js': [].concat(
['build/wrappers/joint.head.js'],
'build/joint.js': [].concat(
['wrappers/joint.head.js'],
js.geometry,
js.vectorizer,
js.core,
allJSPlugins(),
['build/wrappers/joint.foot.js']
['wrappers/joint.foot.js']
),
'dist/joint.min.js': [].concat(
['build/wrappers/joint.head.js'],
'build/joint.min.js': [].concat(
['wrappers/joint.head.js'],
['build/min/geometry.min.js'],
['build/min/vectorizer.min.js'],
['build/min/joint.min.js'],
allMinifiedJSPlugins(),
['build/wrappers/joint.foot.js']
['wrappers/joint.foot.js']
),
'dist/joint.css': [].concat(
'build/joint.css': [].concat(
css.core,
allCSSPlugins()
),
'dist/joint.min.css': [].concat(
'build/joint.min.css': [].concat(
['build/min/joint.min.css'],
allMinifiedCSSPlugins()
),
'dist/joint.nowrap.js': [].concat(
'build/joint.nowrap.js': [].concat(
js.geometry,
js.vectorizer,
js.core,
allJSPlugins()
),
'dist/joint.nowrap.min.js': [].concat(
'build/joint.nowrap.min.js': [].concat(
['build/min/geometry.min.js'],
['build/min/vectorizer.min.js'],
['build/min/joint.min.js'],
Expand All @@ -232,6 +234,26 @@ module.exports = function(grunt) {
}
}
},
copy: {
dist: {
files: [{
nonull: true,
expand: true,
cwd: 'build/',
src: [
'*',
'!min'
],
dest: 'dist/'
}],
options: {
process: function(content) {
// Add JointJS banner to all distribution files.
return banner + content;
}
}
}
},
cssmin: {
joint: {
files: {
Expand Down Expand Up @@ -399,19 +421,19 @@ module.exports = function(grunt) {
// Create targets for all the plugins.
Object.keys(js.plugins).forEach(function(name) {

config.concat[name] = { files: {}, options: { banner: banner } };
config.concat[name] = { files: {} };
config.uglify[name] = { files: {} };

config.uglify[name].files['build/min/joint.' + name + '.min.js'] = js.plugins[name];
config.concat[name].files['dist/joint.' + name + '.js'] = js.plugins[name];
config.concat[name].files['dist/joint.' + name + '.min.js'] = ['build/min/joint.' + name + '.min.js'];
config.concat[name].files['build/joint.' + name + '.js'] = js.plugins[name];
config.concat[name].files['build/joint.' + name + '.min.js'] = ['build/min/joint.' + name + '.min.js'];

if (css.plugins[name]) {

config.cssmin[name] = { files: {} };
config.cssmin[name].files['build/min/joint.' + name + '.min.css'] = css.plugins[name];
config.concat[name].files['dist/joint.' + name + '.css'] = css.plugins[name];
config.concat[name].files['dist/joint.' + name + '.min.css'] = ['build/min/joint.' + name + '.min.css'];
config.concat[name].files['build/joint.' + name + '.css'] = css.plugins[name];
config.concat[name].files['build/joint.' + name + '.min.css'] = ['build/min/joint.' + name + '.min.css'];
}
});

Expand Down Expand Up @@ -469,22 +491,34 @@ module.exports = function(grunt) {
]);

grunt.registerTask('build', ['build:joint']);

grunt.registerTask('build:bundles', ignoreWebpack ? [
'newer:browserify'
] : [
'newer:browserify',
'newer:webpack'
]);
grunt.registerTask('build:all', ['build:joint', 'build:bundles']);

grunt.registerTask('build:all', [
'build:joint',
'build:bundles'
]);

grunt.registerTask('dist', [
'build:all',
'clean:dist',
'copy:dist'
]);

grunt.registerTask('test:server', ['mochaTest:server']);
grunt.registerTask('test:client', ['qunit:all', 'jscs']);
grunt.registerTask('test', ['test:server', 'test:client']);
grunt.registerTask('test:client', ['qunit:all']);
grunt.registerTask('test:code-style', ['jscs']);
grunt.registerTask('test', ['test:server', 'test:client', 'test:code-style']);

grunt.registerTask('bowerInstall', [
'shell:bowerInstall:.'
]);

grunt.registerTask('install', ['bowerInstall']);
grunt.registerTask('install', ['bowerInstall', 'build:all']);
grunt.registerTask('default', ['install', 'build', 'watch']);
};
49 changes: 43 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,43 @@ Only the good ones (those that support SVG):
* IE 9+


## Tests
## Development Environment

Before running tests, be sure to run a full build:
If you want to work on JointJS locally, use the following guidelines to get started.

### Dependencies

Make sure you have the following dependencies installed on your system:
* [Node.js](https://nodejs.org/)
* [grunt-cli](http://gruntjs.com/using-the-cli)
* [bower](http://bower.io/)
* git

### Setup

Clone this git repository:
```
git clone https://github.com/clientIO/joint.git
```

Change into the joint directory:
```
cd joint
```

Run installation
```
grunt build:all
npm install
```
This will install all npm and bower dependencies as well as run a full build.

### Tests

Before running tests, be sure to run the following:
```
npm install
```
This will ensure that you have all NPM and bower dependencies, and will run a full build.

To run all tests:
```
Expand All @@ -62,11 +93,10 @@ grunt test:client

To run code style checks:
```
grunt jscs
grunt test:code-style
```


## Code Coverage
### Code Coverage

It is possible to generate code coverage reports using the existing qunit tests. For example, to output the coverage report in [lcov format](http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php) for all unit tests:
```
Expand All @@ -78,6 +108,13 @@ By default, the output will be saved to `coverage.info` at the root of the proje
grunt qunit:all_coverage --reporter lcov --output customfilename.info --coverage
```

### Building Distribution Files

The `dist` directory contains pre-built distribution files. To re-build them, run the following:
```
grunt dist
```


## License

Expand Down
4 changes: 2 additions & 2 deletions demo/3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<title>3d shapes experiment</title>

<link rel="stylesheet" type="text/css" href="../dist/joint.css" />
<link rel="stylesheet" type="text/css" href="../build/joint.css" />

<style>
#paper {
Expand All @@ -23,7 +23,7 @@
<script src="../node_modules/lodash/index.js"></script>
<script src="../node_modules/backbone/backbone.js"></script>

<script src="../dist/joint.js"></script>
<script src="../build/joint.js"></script>

<script src="./3d.js"></script>

Expand Down
4 changes: 2 additions & 2 deletions demo/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<title>Basic shapes</title>

<link rel="stylesheet" type="text/css" href="../dist/joint.css" />
<link rel="stylesheet" type="text/css" href="../build/joint.css" />

<style>
#paper {
Expand Down Expand Up @@ -49,7 +49,7 @@
<script src="../node_modules/lodash/index.js"></script>
<script src="../node_modules/backbone/backbone.js"></script>

<script src="../dist/joint.js"></script>
<script src="../build/joint.js"></script>

<script src="./basic.js"></script>

Expand Down
Loading