electron-incremental-update 0.8.7 → 0.8.8

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/README.md CHANGED
@@ -75,6 +75,8 @@ initApp({ onStart: console.log })
75
75
  make sure the plugin is set in the **last** build task
76
76
 
77
77
  - for `vite-plugin-electron`, set it to `preload` (the second object in the plugin option array)
78
+ - cert is read from `process.env.UPDATER_CERT` first, then read config
79
+ - privatekey is read from `process.env.UPDATER_PK` first, then read config
78
80
 
79
81
  ```ts
80
82
  // vite.config.ts
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -37,7 +27,7 @@ __export(src_exports, {
37
27
  module.exports = __toCommonJS(src_exports);
38
28
  var import_node_path2 = require("path");
39
29
  var import_node_fs4 = require("fs");
40
- var import_electron4 = __toESM(require("electron"));
30
+ var import_electron4 = require("electron");
41
31
 
42
32
  // src/updater/index.ts
43
33
  var import_node_fs3 = require("fs");
@@ -438,7 +428,7 @@ function initApp(appOptions) {
438
428
  } = hooks || {};
439
429
  function handleError(msg) {
440
430
  onStartError?.(new Error(msg));
441
- import_electron4.default.app.quit();
431
+ import_electron4.app.quit();
442
432
  }
443
433
  async function startup(updater) {
444
434
  try {
@@ -448,7 +438,7 @@ function initApp(appOptions) {
448
438
  await beforeDoUpdate?.(asarPath, updateAsarPath);
449
439
  (0, import_node_fs4.renameSync)(updateAsarPath, asarPath);
450
440
  }
451
- const mainDir = import_electron4.default.app.isPackaged ? asarPath : electronDevDistPath;
441
+ const mainDir = import_electron4.app.isPackaged ? asarPath : electronDevDistPath;
452
442
  const entry = (0, import_node_path2.resolve)(__dirname, mainDir, mainPath);
453
443
  await beforeStart?.(entry);
454
444
  require(entry)(updater);
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  // src/index.ts
19
19
  import { resolve } from "node:path";
20
20
  import { existsSync as existsSync2, renameSync } from "node:fs";
21
- import Electron from "electron";
21
+ import { app } from "electron";
22
22
 
23
23
  // src/updater/index.ts
24
24
  import { existsSync } from "node:fs";
@@ -303,7 +303,7 @@ function initApp(appOptions) {
303
303
  } = hooks || {};
304
304
  function handleError(msg) {
305
305
  onStartError?.(new Error(msg));
306
- Electron.app.quit();
306
+ app.quit();
307
307
  }
308
308
  async function startup(updater) {
309
309
  try {
@@ -313,7 +313,7 @@ function initApp(appOptions) {
313
313
  await beforeDoUpdate?.(asarPath, updateAsarPath);
314
314
  renameSync(updateAsarPath, asarPath);
315
315
  }
316
- const mainDir = Electron.app.isPackaged ? asarPath : electronDevDistPath;
316
+ const mainDir = app.isPackaged ? asarPath : electronDevDistPath;
317
317
  const entry = resolve(__dirname, mainDir, mainPath);
318
318
  await beforeStart?.(entry);
319
319
  __require(entry)(updater);
package/dist/vite.js CHANGED
@@ -189,9 +189,6 @@ async function buildEntry({
189
189
  });
190
190
  }
191
191
 
192
- // src/build-plugins/option.ts
193
- var import_ci_info = require("ci-info");
194
-
195
192
  // src/build-plugins/key.ts
196
193
  var import_node_fs3 = require("fs");
197
194
  var import_node_path = require("path");
@@ -250,8 +247,8 @@ function parseKeys({
250
247
  if (!(0, import_node_fs3.existsSync)(privateKeyPath) || !(0, import_node_fs3.existsSync)(certPath)) {
251
248
  generateKeyPair(keyLength, parseSubjects(subject), days, privateKeyPath, certPath);
252
249
  }
253
- const privateKey = (0, import_node_fs3.readFileSync)(privateKeyPath, "utf-8");
254
- const cert = (0, import_node_fs3.readFileSync)(certPath, "utf-8");
250
+ const privateKey = process.env.UPDATER_PK || (0, import_node_fs3.readFileSync)(privateKeyPath, "utf-8");
251
+ const cert = process.env.UPDATER_CERT || (0, import_node_fs3.readFileSync)(certPath, "utf-8");
255
252
  writeCertToMain(entryPath, cert);
256
253
  return {
257
254
  privateKey,
@@ -312,27 +309,24 @@ function parseOptions(options) {
312
309
  entryOutputPath,
313
310
  minify
314
311
  };
315
- let buildVersionOption;
316
- if (!import_ci_info.isCI) {
317
- const { privateKey, cert } = parseKeys({
318
- keyLength,
319
- privateKeyPath,
320
- certPath,
321
- entryPath,
322
- subject,
323
- days
324
- });
325
- buildVersionOption = {
326
- version,
327
- minimumVersion,
328
- gzipPath,
329
- privateKey,
330
- cert,
331
- versionPath,
332
- generateSignature,
333
- generateVersionJson
334
- };
335
- }
312
+ const { privateKey, cert } = parseKeys({
313
+ keyLength,
314
+ privateKeyPath,
315
+ certPath,
316
+ entryPath,
317
+ subject,
318
+ days
319
+ });
320
+ const buildVersionOption = {
321
+ version,
322
+ minimumVersion,
323
+ gzipPath,
324
+ privateKey,
325
+ cert,
326
+ versionPath,
327
+ generateSignature,
328
+ generateVersionJson
329
+ };
336
330
  return { isBuild, buildAsarOption, buildEntryOption, buildVersionOption };
337
331
  }
338
332
 
@@ -347,16 +341,16 @@ function ElectronUpdater(options) {
347
341
  name: `vite-plugin-${id}`,
348
342
  enforce: "post",
349
343
  async closeBundle() {
350
- log.info("build entry start");
344
+ log.info("build entry start", { timestamp: true });
351
345
  await buildEntry(buildEntryOption);
352
- log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`);
346
+ log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`, { timestamp: true });
353
347
  if (!isBuild) {
354
348
  return;
355
349
  }
356
- log.info("build asar start");
350
+ log.info("build asar start", { timestamp: true });
357
351
  await buildAsar(buildAsarOption);
358
- buildVersionOption && await buildVersion(buildVersionOption);
359
- log.info(`build asar end, output to ${asarOutputPath}`);
352
+ await buildVersion(buildVersionOption);
353
+ log.info(`build asar end, output to ${asarOutputPath}`, { timestamp: true });
360
354
  }
361
355
  };
362
356
  }
package/dist/vite.mjs CHANGED
@@ -94,9 +94,6 @@ async function buildEntry({
94
94
  });
95
95
  }
96
96
 
97
- // src/build-plugins/option.ts
98
- import { isCI } from "ci-info";
99
-
100
97
  // src/build-plugins/key.ts
101
98
  import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "node:fs";
102
99
  import { dirname } from "node:path";
@@ -155,8 +152,8 @@ function parseKeys({
155
152
  if (!existsSync2(privateKeyPath) || !existsSync2(certPath)) {
156
153
  generateKeyPair(keyLength, parseSubjects(subject), days, privateKeyPath, certPath);
157
154
  }
158
- const privateKey = readFileSync(privateKeyPath, "utf-8");
159
- const cert = readFileSync(certPath, "utf-8");
155
+ const privateKey = process.env.UPDATER_PK || readFileSync(privateKeyPath, "utf-8");
156
+ const cert = process.env.UPDATER_CERT || readFileSync(certPath, "utf-8");
160
157
  writeCertToMain(entryPath, cert);
161
158
  return {
162
159
  privateKey,
@@ -217,27 +214,24 @@ function parseOptions(options) {
217
214
  entryOutputPath,
218
215
  minify
219
216
  };
220
- let buildVersionOption;
221
- if (!isCI) {
222
- const { privateKey, cert } = parseKeys({
223
- keyLength,
224
- privateKeyPath,
225
- certPath,
226
- entryPath,
227
- subject,
228
- days
229
- });
230
- buildVersionOption = {
231
- version,
232
- minimumVersion,
233
- gzipPath,
234
- privateKey,
235
- cert,
236
- versionPath,
237
- generateSignature,
238
- generateVersionJson
239
- };
240
- }
217
+ const { privateKey, cert } = parseKeys({
218
+ keyLength,
219
+ privateKeyPath,
220
+ certPath,
221
+ entryPath,
222
+ subject,
223
+ days
224
+ });
225
+ const buildVersionOption = {
226
+ version,
227
+ minimumVersion,
228
+ gzipPath,
229
+ privateKey,
230
+ cert,
231
+ versionPath,
232
+ generateSignature,
233
+ generateVersionJson
234
+ };
241
235
  return { isBuild, buildAsarOption, buildEntryOption, buildVersionOption };
242
236
  }
243
237
 
@@ -252,16 +246,16 @@ function ElectronUpdater(options) {
252
246
  name: `vite-plugin-${id}`,
253
247
  enforce: "post",
254
248
  async closeBundle() {
255
- log.info("build entry start");
249
+ log.info("build entry start", { timestamp: true });
256
250
  await buildEntry(buildEntryOption);
257
- log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`);
251
+ log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`, { timestamp: true });
258
252
  if (!isBuild) {
259
253
  return;
260
254
  }
261
- log.info("build asar start");
255
+ log.info("build asar start", { timestamp: true });
262
256
  await buildAsar(buildAsarOption);
263
- buildVersionOption && await buildVersion(buildVersionOption);
264
- log.info(`build asar end, output to ${asarOutputPath}`);
257
+ await buildVersion(buildVersionOption);
258
+ log.info(`build asar end, output to ${asarOutputPath}`, { timestamp: true });
265
259
  }
266
260
  };
267
261
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "author": "subframe7536",
4
- "version": "0.8.7",
4
+ "version": "0.8.8",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "scripts": {
7
7
  "build": "tsup && node fix-module.js",