@bigbongo/cli 3.0.0 → 3.0.1
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/index.js +9 -1
- 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/index.js
CHANGED
|
@@ -18,4 +18,12 @@ program.command("logs").description("Show app runtime logs")
|
|
|
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
|
+
}
|