This repository has been archived by the owner on Sep 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
Gruntfile.js
191 lines (182 loc) · 5.3 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/**
* Installation:
* 1. Install Grunt CLI (`npm install -g grunt-cli`)
* 1. Install Grunt 0.4.0 and other dependencies (`npm install`)
*
* Build:
* Execute `grunt` from root directory of this directory (where Gruntfile.js is)
* To execute automatically after each change, execute `grunt --force default watch`
* To execute build followed by the test run, execute `grunt test`
*
* See http://gruntjs.com/getting-started for more information about Grunt
*/
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// GENERATED PARSER USING JISON LIBRARY
jison: {
target : {
options: {moduleType: 'js', moduleName: 'Parser'},
files: {'src/parser/parser.js': 'src/parser/parser.jison'}
}
},
// COPY FILES FROM DESIGN DIRECTORY TO DIST DIRECTORY
copy: {
main: {
files: [
{
src: 'lib/underscore.string/lib/underscore.string.js',
dest: 'dist/lib/underscore.string/underscore.string.js'
},
{
src: 'lib/moment/moment.js',
dest: 'dist/lib/moment/moment.js'
},
{
src: 'lib/lodash/dist/lodash.js',
dest: 'dist/lib/lodash/lodash.js'
},
{
src: 'lib/numeral/numeral.js',
dest: 'dist/lib/numeral/numeral.js'
},
{
src: 'lib/js-md5/js/md5.js',
dest: 'dist/lib/js-md5/md5.js'
},
{
src: 'lib/jstat/dist/jstat.js',
dest: 'dist/lib/jstat/jstat.js'
},
{
src: 'lib/formulajs/lib/formula.js',
dest: 'dist/lib/formulajs/formula.js'
},
{
src: 'src/js/ruleJS.js',
dest: 'dist/js/ruleJS.js'
},
{
src: 'src/parser/parser.js',
dest: 'dist/js/parser.js'
}
// ,{
// expand: true,
// cwd: 'src/js/',
// src: ['**'],
// dest: 'dist/js/'
// }
]
}
},
concat: {
dist: {
files : {
'dist/full/ruleJS.lib.full.js': [
'dist/lib/lodash/lodash.js',
'dist/lib/underscore.string/underscore.string.js',
'dist/lib/moment/moment.js',
'dist/lib/numeral/numeral.js',
'dist/lib/js-md5/md5.js',
'dist/lib/jstat/jstat.js',
'dist/lib/formulajs/formula.js'
],
'dist/full/ruleJS.parser.full.js': [
'dist/js/parser.js',
'dist/js/ruleJS.js'
],
'dist/full/ruleJS.all.full.js': [
'dist/full/ruleJS.lib.full.js',
'dist/full/ruleJS.parser.full.js'
]
}
}
},
uglify: {
my_target: {
options: {
preserveComments: false
//mangle: false
},
files: {
'dist/full/ruleJS.all.full.min.js': ['dist/full/ruleJS.all.full.js']
}
}
},
// WATCH CHANGES
watch: {
options: {
livereload: true //works with Chrome LiveReload extension. See: https://github.com/gruntjs/grunt-contrib-watch
},
files: [
'src/*.html',
'src/js/*.js',
'src/parser/*.jison'
],
tasks: ['build']
},
clean: {
dist: ['tmp']
},
replace: {
dist: {
options: {
variables: {
version: '<%= pkg.version %>',
timestamp: '<%= (new Date()).toString() %>'
}
}
}
},
jasmine: {
ruleJS: {
src: [
'dist/js/ruleJS.js',
'dist/js/parser.js'
],
options: {
specs: [
'test/jasmine/spec/*Spec.js',
'test/jasmine/spec/*/*Spec.js'
],
styles: [
'test/jasmine/css/SpecRunner.css'
],
helpers: [
'test/jasmine/spec/SpecHelper.js',
'test/jasmine/lib/nodeShim.js'
],
outfile: 'test/jasmine/SpecRunner.html',
template: 'test/jasmine/templates/SpecRunner.tmpl',
keepRunner: true
}
}
},
connect: {
dev: {
options: {
port: 8080,
hostname: "0.0.0.0",
base: "",
keepalive: true
}
}
}
}
);
// DEFAULT TASKS
grunt.registerTask('default', ['jison', 'copy', 'replace:dist', 'clean', 'concat', 'uglify']);
grunt.registerTask('test', ['default', 'jasmine']);
grunt.registerTask('start', ['default', 'connect']);
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-config');
grunt.loadNpmTasks('grunt-inject');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-jison');
};