Repository navigation
Expand file tree
/
Copy pathbundler.ts
More file actions
92 lines (75 loc) · 2.43 KB
/
Copy pathbundler.ts
File metadata and controls
92 lines (75 loc) · 2.43 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
import { copy } from "https://deno.land/std@0.179.0/fs/copy.ts";
import $ from "https://deno.land/x/dax@0.32.0/mod.ts";
const {
app,
} = JSON.parse(
await Deno.readTextFile("package.json"),
);
await Deno.remove(`./${app.name}.app`, { recursive: true }).catch(() => {});
await Deno.mkdir(`./${app.name}.app/Contents/MacOS`, { recursive: true });
await copy(app.icon, `./${app.name}.app/Contents/NativeScript.icns`);
await copy(app.assets, `./${app.name}.app/Contents/Resources`);
await copy(
new URL(`../../Frameworks/hermes.framework`, import.meta.url),
`./${app.name}.app/Contents/Frameworks/hermes.framework`,
);
await copy(
new URL("../../../build/macos/NativeScript.node", import.meta.url),
`./${app.name}.app/Contents/Resources/NativeScript.node`,
);
await Deno.mkdir(`./${app.name}.app/Contents/Resources`, { recursive: true });
const plistProperties: Record<string, string | string[]> = {
BuildMachineOSBuild: "22F66",
CFBundleDevelopmentRegion: "en",
CFBundleExecutable: app.name,
CFBundleIdentifier: app.identifier,
CFBundleInfoDictionaryVersion: "6.0",
CFBundleName: app.name,
CFBundlePackageType: "APPL",
CFBundleShortVersionString: app.version,
CFBundleSupportedPlatforms: ["MacOSX"],
CFBundleVersion: app.version,
CFBundleIconFile: "NativeScript",
DTCompiler: "com.apple.compilers.llvm.clang.1_0",
DTPlatformBuild: "",
DTPlatformName: "macosx",
DTPlatformVersion: "13.3",
DTSDKBuild: "22E245",
DTSDKName: "macosx10.15",
DTXcode: "1430",
DTXcodeBuild: "14E22b",
LSMinimumSystemVersion: "12.0",
NSPrincipalClass: "NSApplication",
};
let plist = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>\n`;
for (const [key, value] of Object.entries(plistProperties)) {
plist += ` <key>${key}</key>\n`;
if (typeof value === "string") {
plist += `<string>${value}</string>\n`;
} else {
plist += ` <array>\n`;
for (const item of value) {
plist += ` <string>${item}</string>\n`;
}
plist += ` </array>\n`;
}
}
plist += `</dict>
</plist>\n`;
await Deno.writeTextFile(
`./${app.name}.app/Contents/Info.plist`,
plist,
);
await Deno.writeTextFile(
`./${app.name}.app/Contents/PkgInfo`,
"APPL????",
);
await $`npm run build`;
await Deno.copyFile(
"./dist/main",
`./${app.name}.app/Contents/MacOS/${app.name}`,
);
console.log(`Bundled ${app.name}.app`);