ee-bin 4.1.9 → 4.1.11

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/lib/utils.js CHANGED
@@ -205,6 +205,35 @@ function getArgumentByName(name, args) {
205
205
  }
206
206
  }
207
207
 
208
+ function getExtraResourcesDir() {
209
+ const dir = path.join(_basePath, "build", "extraResources")
210
+ return dir;
211
+ }
212
+
213
+ function getModuleNameFromPath(modulePath) {
214
+ // 分割路径段(处理不同系统的分隔符)
215
+ const segments = path.normalize(modulePath).split(path.sep);
216
+
217
+ // 从后往前查找 node_modules
218
+ for (let i = segments.length - 1; i >= 0; i--) {
219
+ if (segments[i] === 'node_modules') {
220
+ // 普通模块:node_modules/dayjs
221
+ if (i + 1 < segments.length) {
222
+ return segments[i + 1];
223
+ }
224
+
225
+ // 作用域模块:node_modules/@scope/module
226
+ if (i + 2 < segments.length && segments[i + 1].startsWith('@')) {
227
+ return `${segments[i + 1]}/${segments[i + 2]}`;
228
+ }
229
+
230
+ break; // 找到 node_modules 但后面没有模块名
231
+ }
232
+ }
233
+
234
+ return null;
235
+ }
236
+
208
237
  module.exports = {
209
238
  loadConfig,
210
239
  getElectronProgram,
@@ -220,5 +249,7 @@ module.exports = {
220
249
  getPackage,
221
250
  readJsonSync,
222
251
  writeJsonSync,
223
- getArgumentByName
252
+ getArgumentByName,
253
+ getExtraResourcesDir,
254
+ getModuleNameFromPath
224
255
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-bin",
3
- "version": "4.1.9",
3
+ "version": "4.1.11",
4
4
  "description": "ee bin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,6 +25,8 @@ class IncrUpdater {
25
25
  'win-ia32-unpacked',
26
26
  'linux-unpacked'
27
27
  ];
28
+ this.nodeModulesString = 'node_modules';
29
+ this.asarUnpackedString = 'app.asar.unpacked';
28
30
  }
29
31
 
30
32
  /**
@@ -101,9 +103,26 @@ class IncrUpdater {
101
103
  const extraResDir = path.dirname(extraResPath);
102
104
  const index = extraResDir.indexOf('extraResources');
103
105
  const zipFileDir = extraResDir.substring(index);
106
+ // 资源路径 extraResPath: D:\www\gofile\src\ee\ee-demo\build\extraResources\hello\c.txt
107
+ // 文件在zip中的路径 zipFileDir: extraResources/hello
104
108
  zip.addLocalFile(extraResPath, zipFileDir);
105
109
  }
106
110
  }
111
+ // 添加 asarUnpacked
112
+ if (cfg.asarUnpacked && cfg.asarUnpacked.length > 0) {
113
+ const modules = cfg.asarUnpacked;
114
+ for (const moduleItem of modules) {
115
+ const modulePath = path.normalize(path.join(homeDir, moduleItem));
116
+ if (!fs.existsSync(modulePath)) {
117
+ throw new Error(`${modulePath} is not exists!`);
118
+ }
119
+
120
+ const zipDir = path.join(this.asarUnpackedString, moduleItem);
121
+ // console.log('modulePath', modulePath);
122
+ // console.log('zipDir', zipDir);
123
+ zip.addLocalFolder(modulePath, zipDir);
124
+ }
125
+ }
107
126
 
108
127
  zip.writeZip(asarZipPath, (err) => {
109
128
  if (err) {
@@ -112,9 +131,9 @@ class IncrUpdater {
112
131
  });
113
132
 
114
133
  // 生成 latest.json
115
- const sha1 = this.generateSha1(asarFilePath);
134
+ const sha1 = this.generateSha1(asarZipPath);
116
135
  const date = this._getFormattedDate();
117
- const fileStat = fs.statSync(asarFilePath);
136
+ const fileStat = fs.statSync(asarZipPath);
118
137
  const item = {
119
138
  version: version,
120
139
  file: zipName,