1
- import type { ForgeConfig } from '@electron-forge/shared-types' ;
2
- import { MakerSquirrel } from '@electron-forge/maker-squirrel' ;
3
- import { MakerDeb } from '@electron-forge/maker-deb' ;
4
- import { MakerRpm } from '@electron-forge/maker-rpm' ;
5
- import { VitePlugin } from '@electron-forge/plugin-vite' ;
6
- import { FusesPlugin } from '@electron-forge/plugin-fuses' ;
7
- import { FuseV1Options , FuseVersion } from '@electron/fuses' ;
1
+ import type { ForgeConfig } from '@electron-forge/shared-types' ;
2
+ import { MakerSquirrel } from '@electron-forge/maker-squirrel' ;
3
+ import { MakerDeb } from '@electron-forge/maker-deb' ;
4
+ import { MakerRpm } from '@electron-forge/maker-rpm' ;
5
+ import { MakerWix } from '@electron-forge/maker-wix' ;
6
+ import { VitePlugin } from '@electron-forge/plugin-vite' ;
7
+ import { FusesPlugin } from '@electron-forge/plugin-fuses' ;
8
+ import { FuseV1Options , FuseVersion } from '@electron/fuses' ;
8
9
import MakerDMG from '@electron-forge/maker-dmg' ;
10
+ import packageJson from './package.json' ;
11
+ import path from 'node:path' ;
12
+ import fs from 'node:fs/promises' ;
13
+
9
14
10
15
const config : ForgeConfig = {
11
16
packagerConfig : {
12
17
asar : true ,
13
18
icon : './assets/icons/icon' ,
14
- extraResource : [ " ./drizzle" , " ./lib" , " ./scripts" ] ,
19
+ extraResource : [ ' ./drizzle' , ' ./lib' , ' ./scripts' ] ,
15
20
executableName : 'dash-player' ,
16
21
name : 'DashPlayer' ,
17
22
} ,
@@ -25,46 +30,42 @@ const config: ForgeConfig = {
25
30
} ) ,
26
31
new MakerDMG ( {
27
32
icon : './assets/icons/icon.icns' ,
28
- format : 'ULFO'
33
+ format : 'ULFO' ,
29
34
} ) ,
30
35
new MakerRpm ( {
31
36
options : {
32
37
name : 'dash-player' ,
33
38
productName : 'DashPlayer' ,
34
39
icon : './assets/icons/icon.png' ,
35
- }
40
+ } ,
36
41
} ) ,
37
42
new MakerDeb ( {
38
43
options : {
39
44
name : 'dash-player' ,
40
45
productName : 'DashPlayer' ,
41
46
icon : './assets/icons/icon.png' ,
42
- }
43
- } ) ] ,
47
+ } ,
48
+ } ) ,
49
+ new MakerWix ( {
50
+ name : 'DashPlayer' ,
51
+ description : 'A video player for English learning' ,
52
+ manufacturer : 'solidSpoon' ,
53
+ version : packageJson . version ,
54
+ icon : './assets/icons/icon.ico' ,
55
+ exe : 'dash-player.exe' ,
56
+ ui : {
57
+ chooseDirectory : true ,
58
+ } ,
59
+ } ) ,
60
+ ] ,
44
61
plugins : [
45
62
new VitePlugin ( {
46
- // `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
47
- // If you are familiar with Vite configuration, it will look really familiar.
48
63
build : [
49
- {
50
- // `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
51
- entry : 'src/main.ts' ,
52
- config : 'vite.main.config.ts' ,
53
- } ,
54
- {
55
- entry : 'src/preload.ts' ,
56
- config : 'vite.preload.config.ts' ,
57
- } ,
58
- ] ,
59
- renderer : [
60
- {
61
- name : 'main_window' ,
62
- config : 'vite.renderer.config.ts' ,
63
- } ,
64
+ { entry : 'src/main.ts' , config : 'vite.main.config.ts' } ,
65
+ { entry : 'src/preload.ts' , config : 'vite.preload.config.ts' } ,
64
66
] ,
67
+ renderer : [ { name : 'main_window' , config : 'vite.renderer.config.ts' } ] ,
65
68
} ) ,
66
- // Fuses are used to enable/disable various Electron functionality
67
- // at package time, before code signing the application
68
69
new FusesPlugin ( {
69
70
version : FuseVersion . V1 ,
70
71
[ FuseV1Options . RunAsNode ] : false ,
@@ -79,14 +80,33 @@ const config: ForgeConfig = {
79
80
{
80
81
name : '@electron-forge/publisher-github' ,
81
82
config : {
82
- repository : {
83
- owner : 'solidSpoon' ,
84
- name : 'DashPlayer'
85
- } ,
86
- prerelease : true
83
+ repository : { owner : 'solidSpoon' , name : 'DashPlayer' } ,
84
+ prerelease : true ,
85
+ } ,
86
+ } ,
87
+ ] ,
88
+ hooks : {
89
+ postMake : async ( _forgeConfig , makeResults ) => {
90
+ const version = packageJson . version ;
91
+ for ( const result of makeResults ) {
92
+ if ( result . platform !== 'win32' ) continue ;
93
+ for ( let i = 0 ; i < result . artifacts . length ; i ++ ) {
94
+ const oldPath = result . artifacts [ i ] ;
95
+ if ( ! oldPath . toLowerCase ( ) . endsWith ( '.msi' ) ) continue ;
96
+ const dir = path . dirname ( oldPath ) ;
97
+ const arch = result . arch ; // 'x64' | 'ia32' | 'arm64'
98
+ const newPath = path . join ( dir , `DashPlayer-${ version } -${ arch } .msi` ) ;
99
+ if ( oldPath !== newPath ) {
100
+ await fs . rename ( oldPath , newPath ) ;
101
+ // 更新 artifacts,确保 Publisher 上传重命名后的文件
102
+ result . artifacts [ i ] = newPath ;
103
+ console . log ( `Renamed MSI: ${ oldPath } -> ${ newPath } ` ) ;
104
+ }
105
+ }
87
106
}
88
- }
89
- ]
107
+ return makeResults ;
108
+ } ,
109
+ } ,
90
110
} ;
91
111
92
112
export default config ;
0 commit comments