forked from chaiNNer-org/chaiNNer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forge.config.js
182 lines (177 loc) · 6.8 KB
/
forge.config.js
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
// eslint-disable-next-line import/no-extraneous-dependencies
const AdmZip = require('adm-zip');
const fs = require('fs/promises');
const path = require('path');
const packageJson = require('./package.json');
const makerOptions = {
categories: ['Graphics'],
genericName: 'Image Processing GUI',
homepage: 'https://chainner.app',
icon: './src/public/icons/cross_platform/icon.png',
mimeType: ['application/json'],
productDescription:
'A node-based image processing GUI aimed at making chaining image processing tasks easy and customizable. Born as an AI upscaling application, chaiNNer has grown into an extremely flexible and powerful programmatic image processing application.\n\nChaiNNer gives you a level of customization of your image processing workflow that very few others do. Not only do you have full control over your processing pipeline, you can do incredibly complex tasks just by connecting a few nodes together.',
};
const deletePycFiles = async (directory) => {
try {
const files = await fs.readdir(directory, { withFileTypes: true });
await Promise.all(
files.map(async (file) => {
const fullPath = path.join(directory, file.name);
if (file.isDirectory()) {
if (file.name === '__pycache__') {
await fs.rm(fullPath, { recursive: true, force: true });
} else {
await deletePycFiles(fullPath);
}
} else if (file.isFile() && path.extname(file.name) === '.pyc') {
await fs.unlink(fullPath);
}
})
);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
};
/** @type {import("@electron-forge/shared-types").ForgeConfig} */
const config = {
packagerConfig: {
asar: false,
executableName: process.platform === 'linux' ? packageJson.name : packageJson.productName,
extraResource: ['./backend/src/', './src/public/icons/mac/file_chn.icns'],
icon: makerOptions.icon,
appBundleId: packageJson.appId,
appCategoryType: 'public.app-category.graphics-design',
extendInfo: './src/public/Info.plist',
...(process.argv.includes('--dry-run') || process.argv.includes('--no-sign')
? {}
: {
osxSign: {},
osxNotarize: {
tool: 'notarytool',
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
},
}),
},
publishers: [
{
name: '@electron-forge/publisher-github',
config: {
repository: {
owner: packageJson.author.name,
name: packageJson.productName,
},
},
draft: true,
prerelease: true,
},
],
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
name: packageJson.productName,
iconUrl:
'https://github.com/chaiNNer-org/chaiNNer/blob/main/src/public/icons/win/icon.ico',
setupIcon: './src/public/icons/win/icon.ico',
loadingGif: './src/public/icons/win/installing_loop.gif',
},
},
{
name: '@electron-forge/maker-zip',
platforms: ['linux', 'win32'],
},
{
name: '@electron-forge/maker-dmg',
config: {
format: 'ULMO',
background: './src/public/dmg-background.png',
icon: './src/public/icons/mac/icon.icns',
additionalDMGOptions: {
window: { size: { width: 660, height: 500 } },
filesystem: 'APFS',
...(process.argv.includes('--dry-run') || process.argv.includes('--no-sign')
? {}
: {
'code-sign': {
'signing-identity': process.env.APPLE_SIGNING_ID,
identifier: packageJson.appId,
},
}),
},
},
},
{
name: '@electron-forge/maker-deb',
config: {
options: {
...makerOptions,
section: 'graphics',
},
},
},
{
name: '@electron-forge/maker-rpm',
config: {
options: { ...makerOptions, compressionLevel: 9 },
},
},
],
plugins: [
{
name: '@electron-forge/plugin-vite',
config: {
// `build` can specify multiple entry builds, which can be
// Main process, Preload scripts, Worker process, etc.
build: [
{
// `entry` is an alias for `build.lib.entry`
// in the corresponding file of `config`.
entry: 'src/main/main.ts',
config: 'vite/main.config.ts',
},
{
entry: 'src/main/preload.ts',
config: 'vite/preload.config.ts',
},
],
renderer: [
{
name: 'main_window',
config: 'vite/renderer.config.ts',
},
],
},
},
],
hooks: {
prePackage: async () => {
// delete all .pyc files from backend folder, recursively
const backendPath = path.join(__dirname, 'backend/src');
await deletePycFiles(backendPath);
},
postMake: async (forgeConfig, makeResults) => {
const justArtifacts = makeResults.map((m) => m.artifacts).reduce((a, b) => a.concat(b));
const zipArtifact = justArtifacts.find((a) => a.endsWith('.zip'));
if (zipArtifact) {
// Add an empty `portable` file to the zip
const zip = new AdmZip(zipArtifact);
switch (process.platform) {
case 'win32':
zip.addFile('portable', Buffer.alloc(0));
break;
case 'linux':
zip.addFile('chaiNNer-linux-x64/portable', Buffer.alloc(0));
break;
default:
break;
}
zip.writeZip(zipArtifact);
}
},
},
};
module.exports = config;