ee-bin 5.0.0-beta.2 → 5.0.0-beta.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.
Files changed (73) hide show
  1. package/dist/cjs/config/bin_default.js +69 -29
  2. package/dist/cjs/config/bin_default.js.map +1 -1
  3. package/dist/cjs/index.js +125 -4
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/lib/extend.js +49 -15
  6. package/dist/cjs/lib/extend.js.map +1 -1
  7. package/dist/cjs/lib/helpers.js +71 -22
  8. package/dist/cjs/lib/helpers.js.map +1 -1
  9. package/dist/cjs/lib/utils.js +71 -30
  10. package/dist/cjs/lib/utils.js.map +1 -1
  11. package/dist/cjs/plugins/bundle_registry_plugin.js +156 -0
  12. package/dist/cjs/plugins/bundle_registry_plugin.js.map +1 -0
  13. package/dist/cjs/tools/encrypt.js +190 -29
  14. package/dist/cjs/tools/encrypt.js.map +1 -1
  15. package/dist/cjs/tools/iconGen.js +118 -30
  16. package/dist/cjs/tools/iconGen.js.map +1 -1
  17. package/dist/cjs/tools/incrUpdater.js +95 -33
  18. package/dist/cjs/tools/incrUpdater.js.map +1 -1
  19. package/dist/cjs/tools/move.js +71 -11
  20. package/dist/cjs/tools/move.js.map +1 -1
  21. package/dist/cjs/tools/serve.js +406 -81
  22. package/dist/cjs/tools/serve.js.map +1 -1
  23. package/dist/cjs/types/config.js +13 -0
  24. package/dist/cjs/types/config.js.map +1 -0
  25. package/dist/esm/config/bin_default.d.ts +19 -147
  26. package/dist/esm/config/bin_default.d.ts.map +1 -1
  27. package/dist/esm/config/bin_default.js +69 -29
  28. package/dist/esm/config/bin_default.js.map +1 -1
  29. package/dist/esm/index.d.ts +20 -0
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.js +125 -4
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/lib/extend.d.ts +33 -0
  34. package/dist/esm/lib/extend.d.ts.map +1 -1
  35. package/dist/esm/lib/extend.js +49 -15
  36. package/dist/esm/lib/extend.js.map +1 -1
  37. package/dist/esm/lib/helpers.d.ts +44 -3
  38. package/dist/esm/lib/helpers.d.ts.map +1 -1
  39. package/dist/esm/lib/helpers.js +71 -22
  40. package/dist/esm/lib/helpers.js.map +1 -1
  41. package/dist/esm/lib/utils.d.ts +57 -3
  42. package/dist/esm/lib/utils.d.ts.map +1 -1
  43. package/dist/esm/lib/utils.js +71 -30
  44. package/dist/esm/lib/utils.js.map +1 -1
  45. package/dist/esm/plugins/bundle_registry_plugin.d.ts +33 -0
  46. package/dist/esm/plugins/bundle_registry_plugin.d.ts.map +1 -0
  47. package/dist/esm/plugins/bundle_registry_plugin.js +156 -0
  48. package/dist/esm/plugins/bundle_registry_plugin.js.map +1 -0
  49. package/dist/esm/tools/encrypt.d.ts +37 -1
  50. package/dist/esm/tools/encrypt.d.ts.map +1 -1
  51. package/dist/esm/tools/encrypt.js +190 -29
  52. package/dist/esm/tools/encrypt.js.map +1 -1
  53. package/dist/esm/tools/iconGen.d.ts +27 -1
  54. package/dist/esm/tools/iconGen.d.ts.map +1 -1
  55. package/dist/esm/tools/iconGen.js +118 -30
  56. package/dist/esm/tools/iconGen.js.map +1 -1
  57. package/dist/esm/tools/incrUpdater.d.ts +60 -13
  58. package/dist/esm/tools/incrUpdater.d.ts.map +1 -1
  59. package/dist/esm/tools/incrUpdater.js +95 -33
  60. package/dist/esm/tools/incrUpdater.js.map +1 -1
  61. package/dist/esm/tools/move.d.ts +41 -0
  62. package/dist/esm/tools/move.d.ts.map +1 -1
  63. package/dist/esm/tools/move.js +71 -11
  64. package/dist/esm/tools/move.js.map +1 -1
  65. package/dist/esm/tools/serve.d.ts +162 -25
  66. package/dist/esm/tools/serve.d.ts.map +1 -1
  67. package/dist/esm/tools/serve.js +406 -81
  68. package/dist/esm/tools/serve.js.map +1 -1
  69. package/dist/esm/types/config.d.ts +211 -0
  70. package/dist/esm/types/config.d.ts.map +1 -0
  71. package/dist/esm/types/config.js +13 -0
  72. package/dist/esm/types/config.js.map +1 -0
  73. package/package.json +16 -13
