@bigbongo/cli 3.1.1 → 3.3.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
@@ -28,8 +28,9 @@ bigbongo login
28
28
  ```
29
29
 
30
30
  Your browser opens to a BigBongo approval page showing a short code. Check the code matches,
31
- approve, and you're in. Your session lasts 7 days; run `bigbongo login` again to refresh it or
32
- `bigbongo logout` to sign out.
31
+ approve, and you're in. No browser on this machine? `bigbongo login --no-browser` prints the
32
+ address to open elsewhere (`BROWSER=<program>` picks the browser). Your session lasts 7 days; run
33
+ `bigbongo login` again to refresh it or `bigbongo logout` to sign out.
33
34
 
34
35
  ### 2. Clone your app
35
36
 
@@ -69,11 +70,12 @@ bigbongo logs # recent logs from your running app
69
70
 
70
71
  | command | what it does |
71
72
  |---|---|
72
- | `bigbongo login` | Sign in with your BigBongo account. |
73
- | `bigbongo clone [app]` | Clone your app and set up git access. Name an app, or omit it to pick your organization, then the app. |
73
+ | `bigbongo login` | Sign in with your BigBongo account. Option: `--no-browser`. |
74
+ | `bigbongo clone [app]` | Clone your app, set up git access and turn on its pre-push check. Name an app, or omit it to pick your organization, then the app. |
74
75
  | `bigbongo status` | Show what's live (version, commit, URL) and any deploy in progress. |
75
76
  | `bigbongo logs` | Show recent runtime logs, newest first. Options: `--lines <n>` (default 50, max 500), `--search <text>`, `--level <error\|warn\|info>`. |
76
- | `bigbongo logout` | Sign out and clear your local session. |
77
+ | `bigbongo claude-setup` | Point Claude Code at BigBongo for the current project, so coding there is billed to your BigBongo credits. Options: `--org <slug>`, `--global`. |
78
+ | `bigbongo logout` | Sign out and delete the login and the git and Claude Code tokens the CLI cached in `~/.bigbongo`. |
77
79
 
78
80
  Run `bigbongo <command> --help` for details on any command.
79
81
 
@@ -82,6 +84,57 @@ then shows just that org's apps (pick `← Back to organizations` to switch). On
82
84
  that actually have apps are listed, and if all your apps are in one org that step is skipped -
83
85
  there's nothing extra to set up.
84
86
 
87
+ ## Using Claude Code with BigBongo
88
+
89
+ Run Claude Code on your own machine and pay for it with your BigBongo credits - no
90
+ Anthropic account and no AWS account needed.
91
+
92
+ ```
93
+ bigbongo login
94
+ cd my-app
95
+ bigbongo claude-setup
96
+ claude
97
+ ```
98
+
99
+ `claude-setup` writes two keys into a Claude settings file: the BigBongo endpoint, and a
100
+ credential helper. Claude Code then fetches its own short-lived credential whenever it
101
+ needs one and refreshes it on its own. **There is no key to copy and none stored in your
102
+ shell profile.**
103
+
104
+ Which file it writes:
105
+
106
+ | how you run it | file written | who it affects |
107
+ |---|---|---|
108
+ | `bigbongo claude-setup` (default) | `.claude/settings.local.json` at the root of the current git repo, or in the current folder when it is not in a git repo | only Claude Code started in this project, only for you. The file is kept out of git (added to `.gitignore` when needed), so it is never shared with people who clone the repo. |
109
+ | `bigbongo claude-setup --global` | `~/.claude/settings.json` | every Claude Code session on this computer, in every project. All of them spend this organization's credit. |
110
+
111
+ It prints the organization whose credit will be used (name and slug) and the file it
112
+ wrote. Run it in each project you want on BigBongo, or once with `--global` if you want
113
+ it everywhere. Add `--org <slug>` if you belong to more than one organization. It will
114
+ not run in your home folder without `--global`, because that is not a project.
115
+
116
+ `--project` still works for older scripts and now means the default. It no longer
117
+ writes the shared `.claude/settings.json`, which gets committed and would hand the
118
+ helper to everyone who clones the repo.
119
+
120
+ A few things differ from a direct Anthropic connection, and it is better to know them up
121
+ front than to discover them mid-task:
122
+
123
+ - Claude Code's built-in web search is unavailable; BigBongo provides
124
+ `mcp__bigbongo__web_search` through its MCP server instead.
125
+ - Some experimental beta features are turned off, because the upstream provider rejects
126
+ them outright rather than ignoring them.
127
+ - Your prompts travel through BigBongo on the way to the model. Token counts are
128
+ recorded; prompts and code are not stored.
129
+ - When your credit balance reaches zero, requests stop with a message telling you so.
130
+
131
+ Everything local is unchanged: subagents, hooks, skills, MCP servers, plugins and your
132
+ CLAUDE.md all behave exactly as they do on any other connection.
133
+
134
+ If you already have `ANTHROPIC_API_KEY` set in your shell, remove it - Claude Code
135
+ prefers it, and it would bill Anthropic instead of BigBongo. `claude-setup` warns you if
136
+ it sees one.
137
+
85
138
  ## How access works
86
139
 
87
140
  You never handle a GitHub credential yourself. When git needs access, BigBongo issues a
package/dist/api.js CHANGED
@@ -13,9 +13,18 @@ async function req(path, init = {}, base) {
13
13
  ...(init.headers || {}),
14
14
  },
15
15
  });
16
- if (!res.ok)
17
- throw new Error(`${res.status} ${res.statusText} on ${path}`);
18
16
  const t = await res.text();
17
+ if (!res.ok) {
18
+ const err = new Error(`${res.status} ${res.statusText} on ${path}`);
19
+ err.status = res.status;
20
+ try {
21
+ err.body = t ? JSON.parse(t) : undefined;
22
+ }
23
+ catch {
24
+ err.body = undefined;
25
+ }
26
+ throw err;
27
+ }
19
28
  return t ? JSON.parse(t) : {};
20
29
  }
21
30
  export const api = {
@@ -36,5 +45,6 @@ export const api = {
36
45
  const q = qs.toString();
37
46
  return req(`/api/cli/apps/${appId}/logs${q ? `?${q}` : ""}`);
38
47
  },
48
+ gatewayToken: (org) => req(`/api/cli/gateway-token${org ? `?organization=${encodeURIComponent(org)}` : ""}`, { method: "POST" }),
39
49
  logout: () => req("/api/cli/auth/logout", { method: "POST" }),
40
50
  };
@@ -0,0 +1,114 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { api } from "../api.js";
6
+ import { loadCredentials } from "../config.js";
7
+ export async function claudeSetup(opts = {}) {
8
+ if (!loadCredentials()?.token) {
9
+ console.error("Not logged in. Run `bigbongo login` first.");
10
+ process.exit(1);
11
+ }
12
+ if (opts.project) {
13
+ console.log("--project is now the default: writing .claude/settings.local.json (just you, git-ignored), not the shared .claude/settings.json.");
14
+ }
15
+ const repoRoot = opts.global ? null : gitRoot(process.cwd());
16
+ const projectRoot = opts.global ? null : repoRoot || process.cwd();
17
+ if (projectRoot && resolve(projectRoot) === resolve(homedir())) {
18
+ console.error("This is your home folder, not a project. Run it inside the project you want to use\n" +
19
+ "BigBongo in, or add --global to use it for every project on this computer.");
20
+ process.exit(1);
21
+ }
22
+ let org = opts.org || "";
23
+ let baseUrl = "https://llm.bigbongo.ai";
24
+ try {
25
+ const r = await api.gatewayToken(org || undefined);
26
+ org = r.organization;
27
+ baseUrl = r.base_url || baseUrl;
28
+ }
29
+ catch (e) {
30
+ if (e?.status === 409 && Array.isArray(e?.body?.organizations)) {
31
+ console.error("Your login reaches several organizations. Re-run with one of:\n");
32
+ for (const o of e.body.organizations)
33
+ console.error(` bigbongo claude-setup --org ${o.slug}`);
34
+ process.exit(1);
35
+ }
36
+ if (e?.status === 402) {
37
+ console.error(e?.body?.error || "This organization has no BigBongo credit.");
38
+ process.exit(1);
39
+ }
40
+ console.error(e?.body?.error || e?.message || "Could not reach BigBongo.");
41
+ process.exit(1);
42
+ }
43
+ const orgName = await api
44
+ .listOrgs()
45
+ .then((r) => (r?.organizations || []).find((o) => o.slug === org)?.name || "")
46
+ .catch(() => "");
47
+ const settingsPath = projectRoot
48
+ ? join(projectRoot, ".claude", "settings.local.json")
49
+ : join(homedir(), ".claude", "settings.json");
50
+ let settings = {};
51
+ if (existsSync(settingsPath)) {
52
+ try {
53
+ settings = JSON.parse(readFileSync(settingsPath, "utf8")) || {};
54
+ }
55
+ catch {
56
+ console.error(`${settingsPath} is not valid JSON. Fix or move it, then run this again -\n` +
57
+ "refusing to overwrite a settings file that might hold your own configuration.");
58
+ process.exit(1);
59
+ }
60
+ }
61
+ const helper = org ? `bigbongo gateway-token --org ${org}` : "bigbongo gateway-token";
62
+ settings.env = { ...(settings.env || {}), ANTHROPIC_BASE_URL: baseUrl };
63
+ settings.apiKeyHelper = helper;
64
+ mkdirSync(dirname(settingsPath), { recursive: true });
65
+ writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
66
+ const ignoredIn = repoRoot ? ensureGitIgnored(repoRoot) : "";
67
+ console.log("\n Claude Code is now pointed at BigBongo.\n");
68
+ console.log(` Credit used: ${orgName ? `${orgName} (${org})` : org}`);
69
+ console.log(` File written: ${settingsPath}`);
70
+ console.log(` ANTHROPIC_BASE_URL ${baseUrl}`);
71
+ console.log(` apiKeyHelper ${helper}\n`);
72
+ if (projectRoot) {
73
+ console.log(` Applies only to Claude Code started in ${projectRoot}.`);
74
+ if (ignoredIn)
75
+ console.log(` Added .claude/settings.local.json to ${ignoredIn} so it is never committed.`);
76
+ console.log(" To use BigBongo in every project on this computer instead, run it with --global.\n");
77
+ }
78
+ else {
79
+ console.log(" Applies to EVERY Claude Code session on this computer, in every project.\n");
80
+ }
81
+ console.log(" Run `claude` as normal. Credits come off that organization's BigBongo balance.");
82
+ console.log(" Nothing to copy - Claude Code fetches and refreshes the credential itself.\n");
83
+ if (process.env.ANTHROPIC_API_KEY) {
84
+ console.log(" Heads up: ANTHROPIC_API_KEY is set in this shell, and it wins over the\n" +
85
+ " helper. Remove it from your shell profile, or this will bill Anthropic\n" +
86
+ " instead of BigBongo.\n");
87
+ }
88
+ }
89
+ function gitRoot(dir) {
90
+ try {
91
+ return resolve(git(dir, ["rev-parse", "--show-toplevel"]));
92
+ }
93
+ catch {
94
+ return null;
95
+ }
96
+ }
97
+ function ensureGitIgnored(root) {
98
+ const entry = ".claude/settings.local.json";
99
+ try {
100
+ git(root, ["check-ignore", "-q", "--no-index", entry]);
101
+ return "";
102
+ }
103
+ catch {
104
+ }
105
+ const gitignore = join(root, ".gitignore");
106
+ const current = existsSync(gitignore) ? readFileSync(gitignore, "utf8") : "";
107
+ if (current.split(/\r?\n/).some((line) => line.trim() === entry || line.trim() === `/${entry}`))
108
+ return "";
109
+ appendFileSync(gitignore, `${current && !current.endsWith("\n") ? "\n" : ""}${entry}\n`);
110
+ return gitignore;
111
+ }
112
+ function git(cwd, args) {
113
+ return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
114
+ }
@@ -0,0 +1,45 @@
1
+ import { api } from "../api.js";
2
+ import { loadCachedGatewayToken, loadCredentials, saveCachedGatewayToken } from "../config.js";
3
+ export async function gatewayToken(opts = {}) {
4
+ if (!loadCredentials()?.token) {
5
+ fail("Not logged in to BigBongo.\n" +
6
+ "Run `bigbongo login` once, then Claude Code will fetch credentials on its own.");
7
+ }
8
+ const org = opts.org || process.env.BIGBONGO_ORG || "";
9
+ const cached = loadCachedGatewayToken(org);
10
+ if (cached) {
11
+ process.stdout.write(cached.token);
12
+ return;
13
+ }
14
+ try {
15
+ const r = await api.gatewayToken(org || undefined);
16
+ saveCachedGatewayToken(org, {
17
+ token: r.token,
18
+ expires_at: r.expires_at,
19
+ base_url: r.base_url,
20
+ });
21
+ process.stdout.write(r.token);
22
+ }
23
+ catch (e) {
24
+ const status = e?.status;
25
+ const body = e?.body || {};
26
+ if (status === 409 && Array.isArray(body.organizations)) {
27
+ const list = body.organizations.map((o) => ` ${o.slug} (${o.name})`).join("\n");
28
+ fail("Your BigBongo login reaches several organizations, so this needs one named:\n" +
29
+ `${list}\n\n` +
30
+ "Set it once with `bigbongo claude-setup --org <slug>`, or export BIGBONGO_ORG=<slug>.");
31
+ }
32
+ if (status === 402) {
33
+ fail(`${body.error || "This organization has no BigBongo credit."}\n` +
34
+ "Top up in BigBongo and the next request will go through.");
35
+ }
36
+ if (status === 401) {
37
+ fail("Your BigBongo login has expired. Run `bigbongo login` again.");
38
+ }
39
+ fail(body.error || e?.message || "Could not fetch a BigBongo gateway credential.");
40
+ }
41
+ }
42
+ function fail(message) {
43
+ process.stderr.write(message + "\n");
44
+ process.exit(1);
45
+ }
@@ -20,7 +20,8 @@ export async function login(opts) {
20
20
  console.log("\n Approve this login in your browser. Confirm this code matches:\n");
21
21
  console.log(` ${session.user_code}\n`);
22
22
  console.log(` ${session.verification_url}\n`);
23
- openBrowser(session.verification_url);
23
+ if (opts.browser !== false)
24
+ openBrowser(session.verification_url);
24
25
  const spin = ora("Waiting for approval...").start();
25
26
  const deadline = Date.now() + (session.expires_in || 900) * 1000;
26
27
  const interval = (session.poll_interval || 5) * 1000;
@@ -1,13 +1,33 @@
1
1
  import { api } from "../api.js";
2
- import { clearCredentials, loadCredentials } from "../config.js";
2
+ import { dirname } from "node:path";
3
+ import { CREDENTIAL_FILES, clearCachedGatewayTokens, clearCachedGitTokens, clearCredentials, loadCredentials, } from "../config.js";
3
4
  export async function logout() {
5
+ let revoked = false;
4
6
  if (loadCredentials()?.token) {
5
7
  try {
6
8
  await api.logout();
9
+ revoked = true;
7
10
  }
8
11
  catch {
9
12
  }
10
13
  }
11
- clearCredentials();
14
+ const failed = [];
15
+ for (const [what, clear] of [
16
+ ["your login", clearCredentials],
17
+ ["the cached git tokens", clearCachedGitTokens],
18
+ ["the cached Claude Code tokens", clearCachedGatewayTokens],
19
+ ]) {
20
+ try {
21
+ clear();
22
+ }
23
+ catch (e) {
24
+ failed.push(`${what} (${e?.code || e?.message || e})`);
25
+ }
26
+ }
27
+ if (failed.length) {
28
+ const server = revoked ? "Logged out on the server, but" : "Could not log out on the server, and";
29
+ console.error(`${server} could not delete ${failed.join(", ")} in ${dirname(CREDENTIAL_FILES[0])}.`);
30
+ process.exit(1);
31
+ }
12
32
  console.log("Logged out.");
13
33
  }
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { homedir } from "node:os";
2
2
  import { join, dirname } from "node:path";
3
- import { mkdirSync, readFileSync, writeFileSync, existsSync, chmodSync } from "node:fs";
3
+ import { mkdirSync, readFileSync, writeFileSync, existsSync, chmodSync, rmSync } from "node:fs";
4
4
  const DIR = join(homedir(), ".bigbongo");
5
5
  const CRED = join(DIR, "credentials.json");
6
6
  export function saveCredentials(c) {
@@ -20,10 +20,7 @@ export function loadCredentials() {
20
20
  }
21
21
  }
22
22
  export function clearCredentials() {
23
- if (existsSync(CRED)) {
24
- writeFileSync(CRED, "{}");
25
- chmodSync(CRED, 0o600);
26
- }
23
+ rmSync(CRED, { force: true });
27
24
  }
28
25
  const GIT_TOKENS = join(DIR, "git-tokens.json");
29
26
  const TOKEN_REFRESH_SKEW_MS = 5 * 60 * 1000;
@@ -86,3 +83,36 @@ export function findProjectUp(startDir = process.cwd()) {
86
83
  dir = parent;
87
84
  }
88
85
  }
86
+ const GATEWAY_TOKENS = join(DIR, "gateway-tokens.json");
87
+ function readGatewayCache() {
88
+ try {
89
+ return JSON.parse(readFileSync(GATEWAY_TOKENS, "utf8"));
90
+ }
91
+ catch {
92
+ return {};
93
+ }
94
+ }
95
+ export function loadCachedGatewayToken(org) {
96
+ const entry = readGatewayCache()[org || "_default"];
97
+ if (!entry?.token || !entry?.expires_at)
98
+ return null;
99
+ const remaining = new Date(entry.expires_at).getTime() - Date.now();
100
+ if (!(remaining > TOKEN_REFRESH_SKEW_MS))
101
+ return null;
102
+ return entry;
103
+ }
104
+ export function saveCachedGatewayToken(org, entry) {
105
+ const all = readGatewayCache();
106
+ all[org || "_default"] = entry;
107
+ mkdirSync(DIR, { recursive: true });
108
+ chmodSync(DIR, 0o700);
109
+ writeFileSync(GATEWAY_TOKENS, JSON.stringify(all));
110
+ chmodSync(GATEWAY_TOKENS, 0o600);
111
+ }
112
+ export function clearCachedGatewayTokens() {
113
+ rmSync(GATEWAY_TOKENS, { force: true });
114
+ }
115
+ export function clearCachedGitTokens() {
116
+ rmSync(GIT_TOKENS, { force: true });
117
+ }
118
+ export const CREDENTIAL_FILES = [CRED, GIT_TOKENS, GATEWAY_TOKENS];
package/dist/git.js CHANGED
@@ -1,4 +1,4 @@
1
- import { appendFileSync } from "node:fs";
1
+ import { appendFileSync, chmodSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { simpleGit } from "simple-git";
4
4
  export function tokenRemote(repoUrl, token) {
@@ -23,4 +23,28 @@ export async function cloneApp(repoUrl, token, dir, author) {
23
23
  await local.addConfig("credential.helper", "", false);
24
24
  await local.addConfig("credential.helper", "!bigbongo git-token --helper", true);
25
25
  appendFileSync(join(dir, ".git", "info", "exclude"), "\n.bigbongo.json\n");
26
+ await enablePrePushCheck(local, dir);
27
+ }
28
+ const PRE_PUSH_WRAPPER = `#!/bin/sh
29
+ # Written by bigbongo clone: runs this app's own pre-push check before every push.
30
+ # A checkout without the check (an older branch) pushes as before.
31
+ [ -f ./.githooks/pre-push ] || exit 0
32
+ exec bash ./.githooks/pre-push "$@"
33
+ `;
34
+ async function enablePrePushCheck(local, dir) {
35
+ if (!existsSync(join(dir, ".githooks", "pre-push")))
36
+ return;
37
+ const hooksPath = (await local.raw(["config", "--get", "core.hooksPath"]).catch(() => "")).trim();
38
+ const notice = (why) => {
39
+ console.log(`${why}, so the app's pre-push check is not turned on.`);
40
+ console.log("To run it before each push, call .githooks/pre-push from your pre-push hook.");
41
+ };
42
+ if (hooksPath)
43
+ return notice(`Your git uses its own hooks folder (${hooksPath})`);
44
+ const hook = join(dir, ".git", "hooks", "pre-push");
45
+ if (existsSync(hook))
46
+ return notice("This clone already has a pre-push hook");
47
+ mkdirSync(join(dir, ".git", "hooks"), { recursive: true });
48
+ writeFileSync(hook, PRE_PUSH_WRAPPER);
49
+ chmodSync(hook, 0o755);
26
50
  }
