electron-version-deployer-cli 0.0.2 → 0.0.3

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
@@ -493,4 +493,4 @@ async function installPrebuilt(configs) {
493
493
  }
494
494
  commander.program.description(
495
495
  "Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
496
- ).helpOption("-h, --help", "使用帮助").version("0.0.2", "-V, --version", "显示版本号").parse(process.argv);
496
+ ).helpOption("-h, --help", "使用帮助").version("0.0.3", "-V, --version", "显示版本号").parse(process.argv);
package/dist/main.d.ts CHANGED
@@ -2,7 +2,8 @@ export declare enum EVDEventEnum {
2
2
  OPEN_LINK = "evd-open-link",
3
3
  UPDATE = "evd-update-now",
4
4
  SKIP = "evd-skip",
5
- GET_CHANGELOGS = "evd-get-change-logs"
5
+ GET_CHANGELOGS = "evd-get-change-logs",
6
+ GET_LOGO = "evd-get-logo"
6
7
  }
7
8
  type EVDInitPropsType = {
8
9
  netlifyUrl: string;
package/dist/main.js CHANGED
@@ -74,6 +74,7 @@ var EVDEventEnum = /* @__PURE__ */ ((EVDEventEnum2) => {
74
74
  EVDEventEnum2["UPDATE"] = "evd-update-now";
75
75
  EVDEventEnum2["SKIP"] = "evd-skip";
76
76
  EVDEventEnum2["GET_CHANGELOGS"] = "evd-get-change-logs";
77
+ EVDEventEnum2["GET_LOGO"] = "evd-get-logo";
77
78
  return EVDEventEnum2;
78
79
  })(EVDEventEnum || {});
79
80
  let globalArgs = null;
@@ -167,7 +168,7 @@ async function showNewVersionDialog() {
167
168
  });
168
169
  }
