-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
164 lines (134 loc) · 5.18 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
module.exports = function(grunt) {
'use strict';
var path = require('path'),
_ =require('underscore');
var settings = grunt.file.readJSON('settings.json'),
personal = grunt.file.exists('personal.json') ?
grunt.file.readJSON('personal.json') : {},
c6Settings = (function(settings) {
function loadGlobalConfig(relPath) {
var configPath = path.join(process.env.HOME, relPath),
configExists = grunt.file.exists(configPath);
return configExists ? grunt.file.readJSON(configPath) : {};
}
_.extend(this, settings);
this.saucelabs = loadGlobalConfig(settings.saucelabsJSON);
this.browserstack = loadGlobalConfig(settings.browserstackJSON);
this.aws = loadGlobalConfig(settings.awsJSON);
return this;
}.call({}, settings));
if (!grunt.file.exists('.c6stubinit') && grunt.cli.tasks[0] !== 'init') {
grunt.fail.warn('This project has not been initialized. Please run "grunt init".');
}
require('load-grunt-config')(grunt, {
configPath: path.join(__dirname, 'tasks/options'),
config: {
settings: c6Settings,
personal: personal
}
});
grunt.loadTasks('tasks');
/*********************************************************************************************
*
* SERVER TASKS
*
*********************************************************************************************/
grunt.registerTask('server', 'start a development server', function() {
var secure = grunt.option('secure');
grunt.config.set('connect.options.protocol', secure ? 'https' : 'http');
[
'configureProxies:app',
'connect:app',
'open:server',
'watch:livereload'
].forEach(function(task) {
grunt.task.run(task);
});
});
/*********************************************************************************************
*
* TEST TASKS
*
*********************************************************************************************/
grunt.registerTask('test', 'run unit and E2E tests', [
'test:unit',
'test:e2e:all'
]);
grunt.registerTask('test:unit', 'run unit tests', [
'jshint:all',
'clean:build',
'ngtemplates:test',
'karma:directives',
'karma:controllers',
'karma:states',
'karma:services',
'karma:other'
]);
grunt.registerTask('test:unit:debug', 'run unit tests whenever files change', [
'karma:debug'
]);
grunt.registerTask('test:e2e', 'run e2e tests on specified browser', function(browser, env) {
var protractorTask;
env = env || settings.defaultE2EEnv;
protractorTask = 'protractor:' + ((browser === 'all') ? '' : browser) + ':' + (env);
grunt.task.run('connect:sandbox');
if (env === 'saucelabs') {
grunt.task.run('sauceconnect:e2e');
} else if (env === 'browserstack') {
grunt.task.run('browserstacktunnel:e2e');
} else if (env === 'local') {
grunt.task.run('updatewebdriver');
}
grunt.task.run(protractorTask);
});
grunt.registerTask(
'test:e2e:debug',
'run e2e tests locally whenever files change',
function(browser) {
grunt.task.run('test:e2e:' + (browser || '') + ':local');
grunt.task.run('watch:e2e:' + (browser || ''));
}
);
grunt.registerTask('test:htmlinspect:selfie', 'validate html', function() {
var secure = grunt.option('secure');
grunt.config.set('connect.options.protocol', secure ? 'https' : 'http');
[
'configureProxies:app',
'connect:app',
'updatewebdriver',
'protractor:phantomjs:phantomjs'
].forEach(function(task) {
grunt.task.run(task);
});
});
/*********************************************************************************************
*
* BUILD TASKS
*
*********************************************************************************************/
grunt.registerTask('build', 'build app into distDir', [
'test:unit',
'git_describe_tags',
'clean:build',
'copy:dist',
'ngtemplates:dist',
'htmlmin:dist',
'replace:dist',
'requirejs:dist'
]);
/*********************************************************************************************
*
* UPLOAD TASKS
*
*********************************************************************************************/
grunt.registerTask('publish:collateral', 'upload collateral assets to s3', function(target) {
grunt.task.run('s3:collateral-' + target);
});
grunt.registerTask('publish:app', 'build and upload the application to s3', function(target) {
grunt.task.run('build');
grunt.task.run('s3:' + target);
});
grunt.registerTask('publish', 'upload the collateral assets and app to s3', function(target) {
grunt.task.run('publish:app:' + target);
});
};