@vibiz/cli 0.2.0 → 0.2.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/{chunk-GSHNECVT.js → chunk-OKWUSSLA.js} +85 -30
- package/dist/src-BY7YFVXW.js +3423 -0
- package/dist/vibiz.js +306 -67
- package/package.json +1 -1
- package/dist/src-2CVAECWM.js +0 -3392
package/dist/vibiz.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
APP_SDK_VERSION,
|
|
3
4
|
Vibiz,
|
|
4
5
|
VibizApiError,
|
|
6
|
+
connectHostMessage,
|
|
5
7
|
deployDirectory,
|
|
6
8
|
formatUnits,
|
|
7
9
|
formatUsd,
|
|
8
|
-
mergeEnvFile
|
|
9
|
-
|
|
10
|
+
mergeEnvFile,
|
|
11
|
+
oneKeyMessage
|
|
12
|
+
} from "./chunk-OKWUSSLA.js";
|
|
10
13
|
|
|
11
14
|
// packages/cli/src/main.ts
|
|
12
15
|
import { spawn } from "node:child_process";
|
|
13
|
-
import { chmod, mkdir, readFile as
|
|
16
|
+
import { chmod, mkdir as mkdir2, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
17
|
+
import { dirname as dirname5, join as join8 } from "node:path";
|
|
14
18
|
import { format } from "node:util";
|
|
15
19
|
|
|
16
20
|
// packages/cli/src/commands.ts
|
|
@@ -688,8 +692,10 @@ async function detectHosts(dir) {
|
|
|
688
692
|
}
|
|
689
693
|
return out;
|
|
690
694
|
}
|
|
691
|
-
|
|
692
|
-
|
|
695
|
+
function hostName(h) {
|
|
696
|
+
return h.label.replace(/\s*\(.*\)$/, "");
|
|
697
|
+
}
|
|
698
|
+
var ONE_KEY_PATHS = ` Then the app loads the rest at start:
|
|
693
699
|
|
|
694
700
|
Node, Bun, Deno import { vibiz } from '@vibiz/app'; await vibiz.loadEnv();
|
|
695
701
|
any language npx @vibiz/cli run -- <your start command>
|
|
@@ -1639,7 +1645,7 @@ async function browserLogin(io, api, deps) {
|
|
|
1639
1645
|
await forget(io, pendingPath);
|
|
1640
1646
|
io.log(
|
|
1641
1647
|
`
|
|
1642
|
-
\u2713 Logged in to ${body.account?.name ?? "your account"} as "${body.key?.name ?? "cli"}" (${body.key?.access
|
|
1648
|
+
\u2713 Logged in to ${body.account?.name ?? "your account"} as "${body.key?.name ?? "cli"}" (${body.key?.access === "agent" ? "Limited access" : "full access"}). Saved to ${configFile(dir)}`
|
|
1643
1649
|
);
|
|
1644
1650
|
return;
|
|
1645
1651
|
}
|
|
@@ -2424,7 +2430,8 @@ var PROJECT_FILE = "vibiz.json";
|
|
|
2424
2430
|
var HELP = `vibiz \u2014 website, database and sign-in for a new business, in one command
|
|
2425
2431
|
|
|
2426
2432
|
vibiz login log in from the browser: prints a link, you click
|
|
2427
|
-
Authorize
|
|
2433
|
+
Authorize (Full access by default, or Limited),
|
|
2434
|
+
and the new key is saved here
|
|
2428
2435
|
[--key <vz_sk_\u2026>] [--api <url>] [--no-browser] or save a key you already have
|
|
2429
2436
|
vibiz signup the same as login: no account yet? one is opened
|
|
2430
2437
|
for you on the way
|
|
@@ -2448,43 +2455,53 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2448
2455
|
schema and no production rows, own sign-in, own AI
|
|
2449
2456
|
key) into .env.development.local
|
|
2450
2457
|
vibiz dev -- <command\u2026> run a command with the development env, no file
|
|
2451
|
-
vibiz env [--write <file>] the PRODUCTION env (
|
|
2458
|
+
vibiz env [--write <file>] the PRODUCTION env (full-access keys only), to paste into
|
|
2452
2459
|
a host outside Vibiz; agents use \`vibiz dev\`
|
|
2453
2460
|
vibiz export [--code] [--db] [--csv] [--env production|development] [-o file.zip]
|
|
2454
2461
|
take the app elsewhere, or keep a backup: its source
|
|
2455
2462
|
with a guide (VIBIZ-EXPORT.md, .env.example), the
|
|
2456
2463
|
database as SQL that psql restores (--csv: tables as
|
|
2457
|
-
CSV). Default: all there is. Production data needs
|
|
2458
|
-
|
|
2464
|
+
CSV). Default: all there is. Production data needs a
|
|
2465
|
+
full-access key; Limited keys default to development
|
|
2459
2466
|
[--deployment <id>] [--secrets] [--no-wait] another deployment's code; --secrets also
|
|
2460
2467
|
writes the env's values to their own file (owner, asks)
|
|
2461
2468
|
vibiz domains [--json] your own domains: status, and the DNS records to add
|
|
2462
|
-
vibiz domains add <domain> [--elsewhere] connect one you own (
|
|
2469
|
+
vibiz domains add <domain> [--elsewhere] connect one you own (Limited keys: analytics counts it now;
|
|
2463
2470
|
sign-in trusts it once its TXT record is in, or an owner
|
|
2464
2471
|
confirms); HTTPS turns on by
|
|
2465
2472
|
itself. --elsewhere: the app runs on another host
|
|
2466
2473
|
vibiz domains verify <domain> check its DNS (and its TXT proof) again now
|
|
2467
|
-
vibiz domains remove <domain> disconnect it (
|
|
2474
|
+
vibiz domains remove <domain> disconnect it (full-access keys)
|
|
2468
2475
|
vibiz domains search <name> find a domain to buy, with prices (sellshelf, sellshelf.app)
|
|
2469
2476
|
vibiz domains buy <domain> [--years 1] [--yes]
|
|
2470
|
-
buy it from your credits for this project (
|
|
2477
|
+
buy it from your credits for this project (full-access keys,
|
|
2478
|
+
or Limited keys up to the owner's per-domain limit;
|
|
2471
2479
|
registered to the saved domain owner details)
|
|
2472
|
-
vibiz domains owned [--json] domains this account bought: expiry, auto-renew
|
|
2473
|
-
|
|
2480
|
+
vibiz domains owned [--json] domains this account bought: expiry, auto-renew, the
|
|
2481
|
+
projects and names using each
|
|
2482
|
+
vibiz domains use <domain> [--project <id|slug>] [--name app.example.com] [--elsewhere]
|
|
2483
|
+
[--points-to <host or IP>] put a bought domain (or any name under it) on any of
|
|
2484
|
+
your projects: no DNS to set, HTTPS by itself; an app
|
|
2485
|
+
elsewhere: --points-to and we write the record
|
|
2486
|
+
vibiz domains move <domain> --to <id|slug> [--name app] [--from <id|slug>]
|
|
2487
|
+
move a bought name to another project (full-access keys)
|
|
2488
|
+
vibiz domains point <name> <host or IP|none>
|
|
2489
|
+
a bought name used by an app elsewhere: we point it there
|
|
2490
|
+
vibiz domains renew <domain> [--years 1] renew now from credits (full-access keys)
|
|
2474
2491
|
vibiz domains auto-renew <domain> on|off renew from credits 30 days before expiry (default on)
|
|
2475
|
-
vibiz domains transfer-code <domain> the code to move it to another registrar (
|
|
2492
|
+
vibiz domains transfer-code <domain> the code to move it to another registrar (full-access keys)
|
|
2476
2493
|
vibiz domains owner [--input <json>] [--open]
|
|
2477
2494
|
the domain owner details (the legal registrant), saved
|
|
2478
2495
|
once; --input sets them, --open edits in the console
|
|
2479
2496
|
vibiz auth [--dev] [--json] how people sign in: providers, callback URLs, email
|
|
2480
|
-
(production for
|
|
2497
|
+
(production for full-access keys; --dev the development copy)
|
|
2481
2498
|
vibiz auth providers add <google|github|vercel> [--own --client-id <id>] [--dev]
|
|
2482
2499
|
turn on a social sign-in; --own uses your OAuth app,
|
|
2483
2500
|
its secret from <PROVIDER>_CLIENT_SECRET or a prompt
|
|
2484
2501
|
vibiz auth providers rm <provider> [--dev] turn one off
|
|
2485
2502
|
vibiz auth domains <a.com,b.com|none> [--dev] only these email domains may sign up
|
|
2486
2503
|
vibiz company [--dev] [--json] the business behind this project: status, what blocks
|
|
2487
|
-
filing, the next step (production for
|
|
2504
|
+
filing, the next step (production for full-access keys)
|
|
2488
2505
|
vibiz company draft --file company.json [--dev] create or replace the draft (docs/COMPANY.md)
|
|
2489
2506
|
vibiz company submit [--dev] file it; production shows the price and asks you to
|
|
2490
2507
|
type the company's name (real filing, real fees)
|
|
@@ -2492,7 +2509,7 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2492
2509
|
vibiz company docs [download <id>] [--dev] formation documents, or a short-lived download link
|
|
2493
2510
|
vibiz company simulate <formation|ein> development only: complete that step at the sandbox
|
|
2494
2511
|
vibiz payments [--dev] [--json] take payments: balance, getting paid, the next step
|
|
2495
|
-
(production for
|
|
2512
|
+
(production for full-access keys; --dev test mode)
|
|
2496
2513
|
vibiz payments products [--dev] the catalog; add one with
|
|
2497
2514
|
products add <name> --amount <cents> [--interval month|year] [--lookup-key k]
|
|
2498
2515
|
vibiz payments checkout <price_id|lookup_key> --success-url <u> --cancel-url <u> [--user id]
|
|
@@ -2524,7 +2541,7 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2524
2541
|
vibiz social accounts [--dev] [--json] connected accounts and their ids
|
|
2525
2542
|
vibiz social post "<text>" --to <account,\u2026> [--media <file|url>]\u2026 [--at <iso>] [--draft]
|
|
2526
2543
|
[--opt key=value]\u2026 [--dev] publish now, schedule or draft; a live post asks you to
|
|
2527
|
-
confirm (
|
|
2544
|
+
confirm (a Limited key's post waits for the owner)
|
|
2528
2545
|
vibiz social posts [--status s] [--dev] posts, newest first
|
|
2529
2546
|
vibiz social approve|reject|cancel <post> [--dev] decide a waiting post, or cancel one
|
|
2530
2547
|
vibiz social campaigns [--dev] ad campaigns with budget and spend
|
|
@@ -2540,13 +2557,13 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2540
2557
|
vibiz connectors ops <name> [--json] its operations: risk, on/off, parameters
|
|
2541
2558
|
vibiz connectors enable|disable <name> <op\u2026> allow (or stop) operations
|
|
2542
2559
|
vibiz connectors secret <name> <VAR> [--dev] set a key from $VAR or a hidden prompt; never printed.
|
|
2543
|
-
Production needs
|
|
2560
|
+
Production needs a full-access key
|
|
2544
2561
|
vibiz connectors call <name> <op> [key=value\u2026] [--body '<json>'] [--dev] [--approval <id>]
|
|
2545
2562
|
call it; dangerous operations (and production writes)
|
|
2546
|
-
by
|
|
2563
|
+
by a Limited key wait for the owner's approval
|
|
2547
2564
|
vibiz connectors check <name> [--dev] does the key work
|
|
2548
2565
|
vibiz connectors logs <name> [--dev] recent calls (no content)
|
|
2549
|
-
vibiz connectors approvals | approve <id> | deny <id> calls waiting for the owner (
|
|
2566
|
+
vibiz connectors approvals | approve <id> | deny <id> calls waiting for the owner (full-access key)
|
|
2550
2567
|
vibiz connect where does this app deploy? how that host gets its env
|
|
2551
2568
|
vibiz run -- <command\u2026> with VIBIZ_APP_KEY set (a server, a container, CI): run
|
|
2552
2569
|
the command with the app's env; any language
|
|
@@ -2555,13 +2572,15 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2555
2572
|
vibiz hosts hosts outside Vibiz that get the env server to server
|
|
2556
2573
|
vibiz hosts add <host> <app> [field=value\u2026] [--dev]
|
|
2557
2574
|
connect your own host so Vibiz keeps its env in sync
|
|
2558
|
-
(
|
|
2575
|
+
(full-access key): vercel, netlify, render, railway, fly,
|
|
2559
2576
|
heroku, cloudflare-workers, cloudflare-pages,
|
|
2560
2577
|
github-actions. The token comes from the host's usual
|
|
2561
2578
|
variable (VERCEL_TOKEN, FLY_API_TOKEN\u2026) or a hidden
|
|
2562
2579
|
prompt. Any other host: vibiz connect
|
|
2563
2580
|
vibiz hosts sync | rm <id> [--keep-values] push again now, or disconnect
|
|
2564
|
-
vibiz app-key [rotate [--dev] [--grace <s>]] the app's one key (VIBIZ_APP_KEY)
|
|
2581
|
+
vibiz app-key [rotate [--dev] [--grace <s>]] the app's one key (VIBIZ_APP_KEY): it gives the
|
|
2582
|
+
app everything; prints the link to copy it (the
|
|
2583
|
+
key itself is never printed)
|
|
2565
2584
|
vibiz add <hosting|database|auth|email|analytics|replay|ai> add a resource to this project
|
|
2566
2585
|
vibiz analytics [--period 24h|7d|30d] [--json] visitors, pages, sources, events
|
|
2567
2586
|
vibiz analytics snippet the tag for a site hosted anywhere, and the domains it counts
|
|
@@ -2569,7 +2588,7 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2569
2588
|
what went wrong for visitors, then sessions to watch
|
|
2570
2589
|
vibiz replay <id> [--json] one session's signals and a link to watch it
|
|
2571
2590
|
vibiz projects list your projects
|
|
2572
|
-
Web data (billed per call
|
|
2591
|
+
Web data (billed per call; every run is kept: vibiz runs, console \u25B8 Web data)
|
|
2573
2592
|
vibiz scrape <url> [--json] one page as markdown
|
|
2574
2593
|
vibiz design <url> [--out design.md] [--tailwind] [--shadcn] [--css] [--own] [--pages /a,/b]
|
|
2575
2594
|
a site's design: type scale, colors, radii, spacing,
|
|
@@ -2634,7 +2653,7 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2634
2653
|
recent messages (sender and subject only)
|
|
2635
2654
|
vibiz email unforward <address@domain|domain> [inbox]
|
|
2636
2655
|
stop forwarding to one inbox, one address, or (domain
|
|
2637
|
-
alone) the whole domain (
|
|
2656
|
+
alone) the whole domain (full-access keys)
|
|
2638
2657
|
vibiz email setup set up newsletters: the sending address news.<project>\u2026
|
|
2639
2658
|
(verifies in minutes). Then the owner adds the postal
|
|
2640
2659
|
address: vibiz email settings set --postal-address "\u2026"
|
|
@@ -2654,7 +2673,7 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2654
2673
|
vibiz email broadcast list|stats <id>|review <id>|test <id> [--to a,b]|cancel <id>|resume <id>
|
|
2655
2674
|
vibiz email broadcast create --subject s --file body.md [--list l] [--segment s] [--html]
|
|
2656
2675
|
[--preview-text t] [--from-name n] [--name n] (edit <id> takes the same flags)
|
|
2657
|
-
vibiz email broadcast send <id> [--at <ISO time>] $0.001 an email;
|
|
2676
|
+
vibiz email broadcast send <id> [--at <ISO time>] $0.001 an email; Limited keys get the owner's
|
|
2658
2677
|
review link unless the owner set an allowance
|
|
2659
2678
|
vibiz email automation list|runs <id>|activate <id>|pause <id>
|
|
2660
2679
|
vibiz email automation create --file automation.json {name, trigger, steps, exit_event}
|
|
@@ -2687,11 +2706,12 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2687
2706
|
vibiz billing [--json] the account's credits: balance, card, auto-recharge
|
|
2688
2707
|
vibiz billing top-up <dollars> [--open] a payment link to add credits (a person pays there)
|
|
2689
2708
|
vibiz billing history [--kind usage,topup] what came in and what used it
|
|
2690
|
-
vibiz billing auto-recharge on|off [--threshold 5] [--amount 25] (
|
|
2709
|
+
vibiz billing auto-recharge on|off [--threshold 5] [--amount 25] (full-access key)
|
|
2691
2710
|
vibiz metrics [--period 7d] [--json] request counts, error rate and latency by capability
|
|
2692
|
-
vibiz keys [create <name> [--
|
|
2693
|
-
named API keys, one per person or agent
|
|
2694
|
-
|
|
2711
|
+
vibiz keys [create <name> [--limited] | access <id> full|limited | revoke <id>]
|
|
2712
|
+
named API keys, one per person or agent: full
|
|
2713
|
+
access by default; Limited ones never move live
|
|
2714
|
+
money or read production secrets
|
|
2695
2715
|
vibiz admin metrics [--period 7d] [--json] [--open] the platform view (admin key)
|
|
2696
2716
|
vibiz mcp serve the Vibiz tools to AI agents (MCP, stdio)
|
|
2697
2717
|
vibiz mcp add --clients "<client>[,\u2026]" connect a coding agent to the remote MCP server once:
|
|
@@ -2757,6 +2777,7 @@ function printDomains(io, list2, only) {
|
|
|
2757
2777
|
io.log(` ${x.next_step}`);
|
|
2758
2778
|
}
|
|
2759
2779
|
}
|
|
2780
|
+
var accessLabel = (access) => access === "agent" ? "Limited access" : "full access";
|
|
2760
2781
|
var BUY_DOMAIN_COMMANDS = /* @__PURE__ */ new Set([
|
|
2761
2782
|
"search",
|
|
2762
2783
|
"buy",
|
|
@@ -2764,7 +2785,10 @@ var BUY_DOMAIN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
2764
2785
|
"renew",
|
|
2765
2786
|
"auto-renew",
|
|
2766
2787
|
"transfer-code",
|
|
2767
|
-
"owner"
|
|
2788
|
+
"owner",
|
|
2789
|
+
"use",
|
|
2790
|
+
"move",
|
|
2791
|
+
"point"
|
|
2768
2792
|
]);
|
|
2769
2793
|
var dollarsOf = (cents2) => cents2 === null || cents2 === void 0 ? "\u2014" : `$${(cents2 / 100).toFixed(2)}`;
|
|
2770
2794
|
function printOwned(io, d) {
|
|
@@ -2772,9 +2796,43 @@ function printOwned(io, d) {
|
|
|
2772
2796
|
io.log(
|
|
2773
2797
|
`${d.domain} ${d.status} ${expires} auto-renew ${d.auto_renew ? "on" : "off"} (${dollarsOf(d.renewal_price_cents)}/year)`
|
|
2774
2798
|
);
|
|
2775
|
-
io.log(` registered to ${d.registered_to}
|
|
2799
|
+
io.log(` registered to ${d.registered_to}`);
|
|
2800
|
+
if (d.status === "active" || d.status === "expired") {
|
|
2801
|
+
if (!d.used_on?.length) {
|
|
2802
|
+
io.log(` not used on a project yet: vibiz domains use ${d.domain} --project <id|slug>`);
|
|
2803
|
+
}
|
|
2804
|
+
for (const u of d.used_on ?? []) {
|
|
2805
|
+
io.log(
|
|
2806
|
+
` on ${u.project_name} (${u.project_slug}): ${u.name}${u.www_redirect ? ` (+ ${u.www_redirect})` : ""}${u.hosting === "elsewhere" ? " runs elsewhere" : ""}`
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2776
2810
|
if (d.next_step) io.log(` ${d.next_step}`);
|
|
2777
2811
|
}
|
|
2812
|
+
function printUse(io, u) {
|
|
2813
|
+
const p = u.project_domain;
|
|
2814
|
+
const project = u.owned.used_on.find((x) => x.name === u.name)?.project_name ?? u.project_id;
|
|
2815
|
+
io.log(
|
|
2816
|
+
u.moved_from ? `${u.name} moved from ${u.moved_from.project_name} to ${project}.` : `${u.name} is on ${project}.`
|
|
2817
|
+
);
|
|
2818
|
+
if (p) {
|
|
2819
|
+
io.log(
|
|
2820
|
+
` ${p.status}${p.https ? ", HTTPS" : ""}${p.trusted_for_sign_in ? ", trusted for sign-in" : ""}${p.www_redirect ? ` \xB7 ${p.www_redirect} redirects here` : ""}${p.points_to ? ` \xB7 points to ${p.points_to}` : ""}`
|
|
2821
|
+
);
|
|
2822
|
+
}
|
|
2823
|
+
io.log(` ${u.next_step}`);
|
|
2824
|
+
}
|
|
2825
|
+
async function zoneFor(vibiz2, name) {
|
|
2826
|
+
const host = name.trim().toLowerCase().replace(/\.$/, "");
|
|
2827
|
+
const owned = (await vibiz2.domains.list()).data.filter((d) => d.status !== "failed");
|
|
2828
|
+
const zone = owned.map((d) => d.domain).filter((z) => host === z || host.endsWith(`.${z}`)).sort((a, b) => b.length - a.length)[0];
|
|
2829
|
+
if (!zone) {
|
|
2830
|
+
throw new Error(
|
|
2831
|
+
`${host} is not under a domain this account bought (vibiz domains owned lists them). A domain bought elsewhere connects with vibiz domains add ${host}.`
|
|
2832
|
+
);
|
|
2833
|
+
}
|
|
2834
|
+
return zone;
|
|
2835
|
+
}
|
|
2778
2836
|
async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
|
|
2779
2837
|
const d = vibiz2.domains;
|
|
2780
2838
|
const json = (v) => io.log(JSON.stringify(v, null, 2));
|
|
@@ -2848,6 +2906,45 @@ async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
|
|
|
2848
2906
|
io.log(` Live at https://${bought.domain} (HTTPS turns on by itself).`);
|
|
2849
2907
|
return;
|
|
2850
2908
|
}
|
|
2909
|
+
if (sub === "use" || sub === "move" || sub === "point") {
|
|
2910
|
+
const given = need();
|
|
2911
|
+
const zone = await zoneFor(vibiz2, given);
|
|
2912
|
+
const name = values.name ?? (given.toLowerCase() === zone ? void 0 : given);
|
|
2913
|
+
const target = values["points-to"];
|
|
2914
|
+
const rest = {
|
|
2915
|
+
...name ? { name } : {},
|
|
2916
|
+
...values.elsewhere ? { hosting: "elsewhere" } : {},
|
|
2917
|
+
...target !== void 0 ? { points_to: target === "" || target === "none" ? null : target } : {}
|
|
2918
|
+
};
|
|
2919
|
+
let out2;
|
|
2920
|
+
if (sub === "use") {
|
|
2921
|
+
out2 = await d.use(zone, values.project ?? await io.project(), rest);
|
|
2922
|
+
} else if (sub === "move") {
|
|
2923
|
+
const to = values.to ?? values.project;
|
|
2924
|
+
if (!to) {
|
|
2925
|
+
throw new Error(
|
|
2926
|
+
"usage: vibiz domains move <domain> --to <project id|slug> [--name app] [--from <project>]"
|
|
2927
|
+
);
|
|
2928
|
+
}
|
|
2929
|
+
out2 = await d.move(zone, to, {
|
|
2930
|
+
...rest,
|
|
2931
|
+
...values.from ? { from_project_id: values.from } : {}
|
|
2932
|
+
});
|
|
2933
|
+
} else {
|
|
2934
|
+
const where = third ?? target;
|
|
2935
|
+
if (where === void 0) {
|
|
2936
|
+
throw new Error("usage: vibiz domains point <name> <host or IP|none>");
|
|
2937
|
+
}
|
|
2938
|
+
out2 = await d.point(zone, {
|
|
2939
|
+
...name ? { name } : {},
|
|
2940
|
+
points_to: where === "" || where === "none" ? null : where,
|
|
2941
|
+
...values.project ? { project_id: values.project } : {}
|
|
2942
|
+
});
|
|
2943
|
+
}
|
|
2944
|
+
if (values.json) return json(out2);
|
|
2945
|
+
printUse(io, out2);
|
|
2946
|
+
return;
|
|
2947
|
+
}
|
|
2851
2948
|
if (sub === "owned") {
|
|
2852
2949
|
const list2 = await d.list();
|
|
2853
2950
|
if (values.json) return json(list2);
|
|
@@ -3027,6 +3124,26 @@ function parseResources(raw) {
|
|
|
3027
3124
|
}
|
|
3028
3125
|
return { resources, services };
|
|
3029
3126
|
}
|
|
3127
|
+
async function oneKeyLines(vibiz2, id, host) {
|
|
3128
|
+
const links = await vibiz2.projects.envLinks(id);
|
|
3129
|
+
const name = host ? hostName(host) : void 0;
|
|
3130
|
+
const lines = links.app_key_console_url ? [oneKeyMessage(links.app_key_console_url, name)] : [];
|
|
3131
|
+
if (!host || host.push) lines.push(connectHostMessage(host?.kind, name));
|
|
3132
|
+
return lines.join("\n");
|
|
3133
|
+
}
|
|
3134
|
+
function commandLine(argv2) {
|
|
3135
|
+
return [
|
|
3136
|
+
"vibiz",
|
|
3137
|
+
...argv2.map((a) => /^[\w@%+=:,./-]+$/.test(a) ? a : `'${a.replace(/'/g, `'\\''`)}'`)
|
|
3138
|
+
].join(" ");
|
|
3139
|
+
}
|
|
3140
|
+
function secretNeeded(io, what, envName, argv2) {
|
|
3141
|
+
const why = io.interactive === false ? "there is no terminal here to type it into (an agent or a script is running this)" : "nothing was typed at the prompt";
|
|
3142
|
+
return new Error(
|
|
3143
|
+
`${what} is needed, and ${why}. It is a secret, so a person types it in their own terminal and it never passes through an agent or a chat. Hand them this command to run there (it asks for the value, hidden): ${commandLine(argv2)}${envName ? `
|
|
3144
|
+
Or they set ${envName} in that terminal first.` : ""}`
|
|
3145
|
+
);
|
|
3146
|
+
}
|
|
3030
3147
|
function printProject(io, p) {
|
|
3031
3148
|
io.log(`${p.name} (${p.id})`);
|
|
3032
3149
|
if (p.url) io.log(` ${p.url}`);
|
|
@@ -3339,6 +3456,7 @@ async function runCli(argv2, io) {
|
|
|
3339
3456
|
"keep-values": { type: "boolean", default: false },
|
|
3340
3457
|
grace: { type: "string" },
|
|
3341
3458
|
owner: { type: "boolean", default: false },
|
|
3459
|
+
limited: { type: "boolean", default: false },
|
|
3342
3460
|
own: { type: "boolean", default: false },
|
|
3343
3461
|
"client-id": { type: "string" },
|
|
3344
3462
|
file: { type: "string" },
|
|
@@ -3370,6 +3488,7 @@ async function runCli(argv2, io) {
|
|
|
3370
3488
|
kind: { type: "string" },
|
|
3371
3489
|
"no-browser": { type: "boolean", default: false },
|
|
3372
3490
|
elsewhere: { type: "boolean", default: false },
|
|
3491
|
+
"points-to": { type: "string" },
|
|
3373
3492
|
"replace-mx": { type: "boolean", default: false },
|
|
3374
3493
|
cc: { type: "string" },
|
|
3375
3494
|
bcc: { type: "string" },
|
|
@@ -3472,7 +3591,7 @@ async function runCli(argv2, io) {
|
|
|
3472
3591
|
return;
|
|
3473
3592
|
}
|
|
3474
3593
|
io.log(`${me.account.name} (${me.account.id})`);
|
|
3475
|
-
io.log(` key ${me.key.name} ${me.key.prefix}\u2026 ${me.key.access}`);
|
|
3594
|
+
io.log(` key ${me.key.name} ${me.key.prefix}\u2026 ${accessLabel(me.key.access)}`);
|
|
3476
3595
|
const saved = await readLogin(io, io.configDir ?? CONFIG_DIR);
|
|
3477
3596
|
io.log(` api ${io.env.VIBIZ_API_URL || saved.apiUrl || DEFAULT_API_URL}`);
|
|
3478
3597
|
return;
|
|
@@ -3534,15 +3653,25 @@ async function runCli(argv2, io) {
|
|
|
3534
3653
|
`Added ${values.domain}${out.domain?.hosting === "elsewhere" ? " (runs on your own host)" : ""}.`
|
|
3535
3654
|
);
|
|
3536
3655
|
}
|
|
3537
|
-
|
|
3656
|
+
const elsewhere = async () => {
|
|
3657
|
+
if (resources === void 0 || resources.includes("hosting")) return;
|
|
3658
|
+
io.log(`
|
|
3659
|
+
${await oneKeyLines(vibiz2, project.id)}`);
|
|
3660
|
+
};
|
|
3661
|
+
if (values["no-wait"]) return elsewhere();
|
|
3538
3662
|
const ready = await vibiz2.projects.waitUntilReady(project.id);
|
|
3539
3663
|
printProject(io, ready);
|
|
3664
|
+
if (!template)
|
|
3665
|
+
io.log(
|
|
3666
|
+
` In the app: npm install --save-exact @vibiz/app@${APP_SDK_VERSION}, then await vibiz.loadEnv() where the server starts`
|
|
3667
|
+
);
|
|
3540
3668
|
if (!template && ready.resources.some((r) => r.type === "analytics"))
|
|
3541
3669
|
io.log(" Analytics tag for your site: vibiz analytics snippet");
|
|
3542
3670
|
if (ready.resources.some((r) => r.type === "hosting"))
|
|
3543
3671
|
io.log(
|
|
3544
3672
|
" Design tip: vibiz design <a site you like> --tailwind writes a brief to build the UI from"
|
|
3545
3673
|
);
|
|
3674
|
+
await elsewhere();
|
|
3546
3675
|
return;
|
|
3547
3676
|
}
|
|
3548
3677
|
case "status": {
|
|
@@ -3650,7 +3779,7 @@ async function runCli(argv2, io) {
|
|
|
3650
3779
|
if (!values["client-id"]) throw new Error("--own needs --client-id <id>");
|
|
3651
3780
|
const envName = `${provider.toUpperCase()}_CLIENT_SECRET`;
|
|
3652
3781
|
const secret = io.env[envName] || await io.promptHidden(`${provider} client secret: `);
|
|
3653
|
-
if (!secret) throw
|
|
3782
|
+
if (!secret) throw secretNeeded(io, `The ${provider} client secret`, envName, argv2);
|
|
3654
3783
|
settings = await vibiz2.projects.auth.setProvider(
|
|
3655
3784
|
id,
|
|
3656
3785
|
provider,
|
|
@@ -4269,7 +4398,7 @@ ${link.url}`
|
|
|
4269
4398
|
${JSON.stringify(a.request)}`
|
|
4270
4399
|
);
|
|
4271
4400
|
}
|
|
4272
|
-
if (list2.length) io.log("Approve with
|
|
4401
|
+
if (list2.length) io.log("Approve with a full-access key: vibiz connectors approve <id>");
|
|
4273
4402
|
});
|
|
4274
4403
|
return;
|
|
4275
4404
|
}
|
|
@@ -4306,7 +4435,7 @@ ${link.url}`
|
|
|
4306
4435
|
const [key] = more;
|
|
4307
4436
|
if (!key) throw new Error("usage: vibiz connectors secret <name> <VAR> [--dev]");
|
|
4308
4437
|
const value = io.env[key] ?? await io.promptHidden(`${key} (hidden): `);
|
|
4309
|
-
if (!value) throw
|
|
4438
|
+
if (!value) throw secretNeeded(io, `A value for ${key}`, key, argv2);
|
|
4310
4439
|
const k = await c.setSecrets(id, name, { [key]: value }, env);
|
|
4311
4440
|
out(
|
|
4312
4441
|
k.ready,
|
|
@@ -4405,7 +4534,7 @@ ${link.url}`
|
|
|
4405
4534
|
}
|
|
4406
4535
|
if (sub)
|
|
4407
4536
|
throw new Error(
|
|
4408
|
-
"usage: vibiz domains [add | verify | remove | search | buy | owned | renew | auto-renew | transfer-code | owner]"
|
|
4537
|
+
"usage: vibiz domains [add | verify | remove | search | buy | owned | use | move | point | renew | auto-renew | transfer-code | owner]"
|
|
4409
4538
|
);
|
|
4410
4539
|
print(await d.list(id));
|
|
4411
4540
|
return;
|
|
@@ -4441,11 +4570,8 @@ ${link.url}`
|
|
|
4441
4570
|
}
|
|
4442
4571
|
const envName = TOKEN_ENV[host.kind];
|
|
4443
4572
|
const token = envName && io.env[envName] || await io.promptHidden(`${host.label} token (${host.token_help}): `);
|
|
4444
|
-
if (!token)
|
|
4445
|
-
throw
|
|
4446
|
-
`A ${host.label} token is needed${envName ? ` (${envName}, or type it)` : ""}.`
|
|
4447
|
-
);
|
|
4448
|
-
}
|
|
4573
|
+
if (!token)
|
|
4574
|
+
throw secretNeeded(io, `A ${host.label} token (${host.token_help})`, envName, argv2);
|
|
4449
4575
|
const t = await vibiz2.projects.hosts.add(id, {
|
|
4450
4576
|
kind: host.kind,
|
|
4451
4577
|
token,
|
|
@@ -4499,6 +4625,8 @@ Hosting and connected hosts get the new value by themselves.`
|
|
|
4499
4625
|
`${k.environment.padEnd(12)} ${k.prefix ? `${k.prefix}\u2026` : "(issued on first use)"}${k.last_used_at ? ` last used ${k.last_used_at}` : ""}`
|
|
4500
4626
|
);
|
|
4501
4627
|
}
|
|
4628
|
+
io.log(`
|
|
4629
|
+
${await oneKeyLines(vibiz2, id)}`);
|
|
4502
4630
|
return;
|
|
4503
4631
|
}
|
|
4504
4632
|
// A site's design as a brief and exports (docs: design).
|
|
@@ -4574,11 +4702,20 @@ Hosting and connected hosts get the new value by themselves.`
|
|
|
4574
4702
|
);
|
|
4575
4703
|
}
|
|
4576
4704
|
case "connect": {
|
|
4577
|
-
const
|
|
4705
|
+
const local = io.local();
|
|
4706
|
+
const found = await detectHosts(local.cwd());
|
|
4707
|
+
const linked = await local.readFile(PROJECT_FILE, "utf8").then((t) => JSON.parse(String(t)).project_id).catch(() => void 0);
|
|
4708
|
+
const oneKey = async (host) => {
|
|
4709
|
+
if (!linked) {
|
|
4710
|
+
return ` One key, VIBIZ_APP_KEY, gives the app everything on Vibiz. This folder has no ${PROJECT_FILE} yet: run vibiz init <name> here, then vibiz connect again for the link to copy it.`;
|
|
4711
|
+
}
|
|
4712
|
+
return oneKeyLines(await io.client(), linked, host);
|
|
4713
|
+
};
|
|
4578
4714
|
io.log("Recommended: Vibiz hosting. Every key is already there and stays in sync:");
|
|
4579
4715
|
io.log(" vibiz deploy\n");
|
|
4580
4716
|
if (!found.length) {
|
|
4581
4717
|
io.log("No other host found in this folder. Hosting somewhere else?");
|
|
4718
|
+
io.log(await oneKey());
|
|
4582
4719
|
io.log(ONE_KEY_PATHS);
|
|
4583
4720
|
return;
|
|
4584
4721
|
}
|
|
@@ -4586,12 +4723,12 @@ Hosting and connected hosts get the new value by themselves.`
|
|
|
4586
4723
|
io.log(`Found ${h.label} (${h.file}).`);
|
|
4587
4724
|
if (h.push) {
|
|
4588
4725
|
io.log(` Vibiz can write the env into it and keep it in sync (an owner, once):`);
|
|
4589
|
-
io.log(` vibiz hosts add ${h.kind} <its project or service
|
|
4590
|
-
`);
|
|
4591
|
-
} else {
|
|
4592
|
-
io.log(`${ONE_KEY_PATHS}
|
|
4593
|
-
`);
|
|
4726
|
+
io.log(` vibiz hosts add ${h.kind} <its project or service>`);
|
|
4727
|
+
io.log(` Or with one key instead:`);
|
|
4594
4728
|
}
|
|
4729
|
+
io.log(await oneKey({ ...h, push: false }));
|
|
4730
|
+
io.log(`${ONE_KEY_PATHS}
|
|
4731
|
+
`);
|
|
4595
4732
|
}
|
|
4596
4733
|
io.log(
|
|
4597
4734
|
"Running it elsewhere? Add its domain too, so sign-in accepts it: vibiz domains add <domain> --elsewhere"
|
|
@@ -5072,16 +5209,25 @@ The credits show in \`vibiz billing\` a few seconds after paying.`
|
|
|
5072
5209
|
const vibiz2 = await io.client();
|
|
5073
5210
|
const [sub, arg] = positionals;
|
|
5074
5211
|
if (sub === "create") {
|
|
5075
|
-
if (!arg) throw new Error("usage: vibiz keys create <name> [--
|
|
5076
|
-
const key = await vibiz2.apiKeys.create(arg, { access: values.
|
|
5212
|
+
if (!arg) throw new Error("usage: vibiz keys create <name> [--limited]");
|
|
5213
|
+
const key = await vibiz2.apiKeys.create(arg, { access: values.limited ? "agent" : "owner" });
|
|
5077
5214
|
io.log(
|
|
5078
|
-
`${key.name} ${key.id} ${key.access}
|
|
5215
|
+
`${key.name} ${key.id} ${accessLabel(key.access)}
|
|
5079
5216
|
${key.secret}
|
|
5080
5217
|
|
|
5081
5218
|
Store the key now: it is not shown again.`
|
|
5082
5219
|
);
|
|
5083
5220
|
return;
|
|
5084
5221
|
}
|
|
5222
|
+
if (sub === "access") {
|
|
5223
|
+
const level = positionals[2];
|
|
5224
|
+
if (!arg || level !== "full" && level !== "limited") {
|
|
5225
|
+
throw new Error("usage: vibiz keys access <key id> full|limited");
|
|
5226
|
+
}
|
|
5227
|
+
const k = await vibiz2.apiKeys.setAccess(arg, level === "full" ? "owner" : "agent");
|
|
5228
|
+
io.log(`${k.name} (${k.id}) now has ${accessLabel(k.access)}.`);
|
|
5229
|
+
return;
|
|
5230
|
+
}
|
|
5085
5231
|
if (sub === "revoke") {
|
|
5086
5232
|
if (!arg) throw new Error("usage: vibiz keys revoke <key id>");
|
|
5087
5233
|
await vibiz2.apiKeys.revoke(arg);
|
|
@@ -5090,7 +5236,7 @@ Store the key now: it is not shown again.`
|
|
|
5090
5236
|
}
|
|
5091
5237
|
for (const k of await vibiz2.apiKeys.list()) {
|
|
5092
5238
|
io.log(
|
|
5093
|
-
`${k.id} ${k.name.padEnd(20)} ${k.prefix}\u2026 ${(k.access
|
|
5239
|
+
`${k.id} ${k.name.padEnd(20)} ${k.prefix}\u2026 ${accessLabel(k.access).padEnd(14)} ${k.revoked_at ? "revoked" : "active"}`
|
|
5094
5240
|
);
|
|
5095
5241
|
}
|
|
5096
5242
|
return;
|
|
@@ -5110,7 +5256,7 @@ Store the key now: it is not shown again.`
|
|
|
5110
5256
|
return;
|
|
5111
5257
|
}
|
|
5112
5258
|
case "docs": {
|
|
5113
|
-
const { DOC_TOPICS, DOCS } = await import("./src-
|
|
5259
|
+
const { DOC_TOPICS, DOCS } = await import("./src-BY7YFVXW.js");
|
|
5114
5260
|
const topic = positionals[0];
|
|
5115
5261
|
if (!topic || !DOC_TOPICS.includes(topic)) {
|
|
5116
5262
|
for (const t of DOC_TOPICS) io.log(` vibiz docs ${t.padEnd(13)} ${DOCS[t].title}`);
|
|
@@ -5135,7 +5281,7 @@ ${DOCS[topic].body}`);
|
|
|
5135
5281
|
if (positionals[0])
|
|
5136
5282
|
throw new Error('usage: vibiz mcp (serve over stdio) | vibiz mcp add --clients "<client>"');
|
|
5137
5283
|
io.local();
|
|
5138
|
-
const { serveStdio } = await import("./src-
|
|
5284
|
+
const { serveStdio } = await import("./src-BY7YFVXW.js");
|
|
5139
5285
|
await serveStdio({ version: cliVersion() });
|
|
5140
5286
|
return;
|
|
5141
5287
|
}
|
|
@@ -5158,6 +5304,13 @@ function cliErrorLines(err) {
|
|
|
5158
5304
|
if (err instanceof VibizApiError) {
|
|
5159
5305
|
const out = [`\u2715 ${err.message} (${err.code})`];
|
|
5160
5306
|
const d = err.details;
|
|
5307
|
+
const problems = (Array.isArray(d?.problems) ? d.problems : []).filter(
|
|
5308
|
+
(p) => typeof p?.message === "string" && !err.message.includes(p.message.replace(/[.\s]+$/, ""))
|
|
5309
|
+
);
|
|
5310
|
+
for (const p of problems.slice(0, 10)) out.push(` \u2022 ${p.message}`);
|
|
5311
|
+
if (typeof d?.field === "string" && d.field && !err.message.includes(d.field) && !problems.length) {
|
|
5312
|
+
out.push(` field: ${d.field}`);
|
|
5313
|
+
}
|
|
5161
5314
|
if (d?.approval_id) out.push(` approval_id: ${d.approval_id}`);
|
|
5162
5315
|
if (d?.next_step) out.push(` ${d.next_step}`);
|
|
5163
5316
|
if (d?.console_url && !d.next_step?.includes(d.console_url)) out.push(` ${d.console_url}`);
|
|
@@ -5228,7 +5381,13 @@ async function aiKeysCommand(io, args, values) {
|
|
|
5228
5381
|
return;
|
|
5229
5382
|
}
|
|
5230
5383
|
const key = io.env.GEMINI_API_KEY || io.env.GOOGLE_API_KEY || await io.promptHidden("API key (hidden): ");
|
|
5231
|
-
if (!key)
|
|
5384
|
+
if (!key)
|
|
5385
|
+
throw secretNeeded(io, "The Gemini API key", "GEMINI_API_KEY", [
|
|
5386
|
+
"ai",
|
|
5387
|
+
"keys",
|
|
5388
|
+
...args,
|
|
5389
|
+
...values.project ? ["--project", values.project] : []
|
|
5390
|
+
]);
|
|
5232
5391
|
show(
|
|
5233
5392
|
await vibiz2.aiKeys.set(
|
|
5234
5393
|
provider,
|
|
@@ -5254,10 +5413,54 @@ async function aiKeysCommand(io, args, values) {
|
|
|
5254
5413
|
}
|
|
5255
5414
|
}
|
|
5256
5415
|
|
|
5416
|
+
// packages/cli/src/update-check.ts
|
|
5417
|
+
import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
5418
|
+
import { join as join7 } from "node:path";
|
|
5419
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
5420
|
+
var LATEST_URL = "https://registry.npmjs.org/@vibiz/cli/latest";
|
|
5421
|
+
function isNewer(latest, current) {
|
|
5422
|
+
const parse = (v) => /^\d+\.\d+\.\d+$/.test(v) ? v.split(".").map(Number) : null;
|
|
5423
|
+
const a = parse(latest);
|
|
5424
|
+
const b = parse(current);
|
|
5425
|
+
if (!a || !b) return false;
|
|
5426
|
+
for (let i = 0; i < 3; i++) {
|
|
5427
|
+
if (a[i] !== b[i]) return (a[i] ?? 0) > (b[i] ?? 0);
|
|
5428
|
+
}
|
|
5429
|
+
return false;
|
|
5430
|
+
}
|
|
5431
|
+
function updateNotice(latest, current) {
|
|
5432
|
+
if (!isNewer(latest, current)) return null;
|
|
5433
|
+
return [
|
|
5434
|
+
`A newer Vibiz CLI is out: ${current} \u2192 ${latest}. Some commands may be missing from this one.`,
|
|
5435
|
+
"Update: npm install -g @vibiz/cli@latest (then refresh the agent skills: vibiz skills add --global)"
|
|
5436
|
+
].join("\n");
|
|
5437
|
+
}
|
|
5438
|
+
async function latestVersion(configDir, env, fetchImpl = fetch, now = Date.now()) {
|
|
5439
|
+
if (env.VIBIZ_NO_UPDATE_CHECK || env.CI) return null;
|
|
5440
|
+
const file = join7(configDir, "update-check.json");
|
|
5441
|
+
let cache = null;
|
|
5442
|
+
try {
|
|
5443
|
+
cache = JSON.parse(await readFile2(file, "utf8"));
|
|
5444
|
+
} catch {
|
|
5445
|
+
}
|
|
5446
|
+
if (cache && now - cache.checkedAt < DAY_MS) return cache.latest;
|
|
5447
|
+
try {
|
|
5448
|
+
const res = await fetchImpl(LATEST_URL, { signal: AbortSignal.timeout(1500) });
|
|
5449
|
+
if (!res.ok) return cache?.latest ?? null;
|
|
5450
|
+
const { version } = await res.json();
|
|
5451
|
+
if (typeof version !== "string") return cache?.latest ?? null;
|
|
5452
|
+
await mkdir(configDir, { recursive: true });
|
|
5453
|
+
await writeFile2(file, JSON.stringify({ checkedAt: now, latest: version }));
|
|
5454
|
+
return version;
|
|
5455
|
+
} catch {
|
|
5456
|
+
return cache?.latest ?? null;
|
|
5457
|
+
}
|
|
5458
|
+
}
|
|
5459
|
+
|
|
5257
5460
|
// packages/cli/src/main.ts
|
|
5258
5461
|
async function readJson2(path) {
|
|
5259
5462
|
try {
|
|
5260
|
-
return JSON.parse(await
|
|
5463
|
+
return JSON.parse(await readFile3(path, "utf8"));
|
|
5261
5464
|
} catch {
|
|
5262
5465
|
return null;
|
|
5263
5466
|
}
|
|
@@ -5316,7 +5519,7 @@ var terminal = {
|
|
|
5316
5519
|
out: (text) => void process.stdout.write(text),
|
|
5317
5520
|
err: (text) => void process.stderr.write(text),
|
|
5318
5521
|
env: process.env,
|
|
5319
|
-
client: async () => new Vibiz(await login()),
|
|
5522
|
+
client: async () => new Vibiz({ ...await login(), client: `vibiz-cli/${cliVersion()}` }),
|
|
5320
5523
|
aiClient: async (project) => {
|
|
5321
5524
|
const { apiKey, baseUrl } = await login();
|
|
5322
5525
|
const headers = project ? { "x-vibiz-project": project } : void 0;
|
|
@@ -5332,19 +5535,47 @@ var terminal = {
|
|
|
5332
5535
|
});
|
|
5333
5536
|
},
|
|
5334
5537
|
project: async () => {
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5538
|
+
for (let dir = process.cwd(); ; dir = dirname5(dir)) {
|
|
5539
|
+
const linked = await readJson2(join8(dir, PROJECT_FILE));
|
|
5540
|
+
if (linked?.project_id) return linked.project_id;
|
|
5541
|
+
if (dirname5(dir) === dir) break;
|
|
5542
|
+
}
|
|
5543
|
+
const list2 = await new Vibiz(await login()).projects.list();
|
|
5544
|
+
const wanted = process.env.VIBIZ_PROJECT?.trim().toLowerCase();
|
|
5545
|
+
if (wanted) {
|
|
5546
|
+
const p = list2.find((x) => [x.id, x.slug, x.name.toLowerCase()].includes(wanted));
|
|
5547
|
+
if (p) return p.id;
|
|
5548
|
+
throw new Error(`No project "${process.env.VIBIZ_PROJECT}" on this account.`);
|
|
5549
|
+
}
|
|
5550
|
+
const lines = list2.map((p, i) => ` ${i + 1}. ${p.name} (${p.slug}, ${p.id})`);
|
|
5551
|
+
if (list2.length && process.stdin.isTTY) {
|
|
5552
|
+
console.error(`No ${PROJECT_FILE} here. Which project?
|
|
5553
|
+
${lines.join("\n")}`);
|
|
5554
|
+
const n = Number(await promptLine("Number (Enter to cancel): "));
|
|
5555
|
+
const p = list2[n - 1];
|
|
5556
|
+
if (!p) throw new Error("Cancelled.");
|
|
5557
|
+
const link = (await promptLine(`Link this folder to ${p.name} (writes ${PROJECT_FILE})? [y/N] `)).trim().toLowerCase();
|
|
5558
|
+
if (link === "y" || link === "yes") {
|
|
5559
|
+
await writeFile3(PROJECT_FILE, `${JSON.stringify({ project_id: p.id }, null, 2)}
|
|
5560
|
+
`);
|
|
5561
|
+
}
|
|
5562
|
+
return p.id;
|
|
5563
|
+
}
|
|
5564
|
+
throw new Error(
|
|
5565
|
+
list2.length ? `No ${PROJECT_FILE} here. Run it in the app's folder, or name the project: VIBIZ_PROJECT=<slug> vibiz \u2026
|
|
5566
|
+
${lines.join("\n")}` : `No ${PROJECT_FILE} here and no projects yet. Run: vibiz init <name>`
|
|
5567
|
+
);
|
|
5338
5568
|
},
|
|
5339
5569
|
promptHidden,
|
|
5570
|
+
interactive: Boolean(process.stdin.isTTY),
|
|
5340
5571
|
promptLine,
|
|
5341
5572
|
openUrl,
|
|
5342
5573
|
local: () => ({
|
|
5343
5574
|
cwd: () => process.cwd(),
|
|
5344
|
-
readFile:
|
|
5345
|
-
writeFile:
|
|
5575
|
+
readFile: readFile3,
|
|
5576
|
+
writeFile: writeFile3,
|
|
5346
5577
|
chmod,
|
|
5347
|
-
mkdir,
|
|
5578
|
+
mkdir: mkdir2,
|
|
5348
5579
|
exec: (cmd, args, env, opts) => {
|
|
5349
5580
|
const child = spawn(cmd, args, { stdio: "inherit", env });
|
|
5350
5581
|
if (opts?.forwardSignals) {
|
|
@@ -5364,8 +5595,16 @@ var argv = process.argv.slice(2);
|
|
|
5364
5595
|
if (argv[0] === "--version" || argv[0] === "-v") {
|
|
5365
5596
|
console.log(cliVersion());
|
|
5366
5597
|
} else {
|
|
5367
|
-
|
|
5598
|
+
const latest = latestVersion(CONFIG_DIR, process.env);
|
|
5599
|
+
const notice = async () => {
|
|
5600
|
+
const v = await latest;
|
|
5601
|
+
const text = v && updateNotice(v, cliVersion());
|
|
5602
|
+
if (text) console.error(`
|
|
5603
|
+
${text}`);
|
|
5604
|
+
};
|
|
5605
|
+
runCli(argv, terminal).then(notice).catch(async (err) => {
|
|
5368
5606
|
for (const line of cliErrorLines(err)) console.error(line);
|
|
5607
|
+
await notice();
|
|
5369
5608
|
process.exit(1);
|
|
5370
5609
|
});
|
|
5371
5610
|
}
|