@pipelab/plugin-electron 1.0.0-beta.1 → 1.0.0-beta.4
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/dist/index.cjs +14 -2
- package/dist/index.mjs +14 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -7
- package/CHANGELOG.md +0 -20
- package/src/configure.ts +0 -23
- package/src/declarations.d.ts +0 -1
- package/src/fixtures/build/index.html +0 -11
- package/src/forge.ts +0 -851
- package/src/index.ts +0 -94
- package/src/make.spec.ts +0 -57
- package/src/make.ts +0 -22
- package/src/package-v2.ts +0 -52
- package/src/package.ts +0 -22
- package/src/preview.ts +0 -35
- package/src/public/electron.webp +0 -0
- package/src/utils.ts +0 -35
- package/tests/e2e/electron.spec.ts +0 -64
- package/tests/e2e/fixtures/folder-to-electron.json +0 -171
- package/tests/e2e/fixtures/folder-to-tauri.json +0 -58
- package/tests/e2e/vitest.config.mts +0 -20
- package/tsconfig.json +0 -10
- package/tsdown.config.ts +0 -15
package/src/forge.ts
DELETED
|
@@ -1,851 +0,0 @@
|
|
|
1
|
-
import { getBinName, outFolderName } from "@pipelab/constants";
|
|
2
|
-
import {
|
|
3
|
-
ActionRunnerData,
|
|
4
|
-
createAction,
|
|
5
|
-
createArray,
|
|
6
|
-
createBooleanParam,
|
|
7
|
-
createColorPicker,
|
|
8
|
-
createNumberParam,
|
|
9
|
-
createPathParam,
|
|
10
|
-
createStringParam,
|
|
11
|
-
detectRuntime,
|
|
12
|
-
generateTempFolder,
|
|
13
|
-
InputsDefinition,
|
|
14
|
-
OutputsDefinition,
|
|
15
|
-
runPnpm,
|
|
16
|
-
runWithLiveLogs,
|
|
17
|
-
fetchPipelabAsset,
|
|
18
|
-
} from "@pipelab/plugin-core";
|
|
19
|
-
|
|
20
|
-
import { dirname, join, basename, delimiter } from "node:path";
|
|
21
|
-
import { cp, readFile, writeFile, rm } from "node:fs/promises";
|
|
22
|
-
import { platform as osPlatform, arch as osArch } from "node:os";
|
|
23
|
-
import { kebabCase } from "change-case";
|
|
24
|
-
import semver from "semver";
|
|
25
|
-
import * as esbuild from "esbuild";
|
|
26
|
-
|
|
27
|
-
// TODO: https://js.electronforge.io/modules/_electron_forge_core.html
|
|
28
|
-
|
|
29
|
-
export const IDMake = "electron:make";
|
|
30
|
-
export const IDPackage = "electron:package";
|
|
31
|
-
export const IDPackageV2 = "electron:package:v2";
|
|
32
|
-
export const IDPackageV3 = "electron:package:v3";
|
|
33
|
-
export const IDPreview = "electron:preview";
|
|
34
|
-
|
|
35
|
-
const paramsInputFolder = {
|
|
36
|
-
"input-folder": createPathParam("", {
|
|
37
|
-
label: "Folder to package",
|
|
38
|
-
required: true,
|
|
39
|
-
control: {
|
|
40
|
-
type: "path",
|
|
41
|
-
options: {
|
|
42
|
-
properties: ["openDirectory"],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
}),
|
|
46
|
-
} satisfies InputsDefinition;
|
|
47
|
-
|
|
48
|
-
const paramsInputURL = {
|
|
49
|
-
"input-url": createStringParam("", {
|
|
50
|
-
label: "URL to preview",
|
|
51
|
-
required: true,
|
|
52
|
-
}),
|
|
53
|
-
} satisfies InputsDefinition;
|
|
54
|
-
|
|
55
|
-
const params = {
|
|
56
|
-
arch: {
|
|
57
|
-
value: "" as NodeJS.Architecture | "", // MakeOptions['arch'],
|
|
58
|
-
label: "Architecture",
|
|
59
|
-
required: false,
|
|
60
|
-
control: {
|
|
61
|
-
type: "select",
|
|
62
|
-
options: {
|
|
63
|
-
placeholder: "Architecture",
|
|
64
|
-
options: [
|
|
65
|
-
{
|
|
66
|
-
label: "Older PCs (ia32)",
|
|
67
|
-
value: "ia32",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: "Modern PCs (x64)",
|
|
71
|
-
value: "x64",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
label: "Older Mobile/Pi (armv7l)",
|
|
75
|
-
value: "armv7l",
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
label: "New Mobile/Apple Silicon (arm64)",
|
|
79
|
-
value: "arm64",
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
label: "Mac Universal (universal)",
|
|
83
|
-
value: "universal",
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
label: "Special Systems (mips64el)",
|
|
87
|
-
value: "mips64el",
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
platform: {
|
|
94
|
-
value: "" as NodeJS.Platform | "", // MakeOptions['platform'],
|
|
95
|
-
label: "Platform",
|
|
96
|
-
required: false,
|
|
97
|
-
control: {
|
|
98
|
-
type: "select",
|
|
99
|
-
options: {
|
|
100
|
-
placeholder: "Platform",
|
|
101
|
-
options: [
|
|
102
|
-
{
|
|
103
|
-
label: "Windows (win32)",
|
|
104
|
-
value: "win32",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
label: "macOS (darwin)",
|
|
108
|
-
value: "darwin",
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
label: "Linux (linux)",
|
|
112
|
-
value: "linux",
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
configuration: {
|
|
119
|
-
label: "Electron configuration",
|
|
120
|
-
value: undefined as Partial<DesktopApp.Electron> | undefined,
|
|
121
|
-
required: true,
|
|
122
|
-
control: {
|
|
123
|
-
type: "json",
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
} satisfies InputsDefinition;
|
|
127
|
-
|
|
128
|
-
export const configureParams = {
|
|
129
|
-
name: createStringParam("Pipelab", {
|
|
130
|
-
label: "Application name",
|
|
131
|
-
description: "The name of the application",
|
|
132
|
-
required: true,
|
|
133
|
-
}),
|
|
134
|
-
appBundleId: createStringParam("com.pipelab.app", {
|
|
135
|
-
label: "Application bundle ID",
|
|
136
|
-
description: "The bundle ID of the application",
|
|
137
|
-
required: true,
|
|
138
|
-
}),
|
|
139
|
-
appCopyright: createStringParam("Copyright © 2024 Pipelab", {
|
|
140
|
-
label: "Application copyright",
|
|
141
|
-
description: "The copyright of the application",
|
|
142
|
-
required: false,
|
|
143
|
-
}),
|
|
144
|
-
appVersion: createStringParam("1.0.0", {
|
|
145
|
-
label: "Application version",
|
|
146
|
-
description: "The version of the application",
|
|
147
|
-
required: true,
|
|
148
|
-
}),
|
|
149
|
-
icon: createPathParam("", {
|
|
150
|
-
label: "Application icon",
|
|
151
|
-
description: "The icon of the application. macOS: .icns. Windows: .ico",
|
|
152
|
-
required: false,
|
|
153
|
-
control: {
|
|
154
|
-
type: "path",
|
|
155
|
-
options: {
|
|
156
|
-
filters: [
|
|
157
|
-
{ name: "Image", extensions: ["png", "jpg", "jpeg", "gif", "bmp", "ico", "icns"] },
|
|
158
|
-
],
|
|
159
|
-
},
|
|
160
|
-
label: "Path to an image file",
|
|
161
|
-
},
|
|
162
|
-
}),
|
|
163
|
-
author: createStringParam("Pipelab", {
|
|
164
|
-
label: "Application author",
|
|
165
|
-
description: "The author of the application",
|
|
166
|
-
required: true,
|
|
167
|
-
}),
|
|
168
|
-
description: createStringParam("A simple Electron application", {
|
|
169
|
-
label: "Application description",
|
|
170
|
-
description: "The description of the application",
|
|
171
|
-
required: false,
|
|
172
|
-
}),
|
|
173
|
-
customPackages: createArray<string[]>(
|
|
174
|
-
`[
|
|
175
|
-
// e.g. "lodash" or "express@4.17.1"
|
|
176
|
-
]`,
|
|
177
|
-
{
|
|
178
|
-
label: "Custom npm packages",
|
|
179
|
-
description:
|
|
180
|
-
'A list of additional npm packages to install (format: "package" or "package@version")',
|
|
181
|
-
required: false,
|
|
182
|
-
control: {
|
|
183
|
-
type: "array",
|
|
184
|
-
options: {
|
|
185
|
-
kind: "text",
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
),
|
|
190
|
-
|
|
191
|
-
appCategoryType: createStringParam("public.app-category.developer-tools", {
|
|
192
|
-
platforms: ["darwin"],
|
|
193
|
-
label: "Application category type",
|
|
194
|
-
description: "The category type of the application",
|
|
195
|
-
required: false,
|
|
196
|
-
}),
|
|
197
|
-
|
|
198
|
-
// window
|
|
199
|
-
width: createNumberParam(800, {
|
|
200
|
-
label: "Window width",
|
|
201
|
-
description: "The width of the window",
|
|
202
|
-
required: false,
|
|
203
|
-
}),
|
|
204
|
-
height: createNumberParam(600, {
|
|
205
|
-
label: "Window height",
|
|
206
|
-
description: "The height of the window",
|
|
207
|
-
required: false,
|
|
208
|
-
}),
|
|
209
|
-
fullscreen: {
|
|
210
|
-
label: "Fullscreen",
|
|
211
|
-
value: false,
|
|
212
|
-
description: "Whether to start the application in fullscreen mode",
|
|
213
|
-
required: false,
|
|
214
|
-
control: {
|
|
215
|
-
type: "boolean",
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
frame: {
|
|
219
|
-
label: "Frame",
|
|
220
|
-
value: true,
|
|
221
|
-
description: "Whether to show the window frame",
|
|
222
|
-
required: false,
|
|
223
|
-
control: {
|
|
224
|
-
type: "boolean",
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
transparent: {
|
|
228
|
-
label: "Transparent",
|
|
229
|
-
value: false,
|
|
230
|
-
description: "Whether to make the window transparent",
|
|
231
|
-
required: false,
|
|
232
|
-
control: {
|
|
233
|
-
type: "boolean",
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
toolbar: {
|
|
237
|
-
label: "Toolbar",
|
|
238
|
-
value: true,
|
|
239
|
-
description: "Whether to show the toolbar",
|
|
240
|
-
required: false,
|
|
241
|
-
control: {
|
|
242
|
-
type: "boolean",
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
alwaysOnTop: {
|
|
246
|
-
label: "Always on top",
|
|
247
|
-
value: false,
|
|
248
|
-
description: "Whether to always keep the window on top",
|
|
249
|
-
required: false,
|
|
250
|
-
control: {
|
|
251
|
-
type: "boolean",
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
backgroundColor: createColorPicker("#ffffff", {
|
|
256
|
-
label: "Background Color",
|
|
257
|
-
description: "The background color of the window",
|
|
258
|
-
required: false,
|
|
259
|
-
}),
|
|
260
|
-
|
|
261
|
-
electronVersion: createStringParam("", {
|
|
262
|
-
label: "Electron version",
|
|
263
|
-
description:
|
|
264
|
-
"The version of Electron to use. If no version specified, it will use the latest one.",
|
|
265
|
-
required: false,
|
|
266
|
-
}),
|
|
267
|
-
customMainCode: createPathParam("", {
|
|
268
|
-
required: false,
|
|
269
|
-
label: "Custom main code",
|
|
270
|
-
control: {
|
|
271
|
-
type: "path",
|
|
272
|
-
options: {
|
|
273
|
-
filters: [{ name: "JavaScript", extensions: ["js"] }],
|
|
274
|
-
},
|
|
275
|
-
label: "Path to a file containing custom main code",
|
|
276
|
-
},
|
|
277
|
-
}),
|
|
278
|
-
disableAsarPackaging: {
|
|
279
|
-
required: false,
|
|
280
|
-
label: "Disable ASAR packaging",
|
|
281
|
-
value: true,
|
|
282
|
-
control: {
|
|
283
|
-
type: "boolean",
|
|
284
|
-
},
|
|
285
|
-
description: "Whether to disable packaging project files in a single binary or not",
|
|
286
|
-
},
|
|
287
|
-
enableExtraLogging: {
|
|
288
|
-
required: false,
|
|
289
|
-
label: "Enable extra logging",
|
|
290
|
-
value: false,
|
|
291
|
-
control: {
|
|
292
|
-
type: "boolean",
|
|
293
|
-
},
|
|
294
|
-
description: "Whether to enable extra logging of internal tools while bundling",
|
|
295
|
-
},
|
|
296
|
-
clearServiceWorkerOnBoot: {
|
|
297
|
-
required: false,
|
|
298
|
-
label: "Clear service worker on boot",
|
|
299
|
-
value: false,
|
|
300
|
-
control: {
|
|
301
|
-
type: "boolean",
|
|
302
|
-
},
|
|
303
|
-
description: "Whether to clear service worker on boot",
|
|
304
|
-
},
|
|
305
|
-
openDevtoolsOnStart: createBooleanParam(false, {
|
|
306
|
-
label: "Open devtools on app start",
|
|
307
|
-
required: false,
|
|
308
|
-
description: "Whether to open devtools on app start",
|
|
309
|
-
}),
|
|
310
|
-
|
|
311
|
-
// Flags
|
|
312
|
-
|
|
313
|
-
enableInProcessGPU: {
|
|
314
|
-
required: false,
|
|
315
|
-
label: "Enable in-process GPU",
|
|
316
|
-
description:
|
|
317
|
-
"When enabled, the GPU process runs inside the main browser process instead of a separate one. This can reduce overhead but may lead to instability or crashes if the GPU process fails.",
|
|
318
|
-
value: false,
|
|
319
|
-
control: {
|
|
320
|
-
type: "boolean",
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
enableDisableRendererBackgrounding: {
|
|
324
|
-
required: false,
|
|
325
|
-
description:
|
|
326
|
-
"Enabling this prevents background tabs from being throttled, which can be useful for web apps that need continuous performance.",
|
|
327
|
-
label: "Disable renderer backgrounding",
|
|
328
|
-
value: false,
|
|
329
|
-
control: {
|
|
330
|
-
type: "boolean",
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
forceHighPerformanceGpu: {
|
|
334
|
-
required: false,
|
|
335
|
-
description:
|
|
336
|
-
"Enabling this forces the app to always use the high-performance GPU, which can improve rendering but may increase power consumption.",
|
|
337
|
-
label: "Force high performance GPU",
|
|
338
|
-
value: false,
|
|
339
|
-
control: {
|
|
340
|
-
type: "boolean",
|
|
341
|
-
},
|
|
342
|
-
},
|
|
343
|
-
|
|
344
|
-
// websocket apis
|
|
345
|
-
websocketApi: {
|
|
346
|
-
required: false,
|
|
347
|
-
label: "WebSocket APIs to allow (empty = all)",
|
|
348
|
-
value: "[]",
|
|
349
|
-
control: {
|
|
350
|
-
type: "array",
|
|
351
|
-
options: {
|
|
352
|
-
kind: "text",
|
|
353
|
-
},
|
|
354
|
-
},
|
|
355
|
-
},
|
|
356
|
-
ignore: createArray<(string | RegExp)[]>(
|
|
357
|
-
`[
|
|
358
|
-
// use 'src/app/' as starting point
|
|
359
|
-
]`,
|
|
360
|
-
{
|
|
361
|
-
required: false,
|
|
362
|
-
label: "Folders to ignore",
|
|
363
|
-
description:
|
|
364
|
-
"An array of string or Regex that allow ignoring certain files or folders from being packaged",
|
|
365
|
-
control: {
|
|
366
|
-
type: "array",
|
|
367
|
-
options: {
|
|
368
|
-
kind: "text",
|
|
369
|
-
},
|
|
370
|
-
},
|
|
371
|
-
},
|
|
372
|
-
),
|
|
373
|
-
|
|
374
|
-
// integrations
|
|
375
|
-
|
|
376
|
-
enableSteamSupport: {
|
|
377
|
-
required: false,
|
|
378
|
-
label: "Enable steam support",
|
|
379
|
-
description: "Whether to enable Steam support",
|
|
380
|
-
value: false,
|
|
381
|
-
control: {
|
|
382
|
-
type: "boolean",
|
|
383
|
-
},
|
|
384
|
-
},
|
|
385
|
-
steamGameId: createNumberParam(480, {
|
|
386
|
-
required: false,
|
|
387
|
-
label: "Steam game ID",
|
|
388
|
-
description: "The Steam game ID",
|
|
389
|
-
}),
|
|
390
|
-
enableDiscordSupport: {
|
|
391
|
-
required: false,
|
|
392
|
-
label: "Enable Discord support",
|
|
393
|
-
description: "Whether to enable Discord support",
|
|
394
|
-
value: false,
|
|
395
|
-
control: {
|
|
396
|
-
type: "boolean",
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
discordAppId: createStringParam("", {
|
|
400
|
-
required: false,
|
|
401
|
-
label: "Discord application ID",
|
|
402
|
-
description: "The Discord application ID",
|
|
403
|
-
}),
|
|
404
|
-
enableDoctor: createBooleanParam(true, {
|
|
405
|
-
required: false,
|
|
406
|
-
label: "Enable doctor file",
|
|
407
|
-
description:
|
|
408
|
-
"Whether to include the doctor.bat file in Windows builds for prerequisite checking and app launching",
|
|
409
|
-
}),
|
|
410
|
-
serverMode: {
|
|
411
|
-
value: '"default"' as "default" | "customProtocol",
|
|
412
|
-
required: false,
|
|
413
|
-
label: "Server mode",
|
|
414
|
-
description: "The server mode to use",
|
|
415
|
-
control: {
|
|
416
|
-
type: "select",
|
|
417
|
-
options: {
|
|
418
|
-
placeholder: "Mode",
|
|
419
|
-
options: [
|
|
420
|
-
{
|
|
421
|
-
value: "default",
|
|
422
|
-
label: "Default",
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
value: "customProtocol",
|
|
426
|
-
label: "Custom Protocol",
|
|
427
|
-
},
|
|
428
|
-
],
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
},
|
|
432
|
-
} satisfies InputsDefinition;
|
|
433
|
-
|
|
434
|
-
const outputs = {
|
|
435
|
-
output: {
|
|
436
|
-
label: "Output",
|
|
437
|
-
value: "",
|
|
438
|
-
control: {
|
|
439
|
-
type: "path",
|
|
440
|
-
options: {
|
|
441
|
-
properties: ["openDirectory"],
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
},
|
|
445
|
-
} satisfies OutputsDefinition;
|
|
446
|
-
|
|
447
|
-
// type Inputs = ParamsToInput<typeof params>
|
|
448
|
-
|
|
449
|
-
export const createMakeProps = (
|
|
450
|
-
id: string,
|
|
451
|
-
name: string,
|
|
452
|
-
description: string,
|
|
453
|
-
icon: string,
|
|
454
|
-
displayString: string,
|
|
455
|
-
) =>
|
|
456
|
-
createAction({
|
|
457
|
-
id,
|
|
458
|
-
name,
|
|
459
|
-
description,
|
|
460
|
-
icon,
|
|
461
|
-
displayString,
|
|
462
|
-
meta: {},
|
|
463
|
-
params: {
|
|
464
|
-
...params,
|
|
465
|
-
...paramsInputFolder,
|
|
466
|
-
},
|
|
467
|
-
outputs,
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
export const createPackageProps = (
|
|
471
|
-
id: string,
|
|
472
|
-
name: string,
|
|
473
|
-
description: string,
|
|
474
|
-
icon: string,
|
|
475
|
-
displayString: string,
|
|
476
|
-
advanced?: boolean,
|
|
477
|
-
deprecated?: boolean,
|
|
478
|
-
deprecatedMessage?: string,
|
|
479
|
-
disabled?: false,
|
|
480
|
-
updateAvailable?: boolean,
|
|
481
|
-
) =>
|
|
482
|
-
createAction({
|
|
483
|
-
id,
|
|
484
|
-
name,
|
|
485
|
-
description,
|
|
486
|
-
icon,
|
|
487
|
-
displayString,
|
|
488
|
-
meta: {},
|
|
489
|
-
advanced,
|
|
490
|
-
deprecated,
|
|
491
|
-
deprecatedMessage,
|
|
492
|
-
disabled,
|
|
493
|
-
updateAvailable,
|
|
494
|
-
params: {
|
|
495
|
-
...params,
|
|
496
|
-
...paramsInputFolder,
|
|
497
|
-
},
|
|
498
|
-
outputs: outputs,
|
|
499
|
-
});
|
|
500
|
-
export const createPackageV2Props = (
|
|
501
|
-
id: string,
|
|
502
|
-
name: string,
|
|
503
|
-
description: string,
|
|
504
|
-
icon: string,
|
|
505
|
-
displayString: string,
|
|
506
|
-
advanced?: boolean,
|
|
507
|
-
deprecated?: boolean,
|
|
508
|
-
deprecatedMessage?: string,
|
|
509
|
-
disabled?: false,
|
|
510
|
-
updateAvailable?: boolean,
|
|
511
|
-
) => {
|
|
512
|
-
const { arch, platform } = params;
|
|
513
|
-
return createAction({
|
|
514
|
-
id,
|
|
515
|
-
name,
|
|
516
|
-
description,
|
|
517
|
-
icon,
|
|
518
|
-
displayString,
|
|
519
|
-
meta: {},
|
|
520
|
-
advanced,
|
|
521
|
-
deprecated,
|
|
522
|
-
deprecatedMessage,
|
|
523
|
-
disabled,
|
|
524
|
-
updateAvailable,
|
|
525
|
-
params: {
|
|
526
|
-
arch,
|
|
527
|
-
platform,
|
|
528
|
-
...paramsInputFolder,
|
|
529
|
-
...configureParams,
|
|
530
|
-
},
|
|
531
|
-
outputs: outputs,
|
|
532
|
-
});
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
export const createPreviewProps = (
|
|
536
|
-
id: string,
|
|
537
|
-
name: string,
|
|
538
|
-
description: string,
|
|
539
|
-
icon: string,
|
|
540
|
-
displayString: string,
|
|
541
|
-
) =>
|
|
542
|
-
createAction({
|
|
543
|
-
id,
|
|
544
|
-
name,
|
|
545
|
-
description,
|
|
546
|
-
icon,
|
|
547
|
-
displayString,
|
|
548
|
-
meta: {},
|
|
549
|
-
params: {
|
|
550
|
-
...params,
|
|
551
|
-
...paramsInputURL,
|
|
552
|
-
},
|
|
553
|
-
outputs: outputs,
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
export const forge = async (
|
|
557
|
-
action: "make" | "package" | "preview",
|
|
558
|
-
appFolder: string | undefined,
|
|
559
|
-
{
|
|
560
|
-
cwd,
|
|
561
|
-
log,
|
|
562
|
-
inputs,
|
|
563
|
-
setOutput,
|
|
564
|
-
paths,
|
|
565
|
-
abortSignal,
|
|
566
|
-
context,
|
|
567
|
-
}: ActionRunnerData<
|
|
568
|
-
| ReturnType<typeof createMakeProps>
|
|
569
|
-
| ReturnType<typeof createPackageProps>
|
|
570
|
-
| ReturnType<typeof createPackageV2Props>
|
|
571
|
-
| ReturnType<typeof createPreviewProps>
|
|
572
|
-
>,
|
|
573
|
-
completeConfiguration: DesktopApp.Electron,
|
|
574
|
-
): Promise<{ folder: string; binary: string | undefined } | undefined> => {
|
|
575
|
-
log("Building electron");
|
|
576
|
-
|
|
577
|
-
if (action !== "preview") {
|
|
578
|
-
await detectRuntime(appFolder);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
const { modules, node } = paths;
|
|
582
|
-
const destinationFolder = await generateTempFolder(paths.cache);
|
|
583
|
-
log(`Staging build in ${destinationFolder}`);
|
|
584
|
-
|
|
585
|
-
try {
|
|
586
|
-
const forge = join(
|
|
587
|
-
destinationFolder,
|
|
588
|
-
"node_modules",
|
|
589
|
-
"@electron-forge",
|
|
590
|
-
"cli",
|
|
591
|
-
"dist",
|
|
592
|
-
"electron-forge.js",
|
|
593
|
-
);
|
|
594
|
-
|
|
595
|
-
const rawAssetFolder = await fetchPipelabAsset("@pipelab/asset-electron", "^1.0.0", {
|
|
596
|
-
context,
|
|
597
|
-
});
|
|
598
|
-
const templateFolder = join(rawAssetFolder, "template");
|
|
599
|
-
console.log("templateFolder", templateFolder);
|
|
600
|
-
console.log("destinationFolder", destinationFolder);
|
|
601
|
-
|
|
602
|
-
// copy template to destination
|
|
603
|
-
await cp(templateFolder, destinationFolder, {
|
|
604
|
-
recursive: true,
|
|
605
|
-
filter: (src) => {
|
|
606
|
-
return basename(src) !== "node_modules";
|
|
607
|
-
},
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
console.log("copy done");
|
|
611
|
-
|
|
612
|
-
const pkgJSONPath = join(destinationFolder, "package.json");
|
|
613
|
-
const pkgJSONContent = await readFile(pkgJSONPath, "utf8");
|
|
614
|
-
const sanitizedName = kebabCase(completeConfiguration.name);
|
|
615
|
-
|
|
616
|
-
const originalIconPath = completeConfiguration.icon;
|
|
617
|
-
const hasIcon = completeConfiguration.icon !== undefined && completeConfiguration.icon !== "";
|
|
618
|
-
const iconFilename = hasIcon ? basename(completeConfiguration.icon) : "";
|
|
619
|
-
const newIconPath = hasIcon ? join(destinationFolder, iconFilename) : "";
|
|
620
|
-
const relativeIconPath = hasIcon ? join("./", "build", iconFilename) : "";
|
|
621
|
-
const relativeIconPath1 = hasIcon ? join("./", iconFilename) : "";
|
|
622
|
-
|
|
623
|
-
log("relativeIconPath", relativeIconPath);
|
|
624
|
-
log("relativeIconPath1", relativeIconPath1);
|
|
625
|
-
|
|
626
|
-
const hasElectronVersion =
|
|
627
|
-
completeConfiguration.electronVersion !== undefined &&
|
|
628
|
-
completeConfiguration.electronVersion !== "";
|
|
629
|
-
const isCJSOnly =
|
|
630
|
-
hasElectronVersion &&
|
|
631
|
-
semver.lt(semver.coerce(completeConfiguration.electronVersion) || "0.0.0", "28.0.0");
|
|
632
|
-
|
|
633
|
-
const pkgJSON = JSON.parse(pkgJSONContent);
|
|
634
|
-
log("Setting name to", sanitizedName);
|
|
635
|
-
pkgJSON.name = sanitizedName;
|
|
636
|
-
log("Setting productName to", completeConfiguration.name);
|
|
637
|
-
pkgJSON.productName = completeConfiguration.name;
|
|
638
|
-
|
|
639
|
-
completeConfiguration.icon = relativeIconPath1;
|
|
640
|
-
|
|
641
|
-
writeFile(
|
|
642
|
-
join(destinationFolder, "config.cjs"),
|
|
643
|
-
`module.exports = ${JSON.stringify(completeConfiguration, undefined, 2)}`,
|
|
644
|
-
"utf8",
|
|
645
|
-
);
|
|
646
|
-
|
|
647
|
-
if (isCJSOnly) {
|
|
648
|
-
log("Setting type to", "commonjs");
|
|
649
|
-
pkgJSON.type = "commonjs";
|
|
650
|
-
} else {
|
|
651
|
-
log("Setting type to", "module");
|
|
652
|
-
pkgJSON.type = "module";
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
await writeFile(pkgJSONPath, JSON.stringify(pkgJSON, null, 2));
|
|
656
|
-
|
|
657
|
-
log("Installing packages");
|
|
658
|
-
const { all: installAll } = await runPnpm(destinationFolder, {
|
|
659
|
-
args: ["install", "--prefer-offline"],
|
|
660
|
-
signal: abortSignal,
|
|
661
|
-
context,
|
|
662
|
-
});
|
|
663
|
-
if (installAll) log(installAll);
|
|
664
|
-
|
|
665
|
-
console.log("done install");
|
|
666
|
-
|
|
667
|
-
// install user-defined custom packages
|
|
668
|
-
if (
|
|
669
|
-
Array.isArray(completeConfiguration.customPackages) &&
|
|
670
|
-
completeConfiguration.customPackages.length > 0
|
|
671
|
-
) {
|
|
672
|
-
log(`Installing custom packages: ${completeConfiguration.customPackages.join(", ")}`);
|
|
673
|
-
const { all: customAll } = await runPnpm(destinationFolder, {
|
|
674
|
-
args: ["install", ...completeConfiguration.customPackages, "--prefer-offline"],
|
|
675
|
-
signal: abortSignal,
|
|
676
|
-
context,
|
|
677
|
-
});
|
|
678
|
-
if (customAll) log(customAll);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// override electron version
|
|
682
|
-
if (completeConfiguration.electronVersion && completeConfiguration.electronVersion !== "") {
|
|
683
|
-
log(`Installing electron@${completeConfiguration.electronVersion}`);
|
|
684
|
-
const { all: electronAll } = await runPnpm(destinationFolder, {
|
|
685
|
-
args: ["install", `electron@${completeConfiguration.electronVersion}`, "--prefer-offline"],
|
|
686
|
-
signal: abortSignal,
|
|
687
|
-
context,
|
|
688
|
-
});
|
|
689
|
-
if (electronAll) log(electronAll);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
if (isCJSOnly) {
|
|
693
|
-
log(`Installing execa@8`);
|
|
694
|
-
const { all: execaAll } = await runPnpm(destinationFolder, {
|
|
695
|
-
args: ["install", `execa@8`, "--prefer-offline"],
|
|
696
|
-
signal: abortSignal,
|
|
697
|
-
context,
|
|
698
|
-
});
|
|
699
|
-
if (execaAll) log(execaAll);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
console.log("completeConfiguration.icon", completeConfiguration.icon);
|
|
703
|
-
|
|
704
|
-
// copy icon
|
|
705
|
-
if (hasIcon) {
|
|
706
|
-
await cp(originalIconPath, newIconPath, { recursive: true });
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
// copy custom main code
|
|
710
|
-
const destinationFile = join(destinationFolder, "src", "custom-main.js");
|
|
711
|
-
if (completeConfiguration.customMainCode) {
|
|
712
|
-
await cp(completeConfiguration.customMainCode, destinationFile, { recursive: true });
|
|
713
|
-
} else {
|
|
714
|
-
await writeFile(destinationFile, 'console.log("No custom main code provided")', {
|
|
715
|
-
signal: abortSignal,
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
if (isCJSOnly) {
|
|
720
|
-
/* ESBUILD transpilation */
|
|
721
|
-
const external = [
|
|
722
|
-
"electron",
|
|
723
|
-
"@pipelab/steamworks.js",
|
|
724
|
-
"electron",
|
|
725
|
-
"node:*",
|
|
726
|
-
"http",
|
|
727
|
-
"node:stream",
|
|
728
|
-
];
|
|
729
|
-
await esbuild.build({
|
|
730
|
-
entryPoints: [join(destinationFolder, "src", "index.js")],
|
|
731
|
-
bundle: true,
|
|
732
|
-
write: true,
|
|
733
|
-
format: "cjs",
|
|
734
|
-
platform: "node",
|
|
735
|
-
external,
|
|
736
|
-
outfile: join(destinationFolder, "dist", "index.js"),
|
|
737
|
-
});
|
|
738
|
-
await esbuild.build({
|
|
739
|
-
entryPoints: [join(destinationFolder, "src", "preload.js")],
|
|
740
|
-
bundle: true,
|
|
741
|
-
platform: "node",
|
|
742
|
-
external,
|
|
743
|
-
format: "cjs",
|
|
744
|
-
write: true,
|
|
745
|
-
outfile: join(destinationFolder, "dist", "preload.js"),
|
|
746
|
-
});
|
|
747
|
-
await esbuild.build({
|
|
748
|
-
entryPoints: [join(destinationFolder, "src", "custom-main.js")],
|
|
749
|
-
bundle: true,
|
|
750
|
-
platform: "node",
|
|
751
|
-
external,
|
|
752
|
-
format: "cjs",
|
|
753
|
-
write: true,
|
|
754
|
-
outfile: join(destinationFolder, "dist", "custom-main.js"),
|
|
755
|
-
});
|
|
756
|
-
await rm(join(destinationFolder, "src"), { recursive: true });
|
|
757
|
-
await cp(join(destinationFolder, "dist"), join(destinationFolder, "src"), {
|
|
758
|
-
recursive: true,
|
|
759
|
-
});
|
|
760
|
-
await rm(join(destinationFolder, "dist"), { recursive: true });
|
|
761
|
-
/* ESBUILD transpilation */
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
const placeAppFolder = join(destinationFolder, "src", "app");
|
|
765
|
-
|
|
766
|
-
// if input is folder, copy folder to destination
|
|
767
|
-
if (appFolder && action !== "preview") {
|
|
768
|
-
// copy app to template
|
|
769
|
-
await cp(appFolder, placeAppFolder, { recursive: true });
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
const inputPlatform = inputs.platform === "" ? undefined : inputs.platform;
|
|
773
|
-
const inputArch = inputs.arch === "" ? undefined : inputs.arch;
|
|
774
|
-
|
|
775
|
-
try {
|
|
776
|
-
log("typeof inputs.platform", typeof inputs.platform);
|
|
777
|
-
const finalPlatform = inputPlatform ?? osPlatform() ?? "";
|
|
778
|
-
log("finalPlatform", finalPlatform);
|
|
779
|
-
const finalArch = inputArch ?? osArch() ?? "";
|
|
780
|
-
|
|
781
|
-
await runWithLiveLogs(
|
|
782
|
-
node,
|
|
783
|
-
[forge, action, /* '--', */ "--arch", finalArch, "--platform", finalPlatform],
|
|
784
|
-
{
|
|
785
|
-
cwd: destinationFolder,
|
|
786
|
-
env: {
|
|
787
|
-
DEBUG: completeConfiguration.enableExtraLogging ? "*" : "",
|
|
788
|
-
ELECTRON_NO_ASAR: "1",
|
|
789
|
-
PATH: `${dirname(node)}${delimiter}${process.env.PATH}`,
|
|
790
|
-
// DEBUG: "electron-packager"
|
|
791
|
-
},
|
|
792
|
-
cancelSignal: abortSignal,
|
|
793
|
-
},
|
|
794
|
-
log,
|
|
795
|
-
{
|
|
796
|
-
onStderr(data) {
|
|
797
|
-
log(data);
|
|
798
|
-
},
|
|
799
|
-
onStdout(data) {
|
|
800
|
-
log(data);
|
|
801
|
-
},
|
|
802
|
-
},
|
|
803
|
-
);
|
|
804
|
-
|
|
805
|
-
if (action === "package") {
|
|
806
|
-
const outName = outFolderName(
|
|
807
|
-
completeConfiguration.name,
|
|
808
|
-
finalPlatform as NodeJS.Platform,
|
|
809
|
-
finalArch as NodeJS.Architecture,
|
|
810
|
-
);
|
|
811
|
-
const binName = getBinName(completeConfiguration.name);
|
|
812
|
-
|
|
813
|
-
const output = join(cwd, "out", outName);
|
|
814
|
-
setOutput("output", output);
|
|
815
|
-
return {
|
|
816
|
-
folder: output,
|
|
817
|
-
binary: join(output, binName),
|
|
818
|
-
};
|
|
819
|
-
} else {
|
|
820
|
-
const output = join(cwd, "out", "make");
|
|
821
|
-
setOutput("output", output);
|
|
822
|
-
return {
|
|
823
|
-
folder: output,
|
|
824
|
-
binary: undefined,
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
} catch (e) {
|
|
828
|
-
if (e instanceof Error) {
|
|
829
|
-
if (e.name === "RequestError") {
|
|
830
|
-
log("Request error");
|
|
831
|
-
}
|
|
832
|
-
if (e.name === "RequestError") {
|
|
833
|
-
log("Request error");
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
log(e);
|
|
837
|
-
throw e;
|
|
838
|
-
}
|
|
839
|
-
} finally {
|
|
840
|
-
try {
|
|
841
|
-
if (action !== "preview") {
|
|
842
|
-
const outDir = join(destinationFolder, "out");
|
|
843
|
-
const finalOutDir = join(cwd, "out");
|
|
844
|
-
await cp(outDir, finalOutDir, { recursive: true });
|
|
845
|
-
}
|
|
846
|
-
} catch (e) {
|
|
847
|
-
log("Failed to copy build output back to cwd:", e);
|
|
848
|
-
}
|
|
849
|
-
await rm(destinationFolder, { recursive: true, force: true });
|
|
850
|
-
}
|
|
851
|
-
};
|