forked from keyboardio/Chrysalis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforge.config.js
More file actions
206 lines (199 loc) · 6.23 KB
/
Copy pathforge.config.js
File metadata and controls
206 lines (199 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
const { spawnSync } = require("child_process");
const { generateCLDRData } = require("./tools/precompile.js");
const { glob } = require("glob");
const fs = require("fs");
const path = require("path");
let config = {
packagerConfig: {
asar: true,
appBundleId: "keyboardio.chrysalis",
darwinDarkModeSupport: "true",
icon: "build/icon",
name: "Chrysalis",
extraResource: ["static", "NEWS.md", "build/app-update.yml"],
osxUniversal: {
x64ArchFiles: "*",
},
osxSign: {
"pre-auto-entitlements": false,
"gatekeeper-assess": false,
identity: "Developer ID Application: Keyboard.io, Inc. (8AUZGMT2H5)",
entitlements: "./build/entitlements",
// optionsForFile: (filePath) => {
// Here, we keep it simple and return a single entitlements.plist file.
// You can use this callback to map different sets of entitlements
// to specific files in your packaged app.
// return { entitlements: './build/entitlements.mac.inherit.plist' }
// }
},
osxNotarize: {
tool: "notarytool",
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
},
packageManager: "yarn",
},
rebuildConfig: {},
makers: [
{
name: "@electron-forge/maker-squirrel",
config: {
certificateFile: "./cert.pfx",
certificatePassword: process.env.WINDOWS_CERTIFICATE_PASSWORD,
},
},
{
name: "@electron-forge/maker-dmg",
config: {},
},
{
name: "@electron-forge/maker-zip",
},
{
name: "@reforged/maker-appimage",
config: {
options: {
// Package name.
// name: "example-app",
// Executable name.
bin: "Chrysalis",
// Human-friendly name of the application.
// productName: "Example Electron Application",
// `GenericName` in generated `.desktop` file.
// genericName: "Example application",
// Path to application's icon.
icon: "build/icon.png",
// `Categories` in generated `.desktop` file.
categories: ["Utility"],
// Actions of generated `.desktop` file.
// actions: {
// new_window: {
// Name: "Launch in new window!",
// Icon: "/path/to/new-window.png",
// Exec: "example-app --new-window"
// }
//},
// Desktop file to be used instead of the configuration above.
// desktopFile: "/path/to/example-app.desktop",
// Release of `AppImage/AppImageKit`, either number or "continuous".
// AppImageKitRelease: "continuous"
},
},
},
],
publishers: [
{
name: "@electron-forge/publisher-github",
config: {
repository: {
owner: "keyboardio",
name: "Chrysalis",
},
draft: true,
},
},
],
plugins: [
{
name: "@electron-forge/plugin-auto-unpack-natives",
config: {},
},
{
name: "@electron-forge/plugin-webpack",
config: {
devContentSecurityPolicy: `default-src 'self' 'unsafe-inline' data:; script-src 'self' 'unsafe-eval' 'unsafe-inline' data:`,
mainConfig: "./webpack.main.config.js",
renderer: {
config: "./webpack.renderer.config.js",
entryPoints: [
{
html: "./src/renderer/index.html",
js: "./src/renderer/index.js",
name: "main_window",
preload: {
js: "./src/preload.js",
},
},
],
},
},
},
],
hooks: {
generateAssets: async (forgeConfig, platform, arch) => {
generateCLDRData();
},
readPackageJson: async (forgeConfig, packageJson) => {
// only copy deps if there isn't any
if (Object.keys(packageJson.dependencies).length === 0) {
const originalPackageJson = await fs.readJson(
path.resolve(__dirname, "package.json"),
);
const webpackConfigJs = require("./webpack.renderer.config.js");
Object.keys(webpackConfigJs.externals).forEach((package) => {
packageJson.dependencies[package] =
originalPackageJson.dependencies[package];
});
}
return packageJson;
},
packageAfterPrune: async (
forgeConfig,
buildPath,
electronVersion,
platform,
arch,
) => {
const npmInstall = spawnSync("npm", ["install", "--omit=dev"], {
cwd: buildPath,
stdio: "inherit",
shell: true,
});
// Clear out prebuilds for other architectures
// 1) we don't need them
// 2) windows binary signing tool blows up when it tries to sign them.
const prebuilds = glob.GlobSync(`${buildPath}/**/prebuilds/*`);
const matchString = new RegExp(`prebuilds/${platform}`);
prebuilds.found.forEach(function (path) {
if (!path.match(matchString)) {
fs.rmSync(path, { recursive: true });
}
});
// Workaround from https://www.update.rocks/blog/fixing-the-python3/
if (platform === "darwin") {
// Directory to inspect
const dirPath = path.join(
buildPath,
"node_modules/macos-alias/build/node_gyp_bins",
);
// Check if the directory exists
if (fs.existsSync(dirPath)) {
// List files in the directory
console.log("Contents of the directory before removal: ");
const files = fs.readdirSync(path.join(dirPath));
files.forEach((file) => {
console.log(file);
});
// Files to remove
const filesToRemove = ["python", "python2", "python3"];
// Remove files if they exist
filesToRemove.forEach((file) => {
const filePath = path.join(dirPath, file);
if (fs.existsSync(filePath)) {
console.log(`Removing file: ${file}`);
fs.unlinkSync(filePath);
}
});
} else {
console.log(`Directory not found: ${dirPath}`);
}
}
},
},
};
if (process.env.UNTRUSTED) {
delete config["packagerConfig"]["osxSign"];
delete config["packagerConfig"]["osxNotarize"];
}
module.exports = config;