claudemesh-cli 1.0.0-alpha.1 → 1.0.0-alpha.3
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/entrypoints/cli.js +29 -30
- package/dist/entrypoints/cli.js.map +4 -4
- package/package.json +4 -4
package/dist/entrypoints/cli.js
CHANGED
|
@@ -1415,35 +1415,25 @@ __export(exports_register, {
|
|
|
1415
1415
|
});
|
|
1416
1416
|
async function register2() {
|
|
1417
1417
|
try {
|
|
1418
|
-
const listener = await startCallbackListener();
|
|
1419
1418
|
console.log(`
|
|
1420
|
-
Opening browser for account signup
|
|
1419
|
+
Opening browser for account signup…`);
|
|
1420
|
+
console.log(` Create your account, then approve the CLI sign-in.
|
|
1421
1421
|
`);
|
|
1422
|
-
const url = `https://claudemesh.com/register?source=cli&callback=http://localhost:${listener.port}`;
|
|
1423
1422
|
try {
|
|
1424
|
-
await openBrowser(
|
|
1423
|
+
await openBrowser("https://claudemesh.com/auth/register");
|
|
1425
1424
|
} catch {
|
|
1426
|
-
console.log(`
|
|
1427
|
-
${url}
|
|
1425
|
+
console.log(` Visit: https://claudemesh.com/auth/register
|
|
1428
1426
|
`);
|
|
1429
1427
|
}
|
|
1430
|
-
|
|
1431
|
-
`);
|
|
1432
|
-
const token = await Promise.race([
|
|
1433
|
-
listener.token,
|
|
1434
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error("Timed out waiting for signup (5 min). Try again.")), 5 * 60 * 1000))
|
|
1435
|
-
]).finally(() => listener.close());
|
|
1436
|
-
let user = { id: "", display_name: "", email: "" };
|
|
1428
|
+
const result = await loginWithDeviceCode();
|
|
1429
|
+
console.log(` ${green(icons.check)} Signed in as ${result.user.display_name}.`);
|
|
1437
1430
|
try {
|
|
1438
|
-
|
|
1431
|
+
const meshes = await exports_my.getMeshes(result.session_token);
|
|
1432
|
+
if (meshes.length > 0) {
|
|
1433
|
+
const names = meshes.map((m) => m.slug).join(", ");
|
|
1434
|
+
console.log(` ${green(icons.check)} Synced ${meshes.length} mesh${meshes.length === 1 ? "" : "es"}: ${names}`);
|
|
1435
|
+
}
|
|
1439
1436
|
} catch {}
|
|
1440
|
-
storeToken({
|
|
1441
|
-
session_token: token,
|
|
1442
|
-
user,
|
|
1443
|
-
token_source: "callback"
|
|
1444
|
-
});
|
|
1445
|
-
const name = user.display_name || user.email || "you";
|
|
1446
|
-
console.log(` ${green(icons.check)} Account created. Signed in as ${name}.`);
|
|
1447
1437
|
return EXIT.SUCCESS;
|
|
1448
1438
|
} catch (err) {
|
|
1449
1439
|
console.error(` ${icons.cross} Registration failed: ${err instanceof Error ? err.message : err}`);
|
|
@@ -3560,7 +3550,12 @@ function enterFullScreen() {
|
|
|
3560
3550
|
function exitFullScreen() {
|
|
3561
3551
|
process.stdout.write(SHOW_CURSOR + CLEAR_SCREEN);
|
|
3562
3552
|
}
|
|
3563
|
-
async function menuSelect(
|
|
3553
|
+
async function menuSelect(itemsOrOpts, prompt = "Choice") {
|
|
3554
|
+
const items = Array.isArray(itemsOrOpts) ? itemsOrOpts : itemsOrOpts.items;
|
|
3555
|
+
const title = !Array.isArray(itemsOrOpts) ? itemsOrOpts.title : undefined;
|
|
3556
|
+
if (title)
|
|
3557
|
+
console.log(`
|
|
3558
|
+
${title}`);
|
|
3564
3559
|
items.forEach((item, i) => console.log(` ${bold(String(i + 1) + ")")} ${item}`));
|
|
3565
3560
|
console.log("");
|
|
3566
3561
|
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
@@ -3572,25 +3567,29 @@ async function menuSelect(items, prompt = "Choice") {
|
|
|
3572
3567
|
});
|
|
3573
3568
|
});
|
|
3574
3569
|
}
|
|
3575
|
-
async function textInput(
|
|
3570
|
+
async function textInput(promptOrOpts, defaultVal = "") {
|
|
3571
|
+
const label = typeof promptOrOpts === "string" ? promptOrOpts : promptOrOpts.label;
|
|
3572
|
+
const placeholder = typeof promptOrOpts === "object" ? promptOrOpts.placeholder : undefined;
|
|
3576
3573
|
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
3577
3574
|
return new Promise((resolve) => {
|
|
3578
|
-
const hint = defaultVal ? ` [${defaultVal}]` : "";
|
|
3579
|
-
rl.question(` ${
|
|
3575
|
+
const hint = placeholder ? ` (${placeholder})` : defaultVal ? ` [${defaultVal}]` : "";
|
|
3576
|
+
rl.question(` ${label}${hint}: `, (answer) => {
|
|
3580
3577
|
rl.close();
|
|
3581
3578
|
resolve(answer.trim() || defaultVal);
|
|
3582
3579
|
});
|
|
3583
3580
|
});
|
|
3584
3581
|
}
|
|
3585
|
-
async function confirmPrompt(
|
|
3582
|
+
async function confirmPrompt(promptOrOpts, defaultYes = true) {
|
|
3583
|
+
const message = typeof promptOrOpts === "string" ? promptOrOpts : promptOrOpts.message;
|
|
3584
|
+
const defYes = typeof promptOrOpts === "object" && promptOrOpts.defaultYes !== undefined ? promptOrOpts.defaultYes : defaultYes;
|
|
3586
3585
|
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
3587
|
-
const hint =
|
|
3586
|
+
const hint = defYes ? "[Y/n]" : "[y/N]";
|
|
3588
3587
|
return new Promise((resolve) => {
|
|
3589
|
-
rl.question(` ${
|
|
3588
|
+
rl.question(` ${message} ${hint}: `, (answer) => {
|
|
3590
3589
|
rl.close();
|
|
3591
3590
|
const a = answer.trim().toLowerCase();
|
|
3592
3591
|
if (!a)
|
|
3593
|
-
resolve(
|
|
3592
|
+
resolve(defYes);
|
|
3594
3593
|
else
|
|
3595
3594
|
resolve(a === "y" || a === "yes");
|
|
3596
3595
|
});
|
|
@@ -10620,4 +10619,4 @@ main().catch((err) => {
|
|
|
10620
10619
|
process.exit(EXIT.INTERNAL_ERROR);
|
|
10621
10620
|
});
|
|
10622
10621
|
|
|
10623
|
-
//# debugId=
|
|
10622
|
+
//# debugId=FA11CE2414855F8F64756E2164756E21
|