2014-03-11 14:54:36 +00:00
|
|
|
module.exports = function(grunt) {
|
|
|
|
|
|
|
|
require('load-grunt-tasks')(grunt);
|
|
|
|
|
|
|
|
// project configuration
|
|
|
|
grunt.initConfig({
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
|
|
|
|
config: {
|
|
|
|
sources: 'lib',
|
|
|
|
tests: 'test',
|
|
|
|
dist: 'dist',
|
|
|
|
samples: 'example'
|
|
|
|
},
|
|
|
|
|
|
|
|
jshint: {
|
|
|
|
src: [
|
|
|
|
['<%=config.sources %>']
|
|
|
|
],
|
|
|
|
gruntfile: [
|
|
|
|
'Gruntfile.js'
|
|
|
|
],
|
|
|
|
options: {
|
|
|
|
jshintrc: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
jasmine_node: {
|
|
|
|
specNameMatcher: '.*Spec',
|
2014-03-13 10:21:03 +00:00
|
|
|
projectRoot: 'test/spec/node',
|
2014-03-11 14:54:36 +00:00
|
|
|
jUnit: {
|
|
|
|
report: true,
|
|
|
|
savePath : 'tmp/reports/jasmine',
|
|
|
|
useDotNotation: true,
|
|
|
|
consolidate: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
karma: {
|
|
|
|
options: {
|
|
|
|
configFile: '<%= config.tests %>/config/karma.unit.js'
|
|
|
|
},
|
|
|
|
single: {
|
|
|
|
singleRun: true,
|
|
|
|
autoWatch: false,
|
|
|
|
|
|
|
|
browsers: ['PhantomJS'],
|
|
|
|
|
|
|
|
browserify: {
|
|
|
|
watch: false,
|
|
|
|
debug: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
unit: {
|
|
|
|
browsers: [ 'Chrome' ]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
browserify: {
|
|
|
|
options: {
|
|
|
|
alias: [
|
2014-03-13 10:21:03 +00:00
|
|
|
'<%= config.sources %>/main.js:bpmn',
|
|
|
|
'<%= config.sources %>/Model.js:bpmn/Model'
|
2014-03-11 14:54:36 +00:00
|
|
|
]
|
|
|
|
},
|
2014-03-13 10:21:03 +00:00
|
|
|
sources: {
|
2014-03-11 14:54:36 +00:00
|
|
|
files: {
|
|
|
|
'<%= config.dist %>/bpmn.js': [ '<%= config.sources %>/**/*.js' ]
|
|
|
|
},
|
|
|
|
options: {
|
2014-03-13 10:21:03 +00:00
|
|
|
debug: true,
|
|
|
|
transform: [ 'debowerify' ]
|
2014-03-11 14:54:36 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
dist: {
|
|
|
|
files: {
|
|
|
|
'<%= config.dist %>/bpmn.js': [ '<%= config.sources %>/**/*.js' ]
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
debug: false,
|
2014-03-13 10:21:03 +00:00
|
|
|
transform: [ 'debowerify', 'uglifyify' ]
|
2014-03-11 14:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-03-11 15:24:31 +00:00
|
|
|
copy: {
|
|
|
|
samples: {
|
|
|
|
files: [
|
|
|
|
// copy sample files
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= config.samples %>/',
|
|
|
|
src: ['*.{js,css,html,png}'],
|
|
|
|
dest: '<%= config.dist %>/<%= config.samples %>'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2014-03-11 14:54:36 +00:00
|
|
|
watch: {
|
|
|
|
sources: {
|
2014-03-13 10:21:03 +00:00
|
|
|
files: [ '<%= config.sources %>/**/*.js', '<%= config.samples %>/**/*.*' ],
|
|
|
|
tasks: [ 'browserify:sources', 'copy:samples' ]
|
|
|
|
},
|
|
|
|
samples: {
|
|
|
|
files: [ '<%= config.samples %>/**/*.*' ],
|
|
|
|
tasks: [ 'copy:samples' ]
|
2014-03-11 14:54:36 +00:00
|
|
|
},
|
|
|
|
jasmine_node: {
|
2014-03-13 10:21:03 +00:00
|
|
|
files: [ '<%= config.sources %>/**/*.js', '<%= config.tests %>/spec/node/**/*.js' ],
|
|
|
|
tasks: [ 'jasmine_node' ]
|
2014-03-11 14:54:36 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
jsdoc: {
|
|
|
|
dist: {
|
|
|
|
src: [ '<%= config.sources %>/**/*.js' ],
|
|
|
|
options: {
|
|
|
|
destination: 'docs',
|
|
|
|
plugins: [ 'plugins/markdown' ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
concurrent: {
|
2014-03-13 10:21:03 +00:00
|
|
|
'sources': [ 'browserify:sources', 'jshint' ],
|
2014-03-11 14:54:36 +00:00
|
|
|
'build': [ 'jshint', 'build', 'jsdoc' ]
|
2014-03-12 09:59:06 +00:00
|
|
|
},
|
|
|
|
connect: {
|
|
|
|
options: {
|
|
|
|
port: 9003,
|
|
|
|
livereload: 35726,
|
|
|
|
hostname: 'localhost'
|
|
|
|
},
|
|
|
|
livereload: {
|
|
|
|
options: {
|
|
|
|
open: true,
|
|
|
|
base: [
|
|
|
|
'<%= config.dist %>'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2014-03-13 10:21:03 +00:00
|
|
|
}
|
2014-03-11 14:54:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// tasks
|
|
|
|
|
|
|
|
grunt.registerTask('test', [ 'jasmine_node', 'karma:single' ]);
|
2014-03-13 10:21:03 +00:00
|
|
|
grunt.registerTask('build', [ 'browserify:dist', 'copy:samples' ]);
|
|
|
|
|
2014-03-12 09:59:06 +00:00
|
|
|
grunt.registerTask('auto-build', [
|
2014-03-13 10:21:03 +00:00
|
|
|
'concurrent:sources',
|
2014-03-12 09:59:06 +00:00
|
|
|
'connect:livereload',
|
|
|
|
'watch'
|
|
|
|
]);
|
2014-03-11 14:54:36 +00:00
|
|
|
|
2014-03-13 10:21:03 +00:00
|
|
|
grunt.registerTask('auto-test', [ 'jasmine_node', 'watch:jasmine_node' ]);
|
2014-03-11 14:54:36 +00:00
|
|
|
|
|
|
|
grunt.registerTask('default', [ 'jshint', 'test', 'build', 'jsdoc' ]);
|
|
|
|
};
|