package/dist/index.js CHANGED
@@ -1,16 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
- import { Command } from "commander";
3
+ import { Command, Option } from "commander";
4
4
  import { login } from "./commands/login.js";
5
5
  import { clone } from "./commands/clone.js";
6
6
  import { status } from "./commands/status.js";
7
7
  import { logs } from "./commands/logs.js";
8
8
  import { gitToken } from "./commands/gitToken.js";
9
9
  import { logout } from "./commands/logout.js";
10
+ import { gatewayToken } from "./commands/gatewayToken.js";
11
+ import { claudeSetup } from "./commands/claudeSetup.js";
10
12
  const version = createRequire(import.meta.url)("../package.json").version;
11
13
  const program = new Command();
12
14
  program.name("bigbongo").description("Edit your BigBongo app locally and git push to deploy.").version(version);
13
- program.command("login").description("Authenticate against BigBongo").option("--token <token>", "non-interactive login").action(login);
15
+ program.command("login").description("Authenticate against BigBongo").option("--token <token>", "non-interactive login")
16
+ .option("--no-browser", "print the approval address without opening a browser (BROWSER=<program> picks the browser)")
17
+ .action(login);
14
18
  program.command("clone [app]").description("Clone your app's repo (BigBongo brokers GitHub access)").action(clone);
