electron-incremental-update 0.1.8 → 0.2.0

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/vite.cjs CHANGED
@@ -99,6 +99,7 @@ async function buildAsar({
99
99
 
100
100
  // src/build-plugins/entry.ts
101
101
  var import_node_fs2 = require("fs");
102
+ var import_node_path = require("path");
102
103
  var import_promises2 = require("fs/promises");
103
104
  var import_node_crypto2 = require("crypto");
104
105
  var import_node_os = require("os");
@@ -146,6 +147,8 @@ async function buildEntry({
146
147
  keyLength
147
148
  }) {
148
149
  if (!import_ci_info2.isCI) {
150
+ const keysDir = (0, import_node_path.dirname)(privateKeyPath);
151
+ !(0, import_node_fs2.existsSync)(keysDir) && await (0, import_promises2.mkdir)(keysDir);
149
152
  !(0, import_node_fs2.existsSync)(privateKeyPath) && await generateKey(privateKeyPath, publicKeyPath, keyLength);
150
153
  await writePublicKeyToMain(entryPath, publicKeyPath);
151
154
  }
@@ -201,25 +204,19 @@ function vite_default(options) {
201
204
  const { asarOutputPath } = buildAsarOption;
202
205
  const id = "electron-incremental-updater";
203
206
  const log = (0, import_vite.createLogger)("info", { prefix: `[${id}]` });
204
- return [
205
- {
206
- name: `vite-plugin-${id}-entry`,
207
- async buildStart() {
208
- log.info("build entry start");
209
- await buildEntry(buildEntryOption);
210
- log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`);
211
- }
212
- },
213
- {
214
- name: `vite-plugin-${id}-asar`,
215
- async closeBundle() {
216
- if (!isBuild) {
217
- return;
218
- }
219
- log.info("build asar start");
220
- await buildAsar(buildAsarOption);
221
- log.info(`build asar end, output to ${asarOutputPath}`);
207
+ return {
208
+ name: `vite-plugin-${id}`,
209
+ enforce: "post",
210
+ async closeBundle() {
211
+ log.info("build entry start");
212
+ await buildEntry(buildEntryOption);
213
+ log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`);
214
+ if (!isBuild) {
215
+ return;
222
216
  }
217
+ log.info("build asar start");
218
+ await buildAsar(buildAsarOption);
219
+ log.info(`build asar end, output to ${asarOutputPath}`);
223
220
  }
224
- ];
221
+ };
225
222
  }
package/dist/vite.d.ts CHANGED
@@ -80,6 +80,6 @@ type Options = {
80
80
  };
81
81
  };
82
82
 
83
- declare function export_default(options: Options): Plugin[];
83
+ declare function export_default(options: Options): Plugin;
84
84
 
85
85
  export { export_default as default };
package/dist/vite.mjs CHANGED
@@ -67,7 +67,8 @@ async function buildAsar({
67
67
 
68
68
  // src/build-plugins/entry.ts
69
69
  import { existsSync } from "node:fs";
70
- import { readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
70
+ import { dirname } from "node:path";
71
+ import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
71
72
  import { generateKeyPairSync } from "node:crypto";
72
73
  import { EOL } from "node:os";
73
74
  import { isCI as isCI2 } from "ci-info";
@@ -114,6 +115,8 @@ async function buildEntry({
114
115
  keyLength
115
116
  }) {
116
117
  if (!isCI2) {
118
+ const keysDir = dirname(privateKeyPath);
119
+ !existsSync(keysDir) && await mkdir(keysDir);
117
120
  !existsSync(privateKeyPath) && await generateKey(privateKeyPath, publicKeyPath, keyLength);
118
121
  await writePublicKeyToMain(entryPath, publicKeyPath);
119
122
  }
@@ -169,27 +172,21 @@ function vite_default(options) {
169
172
  const { asarOutputPath } = buildAsarOption;
170
173
  const id = "electron-incremental-updater";
171
174
  const log = createLogger("info", { prefix: `[${id}]` });
172
- return [
173
- {
174
- name: `vite-plugin-${id}-entry`,
175
- async buildStart() {
176
- log.info("build entry start");
177
- await buildEntry(buildEntryOption);
178
- log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`);
179
- }
180
- },
181
- {
182
- name: `vite-plugin-${id}-asar`,
183
- async closeBundle() {
184
- if (!isBuild) {
185
- return;
186
- }
187
- log.info("build asar start");
188
- await buildAsar(buildAsarOption);
189
- log.info(`build asar end, output to ${asarOutputPath}`);
175
+ return {
176
+ name: `vite-plugin-${id}`,
177
+ enforce: "post",
178
+ async closeBundle() {
179
+ log.info("build entry start");
180
+ await buildEntry(buildEntryOption);
181
+ log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`);
182
+ if (!isBuild) {
183
+ return;
190
184
  }
185
+ log.info("build asar start");
186
+ await buildAsar(buildAsarOption);
187
+ log.info(`build asar end, output to ${asarOutputPath}`);
191
188
  }
192
- ];
189
+ };
193
190
  }
194
191
  export {
195
192
  vite_default as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "electron incremental update tools, powered by vite",
5
5
  "scripts": {
6
6
  "build": "tsup",