forked from camunda/camunda-bpm-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
127 lines (95 loc) · 3.1 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* jshint node: true */
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// require('time-grunt')(grunt);
var dryRun = grunt.option('dryRun') || false;
var pkg = require('./package.json');
var config = {};
config.grunt = grunt;
config.pkg = pkg;
config.dryRun = dryRun;
grunt.initConfig({
pkg: pkg,
dryRun: dryRun,
browserify: require('./grunt/config/browserify')(config),
clean: ['documentation', 'dist', '.tmp', 'staging'],
copy: require('./grunt/config/copy')(config),
eslint: require('./grunt/config/eslint')(config),
mochacli: require('./grunt/config/mocha-cli')(config),
jshint: require('./grunt/config/jshint')(config),
karma: require('./grunt/config/karma')(config),
watch: require('./grunt/config/watch')(config),
uglify: require('./grunt/config/uglify')(config),
bump: require('./grunt/config/bump')(config),
release: require('./grunt/config/release')(config),
bowerRelease: require('./grunt/config/release-bower')(config)
});
grunt.registerTask('build', function(mode) {
mode = mode || 'prod';
grunt.log.writeln('Build JS SDK in "'+ mode +'" mode');
var tasks = [
'newer:eslint',
'clean',
'copy:assets',
'browserify'
];
if (mode === 'prod') {
tasks = tasks.concat([
'uglify'
]);
}
if (mode === 'dev') {
tasks.push('copy:builds');
}
grunt.task.run(tasks);
});
grunt.registerTask('auto-build', [
'build:dev',
'watch:sources',
'watch:karma'
]);
grunt.registerTask('publish', function(mode) {
mode = mode || 'snapshot';
var tasks = [];
var skipBowerRelease = grunt.option('skip-bower-release') || false;
// check options
if (mode !== 'release' && mode !== 'snapshot' && mode !== 'version') {
grunt.fatal('Only snapshot and release targets are allowed for the publish task! mode=' + mode);
}
grunt.log.writeln('Publishing JS SDK in "'+ mode +'" mode.');
if ((mode === 'release' || mode === 'version') && !grunt.option('setversion')) {
grunt.fatal('No version specified using the --set-version=VERSION param!');
}
if (skipBowerRelease) {
grunt.log.writeln('Skipping bower release.');
}
if (mode === 'snapshot') {
tasks = tasks.concat([
'build:prod'
]);
if (!skipBowerRelease) {
tasks = tasks.concat(['bowerRelease:' + mode]);
}
} else if (mode === 'version') {
// just increase version
tasks = tasks.concat([
'bump:only',
'bump:snapshot' // commit, push
]);
} else {
// release mode
tasks = tasks.concat([
'bump:only',
'build:prod',
'bump:release', // commit, tag, push
'release' // npm release
]);
if (!skipBowerRelease) {
tasks = tasks.concat(['bowerRelease:' + mode]);
}
}
grunt.task.run(tasks);
});
grunt.registerTask('default', ['build']);
};