15
19
  program.command("status").description("Show app + deployment status").action(status);
16
20
  program.command("logs").description("Show app runtime logs")
@@ -19,6 +23,19 @@ program.command("logs").description("Show app runtime logs")
19
23
  .option("--level <level>", "filter by level: error | warn | info")
20
24
  .action(logs);
21
25
  program.command("logout").description("Revoke and clear local credentials").action(logout);
26
+ program.command("claude-setup").description("Point Claude Code at BigBongo for this project (writes apiKeyHelper + base URL)")
27
+ .option("--org <slug>", "organization whose BigBongo credit is used")
28
+ .addOption(new Option("--global", "write ~/.claude/settings.json instead, so EVERY Claude Code session on this computer uses BigBongo").conflicts("project"))
29
+ .option("--project", "same as the default (kept for older scripts)")
30
+ .addHelpText("after", `
31
+ By default this writes .claude/settings.local.json at the root of the current git repo
32
+ (or the current folder when it is not in a git repo). That file is just for you: it is
33
+ kept out of git (added to .gitignore when needed) and only Claude Code started in this
34
+ project uses it.`)
35
+ .action(claudeSetup);
36
+ program.command("gateway-token").description("(internal) print a short-lived Claude Code credential")
37
+ .option("--org <slug>", "organization to bill")
38
+ .action(gatewayToken);
22
39
  program.command("git-token [app]").description("(internal) mint a short-lived git token").option("--helper", "git credential-helper mode").action(gitToken);
