argsbarg 5.1.3 → 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,8 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [5.1.3] - 2026-07-04
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
+
17
+ ## [5.1.4] - 2026-07-04
11
18
 
19
+ ### Changed
20
+
21
+ - **Template justfile** — export `HOMEBREW_GITHUB_API_TOKEN` from `gh auth token` at top of justfile; removed `scripts/ensure-brew-github-token.sh` and `HOMEBREW_NO_*` suppress vars.
22
+
23
+ ## [5.1.3] - 2026-07-04
12
24
 
13
25
  ## [5.1.2] - 2026-07-04
14
26
 
@@ -605,7 +617,9 @@ const cli = { ... } satisfies CliProgram; // or : CliProgram
605
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`).
606
618
  - Imports: use `CliPositional` where needed; replace `CliOptionDef` with `CliOption` or `CliPositional` as appropriate.
607
619
 
608
- [Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v5.1.3...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
622
+ [5.1.4]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.1.4
609
623
  [5.1.3]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.1.3
610
624
  [5.1.2]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.1.2
611
625
  [5.1.1]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.1.1
@@ -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
 
@@ -59,7 +59,7 @@ brew install just bun
59
59
  just setup
60
60
  just install # build + local dev formula
61
61
  just reinstall-local # fast binary swap during development
62
- just install-production # remote tap install (needs HOMEBREW_GITHUB_API_TOKEN)
62
+ just install-production # remote tap install (uses gh auth token)
63
63
  just test-release
64
64
  ```
65
65
 
@@ -1,8 +1,6 @@
1
1
  set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
2
2
 
3
- HOMEBREW_NO_AUTO_UPDATE := "1"
4
- HOMEBREW_NO_INSTALL_CLEANUP := "1"
5
- HOMEBREW_NO_ENV_HINTS := "1"
3
+ export HOMEBREW_GITHUB_API_TOKEN := `gh auth token`
6
4
 
7
5
  cli_key := `bun scripts/print-identity.ts key`
8
6
  tap_org := `bun scripts/print-identity.ts tapOrg`
@@ -51,25 +49,25 @@ install: install-local
51
49
  sync-artifacts:
52
50
  just run configure --sync --yes
53
51
 
54
- # Dev install: build, write dev formula, symlink tap, brew install
55
- install-local: build
56
- @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
57
58
  @brew untap {{tap}} 2>/dev/null || true
58
59
  mkdir -p {{tap_parent}}
59
60
  ln -sfn '{{justfile_directory()}}' {{tap_path}}
60
- brew install --formula {{tap}}/{{cli_key}}
61
+ bun scripts/with-dev-formula.ts -- brew install --formula {{tap}}/{{cli_key}}
61
62
  @echo ""
62
63
  @echo "Next: {{cli_key}} configure"
63
64
 
64
- # Remove local dev install, then install from GitHub tap (private release assets need HOMEBREW_GITHUB_API_TOKEN)
65
+ # Remove local dev install, then install from GitHub tap (private release assets need gh auth token)
65
66
  install-production: uninstall
66
- #!/usr/bin/env bash
67
- set -eu -o pipefail
68
- source scripts/ensure-brew-github-token.sh
69
67
  brew tap {{release_repo}} {{tap_git_url}}
70
68
  brew install --formula {{release_repo}}/{{cli_key}}
71
- echo ""
72
- echo "Next: {{cli_key}} configure"
69
+ @echo ""
70
+ @echo "Next: {{cli_key}} configure"
73
71
 
74
72
  # Alias for backward compatibility
75
73
  reinstall: reinstall-local
@@ -101,9 +99,6 @@ test: check
101
99
 
102
100
  # Install release formula from tap and run formula test
103
101
  test-release:
104
- #!/usr/bin/env bash
105
- set -eu -o pipefail
106
- source scripts/ensure-brew-github-token.sh
107
102
  brew untap {{tap}} 2>/dev/null || true
108
103
  mkdir -p {{tap_parent}}
109
104
  ln -sfn '{{justfile_directory()}}' {{tap_path}}
@@ -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.3",
3
+ "version": "5.1.5",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "bun": ">=1.3"
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Ensure HOMEBREW_GITHUB_API_TOKEN is set for private GitHub release downloads.
3
- : "${HOMEBREW_GITHUB_API_TOKEN:=$(gh auth token 2>/dev/null || true)}"
4
- if [[ -z "${HOMEBREW_GITHUB_API_TOKEN}" ]]; then
5
- echo "HOMEBREW_GITHUB_API_TOKEN is required to download private GitHub release assets." >&2
6
- echo "Use: HOMEBREW_GITHUB_API_TOKEN=\"\$(gh auth token)\" (if gh is installed)" >&2
7
- echo "Or create a PAT at https://github.com/settings/personal-access-tokens/new (Contents read on the tap repo)." >&2
8
- exit 1
9
- fi
10
- export HOMEBREW_GITHUB_API_TOKEN