Skip to content

Commit e82dfd7

Browse files
build: package the .ablx into release/ via scripts/package.mjs
Move the packaged artifact out of the repo root into release/ (git-ignored), separating the shippable installable from the intermediate dist/ bundle. The wrapper derives the versioned filename from manifest.json, clears stale .ablx files so only the current build remains, prints a clean summary with the install hint, and supports --reveal to open it in Finder. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8e515a1 commit e82dfd7

4 files changed

Lines changed: 51 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules/
33
dist/
44
ui/dist/
5+
release/
56

67
*.log
78
*.ablx

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ The fastest loop uses Live's Developer Mode and an externally-launched Extension
8282
## Build & package
8383

8484
```bash
85-
npm run build # production bundle
86-
npm run package # produces an installable .ablx
85+
npm run build # production bundle → dist/extension.js
86+
npm run package # build + package the installable → release/Sheet-Music-<version>.ablx
87+
npm run package -- --reveal # same, then reveal the .ablx in Finder (macOS)
8788
```
8889

89-
Install the `.ablx` by dropping it onto Live's **Extensions** preferences (with Developer Mode **off**, so Live manages the host).
90+
`npm run package` writes the installable to `release/` (git-ignored), clearing any older `.ablx` first so there's only ever the current one. Install it by dropping the `.ablx` onto Live's **Extensions** preferences (with Developer Mode **off**, so Live manages the host).
9091

9192
## Test
9293

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"build:dev": "npm run build:ui && npm run typecheck && tsx build.ts",
1717
"build": "npm run build:ui && npm run typecheck && tsx build.ts --production",
1818
"start": "npm run build:dev && extensions-cli run --storage-directory \"$PWD/.dev/storage\" --temp-directory \"$PWD/.dev/temp\"",
19-
"package": "npm run build && extensions-cli package",
19+
"package": "npm run build && node scripts/package.mjs",
2020
"dev:ui": "vite"
2121
},
2222
"dependencies": {

scripts/package.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Builds the installable .ablx into ./release/ — kept out of the repo root and
2+
// git-ignored. The .ablx is the *shippable* artifact (a ZIP of manifest.json +
3+
// the built dist/extension.js) that users drag into Live's Extensions prefs;
4+
// dist/ holds the intermediate bundle that this packages. Run via
5+
// `npm run package` (which builds first). Pass `--reveal` to open the file in
6+
// Finder, ready to drag in: `npm run package -- --reveal`.
7+
import { execFileSync } from "node:child_process";
8+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
9+
import { join } from "node:path";
10+
11+
const OUT_DIR = "release";
12+
13+
function fail(msg) {
14+
console.error(`\n package: ${msg}\n`);
15+
process.exit(1);
16+
}
17+
18+
const manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
19+
if (!existsSync(manifest.entry)) {
20+
fail(`${manifest.entry} not found — run \`npm run build\` first (or just \`npm run package\`).`);
21+
}
22+
23+
// Match extensions-cli's own naming so the file is identical to its default,
24+
// only relocated: "<name with spaces → dashes>-<version>.ablx".
25+
const ablxName = `${(manifest.name || "extension").replace(/\s+/gu, "-")}-${manifest.version || "0.0.0"}.ablx`;
26+
const outPath = join(OUT_DIR, ablxName);
27+
28+
// One artifact per build: clear stale .ablx files so we never ship the wrong one.
29+
mkdirSync(OUT_DIR, { recursive: true });
30+
for (const f of readdirSync(OUT_DIR)) {
31+
if (f.endsWith(".ablx")) rmSync(join(OUT_DIR, f));
32+
}
33+
34+
const cliBin = join("node_modules", ".bin", process.platform === "win32" ? "extensions-cli.cmd" : "extensions-cli");
35+
// Suppress the CLI's bare path print (stdout); surface its errors (stderr).
36+
execFileSync(cliBin, ["package", "-o", outPath], { stdio: ["ignore", "ignore", "inherit"] });
37+
38+
const sizeMB = (statSync(outPath).size / 1024 / 1024).toFixed(2);
39+
console.log(`\n package: ${manifest.name} ${manifest.version}${outPath} (${sizeMB} MB)`);
40+
console.log(` install: drag it onto Live → Preferences → Extensions (Developer Mode off).\n`);
41+
42+
if (process.argv.includes("--reveal")) {
43+
if (process.platform === "darwin") execFileSync("open", ["-R", outPath]);
44+
else console.log(" package: --reveal is macOS-only; skipped.");
45+
}

0 commit comments

Comments
 (0)