@forwardimpact/basecamp 0.3.0 → 2.0.0

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/build.js DELETED
@@ -1,122 +0,0 @@
1
- #!/usr/bin/env -S deno run --allow-all
2
-
3
- // Build script for Basecamp (arm64 macOS).
4
- //
5
- // Usage:
6
- // deno run --allow-all build.js Build standalone executable
7
- // deno run --allow-all build.js --pkg Build executable + macOS .pkg installer
8
-
9
- import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
10
- import { join, dirname } from "node:path";
11
- import { execSync } from "node:child_process";
12
-
13
- const __dirname =
14
- import.meta.dirname || dirname(new URL(import.meta.url).pathname);
15
- const DIST_DIR = join(__dirname, "dist");
16
- const APP_NAME = "fit-basecamp";
17
- const STATUS_MENU_NAME = "BasecampStatus";
18
- const STATUS_MENU_DIR = join(__dirname, "StatusMenu");
19
- const VERSION = JSON.parse(
20
- readFileSync(join(__dirname, "package.json"), "utf8"),
21
- ).version;
22
-
23
- // ---------------------------------------------------------------------------
24
- // Helpers
25
- // ---------------------------------------------------------------------------
26
-
27
- function ensureDir(dir) {
28
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
29
- }
30
-
31
- function run(cmd, opts = {}) {
32
- console.log(` $ ${cmd}`);
33
- return execSync(cmd, { encoding: "utf8", stdio: "inherit", ...opts });
34
- }
35
-
36
- // ---------------------------------------------------------------------------
37
- // Compile standalone binary
38
- // ---------------------------------------------------------------------------
39
-
40
- function compile() {
41
- const outputPath = join(DIST_DIR, APP_NAME);
42
-
43
- console.log(`\nCompiling ${APP_NAME}...`);
44
- ensureDir(DIST_DIR);
45
-
46
- const cmd = [
47
- "deno compile",
48
- "--allow-all",
49
- "--no-check",
50
- `--output "${outputPath}"`,
51
- "--include template/",
52
- "basecamp.js",
53
- ].join(" ");
54
-
55
- run(cmd, { cwd: __dirname });
56
-
57
- console.log(` -> ${outputPath}`);
58
- return outputPath;
59
- }
60
-
61
- // ---------------------------------------------------------------------------
62
- // Compile Swift status menu binary
63
- // ---------------------------------------------------------------------------
64
-
65
- function compileStatusMenu() {
66
- console.log(`\nCompiling ${STATUS_MENU_NAME}...`);
67
- ensureDir(DIST_DIR);
68
-
69
- const buildDir = join(STATUS_MENU_DIR, ".build");
70
- rmSync(buildDir, { recursive: true, force: true });
71
-
72
- run("swift build -c release", { cwd: STATUS_MENU_DIR });
73
-
74
- const binary = join(buildDir, "release", STATUS_MENU_NAME);
75
- const outputPath = join(DIST_DIR, STATUS_MENU_NAME);
76
- run(`cp "${binary}" "${outputPath}"`);
77
-
78
- rmSync(buildDir, { recursive: true, force: true });
79
-
80
- console.log(` -> ${outputPath}`);
81
- return outputPath;
82
- }
83
-
84
- // ---------------------------------------------------------------------------
85
- // Build macOS installer package (.pkg)
86
- // ---------------------------------------------------------------------------
87
-
88
- function buildPKG(statusMenuBinaryPath) {
89
- const pkgName = `${APP_NAME}-${VERSION}.pkg`;
90
-
91
- console.log(`\nBuilding pkg: ${pkgName}...`);
92
-
93
- const buildPkg = join(__dirname, "pkg", "macos", "build-pkg.sh");
94
- run(
95
- `"${buildPkg}" "${DIST_DIR}" "${APP_NAME}" "${VERSION}" "${statusMenuBinaryPath}"`,
96
- { cwd: __dirname },
97
- );
98
-
99
- console.log(` -> ${join(DIST_DIR, pkgName)}`);
100
- return join(DIST_DIR, pkgName);
101
- }
102
-
103
- // ---------------------------------------------------------------------------
104
- // CLI
105
- // ---------------------------------------------------------------------------
106
-
107
- const args = Deno?.args || process.argv.slice(2);
108
- const wantPKG = args.includes("--pkg");
109
-
110
- console.log(`Basecamp Build (v${VERSION})`);
111
- console.log("==========================");
112
-
113
- // Compile Deno binary first (before status menu exists in dist/),
114
- // so the status menu binary is not embedded in the Deno binary.
115
- compile();
116
- const statusMenuBinary = compileStatusMenu();
117
-
118
- if (wantPKG) {
119
- buildPKG(statusMenuBinary);
120
- }
121
-
122
- console.log("\nBuild complete! Output in dist/");