@bigbongo/cli 3.4.1 → 3.5.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/README.md CHANGED
@@ -93,7 +93,7 @@ bigbongo logs # recent logs from your running app
93
93
  | `bigbongo status` | Show what's live (version, commit, URL) and any deploy in progress. |
94
94
  | `bigbongo logs` | Show recent runtime logs, newest first. Options: `--lines <n>` (default 50, max 500), `--search <text>`, `--level <error\|warn\|info>`. |
95
95
  | `bigbongo claude-setup` | Point Claude Code at BigBongo in a folder that is not an app (an app folder gets this from `bigbongo setup`), so coding there is billed to your BigBongo credits. Options: `--org <slug>`, `--global`. |
96
- | `bigbongo mcp-token` | (for Claude Code) Print the MCP headers for this folder's app, for Claude Code's `headersHelper`. |
96
+ | `bigbongo mcp-token` | (for Claude Code) Claude Code's MCP `headersHelper`: prints the MCP headers for this folder's app, only to the BigBongo address of your login (Claude Code names it in `CLAUDE_CODE_MCP_SERVER_URL`). |
97
97
  | `bigbongo logout` | Sign out and delete the login and the git, Claude Code and MCP tokens the CLI cached in `~/.bigbongo`. |
98
98
 
99
99
  Run `bigbongo <command> --help` for details on any command.
package/dist/api.js CHANGED
@@ -1,15 +1,17 @@
1
1
  import { loadCredentials } from "./config.js";
2
2
  export function apiBase() {
3
3
  const c = loadCredentials();
4
- return process.env.BIGBONGO_API_URL || c?.apiUrl || "https://app.bigbongo.ai";
4
+ return c?.apiUrl || process.env.BIGBONGO_API_URL || "https://app.bigbongo.ai";
5
5
  }
6
6
  async function req(path, init = {}, base) {
7
7
  const c = loadCredentials();
8
+ const { timeoutMs, ...rest } = init;
8
9
  const res = await fetch((base || apiBase()) + path, {
9
- ...init,
10
+ ...rest,
11
+ ...(timeoutMs ? { signal: AbortSignal.timeout(timeoutMs) } : {}),
10
12
  headers: {
11
13
  "Content-Type": "application/json",
12
- ...(c?.token ? { Authorization: `Bearer ${c.token}` } : {}),
14
+ ...(c?.token && !base ? { Authorization: `Bearer ${c.token}` } : {}),
13
15
  ...(init.headers || {}),
14
16
  },
15
17
  });
@@ -33,7 +35,7 @@ export const api = {
33
35
  listOrgs: () => req("/api/cli/orgs/"),
34
36
  listApps: (orgId) => req(`/api/cli/apps/${orgId ? `?organization=${orgId}` : ""}`),
35
37
  gitToken: (appId, mode = "write") => req(`/api/cli/apps/${appId}/git-token`, { method: "POST", body: JSON.stringify({ mode }) }),
36
- status: (appId) => req(`/api/cli/apps/${appId}/status`),
38
+ status: (appId, o = {}) => req(`/api/cli/apps/${appId}/status`, o),
37
39
  logs: (appId, opts = {}) => {
38
40
  const qs = new URLSearchParams();
39
41
  if (opts.lines)
@@ -47,6 +49,6 @@ export const api = {
47
49
  },
48
50
  gatewayToken: (org) => req(`/api/cli/gateway-token${org ? `?organization=${encodeURIComponent(org)}` : ""}`, { method: "POST" }),
49
51
  mcpToken: (appId) => req("/api/cli/mcp-token", { method: "POST", body: JSON.stringify({ app_id: appId }) }),
50
- pushResult: (appId, sha) => req(`/api/cli/apps/${appId}/builds/${sha}`),
52
+ pushResult: (appId, sha, o = {}) => req(`/api/cli/apps/${appId}/builds/${sha}`, o),
51
53
  logout: () => req("/api/cli/auth/logout", { method: "POST" }),
52
54
  };
@@ -0,0 +1,22 @@
1
+ import { api } from "../api.js";
2
+ import { loadCredentials } from "../config.js";
3
+ export async function apps(opts = {}) {
4
+ if (!loadCredentials()?.token) {
5
+ console.error("Not logged in. Run `bigbongo login` first.");
6
+ process.exit(1);
7
+ }
8
+ const { apps: list = [] } = await api.listApps();
9
+ const rows = list.map((a) => ({
10
+ slug: a.app_slug, title: a.title, organization: a.organization_name || String(a.org_id ?? ""),
11
+ }));
12
+ if (opts.json) {
13
+ console.log(JSON.stringify(rows, null, 2));
14
+ return;
15
+ }
16
+ if (!rows.length) {
17
+ console.log("No apps found for your account.");
18
+ return;
19
+ }
20
+ for (const r of rows)
21
+ console.log(`${r.slug}\t${r.title}\t(${r.organization})`);
22
+ }
@@ -84,7 +84,7 @@ export async function claudeSetup(opts = {}) {
84
84
  " instead of BigBongo.\n");
85
85
  }
86
86
  }
