@bigbongo/cli 3.2.0 → 3.4.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 +49 -13
- package/dist/api.js +2 -0
- package/dist/commands/claudeSetup.js +92 -17
- package/dist/commands/clone.js +12 -4
- package/dist/commands/login.js +2 -1
- package/dist/commands/logout.js +23 -2
- package/dist/commands/mcpToken.js +30 -0
- package/dist/commands/push.js +135 -0
- package/dist/commands/setup.js +346 -0
- package/dist/config.js +44 -12
- package/dist/git.js +1 -3
- package/dist/helper.js +18 -0
- package/dist/index.js +25 -6
- package/dist/util.js +49 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ you, so you never need a GitHub account. Once you've cloned your app it's all pl
|
|
|
10
10
|
|
|
11
11
|
- **Node.js 18+**
|
|
12
12
|
- **git** installed and on your PATH
|
|
13
|
+
- **Python 3.12+** to run and test your app on your machine (`bigbongo setup` says how to
|
|
14
|
+
install it when it is missing; [uv](https://docs.astral.sh/uv/) is used when installed)
|
|
13
15
|
|
|
14
16
|
## Install
|
|
15
17
|
|
|
@@ -28,8 +30,9 @@ bigbongo login
|
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
Your browser opens to a BigBongo approval page showing a short code. Check the code matches,
|
|
31
|
-
approve, and you're in.
|
|
32
|
-
|
|
33
|
+
approve, and you're in. No browser on this machine? `bigbongo login --no-browser` prints the
|
|
34
|
+
address to open elsewhere (`BROWSER=<program>` picks the browser). Your session lasts 7 days; run
|
|
35
|
+
`bigbongo login` again to refresh it or `bigbongo logout` to sign out.
|
|
33
36
|
|
|
34
37
|
### 2. Clone your app
|
|
35
38
|
|
|
@@ -38,8 +41,18 @@ bigbongo clone # pick your organization, then your app
|
|
|
38
41
|
bigbongo clone my-app # or name one directly
|
|
39
42
|
```
|
|
40
43
|
|
|
41
|
-
This clones your app into `./my-app`
|
|
42
|
-
|
|
44
|
+
This clones your app into `./my-app` (or into the current, empty folder with `--here`) and
|
|
45
|
+
runs `bigbongo setup` in it, so the folder is ready to build in:
|
|
46
|
+
|
|
47
|
+
- a Python environment in `.venv` with what your app's image installs, `requirements.txt`
|
|
48
|
+
and the test packages;
|
|
49
|
+
- the app's pre-push check, so tests run before every push;
|
|
50
|
+
- Claude Code pointed at your BigBongo credit, for this folder only
|
|
51
|
+
(`.claude/settings.local.json`);
|
|
52
|
+
- git access, so a plain `git push` works from any terminal - no tokens or GitHub setup.
|
|
53
|
+
|
|
54
|
+
Setup only writes inside the app's folder. Run `bigbongo setup` again any time (for example
|
|
55
|
+
after pulling a new `requirements.txt`); with nothing to do it finishes in well under a second.
|
|
43
56
|
|
|
44
57
|
### 3. Edit and deploy
|
|
45
58
|
|
|
@@ -48,9 +61,13 @@ cd my-app
|
|
|
48
61
|
# ...make your changes...
|
|
49
62
|
git add -A
|
|
50
63
|
git commit -m "Update the homepage"
|
|
51
|
-
|
|
64
|
+
bigbongo push # pushes, then follows the deploy to the end
|
|
52
65
|
```
|
|
53
66
|
|
|
67
|
+
`bigbongo push` is `git push` plus the result: it prints each step and ends with
|
|
68
|
+
`Live as v6 https://...`, or with the step that failed and why (a failing test stops the push
|
|
69
|
+
on your machine, before anything is sent). A plain `git push` deploys just the same.
|
|
70
|
+
|
|
54
71
|
Deploys come from the **`main`** branch: every push to `main` is deployed as your app's new
|
|
55
72
|
live version. After `bigbongo clone` you're already on `main`, so a plain `git push` deploys.
|
|
56
73
|
If you prefer to work on a separate branch, merge it into `main` and push to deploy.
|
|
@@ -69,12 +86,15 @@ bigbongo logs # recent logs from your running app
|
|
|
69
86
|
|
|
70
87
|
| command | what it does |
|
|
71
88
|
|---|---|
|
|
72
|
-
| `bigbongo login` | Sign in with your BigBongo account. |
|
|
73
|
-
| `bigbongo clone [app]` | Clone your app
|
|
89
|
+
| `bigbongo login` | Sign in with your BigBongo account. Option: `--no-browser`. |
|
|
90
|
+
| `bigbongo clone [app]` | Clone your app, then run `bigbongo setup` in it. Name an app, or omit it to pick your organization, then the app. Option: `--here` (clone into the current, empty folder). |
|
|
91
|
+
| `bigbongo setup` | Make the app folder ready: Python environment and packages, the pre-push check, Claude Code on BigBongo credit, and git access from any terminal. Safe to repeat. Option: `--quiet`. |
|
|
92
|
+
| `bigbongo push` | `git push`, then follow that commit until it is live (version and address) or failed (step and reason). |
|
|
74
93
|
| `bigbongo status` | Show what's live (version, commit, URL) and any deploy in progress. |
|
|
75
94
|
| `bigbongo logs` | Show recent runtime logs, newest first. Options: `--lines <n>` (default 50, max 500), `--search <text>`, `--level <error\|warn\|info>`. |
|
|
76
|
-
| `bigbongo claude-setup` | Point Claude Code at BigBongo, so coding is billed to your BigBongo credits. Options: `--org <slug>`, `--
|
|
77
|
-
| `bigbongo
|
|
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`. |
|
|
97
|
+
| `bigbongo logout` | Sign out and delete the login and the git, Claude Code and MCP tokens the CLI cached in `~/.bigbongo`. |
|
|
78
98
|
|
|
79
99
|
Run `bigbongo <command> --help` for details on any command.
|
|
80
100
|
|
|
@@ -90,17 +110,33 @@ Anthropic account and no AWS account needed.
|
|
|
90
110
|
|
|
91
111
|
```
|
|
92
112
|
bigbongo login
|
|
93
|
-
bigbongo
|
|
113
|
+
bigbongo clone my-app # setup points Claude Code at BigBongo for this folder
|
|
114
|
+
cd my-app
|
|
94
115
|
claude
|
|
95
116
|
```
|
|
96
117
|
|
|
97
|
-
|
|
118
|
+
For a folder that is not a BigBongo app, run `bigbongo claude-setup` there instead.
|
|
119
|
+
|
|
120
|
+
`claude-setup` writes two keys into a Claude settings file: the BigBongo endpoint, and a
|
|
98
121
|
credential helper. Claude Code then fetches its own short-lived credential whenever it
|
|
99
122
|
needs one and refreshes it on its own. **There is no key to copy and none stored in your
|
|
100
123
|
shell profile.**
|
|
101
124
|
|
|
102
|
-
|
|
103
|
-
|
|
125
|
+
Which file it writes:
|
|
126
|
+
|
|
127
|
+
| how you run it | file written | who it affects |
|
|
128
|
+
|---|---|---|
|
|
129
|
+
| `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. |
|
|
130
|
+
| `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. |
|
|
131
|
+
|
|
132
|
+
It prints the organization whose credit will be used (name and slug) and the file it
|
|
133
|
+
wrote. Run it in each project you want on BigBongo, or once with `--global` if you want
|
|
134
|
+
it everywhere. Add `--org <slug>` if you belong to more than one organization. It will
|
|
135
|
+
not run in your home folder without `--global`, because that is not a project.
|
|
136
|
+
|
|
137
|
+
`--project` still works for older scripts and now means the default. It no longer
|
|
138
|
+
writes the shared `.claude/settings.json`, which gets committed and would hand the
|
|
139
|
+
helper to everyone who clones the repo.
|
|
104
140
|
|
|
105
141
|
A few things differ from a direct Anthropic connection, and it is better to know them up
|
|
106
142
|
front than to discover them mid-task:
|
package/dist/api.js
CHANGED
|
@@ -46,5 +46,7 @@ export const api = {
|
|
|
46
46
|
return req(`/api/cli/apps/${appId}/logs${q ? `?${q}` : ""}`);
|
|
47
47
|
},
|
|
48
48
|
gatewayToken: (org) => req(`/api/cli/gateway-token${org ? `?organization=${encodeURIComponent(org)}` : ""}`, { method: "POST" }),
|
|
49
|
+
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}`),
|
|
49
51
|
logout: () => req("/api/cli/auth/logout", { method: "POST" }),
|
|
50
52
|
};
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
5
|
import { api } from "../api.js";
|
|
5
6
|
import { loadCredentials } from "../config.js";
|
|
7
|
+
import { isInside } from "../util.js";
|
|
6
8
|
export async function claudeSetup(opts = {}) {
|
|
7
9
|
if (!loadCredentials()?.token) {
|
|
8
10
|
console.error("Not logged in. Run `bigbongo login` first.");
|
|
9
11
|
process.exit(1);
|
|
10
12
|
}
|
|
13
|
+
if (opts.project) {
|
|
14
|
+
console.log("--project is now the default: writing .claude/settings.local.json (just you, git-ignored), not the shared .claude/settings.json.");
|
|
15
|
+
}
|
|
16
|
+
const repoRoot = opts.global ? null : gitRoot(process.cwd());
|
|
17
|
+
const projectRoot = opts.global ? null : repoRoot || process.cwd();
|
|
18
|
+
if (projectRoot && resolve(projectRoot) === resolve(homedir())) {
|
|
19
|
+
console.error("This is your home folder, not a project. Run it inside the project you want to use\n" +
|
|
20
|
+
"BigBongo in, or add --global to use it for every project on this computer.");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
11
23
|
let org = opts.org || "";
|
|
12
24
|
let baseUrl = "https://llm.bigbongo.ai";
|
|
13
25
|
try {
|
|
@@ -29,34 +41,97 @@ export async function claudeSetup(opts = {}) {
|
|
|
29
41
|
console.error(e?.body?.error || e?.message || "Could not reach BigBongo.");
|
|
30
42
|
process.exit(1);
|
|
31
43
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
44
|
+
const orgName = await api
|
|
45
|
+
.listOrgs()
|
|
46
|
+
.then((r) => (r?.organizations || []).find((o) => o.slug === org)?.name || "")
|
|
47
|
+
.catch(() => "");
|
|
48
|
+
const settingsPath = projectRoot
|
|
49
|
+
? join(projectRoot, ".claude", "settings.local.json")
|
|
34
50
|
: join(homedir(), ".claude", "settings.json");
|
|
51
|
+
const helper = org ? `bigbongo gateway-token --org ${org}` : "bigbongo gateway-token";
|
|
52
|
+
if (projectRoot && !isInside(projectRoot, settingsPath)) {
|
|
53
|
+
console.error(`${settingsPath} is a link or leads out of ${projectRoot}; refusing to write through it.`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
let written = false;
|
|
57
|
+
try {
|
|
58
|
+
written = writeGatewaySettings(settingsPath, baseUrl, helper);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
console.error(e.message);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
const ignoredIn = repoRoot ? ensureGitIgnored(repoRoot) : "";
|
|
65
|
+
console.log("\n Claude Code is now pointed at BigBongo.\n");
|
|
66
|
+
console.log(` Credit used: ${orgName ? `${orgName} (${org})` : org}`);
|
|
67
|
+
console.log(` ${written ? "File written:" : "Already set: "} ${settingsPath}`);
|
|
68
|
+
console.log(` ANTHROPIC_BASE_URL ${baseUrl}`);
|
|
69
|
+
console.log(` apiKeyHelper ${helper}\n`);
|
|
70
|
+
if (projectRoot) {
|
|
71
|
+
console.log(` Applies only to Claude Code started in ${projectRoot}.`);
|
|
72
|
+
if (ignoredIn)
|
|
73
|
+
console.log(` Added .claude/settings.local.json to ${ignoredIn} so it is never committed.`);
|
|
74
|
+
console.log(" To use BigBongo in every project on this computer instead, run it with --global.\n");
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.log(" Applies to EVERY Claude Code session on this computer, in every project.\n");
|
|
78
|
+
}
|
|
79
|
+
console.log(" Run `claude` as normal. Credits come off that organization's BigBongo balance.");
|
|
80
|
+
console.log(" Nothing to copy - Claude Code fetches and refreshes the credential itself.\n");
|
|
81
|
+
if (process.env.ANTHROPIC_API_KEY) {
|
|
82
|
+
console.log(" Heads up: ANTHROPIC_API_KEY is set in this shell, and it wins over the\n" +
|
|
83
|
+
" helper. Remove it from your shell profile, or this will bill Anthropic\n" +
|
|
84
|
+
" instead of BigBongo.\n");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function writeGatewaySettings(settingsPath, baseUrl, helper) {
|
|
35
88
|
let settings = {};
|
|
36
89
|
if (existsSync(settingsPath)) {
|
|
37
90
|
try {
|
|
38
91
|
settings = JSON.parse(readFileSync(settingsPath, "utf8")) || {};
|
|
39
92
|
}
|
|
40
93
|
catch {
|
|
41
|
-
|
|
94
|
+
throw new Error(`${settingsPath} is not valid JSON. Fix or move it, then run this again -\n` +
|
|
42
95
|
"refusing to overwrite a settings file that might hold your own configuration.");
|
|
43
|
-
process.exit(1);
|
|
44
96
|
}
|
|
45
97
|
}
|
|
46
|
-
|
|
98
|
+
if (typeof settings !== "object" || Array.isArray(settings)) {
|
|
99
|
+
throw new Error(`${settingsPath} must hold a JSON object ({ ... }). Fix or move it, then run this again.`);
|
|
100
|
+
}
|
|
101
|
+
if (settings.env?.ANTHROPIC_BASE_URL === baseUrl && settings.apiKeyHelper === helper)
|
|
102
|
+
return false;
|
|
47
103
|
settings.env = { ...(settings.env || {}), ANTHROPIC_BASE_URL: baseUrl };
|
|
48
104
|
settings.apiKeyHelper = helper;
|
|
49
105
|
mkdirSync(dirname(settingsPath), { recursive: true });
|
|
50
106
|
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
" helper. Remove it from your shell profile, or this will bill Anthropic\n" +
|
|
60
|
-
" instead of BigBongo.\n");
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
function gitRoot(dir) {
|
|
110
|
+
try {
|
|
111
|
+
return resolve(git(dir, ["rev-parse", "--show-toplevel"]));
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return null;
|
|
61
115
|
}
|
|
62
116
|
}
|
|
117
|
+
function ensureGitIgnored(root) {
|
|
118
|
+
const entry = ".claude/settings.local.json";
|
|
119
|
+
try {
|
|
120
|
+
git(root, ["check-ignore", "-q", "--no-index", entry]);
|
|
121
|
+
return "";
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
}
|
|
125
|
+
let gitignore = join(root, ".gitignore");
|
|
126
|
+
if (!isInside(root, gitignore))
|
|
127
|
+
gitignore = resolve(root, git(root, ["rev-parse", "--git-path", "info/exclude"]));
|
|
128
|
+
const current = existsSync(gitignore) ? readFileSync(gitignore, "utf8") : "";
|
|
129
|
+
if (current.split(/\r?\n/).some((line) => line.trim() === entry || line.trim() === `/${entry}`))
|
|
130
|
+
return "";
|
|
131
|
+
mkdirSync(dirname(gitignore), { recursive: true });
|
|
132
|
+
appendFileSync(gitignore, `${current && !current.endsWith("\n") ? "\n" : ""}${entry}\n`);
|
|
133
|
+
return gitignore;
|
|
134
|
+
}
|
|
135
|
+
function git(cwd, args) {
|
|
136
|
+
return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
137
|
+
}
|
package/dist/commands/clone.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { readdirSync } from "node:fs";
|
|
1
2
|
import { join } from "node:path";
|
|
2
3
|
import { api } from "../api.js";
|
|
3
4
|
import { loadCredentials, saveProject } from "../config.js";
|
|
4
5
|
import { cloneApp } from "../git.js";
|
|
5
6
|
import { pickOne } from "../prompt.js";
|
|
6
7
|
import { isSafeAppSlug } from "../util.js";
|
|
8
|
+
import { setup } from "./setup.js";
|
|
7
9
|
function requireAuth() {
|
|
8
10
|
const c = loadCredentials();
|
|
9
11
|
if (!c?.token) {
|
|
@@ -36,7 +38,7 @@ async function pickApp(group, allowBack) {
|
|
|
36
38
|
const picked = await pickOne(`Pick an app to clone in ${group.name}`, choices);
|
|
37
39
|
return picked === BACK ? undefined : picked;
|
|
38
40
|
}
|
|
39
|
-
export async function clone(appArg) {
|
|
41
|
+
export async function clone(appArg, opts = {}) {
|
|
40
42
|
const cred = requireAuth();
|
|
41
43
|
const { apps } = await api.listApps();
|
|
42
44
|
if (!apps?.length) {
|
|
@@ -79,10 +81,16 @@ export async function clone(appArg) {
|
|
|
79
81
|
console.error(`Refusing to clone: unexpected app slug '${app.app_slug}'.`);
|
|
80
82
|
process.exit(1);
|
|
81
83
|
}
|
|
84
|
+
const dir = opts.here ? process.cwd() : join(process.cwd(), app.app_slug);
|
|
85
|
+
if (opts.here && readdirSync(dir).length) {
|
|
86
|
+
console.error("--here clones into the current folder, and it is not empty. Run it in an empty folder.");
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
82
89
|
const { token, repo_url } = await api.gitToken(app.id, "read");
|
|
83
|
-
const dir = join(process.cwd(), app.app_slug);
|
|
84
90
|
await cloneApp(repo_url, token, dir, { name: cred.email, email: cred.email });
|
|
85
91
|
saveProject({ app_id: app.id, org_id: app.org_id, app_slug: app.app_slug, repo_url }, dir);
|
|
86
|
-
console.log(`\nCloned ${app.app_slug} into
|
|
87
|
-
|
|
92
|
+
console.log(`\nCloned ${app.app_slug} into ${opts.here ? "this folder" : `./${app.app_slug}`}`);
|
|
93
|
+
await setup({ dir });
|
|
94
|
+
if (!opts.here)
|
|
95
|
+
console.log(`Next: cd ${app.app_slug}`);
|
|
88
96
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import { api } from "../api.js";
|
|
2
|
-
import {
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { CREDENTIAL_FILES, clearCachedGatewayTokens, clearCachedGitTokens, clearCachedMcpTokens, 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
|
-
|
|
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
|
+
["the cached MCP tokens", clearCachedMcpTokens],
|
|
20
|
+
]) {
|
|
21
|
+
try {
|
|
22
|
+
clear();
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
failed.push(`${what} (${e?.code || e?.message || e})`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (failed.length) {
|
|
29
|
+
const server = revoked ? "Logged out on the server, but" : "Could not log out on the server, and";
|
|
30
|
+
console.error(`${server} could not delete ${failed.join(", ")} in ${dirname(CREDENTIAL_FILES[0])}.`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
12
33
|
console.log("Logged out.");
|
|
13
34
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { api } from "../api.js";
|
|
2
|
+
import { findProjectUp, loadCachedMcpHeaders, loadCredentials, saveCachedMcpHeaders } from "../config.js";
|
|
3
|
+
export async function mcpToken(appArg) {
|
|
4
|
+
if (!loadCredentials()?.token)
|
|
5
|
+
fail("Not logged in to BigBongo. Run `bigbongo login`.");
|
|
6
|
+
const appId = appArg || findProjectUp(process.cwd())?.app_id;
|
|
7
|
+
if (!appId)
|
|
8
|
+
fail("No app here: run this inside a cloned app folder, or pass the app id.");
|
|
9
|
+
const cached = loadCachedMcpHeaders(appId);
|
|
10
|
+
if (cached) {
|
|
11
|
+
process.stdout.write(JSON.stringify(cached));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const r = await api.mcpToken(appId);
|
|
16
|
+
saveCachedMcpHeaders(appId, { headers: r.headers, expires_at: r.expires_at });
|
|
17
|
+
process.stdout.write(JSON.stringify(r.headers));
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
if (e?.status === 401)
|
|
21
|
+
fail("Your BigBongo login has expired. Run `bigbongo login` again.");
|
|
22
|
+
if (e?.status === 404)
|
|
23
|
+
fail("This login cannot reach this app (or it no longer exists).");
|
|
24
|
+
fail(e?.body?.error || e?.message || "Could not fetch an MCP token from BigBongo.");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function fail(message) {
|
|
28
|
+
process.stderr.write(message + "\n");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import { api } from "../api.js";
|
|
3
|
+
import { findProjectUp, loadCredentials } from "../config.js";
|
|
4
|
+
import { sleep } from "../util.js";
|
|
5
|
+
import { appWorkTree } from "./setup.js";
|
|
6
|
+
export async function push(opts = {}) {
|
|
7
|
+
const project = findProjectUp(process.cwd());
|
|
8
|
+
if (!project)
|
|
9
|
+
fail("Not in a BigBongo app folder (no .bigbongo.json here or above).");
|
|
10
|
+
const root = appWorkTree(process.cwd());
|
|
11
|
+
if (!root)
|
|
12
|
+
fail("Not in this app's git repository. Run `bigbongo push` in the app's folder.");
|
|
13
|
+
if (!loadCredentials()?.token)
|
|
14
|
+
fail("Not logged in. Run `bigbongo login` first.");
|
|
15
|
+
const pushed = await gitPush(root);
|
|
16
|
+
if (pushed.code !== 0) {
|
|
17
|
+
const why = explainPushFailure(pushed.output);
|
|
18
|
+
console.error(`\n✗ Failed at ${why.step}`);
|
|
19
|
+
for (const line of why.reason)
|
|
20
|
+
console.error(` ${line}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const branch = git(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
24
|
+
if (branch !== "main") {
|
|
25
|
+
console.log(`\nPushed ${branch}. Only the main branch deploys, so there is no build to follow.`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const sha = git(root, ["rev-parse", "HEAD"]);
|
|
29
|
+
console.log(`\nFollowing ${sha.slice(0, 7)} on BigBongo...`);
|
|
30
|
+
const ok = await follow(project.app_id, sha, opts);
|
|
31
|
+
if (!ok)
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
function gitPush(cwd) {
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
let output = "";
|
|
37
|
+
const child = spawn("git", ["push"], { cwd, stdio: ["inherit", "pipe", "pipe"] });
|
|
38
|
+
child.stdout.on("data", (c) => { output += c; process.stdout.write(c); });
|
|
39
|
+
child.stderr.on("data", (c) => { output += c; process.stderr.write(c); });
|
|
40
|
+
child.on("error", (e) => resolve({ code: 1, output: `${output}\nerror: ${e.message}` }));
|
|
41
|
+
child.on("close", (code) => resolve({ code: code ?? 1, output }));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function explainPushFailure(raw) {
|
|
45
|
+
const lines = raw.replace(/\x1b\[[0-9;]*m/g, "").split(/\r?\n/).map((l) => l.trimEnd()).filter(Boolean);
|
|
46
|
+
const text = lines.join("\n");
|
|
47
|
+
if (/Pre-push checks failed|hook declined|failed to push some refs/.test(text) && /^FAIL /m.test(text)) {
|
|
48
|
+
const failed = lines.filter((l) => /^(FAIL |FAILED |ERROR )/.test(l));
|
|
49
|
+
return { step: "the pre-push check on this computer (nothing was sent)", reason: failed };
|
|
50
|
+
}
|
|
51
|
+
if (/\[rejected\].*\((fetch first|non-fast-forward)\)/.test(text)) {
|
|
52
|
+
return {
|
|
53
|
+
step: "git push: main on BigBongo has changes you do not have",
|
|
54
|
+
reason: ["Someone (or BigBongo, for example an app update) pushed since you last pulled.",
|
|
55
|
+
"Run `git pull`, then `bigbongo push` again."],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (/Authentication failed|could not read Username|terminal prompts disabled|returned error: 403/.test(text)) {
|
|
59
|
+
return { step: "git push: GitHub refused the sign-in", reason: ["Run `bigbongo login`, then `bigbongo setup`, and push again."] };
|
|
60
|
+
}
|
|
61
|
+
const errors = lines.filter((l) => /^(error|fatal|remote: error)/i.test(l));
|
|
62
|
+
return { step: "git push", reason: (errors.length ? errors : lines).slice(-8) };
|
|
63
|
+
}
|
|
64
|
+
const MARK = { done: "✓", failed: "✗", in_progress: "…", running: "…" };
|
|
65
|
+
export async function follow(appId, sha, opts = {}) {
|
|
66
|
+
const pollMs = opts.pollMs ?? 3000;
|
|
67
|
+
const started = Date.now();
|
|
68
|
+
const printed = new Map();
|
|
69
|
+
let errors = 0;
|
|
70
|
+
let saidWaiting = false;
|
|
71
|
+
for (;;) {
|
|
72
|
+
let r;
|
|
73
|
+
try {
|
|
74
|
+
r = await api.pushResult(appId, sha);
|
|
75
|
+
errors = 0;
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
if (e?.status === 401)
|
|
79
|
+
fail("Your BigBongo login has expired. Run `bigbongo login`; the push itself went through.");
|
|
80
|
+
if (e?.status === 404)
|
|
81
|
+
fail("BigBongo does not know this app for your login (the push itself went through).");
|
|
82
|
+
if (++errors >= 5)
|
|
83
|
+
fail(`Lost contact with BigBongo (${e?.message || e}). Check later with \`bigbongo status\`.`);
|
|
84
|
+
await sleep(pollMs);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
for (const step of r.steps || []) {
|
|
88
|
+
const mark = MARK[step.status];
|
|
89
|
+
if (mark && printed.get(step.title) !== step.status) {
|
|
90
|
+
printed.set(step.title, step.status);
|
|
91
|
+
console.log(` ${mark} ${step.title}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (r.state === "live") {
|
|
95
|
+
console.log(`\nLive as v${r.version} ${r.url || ""}`.trimEnd());
|
|
96
|
+
if (r.serving === false)
|
|
97
|
+
console.log("(A later push or a rollback has replaced it since.)");
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
if (r.state === "failed") {
|
|
101
|
+
console.error(`\n✗ Failed at ${r.failed_step || "the build"}: ${r.reason || "no reason given"}`);
|
|
102
|
+
const detail = String(r.detail || "").trim().split(/\r?\n/).filter(Boolean).slice(-25);
|
|
103
|
+
if (detail.length)
|
|
104
|
+
console.error(detail.map((l) => ` ${l}`).join("\n"));
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (r.state === "skipped") {
|
|
108
|
+
console.error(`\n✗ Not deployed: ${r.reason || "the push was refused"}`);
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (r.state === "waiting") {
|
|
112
|
+
if (!saidWaiting) {
|
|
113
|
+
console.log(" Waiting for the build to start...");
|
|
114
|
+
saidWaiting = true;
|
|
115
|
+
}
|
|
116
|
+
if (Date.now() - started > (opts.waitStartMs ?? 3 * 60_000)) {
|
|
117
|
+
console.error(`\n✗ ${r.reason || "No build started for this commit."}`);
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const limit = opts.timeoutMs ?? 20 * 60_000;
|
|
122
|
+
if (Date.now() - started > limit) {
|
|
123
|
+
console.error(`\n✗ Still not finished after ${Math.max(1, Math.round(limit / 60_000))} minutes. Check later with \`bigbongo status\`.`);
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
await sleep(pollMs);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function git(cwd, args) {
|
|
130
|
+
return (spawnSync("git", args, { cwd, encoding: "utf8" }).stdout || "").trim();
|
|
131
|
+
}
|
|
132
|
+
function fail(message) {
|
|
133
|
+
console.error(message);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { apiBase } from "../api.js";
|
|
8
|
+
import { findProjectRootUp, findProjectUp, loadCredentials } from "../config.js";
|
|
9
|
+
import { isInside } from "../util.js";
|
|
10
|
+
import { writeGatewaySettings } from "./claudeSetup.js";
|
|
11
|
+
const SDK_INSTALL = "./vendor/platform-sdk[django,llm,connections]";
|
|
12
|
+
const TEST_PACKAGES = ["pytest", "pytest-django"];
|
|
13
|
+
export const HELPER_FILES = [
|
|
14
|
+
"helper.js",
|
|
15
|
+
"commands/gitToken.js",
|
|
16
|
+
"commands/gatewayToken.js",
|
|
17
|
+
"api.js",
|
|
18
|
+
"config.js",
|
|
19
|
+
"util.js",
|
|
20
|
+
];
|
|
21
|
+
const HELPER_DIR = "bigbongo-helper";
|
|
22
|
+
const EXCLUDED = [".claude/settings.local.json", ".venv/", ".claude/worktrees/"];
|
|
23
|
+
export const PRE_PUSH_WRAPPER = `#!/bin/sh
|
|
24
|
+
# Written by bigbongo clone: runs this app's own pre-push check before every push.
|
|
25
|
+
# A checkout without the check (an older branch) pushes as before.
|
|
26
|
+
[ -f ./.githooks/pre-push ] || exit 0
|
|
27
|
+
exec bash ./.githooks/pre-push "$@"
|
|
28
|
+
`;
|
|
29
|
+
class Report {
|
|
30
|
+
quiet;
|
|
31
|
+
problems = [];
|
|
32
|
+
constructor(quiet) {
|
|
33
|
+
this.quiet = quiet;
|
|
34
|
+
}
|
|
35
|
+
ok(line) { if (!this.quiet)
|
|
36
|
+
console.log(` ✓ ${line}`); }
|
|
37
|
+
note(line) { if (!this.quiet)
|
|
38
|
+
console.log(` ${line}`); }
|
|
39
|
+
fail(line) { this.problems.push(line); console.error(` ✗ ${line}`); }
|
|
40
|
+
}
|
|
41
|
+
export async function setup(opts = {}) {
|
|
42
|
+
const start = opts.dir ? resolve(opts.dir) : process.cwd();
|
|
43
|
+
const project = findProjectUp(start);
|
|
44
|
+
if (!project) {
|
|
45
|
+
console.error("This is not a BigBongo app folder (no .bigbongo.json here or above).");
|
|
46
|
+
console.error("Run `bigbongo clone <app>` first, or run this inside the app's folder.");
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const git = version("git", ["--version"], /git version (\S+)/);
|
|
50
|
+
if (!git) {
|
|
51
|
+
console.error(` ✗ git is not installed. ${installHint("git")}`);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const root = appWorkTree(start);
|
|
55
|
+
if (!root) {
|
|
56
|
+
console.error("This app folder is not a git repository of this app. Clone it again with `bigbongo clone`,");
|
|
57
|
+
console.error("or run setup in the app's own folder (not in another repository inside it).");
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const r = new Report(!!opts.quiet);
|
|
61
|
+
if (!opts.quiet)
|
|
62
|
+
console.log(`\nSetting up ${project.app_slug} in ${root}\n`);
|
|
63
|
+
r.ok(`git ${git}`);
|
|
64
|
+
r.ok(`Node ${process.versions.node}`);
|
|
65
|
+
excludeFromGit(root);
|
|
66
|
+
const helper = installHelper(root, opts.sourceDir);
|
|
67
|
+
const runHelper = helper ? `node ${shQuote(helper)}` : "bigbongo";
|
|
68
|
+
if (helper || version("bigbongo", ["--version"], /(\d+\.\d+\.\d+)/)) {
|
|
69
|
+
setUpGitPush(root, runHelper);
|
|
70
|
+
r.ok("git push works from any terminal");
|
|
71
|
+
if (!helper)
|
|
72
|
+
r.note("(using `bigbongo` from your PATH: the helper copy could not be made)");
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
r.fail("Could not copy the git and Claude Code helper, and no `bigbongo` is on the PATH. Install it with `npm install -g @bigbongo/cli`, then run setup again.");
|
|
76
|
+
}
|
|
77
|
+
enablePrePushCheck(root, r);
|
|
78
|
+
if (helper || !r.problems.length)
|
|
79
|
+
setUpClaudeCode(root, project.org_id, runHelper, r);
|
|
80
|
+
setUpPython(root, r, !!opts.quiet);
|
|
81
|
+
if (!opts.quiet) {
|
|
82
|
+
console.log(r.problems.length
|
|
83
|
+
? "\nNot done yet: fix the lines marked ✗, then run `bigbongo setup` again.\n"
|
|
84
|
+
: "\nReady. Start Claude Code here with `claude`, and push with `bigbongo push`.\n");
|
|
85
|
+
}
|
|
86
|
+
return r.problems.length === 0;
|
|
87
|
+
}
|
|
88
|
+
export async function setupCommand(opts) {
|
|
89
|
+
if (!(await setup({ quiet: opts.quiet })))
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
export function appWorkTree(start) {
|
|
93
|
+
const projectRoot = findProjectRootUp(start);
|
|
94
|
+
const top = gitRun(start, ["rev-parse", "--show-toplevel"]).out.trim();
|
|
95
|
+
if (!projectRoot || !top)
|
|
96
|
+
return null;
|
|
97
|
+
const real = (dir) => { try {
|
|
98
|
+
return realpathSync(dir);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return "";
|
|
102
|
+
} };
|
|
103
|
+
const common = (dir) => {
|
|
104
|
+
const out = gitRun(dir, ["rev-parse", "--git-common-dir"]).out.trim();
|
|
105
|
+
return out ? real(resolve(dir, out)) : "";
|
|
106
|
+
};
|
|
107
|
+
if (real(gitRun(projectRoot, ["rev-parse", "--show-toplevel"]).out.trim()) !== real(projectRoot))
|
|
108
|
+
return null;
|
|
109
|
+
const ours = common(projectRoot);
|
|
110
|
+
return ours && ours === common(start) ? resolve(top) : null;
|
|
111
|
+
}
|
|
112
|
+
function setUpGitPush(root, runHelper) {
|
|
113
|
+
const command = `!${runHelper} git-token --helper`;
|
|
114
|
+
const current = gitRun(root, ["config", "--local", "--get-all", "credential.helper"]).out;
|
|
115
|
+
if (current !== `\n${command}\n`) {
|
|
116
|
+
gitRun(root, ["config", "--local", "--unset-all", "credential.helper"]);
|
|
117
|
+
gitRun(root, ["config", "--local", "--add", "credential.helper", ""]);
|
|
118
|
+
gitRun(root, ["config", "--local", "--add", "credential.helper", command]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function installHelper(root, sourceDir = distDir()) {
|
|
122
|
+
const common = gitRun(root, ["rev-parse", "--git-common-dir"]).out.trim();
|
|
123
|
+
if (!common)
|
|
124
|
+
return "";
|
|
125
|
+
const gitDir = resolve(root, common);
|
|
126
|
+
const dest = join(gitDir, HELPER_DIR);
|
|
127
|
+
for (const file of HELPER_FILES) {
|
|
128
|
+
if (!existsSync(join(sourceDir, file)))
|
|
129
|
+
return "";
|
|
130
|
+
}
|
|
131
|
+
const files = [
|
|
132
|
+
...HELPER_FILES.map((f) => [f, readFileSync(join(sourceDir, f), "utf8")]),
|
|
133
|
+
["package.json", '{ "type": "module" }\n'],
|
|
134
|
+
];
|
|
135
|
+
for (const [file, content] of files) {
|
|
136
|
+
const target = join(dest, file);
|
|
137
|
+
if (!isInside(gitDir, target))
|
|
138
|
+
return "";
|
|
139
|
+
if (existsSync(target) && readFileSync(target, "utf8") === content)
|
|
140
|
+
continue;
|
|
141
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
142
|
+
writeFileSync(target, content);
|
|
143
|
+
}
|
|
144
|
+
return toPosix(join(dest, "helper.js"));
|
|
145
|
+
}
|
|
146
|
+
function distDir() {
|
|
147
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
148
|
+
}
|
|
149
|
+
function excludeFromGit(root) {
|
|
150
|
+
const exclude = resolve(root, gitRun(root, ["rev-parse", "--git-path", "info/exclude"]).out.trim());
|
|
151
|
+
const current = existsSync(exclude) ? readFileSync(exclude, "utf8") : "";
|
|
152
|
+
const lines = current.split(/\r?\n/).map((l) => l.trim());
|
|
153
|
+
const missing = EXCLUDED.filter((entry) => !lines.includes(entry));
|
|
154
|
+
if (!missing.length)
|
|
155
|
+
return;
|
|
156
|
+
mkdirSync(dirname(exclude), { recursive: true });
|
|
157
|
+
appendFileSync(exclude, `${current && !current.endsWith("\n") ? "\n" : ""}${missing.join("\n")}\n`);
|
|
158
|
+
}
|
|
159
|
+
export function enablePrePushCheck(root, r) {
|
|
160
|
+
if (!existsSync(join(root, ".githooks", "pre-push"))) {
|
|
161
|
+
r.note("This app has no pre-push check (.githooks/pre-push); nothing to turn on.");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const notice = (why) => {
|
|
165
|
+
r.note(`${why}, so the app's pre-push check is not turned on.`);
|
|
166
|
+
r.note("To run it before each push, call .githooks/pre-push from your pre-push hook.");
|
|
167
|
+
};
|
|
168
|
+
const hooksPath = gitRun(root, ["config", "--get", "core.hooksPath"]).out.trim();
|
|
169
|
+
if (hooksPath)
|
|
170
|
+
return notice(`Your git uses its own hooks folder (${hooksPath})`);
|
|
171
|
+
const hook = resolve(root, gitRun(root, ["rev-parse", "--git-path", "hooks/pre-push"]).out.trim());
|
|
172
|
+
if (existsSync(hook)) {
|
|
173
|
+
if (readFileSync(hook, "utf8") === PRE_PUSH_WRAPPER)
|
|
174
|
+
return r.ok("pre-push check on");
|
|
175
|
+
return notice("This clone already has a pre-push hook");
|
|
176
|
+
}
|
|
177
|
+
mkdirSync(dirname(hook), { recursive: true });
|
|
178
|
+
writeFileSync(hook, PRE_PUSH_WRAPPER);
|
|
179
|
+
chmodSync(hook, 0o755);
|
|
180
|
+
r.ok("pre-push check on");
|
|
181
|
+
}
|
|
182
|
+
function setUpClaudeCode(root, orgId, runHelper, r) {
|
|
183
|
+
if (resolve(root) === resolve(homedir())) {
|
|
184
|
+
r.fail("The app folder is your home folder; refusing to write Claude Code settings there.");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (!loadCredentials()?.token) {
|
|
188
|
+
r.fail("Not logged in, so Claude Code is not set up on BigBongo credit. Run `bigbongo login`, then `bigbongo setup`.");
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const org = /^[A-Za-z0-9-]+$/.test(orgId || "") ? ` --org ${orgId}` : "";
|
|
192
|
+
const helper = `${runHelper} gateway-token${org}`;
|
|
193
|
+
const settingsPath = join(root, ".claude", "settings.local.json");
|
|
194
|
+
if (!isInside(root, settingsPath)) {
|
|
195
|
+
r.fail(".claude/settings.local.json is a link or leads out of this folder; refusing to write through it.");
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
writeGatewaySettings(settingsPath, apiBase(), helper);
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
r.fail(e.message);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
r.ok("Claude Code uses BigBongo credit (.claude/settings.local.json)");
|
|
206
|
+
}
|
|
207
|
+
function setUpPython(root, r, quiet) {
|
|
208
|
+
const venvPython = join(root, ".venv", process.platform === "win32" ? "Scripts/python.exe" : "bin/python");
|
|
209
|
+
if (gitRun(root, ["ls-files", ".venv"]).out.trim()) {
|
|
210
|
+
r.fail(".venv is committed to git; setup only uses an environment it makes. Remove it from git, then run setup again.");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
let venvVersion = existsSync(venvPython) ? pythonVersion(venvPython, []) : null;
|
|
214
|
+
if (venvVersion && !atLeast312(venvVersion)) {
|
|
215
|
+
r.fail(`.venv has Python ${venvVersion}; this app needs 3.12 or newer. Delete .venv and run \`bigbongo setup\` again.`);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const uv = version("uv", ["--version"], /uv (\S+)/);
|
|
219
|
+
if (!venvVersion) {
|
|
220
|
+
const python = findPython();
|
|
221
|
+
if (!python) {
|
|
222
|
+
r.fail(`Python 3.12 or newer is not installed. ${installHint("python")}`);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const made = uv
|
|
226
|
+
? run("uv", ["venv", "--python", python.version, ".venv"], root)
|
|
227
|
+
: run(python.cmd, [...python.pre, "-m", "venv", ".venv"], root);
|
|
228
|
+
venvVersion = made.ok ? pythonVersion(venvPython, []) : null;
|
|
229
|
+
if (!venvVersion) {
|
|
230
|
+
r.fail(`Could not make .venv: ${lastLines(made.out)}`);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
r.ok(`Python ${venvVersion} in .venv (made with ${uv ? "uv" : "python -m venv"})`);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
r.ok(`Python ${venvVersion} in .venv`);
|
|
237
|
+
}
|
|
238
|
+
const args = [
|
|
239
|
+
...imagePackages(root),
|
|
240
|
+
...(existsSync(join(root, "requirements.txt")) ? ["-r", "requirements.txt"] : []),
|
|
241
|
+
...TEST_PACKAGES,
|
|
242
|
+
];
|
|
243
|
+
const marker = join(root, ".venv", ".bigbongo-setup");
|
|
244
|
+
const fingerprint = packagesFingerprint(root, venvVersion, args);
|
|
245
|
+
if (existsSync(marker) && readFileSync(marker, "utf8") === fingerprint) {
|
|
246
|
+
r.ok("packages up to date");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (!quiet)
|
|
250
|
+
console.log(" installing the packages...");
|
|
251
|
+
const installed = uv
|
|
252
|
+
? run("uv", ["pip", "install", "--python", venvPython, ...args], root, !quiet)
|
|
253
|
+
: run(venvPython, ["-m", "pip", "install", "--disable-pip-version-check", ...args], root, !quiet);
|
|
254
|
+
if (!installed.ok) {
|
|
255
|
+
r.fail(`Installing the packages failed${installed.out ? `:\n${lastLines(installed.out)}` : " (the reason is above)"}`);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
writeFileSync(marker, fingerprint);
|
|
259
|
+
r.ok("packages installed: what the app's image installs, requirements.txt, pytest");
|
|
260
|
+
}
|
|
261
|
+
const SDK_ARG = /^\.\/vendor\/platform-sdk(\[[A-Za-z0-9,._-]+\])?$/;
|
|
262
|
+
const PLAIN_PACKAGE = /^[A-Za-z0-9][A-Za-z0-9._-]*(\[[A-Za-z0-9,._-]+\])?((==|>=|<=|~=|!=|<|>)[A-Za-z0-9.*+!-]+)?$/;
|
|
263
|
+
export function imagePackages(root) {
|
|
264
|
+
const dockerfile = join(root, "Dockerfile");
|
|
265
|
+
const sdk = existsSync(join(root, "vendor", "platform-sdk", "pyproject.toml")) ? [SDK_INSTALL] : [];
|
|
266
|
+
if (!existsSync(dockerfile))
|
|
267
|
+
return sdk;
|
|
268
|
+
const packages = [];
|
|
269
|
+
for (const line of readFileSync(dockerfile, "utf8").split(/\r?\n/)) {
|
|
270
|
+
const m = /^RUN\s+(?:python\s+-m\s+)?pip install\s+(.+)$/.exec(line.trim());
|
|
271
|
+
if (!m || /--no-index|(^|\s)-r\s/.test(m[1]))
|
|
272
|
+
continue;
|
|
273
|
+
for (const word of m[1].split("&&")[0].trim().split(/\s+/)) {
|
|
274
|
+
const arg = word.replace(/^["']|["']$/g, "");
|
|
275
|
+
if (SDK_ARG.test(arg) || PLAIN_PACKAGE.test(arg))
|
|
276
|
+
packages.push(arg);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (!packages.some((p) => SDK_ARG.test(p)))
|
|
280
|
+
packages.unshift(...sdk);
|
|
281
|
+
return packages;
|
|
282
|
+
}
|
|
283
|
+
function packagesFingerprint(root, pythonVer, args) {
|
|
284
|
+
const sdk = gitRun(root, ["rev-parse", "HEAD:vendor/platform-sdk"]).out.trim();
|
|
285
|
+
const req = join(root, "requirements.txt");
|
|
286
|
+
return createHash("sha256")
|
|
287
|
+
.update(JSON.stringify({ pythonVer, sdk, req: existsSync(req) ? readFileSync(req, "utf8") : "", args }))
|
|
288
|
+
.digest("hex");
|
|
289
|
+
}
|
|
290
|
+
function findPython() {
|
|
291
|
+
const candidates = process.platform === "win32"
|
|
292
|
+
? [["py", ["-3.13"]], ["py", ["-3.12"]], ["python", []]]
|
|
293
|
+
: [["python3.13", []], ["python3.12", []], ["python3", []], ["python", []]];
|
|
294
|
+
for (const [cmd, pre] of candidates) {
|
|
295
|
+
const v = pythonVersion(cmd, pre);
|
|
296
|
+
if (v && atLeast312(v))
|
|
297
|
+
return { cmd, pre, version: v.split(".").slice(0, 2).join(".") };
|
|
298
|
+
}
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
function pythonVersion(cmd, pre) {
|
|
302
|
+
return version(cmd, [...pre, "--version"], /Python (\d+\.\d+(?:\.\d+)?)/);
|
|
303
|
+
}
|
|
304
|
+
function atLeast312(v) {
|
|
305
|
+
const [major, minor] = v.split(".").map(Number);
|
|
306
|
+
return major > 3 || (major === 3 && minor >= 12);
|
|
307
|
+
}
|
|
308
|
+
function installHint(tool) {
|
|
309
|
+
const hints = {
|
|
310
|
+
git: {
|
|
311
|
+
darwin: "Install it with `xcode-select --install` (or `brew install git`)",
|
|
312
|
+
win32: "Install it with `winget install Git.Git`",
|
|
313
|
+
other: "Install it with your package manager, for example `sudo apt install git`",
|
|
314
|
+
},
|
|
315
|
+
python: {
|
|
316
|
+
darwin: "Install it with `brew install python@3.13`, or from https://www.python.org/downloads/",
|
|
317
|
+
win32: "Install it with `winget install Python.Python.3.13`",
|
|
318
|
+
other: "Install it with your package manager, for example `sudo apt install python3.12 python3.12-venv`",
|
|
319
|
+
},
|
|
320
|
+
}[tool];
|
|
321
|
+
const platform = process.platform === "darwin" || process.platform === "win32" ? process.platform : "other";
|
|
322
|
+
return `${hints[platform]}, then run \`bigbongo setup\` again.`;
|
|
323
|
+
}
|
|
324
|
+
function run(cmd, args, cwd, show = false) {
|
|
325
|
+
const res = spawnSync(cmd, args, { cwd, encoding: "utf8", stdio: show ? "inherit" : "pipe" });
|
|
326
|
+
return { ok: res.status === 0, out: `${res.stdout || ""}${res.stderr || ""}` || String(res.error?.message || "") };
|
|
327
|
+
}
|
|
328
|
+
function gitRun(cwd, args) {
|
|
329
|
+
const res = spawnSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
330
|
+
return { ok: res.status === 0, out: res.stdout || "" };
|
|
331
|
+
}
|
|
332
|
+
function version(cmd, args, re) {
|
|
333
|
+
const res = spawnSync(cmd, args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
334
|
+
if (res.status !== 0)
|
|
335
|
+
return null;
|
|
336
|
+
return re.exec(`${res.stdout || ""}${res.stderr || ""}`)?.[1] ?? null;
|
|
337
|
+
}
|
|
338
|
+
function lastLines(text, n = 20) {
|
|
339
|
+
return text.trim().split(/\r?\n/).slice(-n).join("\n");
|
|
340
|
+
}
|
|
341
|
+
function shQuote(path) {
|
|
342
|
+
return `'${toPosix(path).replace(/'/g, `'\\''`)}'`;
|
|
343
|
+
}
|
|
344
|
+
function toPosix(path) {
|
|
345
|
+
return path.replace(/\\/g, "/");
|
|
346
|
+
}
|
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) {
|
|
@@ -8,6 +8,8 @@ export function saveCredentials(c) {
|
|
|
8
8
|
chmodSync(DIR, 0o700);
|
|
9
9
|
writeFileSync(CRED, JSON.stringify(c, null, 2));
|
|
10
10
|
chmodSync(CRED, 0o600);
|
|
11
|
+
for (const cache of [GIT_TOKENS, GATEWAY_TOKENS, MCP_TOKENS])
|
|
12
|
+
rmSync(cache, { force: true });
|
|
11
13
|
}
|
|
12
14
|
export function loadCredentials() {
|
|
13
15
|
if (!existsSync(CRED))
|
|
@@ -20,10 +22,7 @@ export function loadCredentials() {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
export function clearCredentials() {
|
|
23
|
-
|
|
24
|
-
writeFileSync(CRED, "{}");
|
|
25
|
-
chmodSync(CRED, 0o600);
|
|
26
|
-
}
|
|
25
|
+
rmSync(CRED, { force: true });
|
|
27
26
|
}
|
|
28
27
|
const GIT_TOKENS = join(DIR, "git-tokens.json");
|
|
29
28
|
const TOKEN_REFRESH_SKEW_MS = 5 * 60 * 1000;
|
|
@@ -74,18 +73,21 @@ export function loadProject(dir = process.cwd()) {
|
|
|
74
73
|
export function saveProject(cfg, dir = process.cwd()) {
|
|
75
74
|
writeFileSync(join(dir, ".bigbongo.json"), JSON.stringify(cfg, null, 2));
|
|
76
75
|
}
|
|
77
|
-
export function
|
|
76
|
+
export function findProjectRootUp(startDir = process.cwd()) {
|
|
78
77
|
let dir = startDir;
|
|
79
78
|
for (;;) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return cfg;
|
|
79
|
+
if (loadProject(dir))
|
|
80
|
+
return dir;
|
|
83
81
|
const parent = dirname(dir);
|
|
84
82
|
if (parent === dir)
|
|
85
83
|
return null;
|
|
86
84
|
dir = parent;
|
|
87
85
|
}
|
|
88
86
|
}
|
|
87
|
+
export function findProjectUp(startDir = process.cwd()) {
|
|
88
|
+
const root = findProjectRootUp(startDir);
|
|
89
|
+
return root ? loadProject(root) : null;
|
|
90
|
+
}
|
|
89
91
|
const GATEWAY_TOKENS = join(DIR, "gateway-tokens.json");
|
|
90
92
|
function readGatewayCache() {
|
|
91
93
|
try {
|
|
@@ -113,8 +115,38 @@ export function saveCachedGatewayToken(org, entry) {
|
|
|
113
115
|
chmodSync(GATEWAY_TOKENS, 0o600);
|
|
114
116
|
}
|
|
115
117
|
export function clearCachedGatewayTokens() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
rmSync(GATEWAY_TOKENS, { force: true });
|
|
119
|
+
}
|
|
120
|
+
const MCP_TOKENS = join(DIR, "mcp-tokens.json");
|
|
121
|
+
function readMcpCache() {
|
|
122
|
+
try {
|
|
123
|
+
return JSON.parse(readFileSync(MCP_TOKENS, "utf8"));
|
|
119
124
|
}
|
|
125
|
+
catch {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export function loadCachedMcpHeaders(appId) {
|
|
130
|
+
const entry = readMcpCache()[appId];
|
|
131
|
+
if (!entry?.headers || !entry?.expires_at)
|
|
132
|
+
return null;
|
|
133
|
+
const remaining = new Date(entry.expires_at).getTime() - Date.now();
|
|
134
|
+
if (!(remaining > TOKEN_REFRESH_SKEW_MS))
|
|
135
|
+
return null;
|
|
136
|
+
return entry.headers;
|
|
137
|
+
}
|
|
138
|
+
export function saveCachedMcpHeaders(appId, entry) {
|
|
139
|
+
const all = readMcpCache();
|
|
140
|
+
all[appId] = entry;
|
|
141
|
+
mkdirSync(DIR, { recursive: true });
|
|
142
|
+
chmodSync(DIR, 0o700);
|
|
143
|
+
writeFileSync(MCP_TOKENS, JSON.stringify(all));
|
|
144
|
+
chmodSync(MCP_TOKENS, 0o600);
|
|
145
|
+
}
|
|
146
|
+
export function clearCachedMcpTokens() {
|
|
147
|
+
rmSync(MCP_TOKENS, { force: true });
|
|
148
|
+
}
|
|
149
|
+
export function clearCachedGitTokens() {
|
|
150
|
+
rmSync(GIT_TOKENS, { force: true });
|
|
120
151
|
}
|
|
152
|
+
export const CREDENTIAL_FILES = [CRED, GIT_TOKENS, GATEWAY_TOKENS, MCP_TOKENS];
|
package/dist/git.js
CHANGED
|
@@ -16,11 +16,9 @@ export function tokenRemote(repoUrl, token) {
|
|
|
16
16
|
}
|
|
17
17
|
export async function cloneApp(repoUrl, token, dir, author) {
|
|
18
18
|
await simpleGit().clone(tokenRemote(repoUrl, token), dir);
|
|
19
|
-
const local = simpleGit(dir
|
|
19
|
+
const local = simpleGit(dir);
|
|
20
20
|
await local.remote(["set-url", "origin", repoUrl]);
|
|
21
21
|
await local.addConfig("user.name", author.name);
|
|
22
22
|
await local.addConfig("user.email", author.email);
|
|
23
|
-
await local.addConfig("credential.helper", "", false);
|
|
24
|
-
await local.addConfig("credential.helper", "!bigbongo git-token --helper", true);
|
|
25
23
|
appendFileSync(join(dir, ".git", "info", "exclude"), "\n.bigbongo.json\n");
|
|
26
24
|
}
|
package/dist/helper.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { gitToken } from "./commands/gitToken.js";
|
|
3
|
+
import { gatewayToken } from "./commands/gatewayToken.js";
|
|
4
|
+
async function main(argv) {
|
|
5
|
+
const [command, ...rest] = argv;
|
|
6
|
+
if (command === "git-token" && rest[0] === "--helper")
|
|
7
|
+
return gitToken(rest[1], { helper: true });
|
|
8
|
+
if (command === "gateway-token") {
|
|
9
|
+
const i = rest.indexOf("--org");
|
|
10
|
+
return gatewayToken({ org: i >= 0 ? rest[i + 1] : undefined });
|
|
11
|
+
}
|
|
12
|
+
process.stderr.write("usage: helper.js git-token --helper <op> | gateway-token [--org <id>]\n");
|
|
13
|
+
process.exit(2);
|
|
14
|
+
}
|
|
15
|
+
main(process.argv.slice(2)).catch((err) => {
|
|
16
|
+
process.stderr.write(`${err?.message || err}\n`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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";
|
|
@@ -9,11 +9,22 @@ import { gitToken } from "./commands/gitToken.js";
|
|
|
9
9
|
import { logout } from "./commands/logout.js";
|
|
10
10
|
import { gatewayToken } from "./commands/gatewayToken.js";
|
|
11
11
|
import { claudeSetup } from "./commands/claudeSetup.js";
|
|
12
|
+
import { setupCommand } from "./commands/setup.js";
|
|
13
|
+
import { push } from "./commands/push.js";
|
|
14
|
+
import { mcpToken } from "./commands/mcpToken.js";
|
|
12
15
|
const version = createRequire(import.meta.url)("../package.json").version;
|
|
13
16
|
const program = new Command();
|
|
14
17
|
program.name("bigbongo").description("Edit your BigBongo app locally and git push to deploy.").version(version);
|
|
15
|
-
program.command("login").description("Authenticate against BigBongo").option("--token <token>", "non-interactive login")
|
|
16
|
-
|
|
18
|
+
program.command("login").description("Authenticate against BigBongo").option("--token <token>", "non-interactive login")
|
|
19
|
+
.option("--no-browser", "print the approval address without opening a browser (BROWSER=<program> picks the browser)")
|
|
20
|
+
.action(login);
|
|
21
|
+
program.command("clone [app]").description("Clone your app's repo (BigBongo brokers GitHub access), then set it up")
|
|
22
|
+
.option("--here", "clone into the current folder (it must be empty)")
|
|
23
|
+
.action((app, opts) => clone(app, opts));
|
|
24
|
+
program.command("setup").description("Make this app folder ready: Python environment, packages, pre-push check, Claude Code and git push")
|
|
25
|
+
.option("--quiet", "print only what is wrong")
|
|
26
|
+
.action(setupCommand);
|
|
27
|
+
program.command("push").description("git push, then follow the build until it is live or failed").action(() => push());
|
|
17
28
|
program.command("status").description("Show app + deployment status").action(status);
|
|
18
29
|
program.command("logs").description("Show app runtime logs")
|
|
19
30
|
.option("--lines <n>", "number of log lines (default 50, max 500)")
|
|
@@ -21,13 +32,21 @@ program.command("logs").description("Show app runtime logs")
|
|
|
21
32
|
.option("--level <level>", "filter by level: error | warn | info")
|
|
22
33
|
.action(logs);
|
|
23
34
|
program.command("logout").description("Revoke and clear local credentials").action(logout);
|
|
24
|
-
program.command("claude-setup").description("Point Claude Code at BigBongo (
|
|
25
|
-
.option("--org <slug>", "organization
|
|
26
|
-
.
|
|
35
|
+
program.command("claude-setup").description("Point Claude Code at BigBongo in any folder (an app folder gets this from `bigbongo setup`)")
|
|
36
|
+
.option("--org <slug>", "organization whose BigBongo credit is used")
|
|
37
|
+
.addOption(new Option("--global", "write ~/.claude/settings.json instead, so EVERY Claude Code session on this computer uses BigBongo").conflicts("project"))
|
|
38
|
+
.option("--project", "same as the default (kept for older scripts)")
|
|
39
|
+
.addHelpText("after", `
|
|
40
|
+
By default this writes .claude/settings.local.json at the root of the current git repo
|
|
41
|
+
(or the current folder when it is not in a git repo). That file is just for you: it is
|
|
42
|
+
kept out of git (added to .gitignore when needed) and only Claude Code started in this
|
|
43
|
+
project uses it.`)
|
|
27
44
|
.action(claudeSetup);
|
|
28
45
|
program.command("gateway-token").description("(internal) print a short-lived Claude Code credential")
|
|
29
46
|
.option("--org <slug>", "organization to bill")
|
|
30
47
|
.action(gatewayToken);
|
|
48
|
+
program.command("mcp-token [app]").description("(internal) print the MCP headers for Claude Code's headersHelper")
|
|
49
|
+
.action((app) => mcpToken(app));
|
|
31
50
|
program.command("git-token [app]").description("(internal) mint a short-lived git token").option("--helper", "git credential-helper mode").action(gitToken);
|
|
32
51
|
program.parseAsync(process.argv).catch((err) => {
|
|
33
52
|
const e = err;
|
package/dist/util.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync, lstatSync, realpathSync } from "node:fs";
|
|
3
|
+
import { delimiter, dirname, sep } 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
|
-
|
|
15
|
-
|
|
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) {
|
|
@@ -53,3 +78,18 @@ export function readStdin(timeoutMs = 2000) {
|
|
|
53
78
|
setTimeout(() => resolve(data), timeoutMs);
|
|
54
79
|
});
|
|
55
80
|
}
|
|
81
|
+
export function isInside(root, target) {
|
|
82
|
+
const top = realpathSync(root);
|
|
83
|
+
let dir = dirname(target);
|
|
84
|
+
while (!existsSync(dir))
|
|
85
|
+
dir = dirname(dir);
|
|
86
|
+
const real = realpathSync(dir);
|
|
87
|
+
if (real !== top && !real.startsWith(top + sep))
|
|
88
|
+
return false;
|
|
89
|
+
try {
|
|
90
|
+
return !lstatSync(target).isSymbolicLink();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}
|