23
40
  program.parseAsync(process.argv).catch((err) => {
24
41
  const e = err;
package/dist/util.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { spawn } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { delimiter } from "node:path";
2
4
  export function openBrowser(url) {
3
5
  try {
4
6
  const u = new URL(url);
@@ -10,18 +12,41 @@ export function openBrowser(url) {
10
12
  }
11
13
  if (!/^https?:\/\/[A-Za-z0-9._:/~-]+$/.test(url))
12
14
  return;
15
+ const browser = (process.env.BROWSER || "").trim();
16
+ if (browser === "none")
17
+ return;
18
+ const entries = browser && existsSync(browser) ? [browser] : browser.split(delimiter);
19
+ const candidates = entries
20
+ .map((entry) => entry.trim())
21
+ .filter(Boolean)
22
+ .map((entry) => {
23
+ if (existsSync(entry))
24
+ return [entry, [url]];
25
+ const [program, ...args] = entry.split(/\s+/);
26
+ return [program, args.some((a) => a.includes("%s")) ? args.map((a) => a.replace("%s", url)) : [...args, url]];
27
+ });
28
+ candidates.push(platformOpener(url));
29
+ const tryFrom = (i) => {
30
+ if (i < candidates.length)
31
+ launch(candidates[i][0], candidates[i][1], () => tryFrom(i + 1));
32
+ };
33
+ tryFrom(0);
34
+ }
35
+ function platformOpener(url) {
36
+ if (process.platform === "darwin")
37
+ return ["open", [url]];
38
+ if (process.platform === "win32")
39
+ return ["cmd", ["/c", "start", "", url]];
40
+ return ["xdg-open", [url]];
41
+ }
42
+ function launch(program, args, onError) {
13
43
  try {
14
- if (process.platform === "darwin") {
15
- spawn("open", [url], { stdio: "ignore", detached: true }).unref();
16
- }
17
- else if (process.platform === "win32") {
18
- spawn("cmd", ["/c", "start", "", url], { stdio: "ignore", detached: true }).unref();
19
- }
20
- else {
21
- spawn("xdg-open", [url], { stdio: "ignore", detached: true }).unref();
22
- }
44
+ const child = spawn(program, args, { stdio: "ignore", detached: true });
45
+ child.on("error", onError);
46
+ child.unref();
23
47
  }
24
48
  catch {
49
+ onError();
25
50
  }
26
51
  }
27
52
  export function parseGitCredential(input) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbongo/cli",
3
- "version": "3.1.1",
3
+ "version": "3.3.0",
4
4
  "description": "BigBongo CLI - edit your BigBongo app locally and git push to deploy.",
5
5
  "type": "module",
6
6
  "bin": {