forked from noeticpenguin/ngForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
222 lines (212 loc) · 5.32 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt, {
pattern: ['grunt-*', '!grunt-template-jasmine-istanbul', 'which']
});
var stdMetadata = {
apexclass: ['*'],
apexpage: ['*'],
staticresource: ['*'],
customobject: ['*'],
apextrigger: ['*'],
apexcomponent: ['*']
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
ngAnnotate: {
options: {
singleQuotes: true
},
ngForce: {
files: [{
expand: true,
cwd: 'jsSrc',
ext: '.annotated.js',
src: ['*.js', 'subModules/*.js'],
dest: 'buildTmp'
}]
},
dependencies: {
files: [{
expand: true,
ext: '.annotated.js',
cwd: 'lib',
src: ['*.js'],
dest: 'buildTmp/lib'
}],
}
},
uglify: {
options: {
sourceMap: true,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' +
'/*! visit https://noeticpenguin.github.io/ngForce for more info. */\n'
},
ngForce: {
files: {
'build/ngForce.min.js': ['buildTmp/*.annotated.js', 'buildTmp/subModules/*.annotated.js']
}
},
requirements: {
files: {
'build/ngForce-dependencies.min.js': ['buildTmp/lib/*.annotated.js']
}
},
oneFile: {
files: {
'build/ngForceWithDependencies.min.js': ['build/ngForce-dependencies.min.js', 'build/ngForce.min.js']
}
}
},
jasmine: {
ngForce: {
src: [
'jsSrc/safeApply.js',
'jsSrc/restangular.js',
'jsSrc/ngForce3.js'
],
options: {
// Include path for Jasmine spec files
// Only include those ending in Spec.js
// Specifically excluding those ending in NotReady.js
specs: [
'test/unit/**/*Spec.js'
],
version: '2.0.0',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'bin/coverage/coverage.json',
report: 'bin/coverage',
thresholds: {
lines: 30,
statements: 20,
branches: 10,
functions: 5
}
}
}
}
},
copy: {
deploy: {
files: [{
src: 'src/**',
dest: 'deployTmp/',
}]
},
},
clean: {
buildTmp: ['buildTmp'],
deployTmp: ['deployTmp']
},
antdeploy: {
options: {
version: '29.0',
root: 'deployTmp/src/',
},
automated: {
options: {
useEnv: true,
serverurl: 'https://test.salesforce.com' // default => https://login.salesforce.com
},
pkg: stdMetadata
},
test: {
options: {
serverurl: 'https://test.salesforce.com' // default => https://login.salesforce.com
},
pkg: stdMetadata
},
prod: {
options: {
serverurl: 'https://login.salesforce.com'
},
pkg: stdMetadata
}
},
availabletasks: {
tasks: {}
},
compress: {
ngForce: {
options: {
mode: 'zip',
archive: 'src/staticresources/ngForce.resource'
},
files: [{
expand: true,
cwd: 'build/',
src: ['**'],
dest: ''
}, ]
},
},
deploy: {
test: {},
prod: {}
},
prompt: {
login: {
options: {
questions: [{
config: 'antdeploy.test.options.user', // arbitray name or config for any other grunt task
type: 'input', // list, checkbox, confirm, input, password
message: "Enter the Deploy Username: ", // Question to ask the user, function needs to return a string,
}, {
config: 'antdeploy.test.options.pass', // arbitray name or config for any other grunt task
type: 'password', // list, checkbox, confirm, input, password
message: "Enter Password (without security token): ", // Question to ask the user, function needs to return a string,
}, {
config: 'antdeploy.test.options.token', // arbitray name or config for any other grunt task
type: 'password', // list, checkbox, confirm, input, password
message: "Enter Security Token: ", // Question to ask the user, function needs to return a string,
}],
then: function(ans) {
grunt.config.merge({
antdeploy: {
prod: {
options: {
user: grunt.config.get('antdeploy.test.options.user'),
pass: grunt.config.get('antdeploy.test.options.pass'),
token: grunt.config.get('antdeploy.test.options.token')
}
}
}
});
// grunt.config.set(antdeploy.prod.options.user, antdeploy.test.options.user);
// grunt.config.set(antdeploy.prod.options.pass, antdeploy.test.options.pass);
// grunt.config.set(antdeploy.prod.options.token, antdeploy.test.options.token);
}
}
},
},
});
// Default task. - Run tests
grunt.registerTask('default', 'min');
// Refresh the static Resource bundle.
grunt.registerTask('refreshResources', "Refresh the staticResource.zip files", function() {
grunt.task.run(['compress:ngForce']);
});
// Deploy task
grunt.registerMultiTask('deploy', "Refreshes resources and deploys to selected env", function() {
grunt.task.run([
'refreshResources',
'copy:deploy',
'prompt:login',
'antdeploy:' + this.target,
'clean:deployTmp'
]);
});
// run ngMin, then uglify the the source into a single ngForce.min.js file.
grunt.registerTask('min', function() {
grunt.task.run([
'ngAnnotate:ngForce',
'ngAnnotate:dependencies',
'uglify:ngForce',
'uglify:requirements',
'uglify:oneFile',
'clean:buildTmp'
]);
});
// Show available tasks.
grunt.registerTask('tasks', ['availabletasks']);
};