electron-version-deployer-cli 0.1.6 → 0.2.1

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
@@ -278,6 +278,20 @@ async function genChangelog(configs) {
278
278
  headerIds: false
279
279
  })
280
280
  );
281
+ const allChanges = changes.versions.map((change) => {
282
+ const { date: date2, version: version2, title: title2, body: body2 } = change;
283
+ return {
284
+ date: date2,
285
+ version: version2,
286
+ title: title2,
287
+ changes: purify.sanitize(
288
+ marked.marked.parse(body2, {
289
+ mangle: false,
290
+ headerIds: false
291
+ })
292
+ )
293
+ };
294
+ });
281
295
  node_fs.writeFileSync(
282
296
  r("node_modules/.evd/changelog.json"),
283
297
  JSON.stringify({
@@ -288,6 +302,15 @@ async function genChangelog(configs) {
288
302
  }),
289
303
  "utf-8"
290
304
  );
305
+ const changelogTemplate = node_fs.readFileSync(
306
+ node_path.join(node_path.resolve(__dirname), "templates", "changelogs.html"),
307
+ "utf-8"
308
+ );
309
+ node_fs.writeFileSync(
310
+ r("node_modules/.evd/changelogs.html"),
311
+ changelogTemplate.replace("__INJECT__", JSON.stringify(allChanges)),
312
+ "utf-8"
313
+ );
291
314
  console.log(
292
315
  logSymbols.success,
293
316
  `写入 changelog.json 成功 ${r("node_modules/.evd/changelog.json")}`
@@ -614,4 +637,4 @@ async function installPrebuilt(configs) {
614
637
  }
615
638
  commander.program.description(
616
639
  "Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
617
- ).helpOption("-h, --help", "使用帮助").version("0.1.6", "-V, --version", "显示版本号").parse(process.argv);
640
+ ).helpOption("-h, --help", "使用帮助").version("0.2.1", "-V, --version", "显示版本号").parse(process.argv);
package/dist/main.d.ts CHANGED
@@ -3,7 +3,8 @@ export declare enum EVDEventEnum {
3
3
  UPDATE = "evd-update-now",
4
4
  SKIP = "evd-skip",
5
5
  GET_CHANGELOGS = "evd-get-change-logs",
6
- GET_LOGO = "evd-get-logo"
6
+ GET_LOGO = "evd-get-logo",
7
+ GET_CHANGELOGS_LINK = "evd-get-changelogs-link"
7
8
  }
8
9
  type EVDInitPropsType = {
9
10
  netlifyUrl?: string;
package/dist/main.js CHANGED
@@ -77,6 +77,7 @@ var EVDEventEnum = /* @__PURE__ */ ((EVDEventEnum2) => {
77
77
  EVDEventEnum2["SKIP"] = "evd-skip";
78
78
  EVDEventEnum2["GET_CHANGELOGS"] = "evd-get-change-logs";
79
79
  EVDEventEnum2["GET_LOGO"] = "evd-get-logo";
80
+ EVDEventEnum2["GET_CHANGELOGS_LINK"] = "evd-get-changelogs-link";
80
81
  return EVDEventEnum2;
81
82
  })(EVDEventEnum || {});
82
83
  let globalArgs = null;
@@ -230,16 +231,19 @@ async function installPkg(zipFile) {
230
231
  const tmpFilePath = node_path.join(appPath, fileName);
231
232
  const tmpSplitZip = node_fs.createWriteStream(tmpFilePath);
232
233
  await new Promise((_res) => {
233
- node_https.get(`${remoteUrl}/fullCodeZipSplitZips/${fileName}?hash=${Math.random()}`, (response) => {
234
- response.pipe(tmpSplitZip).on("finish", () => {
235
- tmpSplitZip.end(() => {
236
- mergedStream.write(node_fs.readFileSync(tmpFilePath));
237
- _res();
234
+ node_https.get(
235
+ `${remoteUrl}/fullCodeZipSplitZips/${fileName}?hash=${Math.random()}`,
236
+ (response) => {
237
+ response.pipe(tmpSplitZip).on("finish", () => {
238
+ tmpSplitZip.end(() => {
239
+ mergedStream.write(node_fs.readFileSync(tmpFilePath));
240
+ _res();
241
+ });
242
+ }).on("error", (err) => {
243
+ rej(err);
238
244
  });
239
- }).on("error", (err) => {
240
- rej(err);
241
- });
242
- }).on("error", (err) => {
245
+ }
246
+ ).on("error", (err) => {
243
247
  rej(err);
244
248
  });
245
249
  });
@@ -319,6 +323,10 @@ function bindEvent(promptWindow, onError) {
319
323
  const { remoteUrl: remoteUrl2 } = getConfigs();
320
324
  return await fetchRemoteChangelogJSON(remoteUrl2);
321
325
  });
326
+ electron.ipcMain.handle("evd-get-changelogs-link", async () => {
327
+ const { remoteUrl: remoteUrl2 } = getConfigs();
328
+ return `${remoteUrl2}/changelogs.html`;
329
+ });
322
330
  }
323
331
  function cleanup(promptWindow) {
324
332
  electron.ipcMain.removeAllListeners(
@@ -341,6 +349,10 @@ function cleanup(promptWindow) {
341
349
  "evd-get-logo"
342
350
  /* GET_LOGO */
343
351
  );
352
+ electron.ipcMain.removeHandler(
353
+ "evd-get-changelogs-link"
354
+ /* GET_CHANGELOGS_LINK */
355
+ );
344
356
  try {
345
357
  promptWindow == null ? void 0 : promptWindow.focus();
346
358
  promptWindow == null ? void 0 : promptWindow.destroy();
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta
6
+ name="viewport"
7
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
8
+ />
9
+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />
10
+ <title>Changelogs</title>
11
+ </head>
12
+ <body>
13
+ <div
14
+ id="container"
15
+ style="margin: 0 auto; max-width: 960px; padding-top: 24px"
16
+ ></div>
17
+ </body>
18
+
19
+ <script>
20
+ const changelogs = __INJECT__;
21
+
22
+ let html = ``;
23
+ for (const change of changelogs) {
24
+ html += `<div class="item">`;
25
+ html += `<div class="title" style="font-weight: bold;font-size: 20px;margin-top: 8px">${change.title}</div>`;
26
+ html += `<div class="changes">${change.changes}</div>`;
27
+ html += `</div>`;
28
+ }
29
+
30
+ document.querySelector("#container").innerHTML = html;
31
+ </script>
32
+ </html>
@@ -119,6 +119,12 @@
119
119
  <div class="title-bar">
120
120
  <img src="" width="34" class="logo" style="display: none" />
121
121
  <span>有可用的新版本:</span>
122
+ <a
123
+ href="#"
124
+ class="see-all-changes"
125
+ style="text-decoration: underline; font-size: 14px"
126
+ >(所有版本更新记录)</a
127
+ >
122
128
  </div>
123
129
  <div class="content">具体更新内容请查看 Changelogs</div>
124
130
  <div class="buttons-box">
@@ -146,6 +152,15 @@
146
152
  }
147
153
  });
148
154
 
155
+ ipcRenderer.invoke("evd-get-changelogs-link").then((link) => {
156
+ const aTag = document.querySelector(".see-all-changes");
157
+ if (link) {
158
+ aTag.href = link;
159
+ } else {
160
+ aTag.remove();
161
+ }
162
+ });
163
+
149
164
  ipcRenderer.invoke("evd-get-change-logs").then((data) => {
150
165
  // 如果没有数据就不渲染
151
166
  if (!data) return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-version-deployer-cli",
3
3
  "private": false,
4
- "version": "0.1.6",
4
+ "version": "0.2.1",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.es.js",