@bigbongo/cli 3.0.2 → 3.1.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 +7 -5
- package/dist/commands/clone.js +42 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ approve, and you're in. Your session lasts 7 days; run `bigbongo login` again to
|
|
|
34
34
|
### 2. Clone your app
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
bigbongo clone # pick
|
|
37
|
+
bigbongo clone # pick your organization, then your app
|
|
38
38
|
bigbongo clone my-app # or name one directly
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -70,15 +70,17 @@ bigbongo logs # recent logs from your running app
|
|
|
70
70
|
| command | what it does |
|
|
71
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
|
|
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. |
|
|
74
74
|
| `bigbongo status` | Show what's live (version, commit, URL) and any deploy in progress. |
|
|
75
|
-
| `bigbongo logs` | Show recent runtime logs. Options: `--lines <n>` (default
|
|
75
|
+
| `bigbongo logs` | Show recent runtime logs, newest first. Options: `--lines <n>` (default 50, max 500), `--search <text>`, `--level <error\|warn\|info>`. |
|
|
76
76
|
| `bigbongo logout` | Sign out and clear your local session. |
|
|
77
77
|
|
|
78
78
|
Run `bigbongo <command> --help` for details on any command.
|
|
79
79
|
|
|
80
|
-
If you belong to more than one organization, `bigbongo clone`
|
|
81
|
-
|
|
80
|
+
If you belong to more than one organization, `bigbongo clone` asks which organization first,
|
|
81
|
+
then shows just that org's apps (pick `← Back to organizations` to switch). Only organizations
|
|
82
|
+
that actually have apps are listed, and if all your apps are in one org that step is skipped -
|
|
83
|
+
there's nothing extra to set up.
|
|
82
84
|
|
|
83
85
|
## How access works
|
|
84
86
|
|
package/dist/commands/clone.js
CHANGED
|
@@ -12,6 +12,30 @@ function requireAuth() {
|
|
|
12
12
|
}
|
|
13
13
|
return c;
|
|
14
14
|
}
|
|
15
|
+
function groupByOrg(apps) {
|
|
16
|
+
const byOrg = new Map();
|
|
17
|
+
for (const a of apps) {
|
|
18
|
+
const id = String(a.org_id ?? "");
|
|
19
|
+
let g = byOrg.get(id);
|
|
20
|
+
if (!g) {
|
|
21
|
+
g = { id, name: a.organization_name || id || "(unknown organization)", apps: [] };
|
|
22
|
+
byOrg.set(id, g);
|
|
23
|
+
}
|
|
24
|
+
g.apps.push(a);
|
|
25
|
+
}
|
|
26
|
+
return [...byOrg.values()].sort((x, y) => x.name.localeCompare(y.name));
|
|
27
|
+
}
|
|
28
|
+
const BACK = Symbol("back");
|
|
29
|
+
async function pickApp(group, allowBack) {
|
|
30
|
+
const choices = group.apps.map((a) => ({
|
|
31
|
+
name: `${a.title} (${a.app_slug})`,
|
|
32
|
+
value: a,
|
|
33
|
+
}));
|
|
34
|
+
if (allowBack)
|
|
35
|
+
choices.push({ name: "← Back to organizations", value: BACK });
|
|
36
|
+
const picked = await pickOne(`Pick an app to clone in ${group.name}`, choices);
|
|
37
|
+
return picked === BACK ? undefined : picked;
|
|
38
|
+
}
|
|
15
39
|
export async function clone(appArg) {
|
|
16
40
|
const cred = requireAuth();
|
|
17
41
|
const { apps } = await api.listApps();
|
|
@@ -30,11 +54,26 @@ export async function clone(appArg) {
|
|
|
30
54
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
31
55
|
console.error("Pass an app slug: `bigbongo clone <app>` (the picker needs a terminal).");
|
|
32
56
|
console.error("Your apps:");
|
|
33
|
-
for (const
|
|
34
|
-
console.error(` ${
|
|
57
|
+
for (const g of groupByOrg(apps)) {
|
|
58
|
+
console.error(` ${g.name}:`);
|
|
59
|
+
for (const a of g.apps)
|
|
60
|
+
console.error(` ${a.app_slug}`);
|
|
61
|
+
}
|
|
35
62
|
process.exit(1);
|
|
36
63
|
}
|
|
37
|
-
|
|
64
|
+
const orgs = groupByOrg(apps);
|
|
65
|
+
if (orgs.length === 1) {
|
|
66
|
+
app = await pickApp(orgs[0], false);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
while (!app) {
|
|
70
|
+
const org = await pickOne("Pick an organization", orgs.map((o) => ({
|
|
71
|
+
name: `${o.name} (${o.apps.length} app${o.apps.length === 1 ? "" : "s"})`,
|
|
72
|
+
value: o,
|
|
73
|
+
})));
|
|
74
|
+
app = await pickApp(org, true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
38
77
|
}
|
|
39
78
|
if (!isSafeAppSlug(app.app_slug)) {
|
|
40
79
|
console.error(`Refusing to clone: unexpected app slug '${app.app_slug}'.`);
|