ee-bin 4.1.3 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tools/incrUpdater.js +12 -5
- package/tools/serve.js +56 -9
package/package.json
CHANGED
package/tools/incrUpdater.js
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const fsPro = require('fs-extra');
|
|
6
|
-
const crypto = require('crypto')
|
|
6
|
+
const crypto = require('crypto');
|
|
7
7
|
const chalk = require('chalk');
|
|
8
8
|
const { loadConfig, getPackage, writeJsonSync } = require('../lib/utils');
|
|
9
|
-
const admZip = require('adm-zip')
|
|
9
|
+
const admZip = require('adm-zip');
|
|
10
|
+
const globby = require('globby');
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* 增量升级
|
|
@@ -90,11 +92,16 @@ class IncrUpdater {
|
|
|
90
92
|
zip.addLocalFile(asarFilePath);
|
|
91
93
|
// 添加 extraResources
|
|
92
94
|
if (cfg.extraResources && cfg.extraResources.length > 0) {
|
|
93
|
-
|
|
95
|
+
const files = globby.sync(cfg.extraResources, { cwd: homeDir });
|
|
96
|
+
for (const extraRes of files) {
|
|
94
97
|
const extraResPath = path.normalize(path.join(homeDir, extraRes));
|
|
95
|
-
if (fs.existsSync(extraResPath)) {
|
|
96
|
-
|
|
98
|
+
if (!fs.existsSync(extraResPath)) {
|
|
99
|
+
continue;
|
|
97
100
|
}
|
|
101
|
+
const extraResDir = path.dirname(extraResPath);
|
|
102
|
+
const index = extraResDir.indexOf('extraResources');
|
|
103
|
+
const zipFileDir = extraResDir.substring(index);
|
|
104
|
+
zip.addLocalFile(extraResPath, zipFileDir);
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
107
|
|
package/tools/serve.js
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
const debug = require('debug')('ee-bin:serve');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fsPro = require('fs-extra');
|
|
6
|
-
const { loadConfig } = require('../lib/utils');
|
|
6
|
+
const { loadConfig, isWindows } = require('../lib/utils');
|
|
7
7
|
const is = require('is-type-of');
|
|
8
8
|
const chalk = require('chalk');
|
|
9
9
|
const crossSpawn = require('cross-spawn');
|
|
10
10
|
const { buildSync } = require('esbuild');
|
|
11
11
|
const chokidar = require('chokidar');
|
|
12
12
|
const kill = require('tree-kill');
|
|
13
|
+
const process = require("process");
|
|
13
14
|
|
|
14
15
|
class ServeProcess {
|
|
15
16
|
|
|
@@ -18,6 +19,48 @@ class ServeProcess {
|
|
|
18
19
|
this.execProcess = {};
|
|
19
20
|
this.electronDir = './electron';
|
|
20
21
|
this.defaultBundleDir = './public/electron';
|
|
22
|
+
this._init();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* init
|
|
27
|
+
*/
|
|
28
|
+
_init() {
|
|
29
|
+
// process manager
|
|
30
|
+
// Monitor SIGINT signal(Ctrl + C)
|
|
31
|
+
process.on('SIGINT', () => {
|
|
32
|
+
console.log(chalk.blue('[ee-bin] ') + `Received SIGINT. Closing processes...`);
|
|
33
|
+
this._closeProcess();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Monitor SIGTERM signal
|
|
37
|
+
process.on('SIGTERM', () => {
|
|
38
|
+
console.log(chalk.blue('[ee-bin] ') + `Received SIGTERM. Closing processes...`);
|
|
39
|
+
this._closeProcess();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Close process
|
|
44
|
+
async _closeProcess() {
|
|
45
|
+
const currentProcess = [];
|
|
46
|
+
const keys = Object.keys(this.execProcess);
|
|
47
|
+
const len = keys.length;
|
|
48
|
+
for (let i = 0; i < len; i++) {
|
|
49
|
+
const key = keys[i];
|
|
50
|
+
const p = this.execProcess[key];
|
|
51
|
+
currentProcess.push({
|
|
52
|
+
name: key,
|
|
53
|
+
pid: p.pid,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Cleaning work before the end of the process
|
|
58
|
+
await this.sleep(1000);
|
|
59
|
+
currentProcess.forEach((p) => {
|
|
60
|
+
kill(p.pid);
|
|
61
|
+
debug(`Kill ${chalk.blue(p.name)} server, pid: ${p.pid}`);
|
|
62
|
+
});
|
|
63
|
+
process.exit(0);
|
|
21
64
|
}
|
|
22
65
|
|
|
23
66
|
/**
|
|
@@ -53,7 +96,8 @@ class ServeProcess {
|
|
|
53
96
|
persistent: true
|
|
54
97
|
});
|
|
55
98
|
watcher.on('change', async (f) => {
|
|
56
|
-
console.log(chalk.blue('[ee-bin] [dev] ') +
|
|
99
|
+
//console.log(chalk.blue('[ee-bin] [dev] ') + 'File ' + chalk.cyan(`[${f}]`) + 'has been changed');
|
|
100
|
+
console.log(chalk.blue('[ee-bin] [dev] ') + `File [${chalk.cyan(f)}] has been changed`);
|
|
57
101
|
|
|
58
102
|
// 防抖
|
|
59
103
|
if (debounceTimer) {
|
|
@@ -172,7 +216,7 @@ class ServeProcess {
|
|
|
172
216
|
const cfg = binCmdConfig[cmd];
|
|
173
217
|
|
|
174
218
|
if (!cfg) {
|
|
175
|
-
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + chalk.red(`Error: [${
|
|
219
|
+
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + chalk.red(`Error: [${cmd}] config does not exist` ));
|
|
176
220
|
continue;
|
|
177
221
|
}
|
|
178
222
|
|
|
@@ -181,8 +225,8 @@ class ServeProcess {
|
|
|
181
225
|
continue;
|
|
182
226
|
}
|
|
183
227
|
|
|
184
|
-
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) +
|
|
185
|
-
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + chalk.
|
|
228
|
+
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + `Run ${chalk.green(cmd)} command`);
|
|
229
|
+
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + chalk.magenta('Config:'), JSON.stringify(cfg));
|
|
186
230
|
|
|
187
231
|
const execDir = path.join(process.cwd(), cfg.directory);
|
|
188
232
|
const execArgs = is.string(cfg.args) ? [cfg.args] : cfg.args;
|
|
@@ -195,15 +239,18 @@ class ServeProcess {
|
|
|
195
239
|
execArgs,
|
|
196
240
|
{ stdio: stdio, cwd: execDir, maxBuffer: 1024 * 1024 * 1024 },
|
|
197
241
|
);
|
|
198
|
-
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + 'The ' + chalk.green(
|
|
242
|
+
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + 'The ' + chalk.green(`${cmd}`) + ` command is ${cfg.sync ? 'run completed' : 'running'}`);
|
|
199
243
|
|
|
200
244
|
if(!cfg.sync) {
|
|
201
245
|
this.execProcess[cmd].on('exit', () => {
|
|
202
|
-
if (
|
|
203
|
-
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + chalk.green(
|
|
246
|
+
if (binCmd == 'dev') {
|
|
247
|
+
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + `The ${chalk.green(cmd)} process is exiting`);
|
|
248
|
+
if (isWindows() && cmd == 'electron') {
|
|
249
|
+
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + chalk.green('Press "CTRL+C" to exit'));
|
|
250
|
+
}
|
|
204
251
|
return
|
|
205
252
|
}
|
|
206
|
-
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) +
|
|
253
|
+
console.log(chalk.blue(`[ee-bin] [${binCmd}] `) + `The ${chalk.green(cmd)} command has been executed and exited`);
|
|
207
254
|
});
|
|
208
255
|
}
|
|
209
256
|
}
|