electron-version-deployer-cli 0.0.11 → 0.0.13

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 CHANGED
@@ -15,6 +15,7 @@ const jsdom = require("jsdom");
15
15
  const DOMPurify = require("dompurify");
16
16
  const archiver = require("archiver");
17
17
  const node_https = require("node:https");
18
+ const node_os = require("node:os");
18
19
  const download = require("download");
19
20
  const pkgPath = pkgUp.sync();
20
21
  function r(...paths) {
@@ -382,7 +383,8 @@ commander.program.command("deploy").description("执行部署").action(async (so
382
383
  });
383
384
  async function deploy(configs) {
384
385
  console.log(logSymbols.info, "开始部署", r());
385
- const output = node_child_process.spawn("netlify", [
386
+ const cmd = node_os.platform() === "win32" ? "netlify.cmd" : "netlify";
387
+ const output = node_child_process.spawn(cmd, [
386
388
  "deploy",
387
389
  "--dir",
388
390
  r("node_modules/.evd"),
@@ -495,4 +497,4 @@ async function installPrebuilt(configs) {
495
497
  }
496
498
  commander.program.description(
497
499
  "Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
498
- ).helpOption("-h, --help", "使用帮助").version("0.0.11", "-V, --version", "显示版本号").parse(process.argv);
500
+ ).helpOption("-h, --help", "使用帮助").version("0.0.13", "-V, --version", "显示版本号").parse(process.argv);
package/dist/main.js CHANGED
@@ -69,7 +69,7 @@ function compareObjectsIsEqual(obj1, obj2) {
69
69
  return true;
70
70
  }
71
71
  const CLI_NAME = "electron-version-deployer-cli";
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\nsetTimeout(() => {\n try {\n copyFolderRecursiveSync("__unzipPath__", "__appPath__");\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}, 1);\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 copyFileSync(sourcePath, targetPath);\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';
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\nsetTimeout(() => {\n try {\n copyFolderRecursiveSync("__unzipPath__", "__appPath__");\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}, 1);\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';
73
73
  const id = `${Date.now()}-${Math.random()}`;
74
74
  var EVDEventEnum = /* @__PURE__ */ ((EVDEventEnum2) => {
75
75
  EVDEventEnum2["OPEN_LINK"] = "evd-open-link";
@@ -219,15 +219,20 @@ async function installPkg(zipFile) {
219
219
  __appPath__: appPath
220
220
  }).reduce((prev, current) => {
221
221
  const [key, value] = current;
222
- return prev.replace(key, value);
222
+ return prev.replace(key, value.split(node_path.sep).join("/"));
223
223
  }, installerCodeStr)
224
224
  );
225
225
  await new Promise((res) => setTimeout(res, 1e3));
226
- node_child_process.fork(node_path.join(appPath, "_evdInstallerTmp.js"), {
226
+ const child = node_child_process.fork(node_path.join(appPath, "_evdInstallerTmp.js"), {
227
227
  cwd: appPath,
228
228
  stdio: "inherit"
229
229
  });
230
- await new Promise((res) => setTimeout(res, 5e3));
230
+ await Promise.race([
231
+ new Promise((res) => {
232
+ child.on("exit", () => res);
233
+ }),
234
+ new Promise((res) => setTimeout(res, 10 * 1e3))
235
+ ]);
231
236
  }
232
237
  function bindEvent(promptWindow) {
233
238
  const { logo, onBeforeNewPkgInstall } = getConfigs();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-version-deployer-cli",
3
3
  "private": false,
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.es.js",