-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgulpfile.js
139 lines (121 loc) · 3.69 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
129
130
131
132
133
134
135
136
137
138
139
var gulp = require('gulp');
var shell = require('gulp-shell');
var execSync = require('child_process').execSync;
var runSequence = require('run-sequence');
// ======== meteor-build-client ========
gulp.task('meteor-build-client', function() {
execSync('(cd meteor && ' +
'../node_modules/.bin/meteor-build-client ../meteor-build/ -p "")', {
stdio: [0, 1, 2],
});
});
// ======== move files ========
gulp.task('copy-meteor-to-build', function() {
return gulp
.src('./meteor-build/**/*')
.pipe(gulp.dest('./build'));
});
gulp.task('copy-electron-to-build', function() {
return gulp
.src('./electron/**/*')
.pipe(gulp.dest('./build'));
});
var del = require('del');
gulp.task('clean-build', function() {
return del.sync([
'build/**/*',
'!build',
]);
});
gulp.task('copy-all', [
'clean-build',
'copy-meteor-to-build',
'copy-electron-to-build',
]);
// ======== electron ========
gulp.task('run-electron', ['copy-all'], shell.task([
'electron ./build',
]));
gulp.task('run-electron-localhost', shell.task(['electron .']));
gulp.task('watch-all', function() {
gulp.watch('./electron/**/*', ['copy-all']);
});
// ======== build and package ========
var packager = require('electron-packager');
var argv = require('yargs').argv;
// usage: gulp build-electron --name="MY_APP_NAME"
gulp.task('build-electron', ['copy-all'], function() {
packager({
dir: './build',
name: (argv.name ? argv.name : 'MyApp'),
all: false, // true will build linux, win32, darwin. with ia32, x64
platform: [argv.platform], // optional if "all" is set true
arch: argv.arch,
version: '0.33.0',
icon: 'icon.icns', // ignore the file extension, packager will do the job!
// uncomment the following line if anything you want to ignore (Regex)
// ignore: './electron/node_modules/*',
// prune: true,
overwrite: true,
asar: true,
}, function done(err, appPath) {
if (err) {
throw console.error(err);
}
console.log('Done packaging electron app!\n',
'Your app is at' + appPath);
});
});
// usage: gulp build-electron-all --name="MY_APP_NAME"
gulp.task('build-electron-all', ['copy-all'], function() {
packager({
dir: './build',
name: (argv.name ? argv.name : 'MyApp'),
all: true, // true will build linux, win32, darwin. with ia32, x64
version: '0.33.0',
icon: 'icon.icns', // ignore the file extension, packager will do the job!
// uncomment the following line if anything you want to ignore (Regex)
// ignore: './electron/node_modules/*',
// prune: true,
overwrite: true,
asar: true,
}, function done(err, appPath) {
if (err) {
throw console.error(err);
}
console.log('Done packaging electron app!\n',
'Your app is at' + appPath);
});
});
// ======== commands ========
gulp.task('default', [
'meteor-build-client',
'run-electron',
]);
gulp.task('preview', [
'run-electron-localhost',
]);
gulp.task('watch', [
'meteor-build-client',
'watch-all',
]);
gulp.task('build', function() {
if (!argv.platform) {
console.error('[ERROR] You need to specify a "playform" to build');
console.error(' eg. gulp build --platform="darwin" --arch="x64"');
console.error('or use "gulp build-all" to build for all platforms.');
console.warn('For more information, see README.md build section.');
return;
}
if (!argv.arch) {
console.error('[ERROR] You need to specify a "arch" to build');
console.error(' eg. gulp build --platform="linux" --arch="x64"');
console.warn('For more information, see README.md build section.');
return;
}
runSequence('meteor-build-client', 'build-electron');
});
gulp.task('build-all', [
'meteor-build-client',
'build-electron-all',
]);