-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvelopack.js
More file actions
97 lines (84 loc) · 3.21 KB
/
velopack.js
File metadata and controls
97 lines (84 loc) · 3.21 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
const { spawnSync } = require("child_process");
const fs = require("fs");
const path = require("path");
const noSign = process.env.npm_config_nosign === "true" || process.argv.includes("--nosign");
const version = process.env.npm_package_version.replace(/^v/, ""); // Strip 'v' prefix for SemVer2
const platform = process.platform;
let args;
if (platform === "darwin") {
// macOS build (Apple Silicon)
args = [
"pack",
"--packId", "PhraseVault",
"--packVersion", version,
"--packTitle", "PhraseVault",
"--packAuthors", "SPQRK Web Solutions",
"--packDir", "./out/PhraseVault-darwin-arm64/PhraseVault.app",
"--mainExe", "PhraseVault",
"--icon", "./assets/img/icon.icns",
];
if (!noSign) {
args.push("--signAppIdentity", "Developer ID Application: Gerhard Petermeir (HCJ7D67RFZ)");
args.push("--signInstallIdentity", "Developer ID Installer: Gerhard Petermeir (HCJ7D67RFZ)");
args.push("--signEntitlements", "./entitlements.entitlements");
args.push("--notaryProfile", "PhraseVault-notarize");
}
} else {
// Windows build
args = [
"pack",
"--packId", "PhraseVault",
"--packVersion", version,
"--packTitle", "PhraseVault",
"--packAuthors", "SPQRK Web Solutions",
"--packDir", "./out/PhraseVault-win32-x64",
"--mainExe", "PhraseVault.exe",
"--icon", "./assets/img/icon.ico",
"--splashImage", "./assets/img/splash.png",
];
if (!noSign) {
args.push("--signParams", '/n "Gerhard Petermeir" /a /tr http://timestamp.digicert.com /td SHA256 /fd SHA256');
}
}
console.log("Running vpk with args:", args.join(" "));
const r = spawnSync("vpk", args, { stdio: "inherit" });
if (r.error) {
console.error("Failed to run vpk:", r.error.message);
if (r.error.code === "ENOENT") {
console.error("The 'vpk' command was not found. Make sure Velopack CLI is installed.");
console.error("Install it with: dotnet tool install -g vpk");
}
process.exit(1);
}
if (r.status !== 0) {
console.error(`vpk exited with status code: ${r.status}`);
process.exit(r.status ?? 1);
}
if (r.status === 0) {
// Copy versioned files to dist folder
const distDir = path.join(__dirname, "dist");
if (!fs.existsSync(distDir)) {
fs.mkdirSync(distDir, { recursive: true });
}
let filesToCopy;
if (platform === "darwin") {
filesToCopy = [
{ src: "PhraseVault-osx-Setup.pkg", dest: `PhraseVault-macOS-${version}.pkg` },
{ src: "PhraseVault-osx-Portable.zip", dest: `PhraseVault-macOS-Portable-${version}.zip` },
];
} else {
filesToCopy = [
{ src: "PhraseVault-win-Setup.exe", dest: `PhraseVault-Setup-${version}.exe` },
{ src: "PhraseVault-win-Portable.zip", dest: `PhraseVault-Portable-${version}.zip` },
];
}
for (const file of filesToCopy) {
const srcPath = path.join(__dirname, "Releases", file.src);
const destPath = path.join(distDir, file.dest);
if (fs.existsSync(srcPath)) {
fs.copyFileSync(srcPath, destPath);
console.log(`Copied: ${file.dest}`);
}
}
}
process.exit(0);