87
- export function writeGatewaySettings(settingsPath, baseUrl, helper) {
87
+ export function writeGatewaySettings(settingsPath, baseUrl, helper, extraEnv = {}) {
88
88
  let settings = {};
89
89
  if (existsSync(settingsPath)) {
90
90
  try {
@@ -98,9 +98,18 @@ export function writeGatewaySettings(settingsPath, baseUrl, helper) {
98
98
  if (typeof settings !== "object" || Array.isArray(settings)) {
99
99
  throw new Error(`${settingsPath} must hold a JSON object ({ ... }). Fix or move it, then run this again.`);
100
100
  }
101
- if (settings.env?.ANTHROPIC_BASE_URL === baseUrl && settings.apiKeyHelper === helper)
101
+ const env = { ANTHROPIC_BASE_URL: baseUrl, ...extraEnv };
102
+ const same = Object.entries(env).every(([k, v]) => (v === null ? !(k in (settings.env || {})) : settings.env?.[k] === v));
103
+ if (same && settings.apiKeyHelper === helper)
102
104
  return false;
103
- settings.env = { ...(settings.env || {}), ANTHROPIC_BASE_URL: baseUrl };
105
+ const merged = { ...(settings.env || {}) };
106
+ for (const [k, v] of Object.entries(env)) {
107
+ if (v === null)
108
+ delete merged[k];
109
+ else
110
+ merged[k] = v;
111
+ }
112
+ settings.env = merged;
104
113
  settings.apiKeyHelper = helper;
105
114
  mkdirSync(dirname(settingsPath), { recursive: true });
106
115
  writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
@@ -1,10 +1,11 @@
1
- import { readdirSync } from "node:fs";
2
- import { join } from "node:path";
1
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { dirname, join } from "node:path";
3
4
  import { api } from "../api.js";
4
5
  import { loadCredentials, saveProject } from "../config.js";
5
6
  import { cloneApp } from "../git.js";
6
7
  import { pickOne } from "../prompt.js";
7
- import { isSafeAppSlug } from "../util.js";
8
+ import { isInside, isSafeAppSlug } from "../util.js";
8
9
  import { setup } from "./setup.js";
9
10
  function requireAuth() {
10
11
  const c = loadCredentials();
@@ -82,15 +83,70 @@ export async function clone(appArg, opts = {}) {
82
83
  process.exit(1);
83
84
  }
84
85
  const dir = opts.here ? process.cwd() : join(process.cwd(), app.app_slug);
85
- if (opts.here && readdirSync(dir).length) {
86
+ const keptSettings = opts.here ? claudeLocalSettingsOnly(dir) : null;
87
+ if (opts.here && keptSettings === null && readdirSync(dir).length) {
86
88
  console.error("--here clones into the current folder, and it is not empty. Run it in an empty folder.");
87
89
  process.exit(1);
88
90
  }
89
91
  const { token, repo_url } = await api.gitToken(app.id, "read");
90
- await cloneApp(repo_url, token, dir, { name: cred.email, email: cred.email });
92
+ let copy = "";
93
+ const onSignal = () => { restoreClaudeSettings(dir, keptSettings); process.exit(130); };
94
+ if (keptSettings !== null) {
95
+ copy = join(mkdtempSync(join(tmpdir(), "bigbongo-claude-")), "settings.local.json");
96
+ writeFileSync(copy, keptSettings, { mode: 0o600 });
97
+ process.once("SIGINT", onSignal);
98
+ rmSync(join(dir, ".claude"), { recursive: true, force: true });
99
+ }
100
+ try {
101
+ await cloneApp(repo_url, token, dir, { name: cred.email, email: cred.email });
102
+ }
103
+ finally {
104
+ if (keptSettings !== null) {
105
+ process.removeListener("SIGINT", onSignal);
106
+ if (restoreClaudeSettings(dir, keptSettings))
107
+ rmSync(dirname(copy), { recursive: true, force: true });
108
+ else
109
+ console.error(`A copy is at ${copy}.`);
110
+ }
111
+ }
91
112
  saveProject({ app_id: app.id, org_id: app.org_id, app_slug: app.app_slug, repo_url }, dir);
92
113
  console.log(`\nCloned ${app.app_slug} into ${opts.here ? "this folder" : `./${app.app_slug}`}`);
93
114
  await setup({ dir });
94
115
  if (!opts.here)
95
116
  console.log(`Next: cd ${app.app_slug}`);
96
117
  }
118
+ function claudeLocalSettingsOnly(dir) {
119
+ try {
120
+ if (readdirSync(dir).join() !== ".claude")
121
+ return null;
122
+ const claude = join(dir, ".claude");
123
+ if (lstatSync(claude).isSymbolicLink() || readdirSync(claude).join() !== "settings.local.json")
124
+ return null;
125
+ const file = join(claude, "settings.local.json");
126
+ return lstatSync(file).isFile() ? readFileSync(file, "utf8") : null;
127
+ }
128
+ catch {
129
+ return null;
130
+ }
131
+ }
132
+ function restoreClaudeSettings(dir, content) {
133
+ const file = join(dir, ".claude", "settings.local.json");
134
+ const notBack = (why) => {
135
+ console.error(`Claude Code's settings for this folder (.claude/settings.local.json) were not put back: ${why}.`);
136
+ return false;
137
+ };
138
+ try {
139
+ if (existsSync(join(dir, ".claude")) && lstatSync(join(dir, ".claude")).isSymbolicLink())
140
+ return notBack("the app's .claude is a link");
141
+ if (!isInside(dir, file))
142
+ return notBack("it would land outside this folder");
143
+ if (existsSync(file))
144
+ return notBack("the app brings its own");
145
+ mkdirSync(join(dir, ".claude"), { recursive: true });
146
+ writeFileSync(file, content);
147
+ return true;
148
+ }
149
+ catch (e) {
150
+ return notBack(e?.message || String(e));
151
+ }
152
+ }
@@ -1,11 +1,19 @@
1
- import { api } from "../api.js";
1
+ import { api, apiBase } from "../api.js";
2
+ import { isAppId } from "../util.js";
2
3
  import { findProjectUp, loadCachedMcpHeaders, loadCredentials, saveCachedMcpHeaders } from "../config.js";
3
4
  export async function mcpToken(appArg) {
4
- if (!loadCredentials()?.token)
5
+ const cred = loadCredentials();
6
+ if (!cred?.token)
5
7
  fail("Not logged in to BigBongo. Run `bigbongo login`.");
6
- const appId = appArg || findProjectUp(process.cwd())?.app_id;
8
+ const target = process.env.CLAUDE_CODE_MCP_SERVER_URL || "";
9
+ if (!origin(target) || origin(target) !== origin(apiBase())) {
10
+ fail(`Not sending a BigBongo token to ${origin(target) || "an unnamed server"}: this login belongs to ${origin(apiBase())}.`);
11
+ }
12
+ const appId = appArg || process.env.BIGBONGO_APP_ID || findProjectUp(process.cwd())?.app_id;
7
13
  if (!appId)
8
14
  fail("No app here: run this inside a cloned app folder, or pass the app id.");
15
+ if (!isAppId(appId))
16
+ fail("That is not a BigBongo app id.");
9
17
  const cached = loadCachedMcpHeaders(appId);
10
18
  if (cached) {
11
19
  process.stdout.write(JSON.stringify(cached));
@@ -28,3 +36,11 @@ function fail(message) {
28
36
  process.stderr.write(message + "\n");
29
37
  process.exit(1);
30
38
  }
39
+ function origin(url) {
40
+ try {
41
+ return new URL(url).origin;
42
+ }
43
+ catch {
44
+ return "";
45
+ }
46
+ }
@@ -2,6 +2,7 @@ import { spawn, spawnSync } from "node:child_process";
2
2
  import { api } from "../api.js";
3
3
  import { findProjectUp, loadCredentials } from "../config.js";
4
4
  import { sleep } from "../util.js";
5
+ import { markReported } from "../reported.js";
5
6
  import { appWorkTree } from "./setup.js";
6
7
  export async function push(opts = {}) {
7
8
  const project = findProjectUp(process.cwd());
@@ -27,7 +28,7 @@ export async function push(opts = {}) {
27
28
  }
28
29
  const sha = git(root, ["rev-parse", "HEAD"]);
29
30
  console.log(`\nFollowing ${sha.slice(0, 7)} on BigBongo...`);
30
- const ok = await follow(project.app_id, sha, opts);
31
+ const ok = await follow(project.app_id, sha, { ...opts, root: root });
31
32
  if (!ok)
32
33
  process.exit(1);
33
34
  }
@@ -71,7 +72,7 @@ export async function follow(appId, sha, opts = {}) {
71
72
  for (;;) {
72
73
  let r;
73
74
  try {
74
- r = await api.pushResult(appId, sha);
75
+ r = await api.pushResult(appId, sha, { timeoutMs: 20_000 });
75
76
  errors = 0;
76
77
  }
77
78
  catch (e) {
@@ -91,6 +92,8 @@ export async function follow(appId, sha, opts = {}) {
91
92
  console.log(` ${mark} ${step.title}`);
92
93
  }
93
94
  }
95
+ if (["live", "failed", "skipped"].includes(r.state) && opts.root)
96
+ markReported(opts.root, String(r.sha || sha));
94
97
  if (r.state === "live") {
95
98
  console.log(`\nLive as v${r.version} ${r.url || ""}`.trimEnd());
96
99
  if (r.serving === false)
@@ -0,0 +1,103 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { api } from "../api.js";
3
+ import { findProjectUp, loadCredentials } from "../config.js";
4
+ import { lastFollowed, markFollowed, markReported, wasTold } from "../reported.js";
5
+ import { isAppId } from "../util.js";
6
+ import { follow } from "./push.js";
7
+ import { appWorkTree } from "./setup.js";
8
+ function appFolder() {
9
+ const project = findProjectUp(process.cwd());
10
+ if (!project || !isAppId(project.app_id))
11
+ return null;
12
+ const root = appWorkTree(process.cwd());
13
+ if (!root)
14
+ return null;
15
+ return { root, appId: project.app_id };
16
+ }
17
+ export async function lastPush(opts = {}) {
18
+ const folder = appFolder();
19
+ if (!folder || !loadCredentials()?.token) {
20
+ if (!opts.unreported)
21
+ console.error("Not in a cloned BigBongo app folder, or not logged in.");
22
+ return;
23
+ }
24
+ const timeoutMs = opts.timeoutMs ?? 1500;
25
+ let sha = "";
26
+ let r;
27
+ try {
28
+ const s = await api.status(folder.appId, { timeoutMs });
29
+ sha = String(s?.latest_build?.git_sha || "").toLowerCase();
30
+ if (!/^[0-9a-f]{7,40}$/.test(sha))
31
+ return;
32
+ if (opts.unreported && wasTold(folder.root, sha))
33
+ return;
34
+ r = await api.pushResult(folder.appId, sha, { timeoutMs });
35
+ }
36
+ catch {
37
+ return;
38
+ }
39
+ const line = describe(r, sha);
40
+ if (!line)
41
+ return;
42
+ console.log(line);
43
+ if (["live", "failed", "skipped"].includes(r.state))
44
+ markReported(folder.root, sha);
45
+ }
46
+ export function describe(r, sha) {
47
+ const short = sha.slice(0, 7);
48
+ if (r?.state === "live") {
49
+ const replaced = r.serving === false ? " (a later push or a rollback has replaced it since)" : "";
50
+ return `BigBongo: the push ${short} went live as v${r.version} ${r.url || ""}`.trimEnd() + replaced;
51
+ }
52
+ if (r?.state === "failed") {
53
+ const detail = String(r.detail || "").trim().split(/\r?\n/).filter(Boolean).slice(-10);
54
+ return [`BigBongo: the push ${short} failed at ${r.failed_step || "the build"}: ${r.reason || "no reason given"}`,
55
+ ...detail.map((l) => ` ${l}`)].join("\n");
56
+ }
57
+ if (r?.state === "skipped")
58
+ return `BigBongo: the push ${short} was not deployed: ${r.reason || "it was refused"}`;
59
+ if (r?.state === "building")
60
+ return `BigBongo: the push ${short} is still building; \`bigbongo follow ${short}\` waits for its result.`;
61
+ return "";
62
+ }
63
+ export async function followCommand(shaArg, opts = {}) {
64
+ const folder = appFolder();
65
+ if (!folder) {
66
+ if (opts.unreported)
67
+ return;
68
+ fail("Not in a cloned BigBongo app folder (no .bigbongo.json with an app id here or above).");
69
+ }
70
+ if (!loadCredentials()?.token) {
71
+ if (opts.unreported)
72
+ return;
73
+ fail("Not logged in. Run `bigbongo login` first.");
74
+ }
75
+ const sha = (shaArg || git(folder.root, ["rev-parse", "--verify", "--quiet", "refs/remotes/origin/main"])).toLowerCase();
76
+ if (!/^[0-9a-f]{7,40}$/.test(sha)) {
77
+ if (opts.unreported)
78
+ return;
79
+ fail("No pushed commit to follow: pass its sha, or push to main first.");
80
+ }
81
+ if (opts.unreported) {
82
+ if (!shaArg && (sha === lastFollowed(folder.root) || !movedByPush(folder.root)))
83
+ return;
84
+ if (!shaArg)
85
+ markFollowed(folder.root, sha);
86
+ if (wasTold(folder.root, sha))
87
+ return;
88
+ }
89
+ console.log(`Following ${sha.slice(0, 7)} on BigBongo...`);
90
+ const ok = await follow(folder.appId, sha, { root: folder.root });
91
+ if (!ok)
92
+ process.exit(1);
93
+ }
94
+ function movedByPush(root) {
95
+ return git(root, ["reflog", "show", "-1", "--format=%gs", "refs/remotes/origin/main"]) === "update by push";
96
+ }
97
+ function git(cwd, args) {
98
+ return (spawnSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).stdout || "").trim();
99
+ }
100
+ function fail(message) {
101
+ console.error(message);
102
+ process.exit(1);
103
+ }
@@ -6,7 +6,8 @@ import { dirname, join, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { apiBase } from "../api.js";
8
8
  import { findProjectRootUp, findProjectUp, loadCredentials } from "../config.js";
9
- import { isInside } from "../util.js";
9
+ import { isAppId, isInside } from "../util.js";
10
+ import { hasRecord, markFollowed, markReported } from "../reported.js";
10
11
  import { writeGatewaySettings } from "./claudeSetup.js";
11
12
  const SDK_INSTALL = "./vendor/platform-sdk[django,llm,connections]";
12
13
  const TEST_PACKAGES = ["pytest", "pytest-django"];
@@ -76,8 +77,13 @@ export async function setup(opts = {}) {
76
77
  }
77
78
  enablePrePushCheck(root, r);
78
79
  if (helper || !r.problems.length)
79
- setUpClaudeCode(root, project.org_id, runHelper, r);
80
- setUpPython(root, r, !!opts.quiet);
80
+ setUpClaudeCode(root, project.org_id, project.app_id, runHelper, r);
81
+ if (!hasRecord(root)) {
82
+ const deployed = gitRun(root, ["rev-parse", "--verify", "--quiet", "refs/remotes/origin/main"]).out.trim();
83
+ markReported(root, deployed || gitRun(root, ["rev-parse", "HEAD"]).out.trim());
84
+ markFollowed(root, deployed);
85
+ }
86
+ setUpPython(root, r, !!opts.quiet, opts.install !== false);
81
87
  if (!opts.quiet) {
82
88
  console.log(r.problems.length
83
89
  ? "\nNot done yet: fix the lines marked ✗, then run `bigbongo setup` again.\n"
@@ -86,7 +92,7 @@ export async function setup(opts = {}) {
86
92
  return r.problems.length === 0;
87
93
  }
88
94
  export async function setupCommand(opts) {
89
- if (!(await setup({ quiet: opts.quiet })))
95
+ if (!(await setup({ quiet: opts.quiet, install: opts.install })))
90
96
  process.exit(1);
91
97
  }
92
98
  export function appWorkTree(start) {
@@ -179,7 +185,7 @@ export function enablePrePushCheck(root, r) {
179
185
  chmodSync(hook, 0o755);
180
186
  r.ok("pre-push check on");
181
187
  }
182
- function setUpClaudeCode(root, orgId, runHelper, r) {
188
+ function setUpClaudeCode(root, orgId, appId, runHelper, r) {
183
189
  if (resolve(root) === resolve(homedir())) {
184
190
  r.fail("The app folder is your home folder; refusing to write Claude Code settings there.");
185
191
  return;
@@ -196,7 +202,11 @@ function setUpClaudeCode(root, orgId, runHelper, r) {
196
202
  return;
197
203
  }
198
204
  try {
199
- writeGatewaySettings(settingsPath, apiBase(), helper);
205
+ const mcp = {
206
+ BIGBONGO_MCP_URL: `${apiBase().replace(/\/+$/, "")}/mcp/`,
207
+ BIGBONGO_APP_ID: isAppId(appId) ? appId : null,
208
+ };
209
+ writeGatewaySettings(settingsPath, apiBase(), helper, mcp);
200
210
  }
201
211
  catch (e) {
202
212
  r.fail(e.message);
@@ -204,7 +214,7 @@ function setUpClaudeCode(root, orgId, runHelper, r) {
204
214
  }
205
215
  r.ok("Claude Code uses BigBongo credit (.claude/settings.local.json)");
206
216
  }
207
- function setUpPython(root, r, quiet) {
217
+ function setUpPython(root, r, quiet, install = true) {
208
218
  const venvPython = join(root, ".venv", process.platform === "win32" ? "Scripts/python.exe" : "bin/python");
209
219
  if (gitRun(root, ["ls-files", ".venv"]).out.trim()) {
210
220
  r.fail(".venv is committed to git; setup only uses an environment it makes. Remove it from git, then run setup again.");
@@ -215,6 +225,10 @@ function setUpPython(root, r, quiet) {
215
225
  r.fail(`.venv has Python ${venvVersion}; this app needs 3.12 or newer. Delete .venv and run \`bigbongo setup\` again.`);
216
226
  return;
217
227
  }
228
+ if (!venvVersion && !install) {
229
+ r.fail("This folder has no Python environment yet: run `bigbongo setup` to make it.");
230
+ return;
231
+ }
218
232
  const uv = version("uv", ["--version"], /uv (\S+)/);
219
233
  if (!venvVersion) {
220
234
  const python = findPython();
@@ -246,6 +260,10 @@ function setUpPython(root, r, quiet) {
246
260
  r.ok("packages up to date");
247
261
  return;
248
262
  }
263
+ if (!install) {
264
+ r.fail("The app's packages changed since they were installed: run `bigbongo setup` to install them.");
265
+ return;
266
+ }
249
267
  if (!quiet)
250
268
  console.log(" installing the packages...");
251
269
  const installed = uv
package/dist/index.js CHANGED
@@ -12,6 +12,8 @@ import { claudeSetup } from "./commands/claudeSetup.js";
12
12
  import { setupCommand } from "./commands/setup.js";
13
13
  import { push } from "./commands/push.js";
14
14
  import { mcpToken } from "./commands/mcpToken.js";
15
+ import { followCommand, lastPush } from "./commands/pushResult.js";
16
+ import { apps } from "./commands/apps.js";
15
17
  const version = createRequire(import.meta.url)("../package.json").version;
16
18
  const program = new Command();
17
19
  program.name("bigbongo").description("Edit your BigBongo app locally and git push to deploy.").version(version);
@@ -23,8 +25,16 @@ program.command("clone [app]").description("Clone your app's repo (BigBongo brok
23
25
  .action((app, opts) => clone(app, opts));
24
26
  program.command("setup").description("Make this app folder ready: Python environment, packages, pre-push check, Claude Code and git push")
25
27
  .option("--quiet", "print only what is wrong")
28
+ .option("--no-install", "never make .venv or install packages; say what is missing instead")
26
29
  .action(setupCommand);
27
30
  program.command("push").description("git push, then follow the build until it is live or failed").action(() => push());
31
+ program.command("apps").description("List the apps you can clone").option("--json", "print JSON").action(apps);
32
+ program.command("follow [sha]").description("Follow a pushed commit (default: what this folder last pushed to main) until it is live or failed")
33
+ .option("--unreported", "stay quiet when this folder was already told its result")
34
+ .action((sha, opts) => followCommand(sha, opts));
35
+ program.command("last-push").description("Show the result of this app's latest push")
36
+ .option("--unreported", "only when this folder has not been told about it yet")
37
+ .action((opts) => lastPush(opts));
28
38
  program.command("status").description("Show app + deployment status").action(status);
29
39
  program.command("logs").description("Show app runtime logs")
30
40
  .option("--lines <n>", "number of log lines (default 50, max 500)")
@@ -0,0 +1,50 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ const TOLD = "bigbongo-reported";
5
+ const FOLLOWED = "bigbongo-followed";
6
+ const KEEP = 50;
7
+ const SHA = /^[0-9a-f]{7,40}$/;
8
+ function gitPath(root, name) {
9
+ const out = (spawnSync("git", ["rev-parse", "--git-path", name], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).stdout || "").trim();
10
+ return out ? resolve(root, out) : null;
11
+ }
12
+ function readLines(path) {
13
+ try {
14
+ return path && existsSync(path) ? readFileSync(path, "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => SHA.test(l)) : [];
15
+ }
16
+ catch {
17
+ return [];
18
+ }
19
+ }
20
+ function write(path, lines) {
21
+ if (!path)
22
+ return;
23
+ try {
24
+ writeFileSync(path, lines.length ? `${lines.join("\n")}\n` : "");
25
+ }
26
+ catch { }
27
+ }
28
+ export function sameSha(a, b) {
29
+ return !!a && !!b && (a.startsWith(b) || b.startsWith(a));
30
+ }
31
+ export function hasRecord(root) {
32
+ return existsSync(gitPath(root, TOLD) || "");
33
+ }
34
+ export function wasTold(root, sha) {
35
+ return readLines(gitPath(root, TOLD)).some((told) => sameSha(told, sha));
36
+ }
37
+ export function markReported(root, sha) {
38
+ if (!SHA.test(sha))
39
+ return;
40
+ const path = gitPath(root, TOLD);
41
+ const lines = readLines(path).filter((told) => !sameSha(told, sha));
42
+ write(path, [...lines, sha].slice(-KEEP));
43
+ }
44
+ export function lastFollowed(root) {
45
+ return readLines(gitPath(root, FOLLOWED))[0] || "";
46
+ }
47
+ export function markFollowed(root, sha) {
48
+ if (SHA.test(sha))
49
+ write(gitPath(root, FOLLOWED), [sha]);
50
+ }
package/dist/util.js CHANGED
@@ -93,3 +93,6 @@ export function isInside(root, target) {
93
93
  return true;
94
94
  }
95
95
  }
96
+ export function isAppId(id) {
97
+ return typeof id === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id);
98
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbongo/cli",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "BigBongo CLI - edit your BigBongo app locally and git push to deploy.",
5
5
  "type": "module",
6
6
  "bin": {