-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
176 lines (171 loc) · 6.37 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
/**
* `grunt test` - run tests
* `grunt lint` - lint front and backend
* `grunt docs` - create docs
* `grunt validate` - check everything is how it should be before making a pull request a main branch
*/
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
node : true, // node variables
browser : true, // browser variables
curly: true, // disallow functions without curly braces
eqeqeq: true, // === and !== instead of == and !=
strict: true, // have to enable strict mode
undef: true, // disallow globally defined variables
noarg: true, // prevents depreciated javascript functions
loopfunc: true, // disallow functions inside loops
immed: true, // disallow immediate functions, they need ()
indent: 4, // force tab indentation to be set to 4
quotmark: 'single', // force use of single quotation marks
camelcase: true, // forces camel case - note this needs to be ignored when using json apis
unused: true, // disallows unused variables
eqnull: true, // allow variable comparison with null or undefined
laxcomma: true, // allow commas before variables or keys
'-W018': true, // Ignore `confusing use of ..` - this stops warning for `!!`
globals: {
},
ignores: ['example/client/public/bower_components/**/**/**/**/**/*.js', 'lib/static/dev/*.js', 'lib/static/dist/*.js'],
reporter: require('jshint-stylish')
},
uses_defaults: ['lib/**/**/*.js', 'example/**/**/**/*.js']
},
jsdox: {
generate: {
options: {
contentsEnabled: true,
contentsTitle: 'Upper',
contentsFile: 'readme.md'
},
src: ['lib/**/**/*.js', 'test/server/**/*.js', 'test/client/**/*.js'],
dest: 'docs'
}
},
mochaTest: {
lib: {
options: {
reporter: 'spec',
growl: true,
colors: true
},
src: ['test/server/**/**/*Spec.js', 'test/common.js']
}
},
concat: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %> */ \n \n (function () { \n',
footer: '\n })();\n',
stripHeaders: true
},
dist: {
src: ['lib/static/dev/core.js', 'lib/static/dev/browser.js'],
dest: 'lib/static/dev/temp.js'
},
angular: {
src: ['lib/static/dev/core.js', 'lib/static/dev/ng-upper.js'],
dest: 'lib/static/dev/ng-temp.js'
},
},
browserify: {
dist: {
files: {
'lib/static/dist/upper.js': ['lib/static/dev/temp.js'],
'lib/static/dist/ng-upper.js': ['lib/static/dev/ng-temp.js']
},
options: {
}
}
},
uglify: {
dist: {
files: {
'lib/static/dist/upper.min.js': ['lib/static/dist/upper.js'],
'lib/static/dist/ng-upper.min.js': ['lib/static/dist/ng-upper.js']
}
}
},
clean: {
build: {
src: ["lib/static/dev/temp.js", "lib/static/dev/ng-temp.js"]
}
},
express: {
options: {
},
test: {
options: {
script: 'test/resources/server.js',
spawn: false
}
}
},
shell: {
express: {
options: {
port: 9000
},
command: 'node test/resources/server.js'
}
},
// protractor: {
// options: {
// configFile: "test/e2e/e2e.conf.js",
// keepAlive: false,
// noColor: false,
// args: {
// }
// },
// your_target: {
// options: {
// // configFile: "e2e.conf.js", // Target-specific config file
// // args: {} // Target-specific arguments
// }
// },
// },
// Distribution
mkdir: {
dist: {
options: {
create: ['dist', './dist']
},
},
},
copy: {
dist: {
files: [
{
expand: true,
src: ['index.js', 'package.json', 'README.md', 'lib/**/**/**/**/*.js'],
dest: 'dist'
}
]
}
}
});
// npm modules
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jsdox');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-mocha-selenium');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-mkdir');
grunt.loadNpmTasks('grunt-contrib-copy');
// tasks
grunt.registerTask('build', ['concat:dist', 'concat:angular', 'browserify', 'uglify', 'clean']);
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('test:frontend', ['express']);
grunt.registerTask('test:e2e', ['express']);
grunt.registerTask('test:backend', ['mochaTest']);
grunt.registerTask('test', ['test:backend']);
grunt.registerTask('example', ['shell:express']);
grunt.registerTask('dist', ['mkdir:dist', 'copy:dist']);
grunt.registerTask('default', ['build', 'test', 'lint', 'dist']);
};