forked from PreMiD/PreMiD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkg.ts
123 lines (115 loc) · 2.25 KB
/
pkg.ts
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
import * as electronPackager from "electron-packager";
import { platform } from "os";
import * as prompts from "prompts";
import * as ora from "ora";
(async () => {
let response = {
os: "current",
arch: "all"
};
if (process.env.NODE_ENV !== "DePloY")
response = await prompts([
{
type: "select",
name: "arch",
message: "What architecture?",
choices: [
{
title: "current",
value: "current"
},
{
title: "all",
value: "all"
},
{
title: "arm64",
value: "arm64"
},
{
title: "armv7l",
value: "armv7l"
},
{
title: "ia32",
value: "ia32"
},
{
title: "mips64el",
value: "mips64el"
},
{
title: "x64",
value: "x64"
}
]
},
{
type: "select",
name: "os",
message: "What operating system?",
choices: [
{
title: "current",
value: "current"
},
{
title: "all",
value: "all"
},
{
title: "darwin",
value: "darwin"
},
{
title: "linux",
value: "linux"
},
{
title: "mas",
value: "mas"
},
{
title: "win32",
value: "win32"
}
]
}
]);
if (!response.os) {
process.exit();
}
let icon: string;
if (
response.os == "darwin" ||
(response.os === "current" && platform() === "darwin")
)
icon = "./installer_assets/appIcon.icns";
if (["ia32", "x64"].includes(response.arch) || platform() === "win32")
icon = "./installer_assets/appIcon.ico";
let spinner = ora("Packaging app").start(),
packagingOptions: electronPackager.Options = {
dir: "./dist/app",
out: "./dist",
darwinDarkModeSupport: true,
icon: icon,
overwrite: true,
quiet: true,
appBundleId: "eu.Timeraa.PreMiD",
appCategoryType: "Utilities",
appCopyright: `Timeraa 2018-${new Date().getFullYear()}`,
prune: true,
asar: true,
// @ts-ignore
arch: response.arch,
// @ts-ignore
platform: response.os
};
if (response.arch === "current") delete packagingOptions.arch;
if (response.os === "current") delete packagingOptions.platform;
electronPackager(packagingOptions).then(() => {
spinner.text = "Done!";
spinner.succeed();
process.exit();
});
})();