Skip to content

Commit 2fecbb9

Browse files
committed
Migrate electron-builder config to JS, drop JSON
Removes the legacy `electron-builder.json` file and updates all packaging scripts to reference the new `electron-builder.config.cjs` module. This centralizes the build configuration in a JavaScript file, enabling richer logic and easier maintenance while eliminating the now‑unused JSON config.
1 parent 6bd3968 commit 2fecbb9

3 files changed

Lines changed: 115 additions & 137 deletions

File tree

electron-builder.config.cjs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
const path = require('path');
2+
3+
/**
4+
* @type {import('electron-builder').Configuration}
5+
*/
6+
module.exports = {
7+
appId: 'com.netcatty.app',
8+
productName: 'Netcatty',
9+
artifactName: '${productName}-${version}-${os}-${arch}.${ext}',
10+
icon: 'public/icon.png',
11+
directories: {
12+
buildResources: 'build',
13+
output: 'release'
14+
},
15+
files: [
16+
'dist/**/*',
17+
'electron/**/*',
18+
'!electron/.dev-config.json',
19+
'public/**/*',
20+
'node_modules/**/*'
21+
],
22+
asarUnpack: [
23+
'node_modules/node-pty/**/*',
24+
'node_modules/ssh2/**/*',
25+
'node_modules/cpu-features/**/*'
26+
],
27+
mac: {
28+
target: [
29+
{
30+
target: 'dmg',
31+
arch: ['arm64', 'x64']
32+
},
33+
{
34+
target: 'zip',
35+
arch: ['arm64', 'x64']
36+
}
37+
],
38+
category: 'public.app-category.developer-tools',
39+
hardenedRuntime: false,
40+
gatekeeperAssess: false,
41+
entitlements: 'electron/entitlements.mac.plist',
42+
entitlementsInherit: 'electron/entitlements.mac.plist',
43+
extendInfo: {
44+
NSCameraUsageDescription: 'Netcatty may use the camera for video calls',
45+
NSMicrophoneUsageDescription: 'Netcatty may use the microphone for audio',
46+
NSLocalNetworkUsageDescription: 'Netcatty needs local network access for SSH connections'
47+
}
48+
},
49+
dmg: {
50+
title: '${productName}',
51+
background: 'public/dmg-background.jpg',
52+
iconSize: 100,
53+
iconTextSize: 12,
54+
window: {
55+
width: 672,
56+
height: 500
57+
},
58+
contents: [
59+
{ x: 150, y: 158 },
60+
{ x: 550, y: 158, type: 'link', path: '/Applications' },
61+
{
62+
x: 350,
63+
y: 330,
64+
type: 'file',
65+
// Use absolute path resolved at build time
66+
path: path.resolve(__dirname, 'scripts/FixQuarantine.app'),
67+
name: '已损坏修复.app'
68+
}
69+
]
70+
},
71+
win: {
72+
target: [
73+
{
74+
target: 'nsis',
75+
arch: ['x64']
76+
},
77+
{
78+
target: 'dir',
79+
arch: ['x64']
80+
}
81+
]
82+
},
83+
nsis: {
84+
oneClick: false,
85+
perMachine: false,
86+
allowElevation: true,
87+
allowToChangeInstallationDirectory: true,
88+
createDesktopShortcut: true,
89+
createStartMenuShortcut: true,
90+
shortcutName: 'Netcatty'
91+
},
92+
linux: {
93+
target: [
94+
{
95+
target: 'AppImage',
96+
arch: ['x64', 'arm64']
97+
},
98+
{
99+
target: 'deb',
100+
arch: ['x64', 'arm64']
101+
},
102+
{
103+
target: 'rpm',
104+
arch: ['x64', 'arm64']
105+
}
106+
],
107+
category: 'Development'
108+
}
109+
};

electron-builder.json

Lines changed: 0 additions & 131 deletions
This file was deleted.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"build": "vite build",
1616
"preview": "vite preview",
1717
"start": "node electron/launch.cjs",
18-
"pack": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.json --publish=never",
19-
"pack:dir": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.json --dir --publish=never",
20-
"pack:win": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.json --win --publish=never",
21-
"pack:mac": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.json --mac --publish=never",
22-
"pack:linux": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.json --linux --publish=never",
18+
"pack": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.config.cjs --publish=never",
19+
"pack:dir": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.config.cjs --dir --publish=never",
20+
"pack:win": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.config.cjs --win --publish=never",
21+
"pack:mac": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.config.cjs --mac --publish=never",
22+
"pack:linux": "npm run build && cross-env NODE_OPTIONS=--disable-warning=DEP0190 electron-builder --config electron-builder.config.cjs --linux --publish=never",
2323
"postinstall": "electron-builder install-app-deps",
2424
"rebuild": "electron-builder install-app-deps",
2525
"lint": "eslint .",
@@ -77,4 +77,4 @@
7777
"vite": "^7.2.7",
7878
"wait-on": "^9.0.3"
7979
}
80-
}
80+
}

0 commit comments

Comments
 (0)