electron-version-deployer-cli 0.0.15 → 0.0.17
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/dist/cli.cjs +1 -1
- package/dist/main.js +10 -7
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -507,4 +507,4 @@ async function installPrebuilt(configs) {
|
|
|
507
507
|
}
|
|
508
508
|
commander.program.description(
|
|
509
509
|
"Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
|
|
510
|
-
).helpOption("-h, --help", "使用帮助").version("0.0.
|
|
510
|
+
).helpOption("-h, --help", "使用帮助").version("0.0.17", "-V, --version", "显示版本号").parse(process.argv);
|
package/dist/main.js
CHANGED
|
@@ -6,7 +6,6 @@ const node_path = require("node:path");
|
|
|
6
6
|
const node_https = require("node:https");
|
|
7
7
|
const node_fs = require("node:fs");
|
|
8
8
|
const extract = require("extract-zip");
|
|
9
|
-
const node_child_process = require("node:child_process");
|
|
10
9
|
const node_process = require("node:process");
|
|
11
10
|
function fetchRemoteChangelogJSON(remote_url) {
|
|
12
11
|
return new Promise((res, rej) => {
|
|
@@ -70,7 +69,7 @@ function compareObjectsIsEqual(obj1, obj2) {
|
|
|
70
69
|
return true;
|
|
71
70
|
}
|
|
72
71
|
const CLI_NAME = "electron-version-deployer-cli";
|
|
73
|
-
const installerCodeStr = '// 该文件用于 fork 使用,将会写入到\n// app.getAppPath() + \'/_evdInstallerTmp.js\' 路径中\n// 从避免 window 上替换时出现的资源占用问题\nconst {\n existsSync,\n mkdirSync,\n readdirSync,\n statSync,\n appendFileSync,\n writeFileSync,\n readFileSync,\n} = require("fs");\nconst { join, resolve, basename } = require("node:path");\n\
|
|
72
|
+
const installerCodeStr = '// 该文件用于 fork 使用,将会写入到\n// app.getAppPath() + \'/_evdInstallerTmp.js\' 路径中\n// 从避免 window 上替换时出现的资源占用问题\nconst {\n existsSync,\n mkdirSync,\n readdirSync,\n statSync,\n appendFileSync,\n writeFileSync,\n readFileSync,\n} = require("fs");\nconst { join, resolve, basename } = require("node:path");\n\ntry {\n copyFolderRecursiveSync("__unzipPath__", "__appPath__");\n process.parentPort.postMessage("exitManually");\n process.exit(0);\n} catch (error) {\n appendFileSync(\n resolve(__dirname, "evdInstallerErrors.txt"),\n `\n ${new Date().toString()}\\n\n ${error.toString()}\\n\n -- stack\\n\n ${error.stack}\\n\n ----------------------------------------------------------------\\n\n `\n );\n process.parentPort.postMessage("exitManually");\n process.exit(0);\n}\n\n// 复制文件夹及其内容的函数\nfunction copyFolderRecursiveSync(source, target) {\n // 如果目标目录不存在,则创建目标目录\n if (!existsSync(target)) {\n mkdirSync(target);\n }\n\n // 获取源目录的文件列表\n const files = readdirSync(source);\n\n // 遍历文件列表,处理每个文件或子目录\n files.forEach((file) => {\n const sourcePath = join(source, file);\n const targetPath = join(target, file);\n\n // 如果当前文件是文件夹,则递归复制文件夹\n if (statSync(sourcePath).isDirectory()) {\n copyFolderRecursiveSync(sourcePath, targetPath);\n } else {\n // 否则,复制文件\n try {\n copyFileSync(sourcePath, targetPath);\n } catch (error) {\n appendFileSync(\n resolve(__dirname, "evdInstallerErrors.txt"),\n `\n ${new Date().toString()}\\n\n ${error.toString()}\\n\n -- stack\\n\n ${error.stack}\\n\n ----------------------------------------------------------------\\n\n `\n );\n }\n }\n });\n}\n\nfunction copyFileSync(source, target) {\n let targetFile = target;\n\n if (existsSync(target)) {\n if (statSync(target).isDirectory()) {\n targetFile = join(target, basename(source));\n }\n }\n\n writeFileSync(targetFile, readFileSync(source));\n}\n';
|
|
74
73
|
const id = `${Date.now()}-${Math.random()}`;
|
|
75
74
|
var EVDEventEnum = /* @__PURE__ */ ((EVDEventEnum2) => {
|
|
76
75
|
EVDEventEnum2["OPEN_LINK"] = "evd-open-link";
|
|
@@ -235,15 +234,19 @@ async function installPkg(zipFile) {
|
|
|
235
234
|
}, installerCodeStr)
|
|
236
235
|
);
|
|
237
236
|
await new Promise((res) => setTimeout(res, 1e3));
|
|
238
|
-
const child =
|
|
239
|
-
cwd: appPath,
|
|
240
|
-
stdio: "inherit"
|
|
241
|
-
});
|
|
237
|
+
const child = electron.utilityProcess.fork(node_path.join(appPath, "_evdInstallerTmp.js"));
|
|
242
238
|
await Promise.race([
|
|
243
239
|
new Promise((res) => {
|
|
244
240
|
child.on("exit", () => res);
|
|
245
241
|
}),
|
|
246
|
-
new Promise((res) =>
|
|
242
|
+
new Promise((res) => {
|
|
243
|
+
child.on("message", (msg) => {
|
|
244
|
+
if (msg === "exitManually") {
|
|
245
|
+
res(void 0);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}),
|
|
249
|
+
new Promise((res) => setTimeout(res, 5 * 60 * 1e3))
|
|
247
250
|
]);
|
|
248
251
|
}
|
|
249
252
|
function bindEvent(promptWindow) {
|