@@ -1,17 +1,25 @@
1
+ /**
2
+ * Incremental Update Package Generator — produces incremental update resources for Electron apps
3
+ *
4
+ * Incremental update principle: only package the changed portion of the asar archive (diff files),
5
+ * rather than the full installer. The user downloads the incremental package and merges it locally
6
+ * with the full package, significantly reducing update download size.
7
+ *
8
+ * Generation flow:
9
+ * 1. Read metadata YAML (obtain version number, file list, SHA512 hashes)
10
+ * 2. Determine target asar file path
11
+ * 3. Create a zip archive (containing asar + extraResources + asarUnpacked modules)
12
+ * 4. Generate SHA1 hash of the zip (for quick verification) and SHA512 hash of the full package
13
+ * 5. Verify SHA512 matches the hash recorded in metadata (ensures integrity)
14
+ * 6. Write JSON metadata file (version, filename, size, hash, force-update flag, etc.)
15
+ * 7. Optionally clean up per-platform temporary extraction directories
16
+ *
17
+ * Dependencies: compressing (zip compression), js-yaml (YAML parsing), crypto (hash calculation), globby (file scanning)
18
+ */
1
19
  import crypto from 'crypto';
2
20
  import { zip as compressZip } from 'compressing';
3
- interface UpdaterConfig {
4
- metadata: string;
5
- asarFile?: string;
6
- output: {
7
- directory: string;
8
- zip: string;
9
- file: string;
10
- };
11
- extraResources?: string[];
12
- asarUnpacked?: string[];
13
- cleanCache?: boolean;
14
- }
21
+ import type { UpdaterConfig } from '../types/config.js';
22
+ /** Incremental updater CLI options */
15
23
  interface UpdaterOptions {
16
24
  config?: string;
17
25
  asarFile?: string;
@@ -19,13 +27,52 @@ interface UpdaterOptions {
19
27
  force?: string;
20
28
  }
21
29
  declare class IncrUpdater {
30
+ /** Per-platform electron-builder extraction temp directory names (used by cleanCache cleanup) */
22
31
  tmpAppDirs: string[];
32
+ /** Standard directory name for asar.unpack (must preserve this path hierarchy in the zip) */
23
33
  asarUnpackedString: string;
24
34
  constructor();
35
+ /**
36
+ * Incremental update entry point
37
+ *
38
+ * @param options - CLI options (config file path, asarFile path, target platform, force update flag)
39
+ */
25
40
  run(options?: UpdaterOptions): Promise<void>;
41
+ /**
42
+ * Generate incremental update package — core logic
43
+ *
44
+ * Complete steps:
45
+ * 1. Look up the updater config for the target platform
46
+ * 2. Read metadata YAML to get version number and file list
47
+ * 3. Determine asar file path (CLI argument takes priority, then config asarFile)
48
+ * 4. Generate a platform+version-named zip package
49
+ * 5. Add asar + extraResources + asarUnpacked modules to the zip
50
+ * 6. Calculate SHA1 of the zip and SHA512 of the full package
51
+ * 7. Verify SHA512 matches the metadata
52
+ * 8. Write JSON metadata file
53
+ * 9. Optionally clean temporary directories
54
+ */
26
55
  generateFile(config: Record<string, UpdaterConfig>, asarFile: string | undefined, platform: string, force?: boolean): Promise<void>;
56
+ /**
57
+ * Recursively add folder contents to a zip compression stream
58
+ *
59
+ * @param zipStream - The compressing zip stream to add entries to
60
+ * @param folderPath - Absolute path to the folder on disk
61
+ * @param zipDir - Relative path within the zip archive
62
+ */
27
63
  _addFolderToZip(zipStream: compressZip.Stream, folderPath: string, zipDir: string): void;
28
- generateHash(filepath?: string, algorithm?: string, encoding?: crypto.BinaryToTextEncoding): string;
64
+ /**
65
+ * Calculate the cryptographic hash of a file
66
+ *
67
+ * @param filepath - File path (throws error for empty or non-existent paths instead of
68
+ * silently returning empty values, to prevent empty hashes from being
69
+ * written to update metadata which would cause client verification failures)
70
+ * @param algorithm - Hash algorithm (default: sha512)
71
+ * @param encoding - Output encoding (default: base64; sha1 uses hex)
72
+ * @returns Hash string
73
+ * @throws Error if filepath is empty or the file does not exist
74
+ */
75
+ generateHash(filepath: string, algorithm?: string, encoding?: crypto.BinaryToTextEncoding): string;
29
76
  }
30
77
  export declare const incrUpdater: IncrUpdater;
31
78
  export { IncrUpdater };
@@ -1 +1 @@
1
- {"version":3,"file":"incrUpdater.d.ts","sourceRoot":"","sources":["../../../src/tools/incrUpdater.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;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;;;;;;;;;GAiBG;AAKH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAIjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,sCAAsC;AACtC,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAmBD,cAAM,WAAW;IACf,iGAAiG;IACjG,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,6FAA6F;IAC7F,kBAAkB,EAAE,MAAM,CAAC;;IAO3B;;;;OAIG;IACG,GAAG,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBtD;;;;;;;;;;;;;OAaG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAwJvI;;;;;;OAMG;IACH,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAaxF;;;;;;;;;;OAUG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,SAAW,EAAE,QAAQ,GAAE,MAAM,CAAC,oBAA+B,GAAG,MAAM;CAe/G;AAED,eAAO,MAAM,WAAW,aAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,4 +1,22 @@
1
1
  "use strict";
2
+ /**
3
+ * Incremental Update Package Generator — produces incremental update resources for Electron apps
4
+ *
5
+ * Incremental update principle: only package the changed portion of the asar archive (diff files),
6
+ * rather than the full installer. The user downloads the incremental package and merges it locally
7
+ * with the full package, significantly reducing update download size.
8
+ *
9
+ * Generation flow:
10
+ * 1. Read metadata YAML (obtain version number, file list, SHA512 hashes)
11
+ * 2. Determine target asar file path
12
+ * 3. Create a zip archive (containing asar + extraResources + asarUnpacked modules)
13
+ * 4. Generate SHA1 hash of the zip (for quick verification) and SHA512 hash of the full package
14
+ * 5. Verify SHA512 matches the hash recorded in metadata (ensures integrity)
15
+ * 6. Write JSON metadata file (version, filename, size, hash, force-update flag, etc.)
16
+ * 7. Optionally clean up per-platform temporary extraction directories
17
+ *
18
+ * Dependencies: compressing (zip compression), js-yaml (YAML parsing), crypto (hash calculation), globby (file scanning)
19
+ */
2
20
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
21
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
22
  };
@@ -9,7 +27,7 @@ const fs_1 = __importDefault(require("fs"));
9
27
  const helpers_js_1 = require("../lib/helpers.js");
10
28
  const crypto_1 = __importDefault(require("crypto"));
11
29
  const compressing_1 = require("compressing");
12
- const globby_1 = __importDefault(require("globby"));
30
+ const globby_1 = require("globby");
13
31
  const js_yaml_1 = __importDefault(require("js-yaml"));
14
32
  const utils_js_1 = require("../lib/utils.js");
15
33
  class IncrUpdater {
@@ -17,6 +35,11 @@ class IncrUpdater {
17
35
  this.tmpAppDirs = ['mac', 'mac-arm64', 'win-unpacked', 'win-ia32-unpacked', 'linux-unpacked'];
18
36
  this.asarUnpackedString = 'app.asar.unpacked';
19
37
  }
38
+ /**
39
+ * Incremental update entry point
40
+ *
41
+ * @param options - CLI options (config file path, asarFile path, target platform, force update flag)
42
+ */
20
43
  async run(options = {}) {
21
44
  console.log('[ee-bin] [updater] Start');
22
45
  const { config, asarFile, platform, force } = options;
@@ -24,26 +47,39 @@ class IncrUpdater {
24
47
  const cfg = binCfg.updater;
25
48
  const forceUpdate = force === 'true';
26
49
  if (!cfg || !platform) {
27
- console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + helpers_js_1.chalk.red(`Error: updater config or platform does not exist`));
28
- return;
50
+ throw new Error('[ee-bin] [updater] Error: updater config or platform does not exist');
29
51
  }
30
52
  await this.generateFile(cfg, asarFile, platform, forceUpdate);
31
53
  console.log('[ee-bin] [updater] End');
32
54
  }
55
+ /**
56
+ * Generate incremental update package — core logic
57
+ *
58
+ * Complete steps:
59
+ * 1. Look up the updater config for the target platform
60
+ * 2. Read metadata YAML to get version number and file list
61
+ * 3. Determine asar file path (CLI argument takes priority, then config asarFile)
62
+ * 4. Generate a platform+version-named zip package
63
+ * 5. Add asar + extraResources + asarUnpacked modules to the zip
64
+ * 6. Calculate SHA1 of the zip and SHA512 of the full package
65
+ * 7. Verify SHA512 matches the metadata
66
+ * 8. Write JSON metadata file
67
+ * 9. Optionally clean temporary directories
68
+ */
33
69
  async generateFile(config, asarFile, platform, force = false) {
34
70
  const cfg = config[platform];
35
71
  if (!cfg) {
36
- console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + helpers_js_1.chalk.red(`Error: ${platform} config does not exist`));
37
- return;
72
+ throw new Error(`[ee-bin] [updater] Error: ${platform} config does not exist`);
38
73
  }
39
74
  const homeDir = process.cwd();
40
75
  console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + helpers_js_1.chalk.green(`${platform} config:`), cfg);
76
+ // Read metadata YAML (electron-builder-generated version info file)
41
77
  const metadataPath = path_1.default.join(homeDir, cfg.metadata);
42
78
  if (!fs_1.default.existsSync(metadataPath)) {
43
- console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + helpers_js_1.chalk.red(`Error: ${metadataPath} does not exist!`));
44
- return;
79
+ throw new Error(`[ee-bin] [updater] Error: ${metadataPath} does not exist!`);
45
80
  }
46
81
  const metadataObj = js_yaml_1.default.load(fs_1.default.readFileSync(metadataPath, 'utf8'));
82
+ // Determine asar file path: CLI --asar-file takes priority, then config asarFile
47
83
  let asarFilePath = '';
48
84
  if (asarFile) {
49
85
  asarFilePath = path_1.default.normalize(path_1.default.join(homeDir, asarFile));
@@ -52,36 +88,44 @@ class IncrUpdater {
52
88
  asarFilePath = path_1.default.normalize(path_1.default.join(homeDir, cfg.asarFile));
53
89
  }
54
90
  if (!asarFilePath || !fs_1.default.existsSync(asarFilePath)) {
55
- console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + helpers_js_1.chalk.red(`Error: ${asarFilePath} does not exist`));
56
- return;
91
+ throw new Error(`[ee-bin] [updater] Error: ${asarFilePath || '(empty path)'} does not exist`);
57
92
  }
58
93
  const version = metadataObj.version;
94
+ // Platform name conversion: config keys may use underscores (e.g. mac_arm64),
95
+ // but filenames use hyphens (e.g. mac-arm64)
59
96
  let platformForFilename = platform;
60
- if (platform.indexOf('_') !== -1) {
97
+ if (platform.includes('_')) {
61
98
  const platformArr = platform.split('_');
62
99
  platformForFilename = platformArr.join('-');
63
100
  }
101
+ // Generate zip filename: template-platform-version.zip (e.g. updater-mac-arm64-1.0.0.zip)
64
102
  const extZip = '.zip';
65
103
  const zipName = path_1.default.basename(cfg.output.zip, extZip) + `-${platformForFilename}-${version}${extZip}`;
66
104
  const asarZipPath = path_1.default.join(homeDir, cfg.output.directory, zipName);
105
+ // Remove existing zip if present (ensures clean output)
67
106
  if (fs_1.default.existsSync(asarZipPath)) {
68
107
  fs_1.default.rmSync(asarZipPath, { recursive: true, force: true });
69
108
  }
109
+ // Create zip archive
70
110
  const zipStream = new compressing_1.zip.Stream();
111
+ // First add the asar archive itself (incremental update needs the full asar file)
71
112
  zipStream.addEntry(asarFilePath, { relativePath: path_1.default.basename(asarFilePath) });
113
+ // Add extra resource files (e.g. native modules, config files)
72
114
  if (cfg.extraResources && cfg.extraResources.length > 0) {
73
- const files = globby_1.default.sync(cfg.extraResources, { cwd: homeDir });
115
+ const files = (0, globby_1.globbySync)(cfg.extraResources, { cwd: homeDir });
74
116
  for (const extraRes of files) {
75
117
  const extraResPath = path_1.default.normalize(path_1.default.join(homeDir, extraRes));
76
118
  if (!fs_1.default.existsSync(extraResPath)) {
77
119
  continue;
78
120
  }
121
+ // Preserve extraResources path hierarchy (relative path starting from 'extraResources/')
79
122
  const extraResDir = path_1.default.dirname(extraResPath);
80
123
  const index = extraResDir.indexOf('extraResources');
81
124
  const zipFileDir = extraResDir.substring(index).replace(/\\/g, '/');
82
125
  zipStream.addEntry(extraResPath, { relativePath: zipFileDir + '/' + path_1.default.basename(extraResPath) });
83
126
  }
84
127
  }
128
+ // Add asarUnpacked modules (native modules must exist as separate files, cannot be bundled into asar)
85
129
  if (cfg.asarUnpacked && cfg.asarUnpacked.length > 0) {
86
130
  const modules = cfg.asarUnpacked;
87
131
  for (const moduleItem of modules) {
@@ -89,39 +133,44 @@ class IncrUpdater {
89
133
  if (!fs_1.default.existsSync(modulePath)) {
90
134
  throw new Error(`${modulePath} is not exists!`);
91
135
  }
136
+ // Preserve app.asar.unpacked/ path hierarchy (Electron looks for native modules at this path)
92
137
  const zipDir = path_1.default.join(this.asarUnpackedString, moduleItem).replace(/\\/g, '/');
93
138
  this._addFolderToZip(zipStream, modulePath, zipDir);
94
139
  }
95
140
  }
141
+ // Write zip to disk
96
142
  const writeStream = fs_1.default.createWriteStream(asarZipPath);
97
143
  zipStream.pipe(writeStream);
98
144
  await new Promise((resolve, reject) => {
99
145
  writeStream.on('finish', resolve);
100
146
  writeStream.on('error', reject);
101
147
  });
148
+ // Calculate hashes: SHA1 for the zip (quick verification), SHA512 for the full package (strong verification)
102
149
  const zipSha1 = this.generateHash(asarZipPath, 'sha1', 'hex');
103
150
  const fileStat = fs_1.default.statSync(asarZipPath);
151
+ // Find the full installer file entry from metadata (skip existing .zip entries)
104
152
  let fullFileInfo;
105
153
  for (const item of metadataObj.files) {
106
- if (item.url.indexOf('.zip') !== -1) {
154
+ if (item.url.includes('.zip')) {
107
155
  continue;
108
156
  }
109
157
  fullFileInfo = item;
110
158
  }
111
159
  if (!fullFileInfo) {
112
- console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + helpers_js_1.chalk.red('Error: fullFileInfo not found in metadata'));
113
- return;
160
+ throw new Error('[ee-bin] [updater] Error: fullFileInfo not found in metadata');
114
161
  }
162
+ // Verify SHA512: ensure the local full package hash matches the metadata record.
163
+ // If they don't match, the full package has been tampered with or corrupted,
164
+ // and the incremental update cannot be reliably generated from it.
115
165
  const fullFileName = fullFileInfo.url;
116
166
  const fullFilePath = path_1.default.normalize(path_1.default.join(homeDir, cfg.output.directory, fullFileName));
117
167
  const generateSha512 = this.generateHash(fullFilePath, 'sha512');
118
168
  if (fullFileInfo.sha512 !== generateSha512) {
119
- console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') +
120
- helpers_js_1.chalk.red(`Error: metadata sha512 is not equal to generateSha512 !
121
- at metadata sha512: ${fullFileInfo.sha512}
122
- at generate Sha512: ${generateSha512}`));
123
- return;
169
+ throw new Error(`[ee-bin] [updater] Error: metadata sha512 is not equal to generateSha512!\n` +
170
+ ` at metadata sha512: ${fullFileInfo.sha512}\n` +
171
+ ` at generate sha512: ${generateSha512}`);
124
172
  }
173
+ // Build and write incremental update JSON metadata
125
174
  const item = {
126
175
  version: version,
127
176
  file: zipName,
@@ -136,9 +185,11 @@ class IncrUpdater {
136
185
  releaseDate: metadataObj.releaseDate,
137
186
  };
138
187
  const extJson = '.json';
188
+ // JSON filename: template-platform.json (e.g. updater-mac-arm64.json)
139
189
  const jsonName = path_1.default.basename(cfg.output.file, extJson) + `-${platformForFilename}${extJson}`;
140
190
  const updaterJsonFilePath = path_1.default.join(homeDir, cfg.output.directory, jsonName);
141
191
  (0, utils_js_1.writeJsonSync)(updaterJsonFilePath, item);
192
+ // Optional cleanup: delete per-platform electron-builder temporary extraction directories
142
193
  if (cfg.cleanCache) {
143
194
  for (const dir of this.tmpAppDirs) {
144
195
  const dirPath = path_1.default.join(homeDir, cfg.output.directory, dir);
@@ -148,6 +199,13 @@ class IncrUpdater {
148
199
  }
149
200
  }
150
201
  }
202
+ /**
203
+ * Recursively add folder contents to a zip compression stream
204
+ *
205
+ * @param zipStream - The compressing zip stream to add entries to
206
+ * @param folderPath - Absolute path to the folder on disk
207
+ * @param zipDir - Relative path within the zip archive
208
+ */
151
209
  _addFolderToZip(zipStream, folderPath, zipDir) {
152
210
  const entries = fs_1.default.readdirSync(folderPath, { withFileTypes: true });
153
211
  for (const entry of entries) {
@@ -161,25 +219,29 @@ class IncrUpdater {
161
219
  }
162
220
  }
163
221
  }
164
- generateHash(filepath = '', algorithm = 'sha512', encoding = 'base64') {
222
+ /**
223
+ * Calculate the cryptographic hash of a file
224
+ *
225
+ * @param filepath - File path (throws error for empty or non-existent paths instead of
226
+ * silently returning empty values, to prevent empty hashes from being
227
+ * written to update metadata which would cause client verification failures)
228
+ * @param algorithm - Hash algorithm (default: sha512)
229
+ * @param encoding - Output encoding (default: base64; sha1 uses hex)
230
+ * @returns Hash string
231
+ * @throws Error if filepath is empty or the file does not exist
232
+ */
233
+ generateHash(filepath, algorithm = 'sha512', encoding = 'base64') {
165
234
  if (filepath.length === 0) {
166
- return '';
235
+ throw new Error(`[ee-bin] [updater] Empty filepath for ${algorithm}`);
167
236
  }
168
237
  if (!fs_1.default.existsSync(filepath)) {
169
- return '';
238
+ throw new Error(`[ee-bin] [updater] ${filepath} does not exist for ${algorithm}`);
170
239
  }
171
240
  console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + `generate ${algorithm} for filepath:${filepath}`);
172
- try {
173
- const buffer = fs_1.default.readFileSync(filepath);
174
- const fsHash = crypto_1.default.createHash(algorithm);
175
- fsHash.update(buffer);
176
- return fsHash.digest(encoding);
177
- }
178
- catch (error) {
179
- console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + helpers_js_1.chalk.red(`Error: generate ${algorithm} error!`));
180
- console.log(helpers_js_1.chalk.blue('[ee-bin] [updater] ') + helpers_js_1.chalk.red(`Error: ${error}`));
181
- }
182
- return '';
241
+ const buffer = fs_1.default.readFileSync(filepath);
242
+ const fsHash = crypto_1.default.createHash(algorithm);
243
+ fsHash.update(buffer);
244
+ return fsHash.digest(encoding);
183
245
  }
184
246
  }
185
247
  exports.IncrUpdater = IncrUpdater;
@@ -1 +1 @@
1
- {"version":3,"file":"incrUpdater.js","sourceRoot":"","sources":["../../../src/tools/incrUpdater.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,kDAA0C;AAC1C,oDAA4B;AAC5B,6CAAiD;AACjD,oDAA4B;AAC5B,sDAA2B;AAC3B,8CAA4D;AAkC5D,MAAM,WAAW;IAIf;QACE,IAAI,CAAC,UAAU,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;QAC9F,IAAI,CAAC,kBAAkB,GAAG,mBAAmB,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,UAA0B,EAAE;QACpC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACxC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QACtD,MAAM,MAAM,GAAG,IAAA,qBAAU,EAAC,MAAM,CAAC,CAAC;QAClC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAoD,CAAC;QACxE,MAAM,WAAW,GAAG,KAAK,KAAK,MAAM,CAAC;QAErC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,kBAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,kBAAK,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC,CAAC;YAC/G,OAAO;QACT,CAAC;QAED,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QAE9D,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,YAAY,C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C;QACtB,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF;AAGQ,kCAAW;AADP,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
@@ -1,7 +1,48 @@
1
+ /**
2
+ * Resource Move Module — copies files/directories between project locations
3
+ *
4
+ * This module handles the "move" command, which copies resources from one location
5
+ * to another as defined in the bin.js configuration. The most common use case is
6
+ * moving the frontend build output (dist/) to the public directory so Electron
7
+ * can load it as static assets.
8
+ *
9
+ * Move process:
10
+ * 1. Load configuration and parse the --flag option to determine which items to move
11
+ * 2. For each flagged item, resolve source and destination paths
12
+ * (supports "dist"/"target" aliases that override "src"/"dest")
13
+ * 3. Validate source exists; skip with warning if not found
14
+ * 4. Perform an atomic-ish copy: backup existing destination → copy source → delete backup
15
+ * This prevents data loss if the copy fails partway through
16
+ *
17
+ * Note: Despite the name "move", this module performs copy operations (not file moves).
18
+ * The original source files remain intact after the operation.
19
+ */
20
+ /** Move command CLI options */
1
21
  interface MoveOptions {
22
+ /** Path to custom bin.js config file */
2
23
  config?: string;
24
+ /** Comma-separated move config keys to execute (e.g. "frontend_dist") */
3
25
  flag?: string;
4
26
  }
27
+ /**
28
+ * Execute resource move operations
29
+ *
30
+ * Iterates over the comma-separated flag values, looks up each one in the
31
+ * "move" section of the bin.js config, and copies the source to the destination.
32
+ *
33
+ * Path alias support:
34
+ * - If "dist" is set in config, it takes priority over "src"
35
+ * - If "target" is set in config, it takes priority over "dest"
36
+ * This allows users to override the default paths without modifying the base config.
37
+ *
38
+ * Atomic-ish copy strategy:
39
+ * 1. If destination already exists, rename it to a .bak backup
40
+ * 2. Copy source to destination
41
+ * 3. Delete the .bak backup
42
+ * This ensures the old destination is preserved until the new copy succeeds.
43
+ *
44
+ * @param options - CLI options (config file path, flag string)
45
+ */
5
46
  export declare function move(options?: MoveOptions): void;
6
47
  export {};
7
48
  //# sourceMappingURL=move.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../../../src/tools/move.ts"],"names":[],"mappings":"AAcA,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,IAAI,CAsDpD"}
1
+ {"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../../../src/tools/move.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,+BAA+B;AAC/B,UAAU,WAAW;IACnB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,IAAI,CA2EpD"}
@@ -1,4 +1,23 @@
1
1
  "use strict";
2
+ /**
3
+ * Resource Move Module — copies files/directories between project locations
4
+ *
5
+ * This module handles the "move" command, which copies resources from one location
6
+ * to another as defined in the bin.js configuration. The most common use case is
7
+ * moving the frontend build output (dist/) to the public directory so Electron
8
+ * can load it as static assets.
9
+ *
10
+ * Move process:
11
+ * 1. Load configuration and parse the --flag option to determine which items to move
12
+ * 2. For each flagged item, resolve source and destination paths
13
+ * (supports "dist"/"target" aliases that override "src"/"dest")
14
+ * 3. Validate source exists; skip with warning if not found
15
+ * 4. Perform an atomic-ish copy: backup existing destination → copy source → delete backup
16
+ * This prevents data loss if the copy fails partway through
17
+ *
18
+ * Note: Despite the name "move", this module performs copy operations (not file moves).
19
+ * The original source files remain intact after the operation.
20
+ */
2
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
23
  };
@@ -9,6 +28,25 @@ const fs_1 = __importDefault(require("fs"));
9
28
  const helpers_js_1 = require("../lib/helpers.js");
10
29
  const utils_js_1 = require("../lib/utils.js");
11
30
  const homeDir = process.cwd();
31
+ /**
32
+ * Execute resource move operations
33
+ *
34
+ * Iterates over the comma-separated flag values, looks up each one in the
35
+ * "move" section of the bin.js config, and copies the source to the destination.
36
+ *
37
+ * Path alias support:
38
+ * - If "dist" is set in config, it takes priority over "src"
39
+ * - If "target" is set in config, it takes priority over "dest"
40
+ * This allows users to override the default paths without modifying the base config.
41
+ *
42
+ * Atomic-ish copy strategy:
43
+ * 1. If destination already exists, rename it to a .bak backup
44
+ * 2. Copy source to destination
45
+ * 3. Delete the .bak backup
46
+ * This ensures the old destination is preserved until the new copy succeeds.
47
+ *
48
+ * @param options - CLI options (config file path, flag string)
49
+ */
12
50
  function move(options = {}) {
13
51
  console.log('[ee-bin] [move] Start moving resources');
14
52
  const { config, flag } = options;
@@ -18,37 +56,59 @@ function move(options = {}) {
18
56
  console.log(helpers_js_1.chalk.blue('[ee-bin] [move] ') + helpers_js_1.chalk.red('Error: move config or flag does not exist'));
19
57
  return;
20
58
  }
59
+ // Parse comma-separated flag string into individual flag names
21
60
  const flags = (0, helpers_js_1.formatCmds)(flag.trim());
22
61
  for (const f of flags) {
23
62
  const cfg = moveConfig[f];
24
63
  if (!cfg) {
25
64
  console.log(helpers_js_1.chalk.blue('[ee-bin] [move] ') + helpers_js_1.chalk.red(`Error: ${f} config does not exist`));
26
- return;
65
+ continue;
27
66
  }
67
+ // Resolve source and destination: "dist"/"target" aliases override "src"/"dest"
28
68
  const { src, dest, dist, target } = cfg;
29
69
  const source = dist || src;
30
70
  const destination = target || dest;
31
71
  if (!source || !destination) {
32
72
  console.log(helpers_js_1.chalk.blue('[ee-bin] [move] ') + helpers_js_1.chalk.red(`Error: ${f} config missing src/dest`));
33
- return;
73
+ continue;
34
74
  }
35
75
  console.log(helpers_js_1.chalk.blue('[ee-bin] [move] ') + helpers_js_1.chalk.green(`Move flag: ${f}`));
36
76
  console.log(helpers_js_1.chalk.blue('[ee-bin] [move] ') + helpers_js_1.chalk.green('config:'), cfg);
37
77
  const srcResource = path_1.default.join(homeDir, source);
78
+ // Skip if source doesn't exist (may happen if frontend hasn't been built yet)
38
79
  if (!fs_1.default.existsSync(srcResource)) {
39
- const errorTips = helpers_js_1.chalk.bgRed('Error') + ` ${source} resource does not exist !`;
40
- console.error(errorTips);
41
- return;
80
+ console.log(helpers_js_1.chalk.yellow('[ee-bin] [move] ') + `Warning: ${source} does not exist, skipping`);
81
+ continue;
42
82
  }
43
83
  const destResource = path_1.default.join(homeDir, destination);
44
- if (fs_1.default.statSync(srcResource).isDirectory() && !fs_1.default.existsSync(destResource)) {
45
- fs_1.default.mkdirSync(destResource, { recursive: true, mode: 0o777 });
84
+ // Atomic copy: backup old destination → copy new → delete backup
85
+ const backupDest = destResource + '.bak';
86
+ if (fs_1.default.existsSync(destResource)) {
87
+ // Remove any leftover backup from a previous failed run
88
+ if (fs_1.default.existsSync(backupDest))
89
+ (0, utils_js_1.rm)(backupDest);
90
+ // Rename current destination as backup
91
+ fs_1.default.renameSync(destResource, backupDest);
46
92
  }
47
- else {
48
- (0, utils_js_1.rm)(destResource);
49
- console.log('[ee-bin] [move] Clear history resources:', destResource);
93
+ // Copy source to destination; restore backup if copy fails
94
+ try {
95
+ (0, helpers_js_1.copyDirSync)(srcResource, destResource);
96
+ }
97
+ catch (copyErr) {
98
+ // Restore backup on copy failure to avoid leaving broken state
99
+ if (fs_1.default.existsSync(backupDest)) {
100
+ if (fs_1.default.existsSync(destResource))
101
+ (0, utils_js_1.rm)(destResource);
102
+ fs_1.default.renameSync(backupDest, destResource);
103
+ console.log(helpers_js_1.chalk.yellow('[ee-bin] [move] ') + `Copy failed, restored previous destination: ${destResource}`);
104
+ }
105
+ throw copyErr;
106
+ }
107
+ // Clean up backup (old destination) after successful copy
108
+ if (fs_1.default.existsSync(backupDest)) {
109
+ (0, utils_js_1.rm)(backupDest);
110
+ console.log('[ee-bin] [move] Cleaned previous resources:', destResource);
50
111
  }
51
- (0, helpers_js_1.copyDirSync)(srcResource, destResource);
52
112
  console.log(`[ee-bin] [move] Copy ${srcResource} to ${destResource}`);
53
113
  }
54
114
  console.log('[ee-bin] [move] End');
@@ -1 +1 @@
1
- {"version":3,"file":"move.js","sourceRoot":"","sources":["../../../src/tools/move.ts"],"names":[],"mappings":";;;;;AAmBA,oBAsDC;AAzED,gDAAwB;AACxB,4CAAoB;AACpB,kDAAmE;AACnE,8CAAiD;AAEjD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAc9B,SAAgB,IAAI,CAAC,UAAuB,EAAE;IAC5C,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;IACtD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACjC,MAAM,MAAM,GAAG,IAAA,qBAAU,EAAC,MAAM,CAAC,CAAC;IAClC,MAAM,UAAU,GAAG,MAAM,CAAC,IAA8C,CAAC;IAEzE,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,kBAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,kBAAK,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC,CAAC;QACrG,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,uBAAU,EAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAEtC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAE1B,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,kBAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,kBAAK,CAAC,GAAG,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC,CAAC;YAC7F,OAAO;QACT,CAAC;QAED,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QACxC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