@bigbongo/cli 3.0.0 → 3.0.2
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/dist/commands/clone.js +2 -5
- package/dist/commands/context.js +1 -1
- package/dist/commands/logs.js +4 -7
- package/dist/commands/status.js +2 -0
- package/dist/index.js +10 -2
- package/dist/prompt.js +25 -0
- package/package.json +1 -1
package/dist/commands/clone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import select from "@inquirer/select";
|
|
3
2
|
import { api } from "../api.js";
|
|
4
3
|
import { loadCredentials, saveProject } from "../config.js";
|
|
5
4
|
import { cloneApp } from "../git.js";
|
|
5
|
+
import { pickOne } from "../prompt.js";
|
|
6
6
|
import { isSafeAppSlug } from "../util.js";
|
|
7
7
|
function requireAuth() {
|
|
8
8
|
const c = loadCredentials();
|
|
@@ -34,10 +34,7 @@ export async function clone(appArg) {
|
|
|
34
34
|
console.error(` ${a.app_slug}`);
|
|
35
35
|
process.exit(1);
|
|
36
36
|
}
|
|
37
|
-
app = await
|
|
38
|
-
message: "Pick an app to clone",
|
|
39
|
-
choices: apps.map((a) => ({ name: `${a.title} (${a.app_slug})`, value: a })),
|
|
40
|
-
});
|
|
37
|
+
app = await pickOne("Pick an app to clone", apps.map((a) => ({ name: `${a.title} (${a.app_slug})`, value: a })));
|
|
41
38
|
}
|
|
42
39
|
if (!isSafeAppSlug(app.app_slug)) {
|
|
43
40
|
console.error(`Refusing to clone: unexpected app slug '${app.app_slug}'.`);
|
package/dist/commands/context.js
CHANGED
|
@@ -7,7 +7,7 @@ export function requireProject() {
|
|
|
7
7
|
}
|
|
8
8
|
const cfg = findProjectUp();
|
|
9
9
|
if (!cfg) {
|
|
10
|
-
console.error("Not in a BigBongo app directory (no .bigbongo.json).
|
|
10
|
+
console.error("Not in a BigBongo app directory (no .bigbongo.json). cd into your app folder, or run `bigbongo clone <app>` first.");
|
|
11
11
|
process.exit(1);
|
|
12
12
|
}
|
|
13
13
|
return cfg;
|
package/dist/commands/logs.js
CHANGED
|
@@ -17,17 +17,14 @@ function fmtTs(ms) {
|
|
|
17
17
|
}
|
|
18
18
|
export async function logs(opts = {}) {
|
|
19
19
|
const cfg = requireProject();
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
search: opts.search,
|
|
24
|
-
level: opts.level,
|
|
25
|
-
});
|
|
20
|
+
const parsed = opts.lines ? parseInt(opts.lines, 10) : NaN;
|
|
21
|
+
const lines = isNaN(parsed) ? undefined : Math.min(Math.max(parsed, 1), 500);
|
|
22
|
+
const { events } = await api.logs(cfg.app_id, { lines, search: opts.search, level: opts.level });
|
|
26
23
|
if (!events?.length) {
|
|
27
24
|
console.log("No logs yet.");
|
|
28
25
|
return;
|
|
29
26
|
}
|
|
30
|
-
for (const e of events) {
|
|
27
|
+
for (const e of [...events].reverse()) {
|
|
31
28
|
const tag = LEVEL_TAG[e.level] ?? (e.level ? String(e.level).toUpperCase().slice(0, 3) : " ");
|
|
32
29
|
console.log(`${fmtTs(e.timestamp)} ${tag} ${e.message}`);
|
|
33
30
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -22,6 +22,8 @@ export async function status() {
|
|
|
22
22
|
const b = s.latest_build;
|
|
23
23
|
if (b) {
|
|
24
24
|
let line = ` Build: ${b.source_type} ${b.status}`;
|
|
25
|
+
if (b.git_sha)
|
|
26
|
+
line += ` (${String(b.git_sha).slice(0, 7)})`;
|
|
25
27
|
if (b.deployment_status)
|
|
26
28
|
line += ` (deploy: ${b.deployment_status})`;
|
|
27
29
|
console.log(line);
|
package/dist/index.js
CHANGED
|
@@ -12,10 +12,18 @@ program.command("login").description("Authenticate against BigBongo").option("--
|
|
|
12
12
|
program.command("clone [app]").description("Clone your app's repo (BigBongo brokers GitHub access)").action(clone);
|
|
13
13
|
program.command("status").description("Show app + deployment status").action(status);
|
|
14
14
|
program.command("logs").description("Show app runtime logs")
|
|
15
|
-
.option("--lines <n>", "number of log lines (default
|
|
15
|
+
.option("--lines <n>", "number of log lines (default 50, max 500)")
|
|
16
16
|
.option("--search <text>", "filter to lines containing text")
|
|
17
17
|
.option("--level <level>", "filter by level: error | warn | info")
|
|
18
18
|
.action(logs);
|
|
19
19
|
program.command("logout").description("Revoke and clear local credentials").action(logout);
|
|
20
20
|
program.command("git-token [app]").description("(internal) mint a short-lived git token").option("--helper", "git credential-helper mode").action(gitToken);
|
|
21
|
-
program.parseAsync(process.argv)
|
|
21
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
22
|
+
const e = err;
|
|
23
|
+
if (e?.name === "ExitPromptError" || e?.name === "AbortPromptError") {
|
|
24
|
+
console.log("\nCancelled.");
|
|
25
|
+
process.exit(130);
|
|
26
|
+
}
|
|
27
|
+
console.error(e?.message || String(err));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
});
|
package/dist/prompt.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { emitKeypressEvents } from "node:readline";
|
|
2
|
+
import select from "@inquirer/select";
|
|
3
|
+
export async function pickOne(message, choices) {
|
|
4
|
+
const ac = new AbortController();
|
|
5
|
+
emitKeypressEvents(process.stdin);
|
|
6
|
+
const onKey = (_s, key) => {
|
|
7
|
+
if (key?.name === "escape")
|
|
8
|
+
ac.abort();
|
|
9
|
+
};
|
|
10
|
+
process.stdin.on("keypress", onKey);
|
|
11
|
+
try {
|
|
12
|
+
return await select({ message, choices }, { signal: ac.signal });
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
const name = err?.name;
|
|
16
|
+
if (name === "AbortPromptError" || name === "ExitPromptError") {
|
|
17
|
+
console.log("\nCancelled.");
|
|
18
|
+
process.exit(130);
|
|
19
|
+
}
|
|
20
|
+
throw err;
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
process.stdin.off("keypress", onKey);
|
|
24
|
+
}
|
|
25
|
+
}
|