argsbarg 5.1.4 → 5.1.5

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/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [5.1.5] - 2026-07-05
11
+
12
+ ### Changed
13
+
14
+ - **`just install-local`** — back up release `Formula/{key}.rb`, write dev formula for `brew install`, then restore the release formula (`scripts/with-dev-formula.ts`).
15
+ - **`just ensure-release-formula`** — normalize release formula layout; restore from install-local backup or fail with `git restore` hint if a dev `file://` formula is left on disk.
16
+
10
17
  ## [5.1.4] - 2026-07-04
11
18
 
12
19
  ### Changed
@@ -610,7 +617,8 @@ const cli = { ... } satisfies CliProgram; // or : CliProgram
610
617
  - Migrate schemas: rename every `children` property to **`commands`**; move positional definitions to **`CliPositional`** objects on `positionals` and strip `positional` / `argMin` / `argMax` from flag definitions under `options` (flags only carry `name`, `description`, `kind`, and optional `shortName`).
611
618
  - Imports: use `CliPositional` where needed; replace `CliOptionDef` with `CliOption` or `CliPositional` as appropriate.
612
619
 
613
- [Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v5.1.4...HEAD
620
+ [Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v5.1.5...HEAD
621
+ [5.1.5]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.1.5
614
622
  [5.1.4]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.1.4
615
623
  [5.1.3]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.1.3
616
624
  [5.1.2]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.1.2
@@ -51,7 +51,7 @@ just reinstall-local # fast binary swap (`install -m 755` into Cellar; run ins
51
51
  just uninstall # undo formula + agent artifacts (not app config)
52
52
  ```
53
53
 
54
- Dev and release use the **same formula** (`Formula/{key}.rb`, class name, install/post_install/test). `gen-dev-formula.ts` only changes `url`, `version`, and `sha256` to point at the local binary in `Formula/.staging/`. Release bumps restore the GitHub URL via `scripts/release.ts`.
54
+ Dev and release use the **same formula file** (`Formula/{key}.rb`, class name, install/post_install/test). `just install-local` temporarily overwrites it with a `file://` dev formula (staged under `Formula/.staging/`), runs `brew install`, then **restores** the release formula from backup. Release bumps rewrite the GitHub URL via `scripts/release.ts`.
55
55
 
56
56
  ### Developer uninstall
57
57
 
@@ -49,13 +49,16 @@ install: install-local
49
49
  sync-artifacts:
50
50
  just run configure --sync --yes
51
51
 
52
- # Dev install: build, write dev formula, symlink tap, brew install
53
- install-local: build
54
- @bun scripts/gen-dev-formula.ts
52
+ # Normalize release formula (fix leftover dev formula or stale layout)
53
+ ensure-release-formula:
54
+ bun scripts/ensure-release-formula.ts
55
+
56
+ # Dev install: build, dev formula (restored after brew), symlink tap, brew install
57
+ install-local: build ensure-release-formula
55
58
  @brew untap {{tap}} 2>/dev/null || true
56
59
  mkdir -p {{tap_parent}}
57
60
  ln -sfn '{{justfile_directory()}}' {{tap_path}}
58
- brew install --formula {{tap}}/{{cli_key}}
61
+ bun scripts/with-dev-formula.ts -- brew install --formula {{tap}}/{{cli_key}}
59
62
  @echo ""
60
63
  @echo "Next: {{cli_key}} configure"
61
64
 
@@ -0,0 +1,54 @@
1
+ /** Backup, write, and restore the release formula for local dev Homebrew installs. */
2
+
3
+ import { createHash } from "node:crypto";
4
+ import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { createIdentity } from "./create-identity.ts";
7
+ import { renderDevFormula } from "./formula-shared.ts";
8
+
9
+ const { key } = createIdentity;
10
+ const root = join(import.meta.dir, "..");
11
+ const stagingDir = join(root, "Formula", ".staging");
12
+ const stagingPath = join(stagingDir, key);
13
+ const formulaPath = join(root, "Formula", `${key}.rb`);
14
+ const backupPath = join(stagingDir, `${key}.rb.bak`);
15
+
16
+ /** Path to the committed release formula (`Formula/full-example.rb`). */
17
+ export function releaseFormulaPath(): string {
18
+ return formulaPath;
19
+ }
20
+
21
+ /** Gitignored backup path used during `install-local`. */
22
+ export function releaseFormulaBackupPath(): string {
23
+ return backupPath;
24
+ }
25
+
26
+ /** Copy the release formula to `.staging` before overwriting with the dev formula. */
27
+ export function backupReleaseFormula(): void {
28
+ if (!existsSync(formulaPath)) {
29
+ return;
30
+ }
31
+ mkdirSync(stagingDir, { recursive: true });
32
+ copyFileSync(formulaPath, backupPath);
33
+ }
34
+
35
+ /** Restore the release formula from backup; no-op when no backup exists. */
36
+ export function restoreReleaseFormula(): void {
37
+ if (!existsSync(backupPath)) {
38
+ return;
39
+ }
40
+ copyFileSync(backupPath, formulaPath);
41
+ unlinkSync(backupPath);
42
+ }
43
+
44
+ /** Stage `dist/full-example` and overwrite `Formula/full-example.rb` with a local `file://` dev formula. */
45
+ export function writeDevFormula(): void {
46
+ const distPath = join(root, "dist", key);
47
+ mkdirSync(stagingDir, { recursive: true });
48
+ copyFileSync(distPath, stagingPath);
49
+ chmodSync(stagingPath, 0o755);
50
+
51
+ const sha256 = createHash("sha256").update(readFileSync(stagingPath)).digest("hex");
52
+ const version = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version as string;
53
+ writeFileSync(formulaPath, renderDevFormula(stagingPath, version, sha256), "utf8");
54
+ }
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bun
2
+ /** Normalize `Formula/full-example.rb` to the release layout; recover from a leftover dev formula. */
3
+
4
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
5
+ import {
6
+ releaseFormulaPath,
7
+ restoreReleaseFormula,
8
+ releaseFormulaBackupPath,
9
+ } from "./dev-formula.ts";
10
+ import { renderReleaseFormula } from "./formula-shared.ts";
11
+
12
+ const formulaPath = releaseFormulaPath();
13
+ const backupPath = releaseFormulaBackupPath();
14
+
15
+ if (existsSync(backupPath)) {
16
+ restoreReleaseFormula();
17
+ console.log(`Restored release formula from ${backupPath}`);
18
+ }
19
+
20
+ let content = readFileSync(formulaPath, "utf8");
21
+ if (content.includes("file://")) {
22
+ process.stderr.write(
23
+ `Dev formula still present at ${formulaPath}. Run: git restore ${formulaPath}\n`,
24
+ );
25
+ process.exit(1);
26
+ }
27
+
28
+ const version = content.match(/^\s*version\s+"([^"]+)"/m)?.[1];
29
+ const sha256 = content.match(/^\s*sha256\s+"([^"]+)"/m)?.[1];
30
+ if (!version || !sha256) {
31
+ process.stderr.write(`Could not parse version/sha256 from ${formulaPath}\n`);
32
+ process.exit(1);
33
+ }
34
+
35
+ const normalized = renderReleaseFormula(version, sha256);
36
+ if (content !== normalized) {
37
+ writeFileSync(formulaPath, normalized, "utf8");
38
+ console.log(`Normalized ${formulaPath} (v${version})`);
39
+ } else {
40
+ console.log(`Release formula OK: ${formulaPath} (v${version})`);
41
+ }
@@ -1,26 +1,7 @@
1
1
  #!/usr/bin/env bun
