-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
128 lines (108 loc) · 4.07 KB
/
gulpfile.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
'use strict'
const gulp = require('gulp')
const shell = require('gulp-shell')
const packager = require('electron-packager')
const childProcess = require('child_process')
const conf = require('./package.json')
const fs = require('fs')
const Zip = require('node-7z')
const git_hash = childProcess.execSync('git rev-parse HEAD').toString().trim()
const iconColor = '#ff8080'
gulp.task('update:icon', [], shell.task([
'mkdir -p build/tmp build/tmp/app.iconset/',
`curl ls8h.com/yosemite-icon/api -F "icon_image=@src/icon.png" -F "base_color=${iconColor}" > build/tmp/icon.png`,
'sips -Z 16 build/tmp/icon.png --out build/tmp/app.iconset/icon_16x16.png',
'sips -Z 32 build/tmp/icon.png --out build/tmp/app.iconset/[email protected]',
'sips -Z 32 build/tmp/icon.png --out build/tmp/app.iconset/icon_32x32.png',
'sips -Z 64 build/tmp/icon.png --out build/tmp/app.iconset/[email protected]',
'sips -Z 128 build/tmp/icon.png --out build/tmp/app.iconset/icon_128x128.png',
'sips -Z 256 build/tmp/icon.png --out build/tmp/app.iconset/[email protected]',
'sips -Z 256 build/tmp/icon.png --out build/tmp/app.iconset/icon_256x256.png',
'sips -Z 512 build/tmp/icon.png --out build/tmp/app.iconset/[email protected]',
'sips -Z 512 build/tmp/icon.png --out build/tmp/app.iconset/icon_512x512.png',
'sips -Z 1024 build/tmp/icon.png --out build/tmp/app.iconset/[email protected]',
'(cd build && iconutil -c icns tmp/app.iconset && mv tmp/app.icns ../src/)',
'(cd build && convert tmp/icon.png -define icon:auto-resize ../src/app.ico)',
'sips -Z 18 src/icon.png --out src/browser/tray-icon.png'
]))
gulp.task('build:webpack', shell.task([
'webpack --progress --colors'
]))
gulp.task('build', ['build:webpack'])
gulp.task('release:osx', ['build'], (done) => {
let packagerConf = {
dir: 'build',
out: 'release/',
name: conf.name,
arch: 'x64',
asar: true,
platform: 'darwin',
version: conf.dependencies['electron-prebuilt'],
icon: 'build/tmp/app.icns',
ignore: ['tmp'],
overwrite: true
}
if (process.env.ELECTRON_SIGN) {
packagerConf['sign'] = process.env.ELECTRON_SIGN
}
packager(packagerConf, (err, path) => {
let archive = new Zip()
archive.add(`release/${conf.name}-darwin-${conf.version}.7z`, `release/${conf.name}-darwin-x64/`, {
m0: '=BCJ',
m1: '=LZMA:d=21'
}).then(() => {
})
})
})
gulp.task('release:win', ['build'], (done) => {
let packagerConf = {
dir: 'build',
out: 'release/',
name: conf.name,
arch: ['ia32', 'x64'],
asar: true,
platform: 'win32',
version: conf.dependencies['electron-prebuilt'],
icon: 'build/tmp/app.ico',
ignore: ['tmp'],
overwrite: true
}
if (process.env.ELECTRON_SIGN) {
packagerConf['sign'] = process.env.ELECTRON_SIGN
}
packager(packagerConf, (err, pathes) => {
pathes.forEach((path) => {
const a = path.split('-')
const platform = a[1]
const arch = a[2]
let archive = new Zip()
archive.add(`release/${conf.name}-${platform}-${arch}-${conf.version}.7z`, path, {
m0: '=BCJ',
m1: '=LZMA:d=21'
}).then(() => {
})
})
})
})
gulp.task('release', ['release:osx', 'release:win'])
gulp.task('serve', ['build'], () => {
const electron = require('electron-connect').server.create({
path: 'build/',
spawnOpt: {
env: {
GIT_HASH: git_hash,
ROOT: __dirname,
NAME: conf.name,
VERSION: conf.version
}
}
})
electron.start()
// gulp.watch('src/browser/*', ['build:webpack', electron.restart])
gulp.watch('src/renderer/**', ['build:webpack', electron.reload])
electron.on('quit', () => {
process.exit(0)
})
// electron.on('changeBounds', (arg) => console.dir(arg))
})
gulp.task('default', ['serve'])