-
Notifications
You must be signed in to change notification settings - Fork 296
Expand file tree
/
Copy pathbuild.mjs
More file actions
99 lines (91 loc) · 2.48 KB
/
Copy pathbuild.mjs
File metadata and controls
99 lines (91 loc) · 2.48 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
import { join } from "node:path";
import { rm } from "node:fs/promises";
import { platform, arch } from "node:os";
import { execSync } from "node:child_process";
import dotEnv from "dotenv";
import yargs from "minimist";
import Builder from "electron-builder";
import packageJson from "./editor/package.json" with { type: "json" };
dotEnv.config();
const args = yargs(process.argv.slice(2));
const architecture = arch();
function build({ x64, arm64 } = options) {
return Builder.build({
x64,
arm64,
projectDir: "./editor",
config: {
protocols: packageJson.build.protocols,
publish: {
provider: "generic",
url: `https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/${platform() === "darwin" && architecture === "x64" ? "x64/" : ""}`,
},
mac:
platform() !== "darwin"
? null
: {
hardenedRuntime: true,
appId: "com.babylonjs.editor",
notarize: args.noSign ? false : true,
identity: args.noSign ? null : undefined,
},
win: {
target: "nsis",
verifyUpdateCodeSignature: false,
forceCodeSigning: args.noSign ? false : true,
signtoolOptions: args.noSign
? undefined
: {
sign: (configuration) => {
if (configuration.path) {
execSync(`smctl.exe sign --keypair-alias=${process.env.KEYPAIR_ALIAS} --input "${String(configuration.path)}"`);
}
},
publisherName: "cesharpe",
signingHashAlgorithms: ["sha256"],
rfc3161TimeStampServer: "http://timestamp.digicert.com",
},
},
fileAssociations: [
{
ext: "bjseditor",
name: "Babylon.js Editor Project",
},
],
appId: "com.babylonjs.editor",
productName: "BabylonJS Editor",
icon: "./icons/babylonjs_icon",
directories: {
output: "./electron-packages/",
},
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true,
},
linux: {
target: "AppImage",
},
asar: true,
asarUnpack: ["**/node_modules/sharp/**/*", "**/node_modules/@img/**/*"],
compression: "normal",
extraFiles: ["bin/**", "templates/**"],
files: ["./build/**", "./fonts/**", "./assets/**", "./index.html"],
},
});
}
// Remove old build
await rm(join(import.meta.dirname, "editor/electron-packages"), {
force: true,
recursive: true,
});
// Create build(s)
if (args.x64 || args.arm64) {
await build({
x64: args.x64,
arm64: args.arm64,
});
} else {
const x64 = architecture === "x64";
const arm64 = architecture === "arm64";
await build({ x64, arm64 });
}