electron-incremental-update 1.0.0 → 1.0.2
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 +15 -3
- package/dist/vite.d.mts +26 -16
- package/dist/vite.d.ts +26 -16
- package/dist/vite.js +6 -4
- package/dist/vite.mjs +6 -4
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -50,8 +50,9 @@ src
|
|
|
50
50
|
|
|
51
51
|
### Setup entry
|
|
52
52
|
|
|
53
|
+
in `electron/entry.ts` (build by `Esbuild`)
|
|
54
|
+
|
|
53
55
|
```ts
|
|
54
|
-
// electron/entry.ts
|
|
55
56
|
import { initApp } from 'electron-incremental-update'
|
|
56
57
|
import { parseGithubCdnURL } from 'electron-incremental-update/utils'
|
|
57
58
|
import { repository } from '../package.json'
|
|
@@ -77,8 +78,9 @@ All options are documented with JSDoc
|
|
|
77
78
|
- cert will read from `process.env.UPDATER_CERT` first, if absend, read config
|
|
78
79
|
- privatekey will read from `process.env.UPDATER_PK` first, if absend, read config
|
|
79
80
|
|
|
81
|
+
in `vite.config.mts`
|
|
82
|
+
|
|
80
83
|
```ts
|
|
81
|
-
// vite.config.mts
|
|
82
84
|
import { defineConfig } from 'vite'
|
|
83
85
|
import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
|
|
84
86
|
import pkg from './package.json'
|
|
@@ -164,8 +166,9 @@ However, you have the option to customize the download function when creating th
|
|
|
164
166
|
|
|
165
167
|
**NOTE: There should only one function and should be default export in the entry file**
|
|
166
168
|
|
|
169
|
+
in `electron/main/index.ts`
|
|
170
|
+
|
|
167
171
|
```ts
|
|
168
|
-
// electron/main/index.ts
|
|
169
172
|
import { startupWithUpdater } from 'electron-incremental-update'
|
|
170
173
|
import { getPathFromAppNameAsar, getVersions } from 'electron-incremental-update/utils'
|
|
171
174
|
import { app } from 'electron'
|
|
@@ -229,6 +232,13 @@ const plugin = electronWithUpdater({
|
|
|
229
232
|
from: './node_modules/better-sqlite3/build/Release/better_sqlite3.node',
|
|
230
233
|
skipIfExist: false,
|
|
231
234
|
})
|
|
235
|
+
// for @napi-rs/image
|
|
236
|
+
const startStr = '@napi-rs+image-'
|
|
237
|
+
const fileName = (await readdir('./node_modules/.pnpm')).filter(p => p.startsWith(startStr))[0]
|
|
238
|
+
const archName = fileName.substring(startStr.length).split('@')[0]
|
|
239
|
+
existsAndCopyToEntryOutputDir({
|
|
240
|
+
from: `./node_modules/.pnpm/${fileName}/node_modules/@napi-rs/image-${archName}/image.${archName}.node`,
|
|
241
|
+
})
|
|
232
242
|
},
|
|
233
243
|
},
|
|
234
244
|
},
|
|
@@ -280,6 +290,8 @@ module.exports = {
|
|
|
280
290
|
'dist-entry',
|
|
281
291
|
// exclude better-sqlite3 from electron-builder
|
|
282
292
|
'!node_modules/better-sqlite3/**',
|
|
293
|
+
// exclude @napi-rs/image from electron-builder
|
|
294
|
+
'!node_modules/@napi-rs*/**',
|
|
283
295
|
]
|
|
284
296
|
}
|
|
285
297
|
```
|
package/dist/vite.d.mts
CHANGED
|
@@ -287,27 +287,37 @@ type ElectronWithUpdaterOptions = {
|
|
|
287
287
|
*
|
|
288
288
|
* @example
|
|
289
289
|
* import { defineConfig } from 'vite'
|
|
290
|
-
* import
|
|
291
|
-
* import { buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
290
|
+
* import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
|
|
292
291
|
* import pkg from './package.json'
|
|
293
292
|
*
|
|
294
|
-
* export default defineConfig(({ command }) => {
|
|
295
|
-
* const
|
|
296
|
-
* isBuild: command === 'build',
|
|
297
|
-
* pkg,
|
|
298
|
-
* main: {
|
|
299
|
-
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
300
|
-
* },
|
|
301
|
-
* preload: {
|
|
302
|
-
* files: './electron/preload/index.ts',
|
|
303
|
-
* },
|
|
304
|
-
* })
|
|
293
|
+
* export default defineConfig(async ({ command }) => {
|
|
294
|
+
* const isBuild = command === 'build'
|
|
305
295
|
* return {
|
|
306
|
-
* plugins: [
|
|
296
|
+
* plugins: [
|
|
297
|
+
* electronWithUpdater({
|
|
298
|
+
* pkg,
|
|
299
|
+
* isBuild,
|
|
300
|
+
* logParsedOptions: true,
|
|
301
|
+
* main: {
|
|
302
|
+
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
303
|
+
* // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
|
|
304
|
+
* onstart: debugStartup,
|
|
305
|
+
* },
|
|
306
|
+
* preload: {
|
|
307
|
+
* files: './electron/preload/index.ts',
|
|
308
|
+
* },
|
|
309
|
+
* updater: {
|
|
310
|
+
* // options
|
|
311
|
+
* }
|
|
312
|
+
* }),
|
|
313
|
+
* ],
|
|
307
314
|
* server: process.env.VSCODE_DEBUG && (() => {
|
|
308
315
|
* const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
|
309
|
-
* return {
|
|
310
|
-
*
|
|
316
|
+
* return {
|
|
317
|
+
* host: url.hostname,
|
|
318
|
+
* port: +url.port,
|
|
319
|
+
* }
|
|
320
|
+
* })(),
|
|
311
321
|
* }
|
|
312
322
|
* })
|
|
313
323
|
*/
|
package/dist/vite.d.ts
CHANGED
|
@@ -287,27 +287,37 @@ type ElectronWithUpdaterOptions = {
|
|
|
287
287
|
*
|
|
288
288
|
* @example
|
|
289
289
|
* import { defineConfig } from 'vite'
|
|
290
|
-
* import
|
|
291
|
-
* import { buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
290
|
+
* import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
|
|
292
291
|
* import pkg from './package.json'
|
|
293
292
|
*
|
|
294
|
-
* export default defineConfig(({ command }) => {
|
|
295
|
-
* const
|
|
296
|
-
* isBuild: command === 'build',
|
|
297
|
-
* pkg,
|
|
298
|
-
* main: {
|
|
299
|
-
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
300
|
-
* },
|
|
301
|
-
* preload: {
|
|
302
|
-
* files: './electron/preload/index.ts',
|
|
303
|
-
* },
|
|
304
|
-
* })
|
|
293
|
+
* export default defineConfig(async ({ command }) => {
|
|
294
|
+
* const isBuild = command === 'build'
|
|
305
295
|
* return {
|
|
306
|
-
* plugins: [
|
|
296
|
+
* plugins: [
|
|
297
|
+
* electronWithUpdater({
|
|
298
|
+
* pkg,
|
|
299
|
+
* isBuild,
|
|
300
|
+
* logParsedOptions: true,
|
|
301
|
+
* main: {
|
|
302
|
+
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
303
|
+
* // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
|
|
304
|
+
* onstart: debugStartup,
|
|
305
|
+
* },
|
|
306
|
+
* preload: {
|
|
307
|
+
* files: './electron/preload/index.ts',
|
|
308
|
+
* },
|
|
309
|
+
* updater: {
|
|
310
|
+
* // options
|
|
311
|
+
* }
|
|
312
|
+
* }),
|
|
313
|
+
* ],
|
|
307
314
|
* server: process.env.VSCODE_DEBUG && (() => {
|
|
308
315
|
* const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
|
309
|
-
* return {
|
|
310
|
-
*
|
|
316
|
+
* return {
|
|
317
|
+
* host: url.hostname,
|
|
318
|
+
* port: +url.port,
|
|
319
|
+
* }
|
|
320
|
+
* })(),
|
|
311
321
|
* }
|
|
312
322
|
* })
|
|
313
323
|
*/
|
package/dist/vite.js
CHANGED
|
@@ -297,7 +297,8 @@ function parseOptions(isBuild, pkg, options = {}) {
|
|
|
297
297
|
entryOutputDirPath = "dist-entry",
|
|
298
298
|
appEntryPath = "electron/entry.ts",
|
|
299
299
|
nativeModuleEntryMap = {},
|
|
300
|
-
postBuild
|
|
300
|
+
postBuild,
|
|
301
|
+
overrideEsbuildOptions
|
|
301
302
|
} = {},
|
|
302
303
|
paths: {
|
|
303
304
|
asarOutputPath = `release/${pkg.name}.asar`,
|
|
@@ -335,7 +336,8 @@ function parseOptions(isBuild, pkg, options = {}) {
|
|
|
335
336
|
entryOutputDirPath,
|
|
336
337
|
appEntryPath,
|
|
337
338
|
nativeModuleEntryMap,
|
|
338
|
-
postBuild
|
|
339
|
+
postBuild,
|
|
340
|
+
overrideEsbuildOptions
|
|
339
341
|
};
|
|
340
342
|
const { privateKey, cert } = parseKeys({
|
|
341
343
|
keyLength,
|
|
@@ -386,7 +388,7 @@ function electronWithUpdater(options) {
|
|
|
386
388
|
const sourcemap = isBuild || !!process.env.VSCODE_DEBUG;
|
|
387
389
|
const _appPath = (0, import_node_path3.join)(entryOutputDirPath, "entry.js");
|
|
388
390
|
if ((0, import_node_path3.resolve)((0, import_vite.normalizePath)(pkg.main)) !== (0, import_node_path3.resolve)((0, import_vite.normalizePath)(_appPath))) {
|
|
389
|
-
throw new Error(`wrong "main" field in package.json: "${pkg.main}", it should be "${
|
|
391
|
+
throw new Error(`wrong "main" field in package.json: "${pkg.main}", it should be "${(0, import_vite.normalizePath)(_appPath)}"`);
|
|
390
392
|
}
|
|
391
393
|
let isInit = false;
|
|
392
394
|
const _buildEntry = async () => {
|
|
@@ -401,7 +403,7 @@ function electronWithUpdater(options) {
|
|
|
401
403
|
isInit = true;
|
|
402
404
|
await _buildEntry();
|
|
403
405
|
}
|
|
404
|
-
_main.onstart
|
|
406
|
+
_main.onstart ? _main.onstart(args) : args.startup();
|
|
405
407
|
},
|
|
406
408
|
vite: (0, import_vite.mergeConfig)(
|
|
407
409
|
{
|
package/dist/vite.mjs
CHANGED
|
@@ -203,7 +203,8 @@ function parseOptions(isBuild, pkg, options = {}) {
|
|
|
203
203
|
entryOutputDirPath = "dist-entry",
|
|
204
204
|
appEntryPath = "electron/entry.ts",
|
|
205
205
|
nativeModuleEntryMap = {},
|
|
206
|
-
postBuild
|
|
206
|
+
postBuild,
|
|
207
|
+
overrideEsbuildOptions
|
|
207
208
|
} = {},
|
|
208
209
|
paths: {
|
|
209
210
|
asarOutputPath = `release/${pkg.name}.asar`,
|
|
@@ -241,7 +242,8 @@ function parseOptions(isBuild, pkg, options = {}) {
|
|
|
241
242
|
entryOutputDirPath,
|
|
242
243
|
appEntryPath,
|
|
243
244
|
nativeModuleEntryMap,
|
|
244
|
-
postBuild
|
|
245
|
+
postBuild,
|
|
246
|
+
overrideEsbuildOptions
|
|
245
247
|
};
|
|
246
248
|
const { privateKey, cert } = parseKeys({
|
|
247
249
|
keyLength,
|
|
@@ -292,7 +294,7 @@ function electronWithUpdater(options) {
|
|
|
292
294
|
const sourcemap = isBuild || !!process.env.VSCODE_DEBUG;
|
|
293
295
|
const _appPath = join2(entryOutputDirPath, "entry.js");
|
|
294
296
|
if (resolve(normalizePath(pkg.main)) !== resolve(normalizePath(_appPath))) {
|
|
295
|
-
throw new Error(`wrong "main" field in package.json: "${pkg.main}", it should be "${_appPath
|
|
297
|
+
throw new Error(`wrong "main" field in package.json: "${pkg.main}", it should be "${normalizePath(_appPath)}"`);
|
|
296
298
|
}
|
|
297
299
|
let isInit = false;
|
|
298
300
|
const _buildEntry = async () => {
|
|
@@ -307,7 +309,7 @@ function electronWithUpdater(options) {
|
|
|
307
309
|
isInit = true;
|
|
308
310
|
await _buildEntry();
|
|
309
311
|
}
|
|
310
|
-
_main.onstart
|
|
312
|
+
_main.onstart ? _main.onstart(args) : args.startup();
|
|
311
313
|
},
|
|
312
314
|
vite: mergeConfig(
|
|
313
315
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-incremental-update",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "electron incremental update tools, powered by vite",
|
|
5
5
|
"author": "subframe7536",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,21 +49,21 @@
|
|
|
49
49
|
"vite-plugin-electron": "^0.15.6 || ^0.28"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@electron/asar": "^3.2.
|
|
53
|
-
"@subframe7536/type-utils": "^0.1.
|
|
52
|
+
"@electron/asar": "^3.2.9",
|
|
53
|
+
"@subframe7536/type-utils": "^0.1.6",
|
|
54
54
|
"selfsigned": "^2.4.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@subframe7536/eslint-config": "^0.
|
|
58
|
-
"@types/node": "^20.
|
|
59
|
-
"bumpp": "^9.
|
|
57
|
+
"@subframe7536/eslint-config": "^0.6.0",
|
|
58
|
+
"@types/node": "^20.12.5",
|
|
59
|
+
"bumpp": "^9.4.0",
|
|
60
60
|
"electron": "28.1.1",
|
|
61
|
-
"eslint": "^8.
|
|
62
|
-
"tsup": "^8.0.
|
|
63
|
-
"typescript": "^5.
|
|
64
|
-
"vite": "^5.
|
|
65
|
-
"vite-plugin-electron": "^0.
|
|
66
|
-
"vitest": "^1.
|
|
61
|
+
"eslint": "^8.57.0",
|
|
62
|
+
"tsup": "^8.0.2",
|
|
63
|
+
"typescript": "^5.4.4",
|
|
64
|
+
"vite": "^5.2.8",
|
|
65
|
+
"vite-plugin-electron": "^0.28.4",
|
|
66
|
+
"vitest": "^1.4.0"
|
|
67
67
|
},
|
|
68
68
|
"pnpm": {
|
|
69
69
|
"overrides": {
|