forked from felixrieseberg/xplat
/
Gruntfile.js
300 lines (295 loc) · 12.9 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
module.exports = function (grunt) {
// Load all grunt tasks matching the `grunt-*` pattern,
// unless we're on Linux or Windows
if (process.platform && process.platform === 'darwin') {
require('load-grunt-tasks')(grunt);
} else {
require('load-grunt-tasks')(grunt, {scope: ['devDependencies', 'dependencies']});
}
// Get Version
function getVersion () {
var githash = require('githash');
var version = process.env.RELEASE_VERSION ? process.env.RELEASE_VERSION : githash();
}
var files = ['app/**/*.js', 'Brocfile.js'];
// Tagged builds get their own folders. live builds just go to live folder
var cdnPath = process.env.RELEASE_VERSION ? process.env.RELEASE_VERSION : 'live';
grunt.initConfig({
appdmg: {
options: {
title: 'Azure Storage Exporer',
icon: './public/icon/ase.icns',
background: './postcompile/osx/background.tiff',
'icon-size': 156,
contents: [{
x: 470,
y: 430,
type: 'link',
path: '/Applications'
}, {
x: 120,
y: 430,
type: 'file',
path: './builds/storageexplorer-darwin-x64/storageexplorer.app'
}]
},
target: {
dest: './builds/Azure Storage Explorer-darwin-x64/storageexplorer.dmg'
}
},
copy: {
app: {
expand: true,
src: ['electron.js', 'package.json', 'dist/**', 'node_modules/azure-storage/**', 'node_modules/fs-extra/**', 'node_modules/electron-gh-releases/**'],
dest: 'electronbuildcache/'
},
version_file: {
src: ['./.version'],
dest: 'electronbuildcache/dist/version'
}
},
'create-windows-installer': {
ia32: {
appDirectory: 'builds/storageexplorer-win32-ia32',
outputDirectory: 'builds/installer32',
exe: 'storageexplorer.exe',
iconUrl: 'http://raw.githubusercontent.com/azure-storage/xplat/master/public/icon/ase.ico',
setupIcon: 'public/icon/ase.ico',
authors: 'Felix Rieseberg, Steven Edouard, Rita Zhang',
loadingGif: 'postcompile/windows/installer.gif'
},
x64: {
appDirectory: 'builds/storageexplorer-win32-x64',
outputDirectory: 'builds/installer64',
exe: 'storageexplorer.exe',
iconUrl: 'http://raw.githubusercontent.com/azure-storage/xplat/master/public/icon/ase.ico',
setupIcon: 'public/icon/ase.ico',
authors: 'Felix Rieseberg, Steven Edouard, Rita Zhang',
loadingGif: 'postcompile/windows/installer.gif'
}
},
jshint: {
files: files,
options: {
jshintrc: './.jshintrc'
}
},
jscs: {
files: {
src: files
},
options: {
config: '.jscsrc',
esnext: true
}
},
jsbeautifier: {
test: {
files: {
src: files
},
options: {
mode: 'VERIFY_ONLY',
config: '.beautifyrc'
}
},
write: {
files: {
src: files
},
options: {
config: '.beautifyrc'
}
}
},
electron: {
osx: {
options: {
name: 'Azure Storage Explorer',
platform: 'darwin',
arch: 'x64',
dir: 'electronbuildcache',
out: 'builds',
version: '0.32.1',
overwrite: true,
icon: 'public/icon/ase.icns',
'app-version': getVersion(),
'build-version': getVersion()
}
},
windows: {
options: {
name: 'storageexplorer',
platform: 'win32',
arch: 'all',
dir: 'electronbuildcache',
out: 'builds',
version: '0.32.1',
overwrite: true,
}
},
windowsWithIcon: {
options: {
name: 'storageexplorer',
platform: 'win32',
arch: 'all',
dir: 'electronbuildcache',
out: 'builds',
version: '0.32.1',
overwrite: true,
icon: 'public/icon/ase.ico',
asar: true,
'version-string': {
ProductName: 'Azure Storage Explorer',
ProductVersion: getVersion(),
FileDescription: 'Azure Storage Explorer',
ProductVersion: 'Azure Storage Explorer.exe'
}
}
},
linux: {
options: {
name: 'storageexplorer',
platform: 'linux',
arch: 'ia32',
dir: 'electronbuildcache',
out: 'builds',
version: '0.32.1',
overwrite: true
}
},
},
exec: {
build: {
command: 'node ./node_modules/ember-cli/bin/ember build --environment=production'
},
flatten: {
command: 'node ../node_modules/flatten-packages/bin/flatten .',
cwd: './electronbuildcache'
}
},
zip: {
linux: {
cwd: './builds/storageexplorer-linux-ia32',
src: ['./builds/storageexplorer-linux-ia32/**/*'],
dest: './builds/storageexplorer-linux-ia32/build.zip'
},
osx: {
cwd: './builds/storageexplorer-darwin-x64',
src: ['./builds/storageexplorer-darwin-x64/**/*'],
dest: './builds/storageexplorer-darwin-x64/build.zip'
},
windows: {
cwd: './builds/storageexplorer-win32-ia32',
src: ['./builds/storageexplorer-win32-ia32/*'],
dest: './builds/storageexplorer-win32-ia32/build.zip'
}
},
'if': {
'trusted-deploy-to-azure-cdn-windows': {
options: {
test: function () {
// these variables will only be valid and set during trusted builds
var trustedBuild = (typeof process.env.AZURE_STORAGE_ACCOUNT === 'string' && typeof process.env.AZURE_STORAGE_ACCESS_KEY === 'string');
return trustedBuild;
}
},
ifTrue: ['azure-cdn-deploy:windows'],
ifFalse: []
},
'trusted-deploy-to-azure-cdn-unix': {
options: {
test: function () {
// these variables will only be valid and set during trusted builds
var trustedBuild = (typeof process.env.AZURE_STORAGE_ACCOUNT === 'string' && typeof process.env.AZURE_STORAGE_ACCESS_KEY === 'string');
return trustedBuild;
}
},
ifTrue: ['azure-cdn-deploy:osx', 'azure-cdn-deploy:linux'],
ifFalse: []
}
},
// deploys live build to cdn
'azure-cdn-deploy': {
linux: {
options: {
containerName: 'builds', // container name in blob
folder: cdnPath + '/linux32', // path within container
zip: false, // gzip files if they become smaller after zipping, content-encoding header will change if file is zipped
deleteExistingBlobs: false, // true means recursively deleting anything under folder
concurrentUploadThreads: 10, // number of concurrent uploads, choose best for your network condition
metadata: {
cacheControl: 'public, max-age=31530000', // cache in browser
cacheControlHeader: 'public, max-age=31530000' // cache in azure CDN. As this data does not change, we set it to 1 year
},
testRun: false // test run - means no blobs will be actually deleted or uploaded, see log messages for details
},
src: [
'./build.zip'
],
cwd: './builds/storageexplorer-linux-ia32/'
},
osx: {
options: {
containerName: 'builds', // container name in blob
folder: cdnPath + '/darwin64', // path within container
zip: false, // gzip files if they become smaller after zipping, content-encoding header will change if file is zipped
deleteExistingBlobs: false, // true means recursively deleting anything under folder
concurrentUploadThreads: 10, // number of concurrent uploads, choose best for your network condition
metadata: {
cacheControl: 'public, max-age=31530000', // cache in browser
cacheControlHeader: 'public, max-age=31530000' // cache in azure CDN. As this data does not change, we set it to 1 year
},
testRun: false // test run - means no blobs will be actually deleted or uploaded, see log messages for details
},
src: [
'./build.zip'
],
cwd: './builds/storageexplorer-darwin-x64/'
},
windows: {
options: {
containerName: 'builds', // container name in blob
folder: cdnPath + '/win32', // path within container
zip: false, // gzip files if they become smaller after zipping, content-encoding header will change if file is zipped
deleteExistingBlobs: false, // true means recursively deleting anything under folder
concurrentUploadThreads: 10, // number of concurrent uploads, choose best for your network condition
metadata: {
cacheControl: 'public, max-age=31530000', // cache in browser
cacheControlHeader: 'public, max-age=31530000' // cache in azure CDN. As this data does not change, we set it to 1 year
},
testRun: false // test run - means no blobs will be actually deleted or uploaded, see log messages for details
},
src: [
'./build.zip'
],
cwd: './builds/storageexplorer-win32-ia32/'
}
},
'file-creator': {
version_file: {
'.version': function (fs, fd, done) {
var githash = require('githash');
var version = process.env.RELEASE_VERSION ? process.env.RELEASE_VERSION : githash();
fs.writeSync(fd, version);
done();
}
}
},
clean: ['./electronbuildcache', './dist', './builds'],
});
grunt.registerTask('test', ['jshint', 'jscs', 'jsbeautifier:test']);
grunt.registerTask('copyForBuild', ['copy:app', 'copy:version_file']);
grunt.registerTask('prebuild', ['clean', 'exec:build', 'file-creator:version_file', 'copyForBuild']);
grunt.registerTask('osx', ['clean', 'prebuild', 'electron:osx', 'appdmg']);
grunt.registerTask('linux', ['prebuild', 'electron:linux']);
grunt.registerTask('windows', ['prebuild', 'exec:flatten', 'electron:windowsWithIcon', 'create-windows-installer']);
grunt.registerTask('compile', ['prebuild', 'electron:osx', 'appdmg', 'electron:linux', 'electron:windows', 'create-windows-installer']);
// Development Builds
// To deploy a build with an official build number, set env var RELEASE_VERSION to release number
// otherwise application is tagged with git hash
grunt.registerTask('createUnixDevBuild', ['prebuild', 'exec:flatten', 'electron:osx', 'electron:linux', 'zip:osx', 'zip:linux']);
grunt.registerTask('deployUnixDevBuild', ['if:trusted-deploy-to-azure-cdn-unix']);
grunt.registerTask('createWinDevBuild', ['prebuild', 'exec:flatten', 'electron:windowsWithIcon', 'zip:windows']);
grunt.registerTask('deployWinDevBuild', ['if:trusted-deploy-to-azure-cdn-windows']);
};