2
- /** Generate Formula/full-example.rb for local dev install (same formula as release; file:// URL only). */
2
+ /** Generate Formula/full-example.rb for local dev install (file:// URL). Prefer `with-dev-formula.ts` via `just install-local`. */
3
3
 
4
- import { createHash } from "node:crypto";
5
- import { chmodSync, copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
- import { join } from "node:path";
7
- import { createIdentity } from "./create-identity.ts";
8
- import { renderDevFormula } from "./formula-shared.ts";
4
+ import { releaseFormulaPath, writeDevFormula } from "./dev-formula.ts";
9
5
 
10
- const { key } = createIdentity;
11
- const root = join(import.meta.dir, "..");
12
- const distPath = join(root, "dist", key);
13
- const stagingDir = join(root, "Formula", ".staging");
14
- const stagingPath = join(stagingDir, key);
15
-
16
- mkdirSync(stagingDir, { recursive: true });
17
- copyFileSync(distPath, stagingPath);
18
- chmodSync(stagingPath, 0o755);
19
-
20
- const binary = readFileSync(stagingPath);
21
- const sha256 = createHash("sha256").update(binary).digest("hex");
22
- const version = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version as string;
23
-
24
- const out = join(root, "Formula", `${key}.rb`);
25
- writeFileSync(out, renderDevFormula(stagingPath, version, sha256), "utf8");
26
- console.log(`Wrote ${out}`);
6
+ writeDevFormula();
7
+ console.log(`Wrote ${releaseFormulaPath()}`);
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env bun
2
+ /** Back up release formula, write dev formula, run a command, then restore. Usage: bun scripts/with-dev-formula.ts -- brew install … */
3
+
4
+ import { spawnSync } from "node:child_process";
5
+ import { backupReleaseFormula, releaseFormulaPath, restoreReleaseFormula, writeDevFormula } from "./dev-formula.ts";
6
+
7
+ const sep = process.argv.indexOf("--");
8
+ if (sep === -1 || sep === process.argv.length - 1) {
9
+ process.stderr.write("Usage: bun scripts/with-dev-formula.ts -- <command...>\n");
10
+ process.exit(1);
11
+ }
12
+
13
+ const cmd = process.argv.slice(sep + 1);
14
+ let restored = false;
15
+
16
+ function restore(): void {
17
+ if (restored) {
18
+ return;
19
+ }
20
+ restored = true;
21
+ restoreReleaseFormula();
22
+ }
23
+
24
+ try {
25
+ backupReleaseFormula();
26
+ writeDevFormula();
27
+ const result = spawnSync(cmd[0], cmd.slice(1), { stdio: "inherit" });
28
+ process.exitCode = result.status === null ? 1 : result.status;
29
+ } finally {
30
+ restore();
31
+ }
32
+
33
+ if (process.exitCode === 0) {
34
+ console.log(`Restored ${releaseFormulaPath()}`);
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argsbarg",
3
- "version": "5.1.4",
3
+ "version": "5.1.5",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "bun": ">=1.3"