electron-version-deployer-cli 0.2.1 → 0.2.2
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 +31 -6
- package/dist/main.js +26 -1
- package/dist/utils/utils.d.ts +1 -0
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -22,6 +22,8 @@ const archiver = require("archiver");
|
|
|
22
22
|
const prompts = require("@inquirer/prompts");
|
|
23
23
|
const node_https = require("node:https");
|
|
24
24
|
const node_os = require("node:os");
|
|
25
|
+
const fs = require("fs");
|
|
26
|
+
const path = require("path");
|
|
25
27
|
const download = require("download");
|
|
26
28
|
const pkgPath = pkgUp.sync();
|
|
27
29
|
function r(...paths) {
|
|
@@ -363,7 +365,7 @@ function versionToNum(a) {
|
|
|
363
365
|
let res = c.join("");
|
|
364
366
|
return res;
|
|
365
367
|
}
|
|
366
|
-
const _Netlify = class {
|
|
368
|
+
const _Netlify = class _Netlify {
|
|
367
369
|
static get instance() {
|
|
368
370
|
if (!this._instance) {
|
|
369
371
|
this._instance = new _Netlify();
|
|
@@ -420,9 +422,32 @@ const _Netlify = class {
|
|
|
420
422
|
return `configs.netlify 配置不存在`;
|
|
421
423
|
}
|
|
422
424
|
};
|
|
425
|
+
__publicField(_Netlify, "_instance");
|
|
423
426
|
let Netlify = _Netlify;
|
|
424
|
-
|
|
425
|
-
|
|
427
|
+
function forceDeleteSync(targetPath) {
|
|
428
|
+
try {
|
|
429
|
+
const stats = fs.statSync(targetPath);
|
|
430
|
+
if (stats.isDirectory()) {
|
|
431
|
+
fs.chmodSync(targetPath, 511);
|
|
432
|
+
const files = fs.readdirSync(targetPath);
|
|
433
|
+
for (const file of files) {
|
|
434
|
+
forceDeleteSync(path.join(targetPath, file));
|
|
435
|
+
}
|
|
436
|
+
fs.rmdirSync(targetPath);
|
|
437
|
+
} else {
|
|
438
|
+
fs.chmodSync(targetPath, 438);
|
|
439
|
+
fs.unlinkSync(targetPath);
|
|
440
|
+
}
|
|
441
|
+
console.log(`成功删除: ${targetPath}`);
|
|
442
|
+
} catch (error) {
|
|
443
|
+
if (error.code === "ENOENT") {
|
|
444
|
+
console.log(`${targetPath} 不存在,无需删除`);
|
|
445
|
+
} else {
|
|
446
|
+
console.error(`删除 ${targetPath} 时发生错误:`, error);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const _Cloudflare = class _Cloudflare {
|
|
426
451
|
static get instance() {
|
|
427
452
|
if (!this._instance) {
|
|
428
453
|
this._instance = new _Cloudflare();
|
|
@@ -470,7 +495,7 @@ const _Cloudflare = class {
|
|
|
470
495
|
node_path.join(outputFolder, "index.json"),
|
|
471
496
|
JSON.stringify(splitZipsFileName)
|
|
472
497
|
);
|
|
473
|
-
|
|
498
|
+
forceDeleteSync(node_path.join(folderPath, "fullCode.zip"));
|
|
474
499
|
}
|
|
475
500
|
deploy(props) {
|
|
476
501
|
this.splitFileIfNeed(props.folder);
|
|
@@ -521,8 +546,8 @@ const _Cloudflare = class {
|
|
|
521
546
|
return `configs.cloudflare 配置不存在`;
|
|
522
547
|
}
|
|
523
548
|
};
|
|
549
|
+
__publicField(_Cloudflare, "_instance");
|
|
524
550
|
let Cloudflare = _Cloudflare;
|
|
525
|
-
__publicField(Cloudflare, "_instance");
|
|
526
551
|
commander.program.command("deploy").description("执行部署").action(async (source, destination) => {
|
|
527
552
|
const configs = await getConfigs();
|
|
528
553
|
try {
|
|
@@ -637,4 +662,4 @@ async function installPrebuilt(configs) {
|
|
|
637
662
|
}
|
|
638
663
|
commander.program.description(
|
|
639
664
|
"Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
|
|
640
|
-
).helpOption("-h, --help", "使用帮助").version("0.2.
|
|
665
|
+
).helpOption("-h, --help", "使用帮助").version("0.2.2", "-V, --version", "显示版本号").parse(process.argv);
|
package/dist/main.js
CHANGED
|
@@ -7,6 +7,8 @@ const node_https = require("node:https");
|
|
|
7
7
|
const node_fs = require("node:fs");
|
|
8
8
|
const extract = require("extract-zip");
|
|
9
9
|
const node_process = require("node:process");
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path = require("path");
|
|
10
12
|
function fetchRemoteChangelogJSON(remote_url) {
|
|
11
13
|
return new Promise((res, rej) => {
|
|
12
14
|
node_https.get(`${remote_url}/changelog.json`, (_res) => {
|
|
@@ -70,6 +72,29 @@ function compareObjectsIsEqual(obj1, obj2) {
|
|
|
70
72
|
}
|
|
71
73
|
const CLI_NAME = "electron-version-deployer-cli";
|
|
72
74
|
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';
|
|
75
|
+
function forceDeleteSync(targetPath) {
|
|
76
|
+
try {
|
|
77
|
+
const stats = fs.statSync(targetPath);
|
|
78
|
+
if (stats.isDirectory()) {
|
|
79
|
+
fs.chmodSync(targetPath, 511);
|
|
80
|
+
const files = fs.readdirSync(targetPath);
|
|
81
|
+
for (const file of files) {
|
|
82
|
+
forceDeleteSync(path.join(targetPath, file));
|
|
83
|
+
}
|
|
84
|
+
fs.rmdirSync(targetPath);
|
|
85
|
+
} else {
|
|
86
|
+
fs.chmodSync(targetPath, 438);
|
|
87
|
+
fs.unlinkSync(targetPath);
|
|
88
|
+
}
|
|
89
|
+
console.log(`成功删除: ${targetPath}`);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error.code === "ENOENT") {
|
|
92
|
+
console.log(`${targetPath} 不存在,无需删除`);
|
|
93
|
+
} else {
|
|
94
|
+
console.error(`删除 ${targetPath} 时发生错误:`, error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
73
98
|
const id = `${Date.now()}-${Math.random()}`;
|
|
74
99
|
var EVDEventEnum = /* @__PURE__ */ ((EVDEventEnum2) => {
|
|
75
100
|
EVDEventEnum2["OPEN_LINK"] = "evd-open-link";
|
|
@@ -247,7 +272,7 @@ async function installPkg(zipFile) {
|
|
|
247
272
|
rej(err);
|
|
248
273
|
});
|
|
249
274
|
});
|
|
250
|
-
|
|
275
|
+
forceDeleteSync(tmpFilePath);
|
|
251
276
|
}
|
|
252
277
|
mergedStream.end(() => {
|
|
253
278
|
res();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function forceDeleteSync(targetPath: any): void;
|