169
170
  async function installNewVersion() {
170
- const { netlifyUrl } = getConfigs();
171
+ const { netlifyUrl, onError } = getConfigs();
171
172
  const remoteJSON = await fetchRemotePkgJSON(netlifyUrl);
172
173
  const needInstallFullSize = compareObjectsIsEqual(
173
174
  remoteJSON.dependencies,
@@ -176,21 +177,7 @@ async function installNewVersion() {
176
177
  try {
177
178
  await installPkg(needInstallFullSize ? "fullCode.zip" : "logicCode.zip");
178
179
  } catch (error) {
179
- node_fs.appendFileSync(
180
- node_path.join(electron.app.getPath("userData"), "evd-runtime-error.txt"),
181
- `
182
- ${(/* @__PURE__ */ new Date()).toString()}
183
-
184
- ${error.toString()}
185
-
186
- -- stack
187
-
188
- ${error.stack}
189
-
190
- ----------------------------------------------------------------
191
-
192
- `
193
- );
180
+ onError(error);
194
181
  }
195
182
  }
196
183
  async function installPkg(zipFile) {
@@ -223,6 +210,7 @@ async function installPkg(zipFile) {
223
210
  await new Promise((res) => setTimeout(res, 1e3));
224
211
  }
225
212
  function bindEvent(promptWindow) {
213
+ const { logo } = getConfigs();
226
214
  electron.ipcMain.on("evd-open-link", (_, link) => {
227
215
  electron.shell.openExternal(link);
228
216
  });
@@ -237,6 +225,9 @@ function bindEvent(promptWindow) {
237
225
  electron.app.exit();
238
226
  });
239
227
  });
228
+ electron.ipcMain.handle("evd-get-logo", () => {
229
+ return logo;
230
+ });
240
231
  electron.ipcMain.handle("evd-get-change-logs", async () => {
241
232
  const { netlifyUrl } = getConfigs();
242
233
  return await fetchRemoteChangelogJSON(netlifyUrl);
@@ -255,6 +246,14 @@ function cleanup(promptWindow) {
255
246
  "evd-update-now"
256
247
  /* UPDATE */
257
248
  );
249
+ electron.ipcMain.removeHandler(
250
+ "evd-get-change-logs"
251
+ /* GET_CHANGELOGS */
252
+ );
253
+ electron.ipcMain.removeHandler(
254
+ "evd-get-logo"
255
+ /* GET_LOGO */
256
+ );
258
257
  promptWindow == null ? void 0 : promptWindow.focus();
259
258
  if (promptWindow) {
260
259
  promptWindow.destroy();
@@ -1,163 +1,171 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="zh">
3
- <head>
3
+ <head>
4
4
  <meta charset="UTF-8" />
5
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"
6
+ name="viewport"
7
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
8
8
  />
9
9
  <link
10
- rel="icon"
11
- type="image/png"
12
- sizes="32x32"
13
- href="https://chat.openai.com/favicon-32x32.png"
10
+ rel="icon"
11
+ type="image/png"
12
+ sizes="32x32"
13
+ href="https://chat.openai.com/favicon-32x32.png"
14
14
  />
15
15
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
16
16
  <title>有可用的更新 (4.3.5)</title>
17
17
  <style>
18
- * {
19
- margin: 0;
20
- padding: 0;
21
- }
22
-
23
- body {
24
- font-family: -apple-system, Helvetica, Arial, sans-serif,
25
- "Microsoft YaHei", "ST Heiti";
26
- color: #333;
27
- padding: 20px;
28
- background-color: #f5f5f5;
29
- }
30
-
31
- .title {
32
- font-size: 18px;
33
- font-weight: bold;
34
- margin-bottom: 10px;
35
- }
36
-
37
- .content {
38
- margin-top: 8px;
39
- margin-bottom: 12px;
40
- margin-left: -20px;
41
- margin-right: -20px;
42
- height: 200px;
43
- overflow: auto;
44
- padding: 0 20px;
45
- }
46
-
47
- .content ul {
48
- padding-left: 20px;
49
- margin-top: 5px;
50
- margin-bottom: 10px;
51
- }
52
-
53
- .content ul li {
54
- margin-bottom: 4px;
55
- }
56
-
57
- .buttons-box {
58
- display: flex;
59
- justify-content: flex-end;
60
- }
61
-
62
- .buttons-box button {
63
- padding: 10px 20px;
64
- font-size: 14px;
65
- font-weight: bold;
66
- border-radius: 5px;
67
- border: none;
68
- cursor: pointer;
69
- margin-left: 12px;
70
- }
71
-
72
- .buttons-box button:first-child {
73
- background-color: #007bff;
74
- color: #fff;
75
- }
76
-
77
- .buttons-box button:last-child {
78
- background-color: #ccc;
79
- color: #333;
80
- }
18
+ * {
19
+ margin: 0;
20
+ padding: 0;
21
+ }
22
+
23
+ body {
24
+ font-family: -apple-system, Helvetica, Arial, sans-serif,
25
+ "Microsoft YaHei", "ST Heiti";
26
+ color: #333;
27
+ padding: 20px;
28
+ background-color: #f5f5f5;
29
+ }
30
+
31
+ .title {
32
+ font-size: 18px;
33
+ font-weight: bold;
34
+ margin-bottom: 10px;
35
+ }
36
+
37
+ .content {
38
+ margin-top: 8px;
39
+ margin-bottom: 12px;
40
+ margin-left: -20px;
41
+ margin-right: -20px;
42
+ height: 200px;
43
+ overflow: auto;
44
+ padding: 0 20px;
45
+ }
46
+
47
+ .content ul {
48
+ padding-left: 20px;
49
+ margin-top: 5px;
50
+ margin-bottom: 10px;
51
+ }
52
+
53
+ .content ul li {
54
+ margin-bottom: 4px;
55
+ }
56
+
57
+ .buttons-box {
58
+ display: flex;
59
+ justify-content: flex-end;
60
+ }
61
+
62
+ .buttons-box button {
63
+ padding: 10px 20px;
64
+ font-size: 14px;
65
+ font-weight: bold;
66
+ border-radius: 5px;
67
+ border: none;
68
+ cursor: pointer;
69
+ margin-left: 12px;
70
+ }
71
+
72
+ .buttons-box button:first-child {
73
+ background-color: #007bff;
74
+ color: #fff;
75
+ }
76
+
77
+ .buttons-box button:last-child {
78
+ background-color: #ccc;
79
+ color: #333;
80
+ }
81
+
82
+ .buttons-box button:first-child:hover {
83
+ background-color: #0056b3;
84
+ }
85
+
86
+ .buttons-box button:last-child:hover {
87
+ background-color: #b3b3b3;
88
+ }
89
+
90
+ .title-bar {
91
+ display: flex;
92
+ flex-direction: row;
93
+ justify-content: flex-start;
94
+ align-items: center;
95
+ }
96
+
97
+ .title-bar img {
98
+ margin-right: 8px;
99
+ }
100
+
101
+ .loading-box {
102
+ position: fixed;
103
+ left: 0;
104
+ top: 0;
105
+ bottom: 0;
106
+ right: 0;
107
+ background: rgba(255, 255, 255, 0.9);
108
+ font-size: 18px;
109
+ flex-direction: row;
110
+ align-items: center;
111
+ justify-content: center;
112
+ display: none;
113
+ font-weight: bold;
114
+ }
115
+ </style>
116
+ </head>
117
+ <body>
118
+ <div class="loading-box">软件更新中……</div>
119
+ <div class="title-bar">
120
+ <img src="" width="28" class="logo" style="display: none" />
121
+ <span>有可用的新版本:</span>
122
+ </div>
123
+ <div class="content">具体更新内容请查看 Changelogs</div>
124
+ <div class="buttons-box">
125
+ <button id="updateBtn">现在更新</button>
126
+ <button id="skipBtn">稍后再提醒我</button>
127
+ </div>
128
+
129
+ <script>
130
+ const { ipcRenderer } = require("electron");
131
+
132
+ document.querySelector("#updateBtn").addEventListener("click", () => {
133
+ ipcRenderer.send("evd-update-now");
134
+ document.querySelector(".loading-box").style.display = "flex";
135
+ });
81
136
 
82
- .buttons-box button:first-child:hover {
83
- background-color: #0056b3;
84
- }
137
+ document.querySelector("#skipBtn").addEventListener("click", () => {
138
+ ipcRenderer.send("evd-skip");
139
+ });
85
140
 
86
- .buttons-box button:last-child:hover {
87
- background-color: #b3b3b3;
141
+ ipcRenderer.invoke("evd-get-logo").then((link) => {
142
+ if (link) {
143
+ const imgRef = document.querySelector(".logo");
144
+ imgRef.src = link;
145
+ imgRef.style.display = "inline-block";
88
146
  }
147
+ });
89
148
 
90
- .title-bar {
91
- display: flex;
92
- flex-direction: row;
93
- justify-content: flex-start;
94
- align-items: center;
95
- }
149
+ ipcRenderer.invoke("evd-get-change-logs").then((data) => {
150
+ // 如果没有数据就不渲染
151
+ if (!data) return;
96
152
 
97
- .title-bar img {
98
- margin-right: 8px;
99
- }
153
+ const contentRef = document.querySelector(".content");
100
154
 
101
- .loading-box {
102
- position: fixed;
103
- left: 0;
104
- top: 0;
105
- bottom: 0;
106
- right: 0;
107
- background: rgba(255, 255, 255, 0.9);
108
- font-size: 18px;
109
- flex-direction: row;
110
- align-items: center;
111
- justify-content: center;
112
- display: none;
113
- font-weight: bold;
114
- }
115
- </style>
116
- </head>
117
- <body>
118
- <div class="loading-box">软件更新中……</div>
119
- <div class="title-bar">
120
- <img src="https://chat.openai.com/favicon-32x32.png" width="28" alt="" />
121
- <span>有可用的新版本:</span>
122
- </div>
123
- <div class="content">具体更新内容请查看 Changelogs</div>
124
- <div class="buttons-box">
125
- <button id="updateBtn">现在更新</button>
126
- <button id="skipBtn">稍后再提醒我</button>
127
- </div>
128
-
129
- <script>
130
- const { ipcRenderer } = require("electron");
131
-
132
- document.querySelector("#updateBtn").addEventListener("click", () => {
133
- ipcRenderer.send("evd-update-now");
134
- document.querySelector(".loading-box").style.display = "flex";
135
- });
136
-
137
- document.querySelector("#skipBtn").addEventListener("click", () => {
138
- ipcRenderer.send("evd-skip");
139
- });
140
-
141
- ipcRenderer.invoke("evd-get-change-logs").then((data) => {
142
- // 如果没有数据就不渲染
143
- if (!data) return;
144
-
145
- const contentRef = document.querySelector(".content");
146
-
147
- contentRef.innerHTML = `
155
+ contentRef.innerHTML = `
148
156
  <p class="title">${data.title}</p>
149
157
  ${data.changes}
150
158
  `;
151
159
 
152
- // 监听所有 A 链接点击
153
- Array.from(document.querySelectorAll("a")).map((a) => {
154
- a.addEventListener("click", (ev) => {
155
- ev.preventDefault();
160
+ // 监听所有 A 链接点击
161
+ Array.from(document.querySelectorAll("a")).map((a) => {
162
+ a.addEventListener("click", (ev) => {
163
+ ev.preventDefault();
156
164
 
157
- ipcRenderer.send("evd-open-link", ev.target.href);
165
+ ipcRenderer.send("evd-open-link", ev.target.href);
166
+ });
167
+ });
158
168
  });
159
- });
160
- });
161
- </script>
162
- </body>
169
+ </script>
170
+ </body>
163
171
  </html>
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "electron-version-deployer-cli",
3
3
  "private": false,
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.es.js",
8
8
  "scripts": {
9
9
  "serve": "esno ./watch.ts",
10
- "build": "MODE=production esno ./watch.ts && tsc -p ./tsconfig.dist.json -emitDeclarationOnly && tsc-alias -p ./tsconfig.dist.json"
10
+ "build": "MODE=production esno ./watch.ts && tsc -p ./tsconfig.dist.json -emitDeclarationOnly && tsc-alias -p ./tsconfig.dist.json",
11
+ "format": "npx prettier --write \"**/*.{js,mjs,cjs,ts,tsx,jsx,json,html}\"",
12
+ "typecheck": "tsc -p tsconfig.json"
11
13
  },
12
14
  "bin": {
13
15
  "evd": "./dist/cli.cjs"