@vibiz/cli 0.2.2 → 0.2.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/vibiz.js
CHANGED
|
@@ -5,21 +5,22 @@ import {
|
|
|
5
5
|
VibizApiError,
|
|
6
6
|
connectHostMessage,
|
|
7
7
|
deployDirectory,
|
|
8
|
+
deployPathProblem,
|
|
8
9
|
formatUnits,
|
|
9
10
|
formatUsd,
|
|
10
11
|
mergeEnvFile,
|
|
11
12
|
oneKeyMessage
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RXH3L5IW.js";
|
|
13
14
|
|
|
14
15
|
// packages/cli/src/main.ts
|
|
15
16
|
import { spawn } from "node:child_process";
|
|
16
17
|
import { chmod, mkdir as mkdir2, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
17
|
-
import { dirname as
|
|
18
|
+
import { dirname as dirname7, join as join9 } from "node:path";
|
|
18
19
|
import { format } from "node:util";
|
|
19
20
|
|
|
20
21
|
// packages/cli/src/commands.ts
|
|
21
22
|
import { homedir as homedir2 } from "node:os";
|
|
22
|
-
import { join as
|
|
23
|
+
import { dirname as dirname6, join as join7, resolve as resolve2 } from "node:path";
|
|
23
24
|
import { parseArgs } from "node:util";
|
|
24
25
|
|
|
25
26
|
// packages/app/src/index.ts
|
|
@@ -568,8 +569,86 @@ function formatBilling(b, history) {
|
|
|
568
569
|
return lines.join("\n");
|
|
569
570
|
}
|
|
570
571
|
|
|
572
|
+
// packages/cli/src/code.ts
|
|
573
|
+
import { readdir } from "node:fs/promises";
|
|
574
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
575
|
+
async function deploymentOf(vibiz2, projectId, wanted) {
|
|
576
|
+
if (wanted) return wanted;
|
|
577
|
+
const project = await vibiz2.projects.get(projectId);
|
|
578
|
+
if (project.production_deployment_id) return project.production_deployment_id;
|
|
579
|
+
const latest = (await vibiz2.deployments.list(projectId))[0];
|
|
580
|
+
if (!latest)
|
|
581
|
+
throw new Error(
|
|
582
|
+
`${projectId} has no deployment yet, so there is no code to read. Deploy it first: vibiz deploy`
|
|
583
|
+
);
|
|
584
|
+
return latest.id;
|
|
585
|
+
}
|
|
586
|
+
async function manifest(vibiz2, projectId, wanted) {
|
|
587
|
+
const id = await deploymentOf(vibiz2, projectId, wanted);
|
|
588
|
+
const listed = await vibiz2.deployments.files(id);
|
|
589
|
+
if (listed.project_id !== projectId)
|
|
590
|
+
throw new Error(`${id} is a deployment of ${listed.project_id}, not of ${projectId}.`);
|
|
591
|
+
return { id, files: listed.data };
|
|
592
|
+
}
|
|
593
|
+
async function codeCommand(io, positionals, flags) {
|
|
594
|
+
const [sub = "ls", path] = positionals;
|
|
595
|
+
const vibiz2 = await io.client();
|
|
596
|
+
const projectId = await io.project();
|
|
597
|
+
if (sub === "ls" || sub === "list") {
|
|
598
|
+
const { id, files } = await manifest(vibiz2, projectId, flags.deployment);
|
|
599
|
+
if (flags.json) {
|
|
600
|
+
io.log(JSON.stringify({ deployment_id: id, files }, null, 2));
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
io.log(`${id}: ${files.length} file${files.length === 1 ? "" : "s"}`);
|
|
604
|
+
for (const f of files) io.log(` ${bytesLabel(f.size).padStart(9)} ${f.path}`);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (sub === "cat" || sub === "read") {
|
|
608
|
+
if (!path) throw new Error("usage: vibiz code cat <path> [--deployment <id>]");
|
|
609
|
+
const id = await deploymentOf(vibiz2, projectId, flags.deployment);
|
|
610
|
+
const bytes = await vibiz2.deployments.readFile(id, path);
|
|
611
|
+
io.out(new TextDecoder().decode(bytes));
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
throw new Error("usage: vibiz code [ls | cat <path>] [--deployment <id>]");
|
|
615
|
+
}
|
|
616
|
+
async function pullCommand(io, positionals, flags) {
|
|
617
|
+
const local = io.local();
|
|
618
|
+
const vibiz2 = await io.client();
|
|
619
|
+
const projectId = await io.project();
|
|
620
|
+
const dir = resolve(local.cwd(), positionals[0] ?? ".");
|
|
621
|
+
const existing = await readdir(dir).catch((e) => {
|
|
622
|
+
if (e.code === "ENOENT") return [];
|
|
623
|
+
throw e;
|
|
624
|
+
});
|
|
625
|
+
if (existing.some((n) => n !== "vibiz.json") && !flags.force)
|
|
626
|
+
throw new Error(
|
|
627
|
+
`${dir} is not empty, and pulling would overwrite files there. Pull into a new folder (vibiz pull my-site), or add --force to overwrite.`
|
|
628
|
+
);
|
|
629
|
+
const { id, files } = await manifest(vibiz2, projectId, flags.deployment);
|
|
630
|
+
let bytesTotal = 0;
|
|
631
|
+
for (const f of files) {
|
|
632
|
+
const problem = deployPathProblem(f.path);
|
|
633
|
+
if (problem) throw new Error(`Refusing to write ${JSON.stringify(f.path)}: it ${problem}.`);
|
|
634
|
+
const target = join(dir, ...f.path.split("/"));
|
|
635
|
+
if (!target.startsWith(`${dir}${sep}`))
|
|
636
|
+
throw new Error(`Refusing to write ${f.path}: it is outside ${dir}.`);
|
|
637
|
+
const bytes = await vibiz2.deployments.readFile(id, f.path);
|
|
638
|
+
await local.mkdir(dirname(target), { recursive: true });
|
|
639
|
+
await local.writeFile(target, bytes);
|
|
640
|
+
bytesTotal += bytes.byteLength;
|
|
641
|
+
}
|
|
642
|
+
if (flags.json) {
|
|
643
|
+
io.log(JSON.stringify({ deployment_id: id, dir, files: files.length }, null, 2));
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
io.log(`Pulled ${files.length} files (${bytesLabel(bytesTotal)}) of ${id} into ${dir}`);
|
|
647
|
+
io.log(" Change what you need, then deploy it: vibiz deploy");
|
|
648
|
+
}
|
|
649
|
+
|
|
571
650
|
// packages/cli/src/design.ts
|
|
572
|
-
import { dirname, join } from "node:path";
|
|
651
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
573
652
|
var usd = (micro) => micro === null || micro === void 0 ? "" : `$${(micro / 1e6).toFixed(micro < 1e4 ? 4 : 2)}`;
|
|
574
653
|
var DESIGN_USAGE = "vibiz design <url> [--out design.md] [--tailwind] [--shadcn] [--css] [--own] [--pages /pricing,/about] [--fresh] [--json]";
|
|
575
654
|
async function designCommand(io, args, flags) {
|
|
@@ -597,8 +676,8 @@ async function designCommand(io, args, flags) {
|
|
|
597
676
|
const local = io.local();
|
|
598
677
|
const out = flags.out ?? "design.md";
|
|
599
678
|
const write = async (name, text) => {
|
|
600
|
-
const path =
|
|
601
|
-
await local.mkdir(
|
|
679
|
+
const path = join2(local.cwd(), name);
|
|
680
|
+
await local.mkdir(dirname2(path), { recursive: true });
|
|
602
681
|
await local.writeFile(path, text);
|
|
603
682
|
return name;
|
|
604
683
|
};
|
|
@@ -640,7 +719,7 @@ ${tail}
|
|
|
640
719
|
}
|
|
641
720
|
|
|
642
721
|
// packages/cli/src/detect.ts
|
|
643
|
-
import { readdir } from "node:fs/promises";
|
|
722
|
+
import { readdir as readdir2 } from "node:fs/promises";
|
|
644
723
|
var SIGNS = [
|
|
645
724
|
{ kind: "vercel", label: "Vercel", files: /^(vercel\.json|\.vercel)$/, push: true },
|
|
646
725
|
{ kind: "netlify", label: "Netlify", files: /^(netlify\.toml|\.netlify)$/, push: true },
|
|
@@ -682,7 +761,7 @@ var SIGNS = [
|
|
|
682
761
|
{ kind: "digitalocean", label: "DigitalOcean App Platform", files: /^\.do$/, push: false }
|
|
683
762
|
];
|
|
684
763
|
async function detectHosts(dir) {
|
|
685
|
-
const names = await
|
|
764
|
+
const names = await readdir2(dir).catch(() => []);
|
|
686
765
|
const out = [];
|
|
687
766
|
for (const sign of SIGNS) {
|
|
688
767
|
const file = names.find((n) => sign.files.test(n));
|
|
@@ -1197,7 +1276,7 @@ ${EMAIL_MARKETING_HELP}`);
|
|
|
1197
1276
|
}
|
|
1198
1277
|
|
|
1199
1278
|
// packages/cli/src/export.ts
|
|
1200
|
-
import { dirname as
|
|
1279
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
1201
1280
|
import { Readable } from "node:stream";
|
|
1202
1281
|
var STEP = {
|
|
1203
1282
|
starting: "starting",
|
|
@@ -1257,7 +1336,7 @@ async function exportCommand(io, flags) {
|
|
|
1257
1336
|
}
|
|
1258
1337
|
const out = local;
|
|
1259
1338
|
const zipKind = done.files.find((f) => f.kind === "code" || f.kind === "guide");
|
|
1260
|
-
const dir = flags.output ?
|
|
1339
|
+
const dir = flags.output ? dirname3(flags.output) : ".";
|
|
1261
1340
|
const saved = [];
|
|
1262
1341
|
for (const f of done.files) {
|
|
1263
1342
|
if (!f.url) {
|
|
@@ -1265,7 +1344,7 @@ async function exportCommand(io, flags) {
|
|
|
1265
1344
|
`);
|
|
1266
1345
|
continue;
|
|
1267
1346
|
}
|
|
1268
|
-
const path = f === zipKind && flags.output ? flags.output :
|
|
1347
|
+
const path = f === zipKind && flags.output ? flags.output : join3(dir, f.name);
|
|
1269
1348
|
const res = await vibiz2.exports.download(f.url);
|
|
1270
1349
|
if (!res.body) throw new Error(`${f.name} came back empty`);
|
|
1271
1350
|
await out.writeFile(path, Readable.fromWeb(res.body));
|
|
@@ -1274,7 +1353,7 @@ async function exportCommand(io, flags) {
|
|
|
1274
1353
|
let envPath = null;
|
|
1275
1354
|
if (flags.secrets) {
|
|
1276
1355
|
const project = await vibiz2.projects.get(projectId);
|
|
1277
|
-
envPath =
|
|
1356
|
+
envPath = join3(dir, `${project.slug}.env.${done.environment}`);
|
|
1278
1357
|
if (!flags.yes) {
|
|
1279
1358
|
const answer = await io.promptLine(
|
|
1280
1359
|
`Write the ${done.environment} secret values to ${envPath}? They are live credentials: never commit or share that file. Type yes: `
|
|
@@ -1510,7 +1589,7 @@ async function inboxCommand(io, vibiz2, flags, positionals) {
|
|
|
1510
1589
|
|
|
1511
1590
|
// packages/cli/src/login.ts
|
|
1512
1591
|
import { hostname, platform, release } from "node:os";
|
|
1513
|
-
import { join as
|
|
1592
|
+
import { join as join4 } from "node:path";
|
|
1514
1593
|
|
|
1515
1594
|
// packages/cli/src/version.ts
|
|
1516
1595
|
import { readFileSync } from "node:fs";
|
|
@@ -1525,8 +1604,8 @@ function cliVersion() {
|
|
|
1525
1604
|
|
|
1526
1605
|
// packages/cli/src/login.ts
|
|
1527
1606
|
var DEFAULT_API_URL = "https://app.vibiz.app";
|
|
1528
|
-
var pendingFile = (dir) =>
|
|
1529
|
-
var configFile = (dir) =>
|
|
1607
|
+
var pendingFile = (dir) => join4(dir, "pending-login.json");
|
|
1608
|
+
var configFile = (dir) => join4(dir, "config.json");
|
|
1530
1609
|
async function readJson(io, path) {
|
|
1531
1610
|
try {
|
|
1532
1611
|
return JSON.parse(String(await io.local().readFile(path, "utf8")));
|
|
@@ -1672,8 +1751,8 @@ async function browserLogin(io, api, deps) {
|
|
|
1672
1751
|
|
|
1673
1752
|
// packages/cli/src/scaffold.ts
|
|
1674
1753
|
import { existsSync } from "node:fs";
|
|
1675
|
-
import { cp, readdir as
|
|
1676
|
-
import { dirname as
|
|
1754
|
+
import { cp, readdir as readdir3, readFile, rename, writeFile } from "node:fs/promises";
|
|
1755
|
+
import { dirname as dirname4, join as join5 } from "node:path";
|
|
1677
1756
|
import { fileURLToPath } from "node:url";
|
|
1678
1757
|
var TEMPLATES = ["nextjs-saas"];
|
|
1679
1758
|
var SKIP = /* @__PURE__ */ new Set([
|
|
@@ -1694,10 +1773,10 @@ var packedName = (dotfile) => `_${dotfile.slice(1)}`;
|
|
|
1694
1773
|
function templatesDir() {
|
|
1695
1774
|
const fromEnv = process.env.VIBIZ_TEMPLATES_DIR?.trim();
|
|
1696
1775
|
if (fromEnv) return fromEnv;
|
|
1697
|
-
const here =
|
|
1698
|
-
const packaged =
|
|
1776
|
+
const here = dirname4(fileURLToPath(import.meta.url));
|
|
1777
|
+
const packaged = join5(here, "..", "templates");
|
|
1699
1778
|
if (existsSync(packaged)) return packaged;
|
|
1700
|
-
return
|
|
1779
|
+
return join5(here, "..", "..", "..", "templates");
|
|
1701
1780
|
}
|
|
1702
1781
|
function isTemplate(name) {
|
|
1703
1782
|
return TEMPLATES.includes(name);
|
|
@@ -1708,7 +1787,7 @@ function packageName(name) {
|
|
|
1708
1787
|
}
|
|
1709
1788
|
async function isEffectivelyEmpty(dir) {
|
|
1710
1789
|
try {
|
|
1711
|
-
return (await
|
|
1790
|
+
return (await readdir3(dir)).every((e) => HARMLESS.has(e));
|
|
1712
1791
|
} catch (err) {
|
|
1713
1792
|
if (err.code === "ENOENT") return true;
|
|
1714
1793
|
throw err;
|
|
@@ -1718,7 +1797,7 @@ async function scaffold(opts) {
|
|
|
1718
1797
|
if (!opts.force && !await isEffectivelyEmpty(opts.dir)) {
|
|
1719
1798
|
throw new Error(`${opts.dir} is not empty. Use an empty folder, or pass --force.`);
|
|
1720
1799
|
}
|
|
1721
|
-
const source =
|
|
1800
|
+
const source = join5(opts.templatesRoot ?? templatesDir(), opts.template);
|
|
1722
1801
|
await cp(source, opts.dir, {
|
|
1723
1802
|
recursive: true,
|
|
1724
1803
|
force: true,
|
|
@@ -1728,24 +1807,24 @@ async function scaffold(opts) {
|
|
|
1728
1807
|
}
|
|
1729
1808
|
}).catch((err) => {
|
|
1730
1809
|
if (err.code === "ENOENT") {
|
|
1731
|
-
throw new Error(`Template "${opts.template}" not found in ${
|
|
1810
|
+
throw new Error(`Template "${opts.template}" not found in ${dirname4(source)}`);
|
|
1732
1811
|
}
|
|
1733
1812
|
throw err;
|
|
1734
1813
|
});
|
|
1735
1814
|
for (const dotfile of PACKED_DOTFILES) {
|
|
1736
|
-
await rename(
|
|
1815
|
+
await rename(join5(opts.dir, packedName(dotfile)), join5(opts.dir, dotfile)).catch((err) => {
|
|
1737
1816
|
if (err.code !== "ENOENT") throw err;
|
|
1738
1817
|
});
|
|
1739
1818
|
}
|
|
1740
1819
|
await setAppName(opts.dir, opts.name);
|
|
1741
1820
|
}
|
|
1742
1821
|
async function setAppName(dir, name) {
|
|
1743
|
-
const pkgPath =
|
|
1822
|
+
const pkgPath = join5(dir, "package.json");
|
|
1744
1823
|
const pkg = JSON.parse(await readFile(pkgPath, "utf8"));
|
|
1745
1824
|
pkg.name = packageName(name);
|
|
1746
1825
|
await writeFile(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
1747
1826
|
`);
|
|
1748
|
-
const lockPath =
|
|
1827
|
+
const lockPath = join5(dir, "package-lock.json");
|
|
1749
1828
|
const lockText = await readFile(lockPath, "utf8").catch(() => null);
|
|
1750
1829
|
if (lockText !== null) {
|
|
1751
1830
|
const lock = JSON.parse(lockText);
|
|
@@ -1755,7 +1834,7 @@ async function setAppName(dir, name) {
|
|
|
1755
1834
|
await writeFile(lockPath, `${JSON.stringify(lock, null, 2)}
|
|
1756
1835
|
`);
|
|
1757
1836
|
}
|
|
1758
|
-
const configPath =
|
|
1837
|
+
const configPath = join5(dir, "app.config.ts");
|
|
1759
1838
|
const config = await readFile(configPath, "utf8").catch(() => null);
|
|
1760
1839
|
if (config === null) return;
|
|
1761
1840
|
const literal = `'${name.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
@@ -1767,7 +1846,7 @@ async function setAppName(dir, name) {
|
|
|
1767
1846
|
// packages/cli/src/setup.ts
|
|
1768
1847
|
import { accessSync, constants } from "node:fs";
|
|
1769
1848
|
import { homedir, platform as platform2 } from "node:os";
|
|
1770
|
-
import { delimiter, dirname as
|
|
1849
|
+
import { delimiter, dirname as dirname5, join as join6 } from "node:path";
|
|
1771
1850
|
var CLIENT_NAMES = {
|
|
1772
1851
|
"claude code": "claude",
|
|
1773
1852
|
claude: "claude",
|
|
@@ -1797,7 +1876,7 @@ function onPath(cmd, env) {
|
|
|
1797
1876
|
for (const dir of (env.PATH ?? "").split(delimiter).filter(Boolean)) {
|
|
1798
1877
|
for (const ext of exts) {
|
|
1799
1878
|
try {
|
|
1800
|
-
accessSync(
|
|
1879
|
+
accessSync(join6(dir, cmd + ext), constants.X_OK);
|
|
1801
1880
|
return true;
|
|
1802
1881
|
} catch {
|
|
1803
1882
|
}
|
|
@@ -1825,24 +1904,24 @@ function parseClients(raw) {
|
|
|
1825
1904
|
function mcpConfigPath(client, home) {
|
|
1826
1905
|
switch (client) {
|
|
1827
1906
|
case "cursor":
|
|
1828
|
-
return
|
|
1907
|
+
return join6(home, ".cursor", "mcp.json");
|
|
1829
1908
|
case "windsurf":
|
|
1830
|
-
return
|
|
1909
|
+
return join6(home, ".codeium", "windsurf", "mcp_config.json");
|
|
1831
1910
|
case "gemini":
|
|
1832
|
-
return
|
|
1911
|
+
return join6(home, ".gemini", "settings.json");
|
|
1833
1912
|
case "opencode":
|
|
1834
|
-
return
|
|
1913
|
+
return join6(home, ".config", "opencode", "opencode.json");
|
|
1835
1914
|
case "vscode":
|
|
1836
1915
|
if (platform2() === "darwin")
|
|
1837
|
-
return
|
|
1916
|
+
return join6(home, "Library", "Application Support", "Code", "User", "mcp.json");
|
|
1838
1917
|
if (platform2() === "win32")
|
|
1839
|
-
return
|
|
1840
|
-
process.env.APPDATA ??
|
|
1918
|
+
return join6(
|
|
1919
|
+
process.env.APPDATA ?? join6(home, "AppData", "Roaming"),
|
|
1841
1920
|
"Code",
|
|
1842
1921
|
"User",
|
|
1843
1922
|
"mcp.json"
|
|
1844
1923
|
);
|
|
1845
|
-
return
|
|
1924
|
+
return join6(home, ".config", "Code", "User", "mcp.json");
|
|
1846
1925
|
}
|
|
1847
1926
|
}
|
|
1848
1927
|
function jsonEntry(client, url) {
|
|
@@ -1890,7 +1969,7 @@ async function mergeJsonServer(io, path, key, entry) {
|
|
|
1890
1969
|
if (before && JSON.stringify(before) === JSON.stringify(entry)) return "unchanged";
|
|
1891
1970
|
doc[key] = { ...servers, vibiz: entry };
|
|
1892
1971
|
const local = io.local();
|
|
1893
|
-
await local.mkdir(
|
|
1972
|
+
await local.mkdir(dirname5(path), { recursive: true });
|
|
1894
1973
|
await local.writeFile(path, `${JSON.stringify(doc, null, 2)}
|
|
1895
1974
|
`);
|
|
1896
1975
|
return before ? "updated" : "added";
|
|
@@ -1899,9 +1978,9 @@ async function mergeCodexToml(io, path, url) {
|
|
|
1899
1978
|
const text = await readText2(io, path) ?? "";
|
|
1900
1979
|
if (/^\s*\[mcp_servers\.vibiz\]\s*$/m.test(text)) return "unchanged";
|
|
1901
1980
|
const local = io.local();
|
|
1902
|
-
await local.mkdir(
|
|
1903
|
-
const
|
|
1904
|
-
await local.writeFile(path, `${text}${
|
|
1981
|
+
await local.mkdir(dirname5(path), { recursive: true });
|
|
1982
|
+
const sep2 = text && !text.endsWith("\n") ? "\n\n" : text ? "\n" : "";
|
|
1983
|
+
await local.writeFile(path, `${text}${sep2}[mcp_servers.vibiz]
|
|
1905
1984
|
url = "${url}"
|
|
1906
1985
|
`);
|
|
1907
1986
|
return "added";
|
|
@@ -1935,7 +2014,7 @@ async function mcpAdd(io, api, rawClients) {
|
|
|
1935
2014
|
continue;
|
|
1936
2015
|
}
|
|
1937
2016
|
if (client === "claude") {
|
|
1938
|
-
const path2 =
|
|
2017
|
+
const path2 = join6(home, ".claude.json");
|
|
1939
2018
|
const out2 = await mergeJsonServer(io, path2, "mcpServers", { type: "http", url });
|
|
1940
2019
|
io.log(`\u25CF ${name}: ${out2} in ${path2}`);
|
|
1941
2020
|
io.log(" To sign in: open /mcp in Claude Code, select vibiz, choose Authenticate.");
|
|
@@ -1953,7 +2032,7 @@ async function mcpAdd(io, api, rawClients) {
|
|
|
1953
2032
|
continue;
|
|
1954
2033
|
}
|
|
1955
2034
|
if (client === "codex") {
|
|
1956
|
-
const path2 =
|
|
2035
|
+
const path2 = join6(io.env.CODEX_HOME || join6(home, ".codex"), "config.toml");
|
|
1957
2036
|
const out2 = await mergeCodexToml(io, path2, url);
|
|
1958
2037
|
io.log(`\u25CF ${name}: ${out2} in ${path2}`);
|
|
1959
2038
|
io.log(" To sign in: codex mcp login vibiz");
|
|
@@ -1991,7 +2070,7 @@ function detectAgent(env) {
|
|
|
1991
2070
|
return "claude";
|
|
1992
2071
|
}
|
|
1993
2072
|
function skillsDir(io, agent, global) {
|
|
1994
|
-
return
|
|
2073
|
+
return join6(global ? homeOf(io) : io.local().cwd(), AGENT_DIR[agent]);
|
|
1995
2074
|
}
|
|
1996
2075
|
async function skillIndex(io, api) {
|
|
1997
2076
|
const f = io.fetch ?? fetch;
|
|
@@ -2007,7 +2086,7 @@ function parseAgent(raw, env) {
|
|
|
2007
2086
|
return a;
|
|
2008
2087
|
}
|
|
2009
2088
|
async function installed(io, dir, name) {
|
|
2010
|
-
return await readText2(io,
|
|
2089
|
+
return await readText2(io, join6(dir, name, "SKILL.md")) !== null;
|
|
2011
2090
|
}
|
|
2012
2091
|
async function skillsList(io, api, opts) {
|
|
2013
2092
|
const agent = parseAgent(opts.agent, io.env);
|
|
@@ -2050,8 +2129,8 @@ async function skillsAdd(io, api, names, opts) {
|
|
|
2050
2129
|
}
|
|
2051
2130
|
const res = await f(url);
|
|
2052
2131
|
if (!res.ok) throw new Error(`Could not download ${url} (${res.status})`);
|
|
2053
|
-
const target =
|
|
2054
|
-
await local.mkdir(
|
|
2132
|
+
const target = join6(dir, rel);
|
|
2133
|
+
await local.mkdir(dirname5(target), { recursive: true });
|
|
2055
2134
|
await local.writeFile(target, await res.text());
|
|
2056
2135
|
}
|
|
2057
2136
|
}
|
|
@@ -2424,8 +2503,8 @@ function printAction(io, a) {
|
|
|
2424
2503
|
}
|
|
2425
2504
|
|
|
2426
2505
|
// packages/cli/src/commands.ts
|
|
2427
|
-
var CONFIG_DIR =
|
|
2428
|
-
var CONFIG_FILE =
|
|
2506
|
+
var CONFIG_DIR = join7(homedir2(), ".vibiz");
|
|
2507
|
+
var CONFIG_FILE = join7(CONFIG_DIR, "config.json");
|
|
2429
2508
|
var PROJECT_FILE = "vibiz.json";
|
|
2430
2509
|
var HELP = `vibiz \u2014 website, database and sign-in for a new business, in one command
|
|
2431
2510
|
|
|
@@ -2449,6 +2528,12 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2449
2528
|
vibiz status this project, its resources and deployments
|
|
2450
2529
|
vibiz deploy [dir] [--preview] [--project <id>]
|
|
2451
2530
|
upload and deploy live (or a preview with --preview)
|
|
2531
|
+
vibiz code [ls|cat <path>] [--deployment <id>]
|
|
2532
|
+
the project's code: the live deployment's files (ls),
|
|
2533
|
+
or one file's content (cat)
|
|
2534
|
+
vibiz pull [dir] [--deployment <id>] [--force]
|
|
2535
|
+
write the live deployment's files into a folder to edit
|
|
2536
|
+
them (refuses a non-empty folder unless --force)
|
|
2452
2537
|
vibiz promote <deployment-id> make a deployment the live site
|
|
2453
2538
|
vibiz rollback go back to the previous production deployment
|
|
2454
2539
|
vibiz dev [--write <file>] [--reset] the development env (own database branch with your
|
|
@@ -2457,6 +2542,12 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
2457
2542
|
vibiz dev -- <command\u2026> run a command with the development env, no file
|
|
2458
2543
|
vibiz env [--write <file>] the PRODUCTION env (full-access keys only), to paste into
|
|
2459
2544
|
a host outside Vibiz; agents use \`vibiz dev\`
|
|
2545
|
+
vibiz env set <NAME> [--dev] the app's own variable (a third-party key\u2026): from $NAME
|
|
2546
|
+
or a hidden prompt; write-only, never printed. The app
|
|
2547
|
+
reads it from its env; connected hosts get it too
|
|
2548
|
+
vibiz env vars the app's own variables: names only, never values
|
|
2549
|
+
vibiz env unset <NAME> [--dev] remove one
|
|
2550
|
+
vibiz env link <NAME> [--dev] a console link where a person pastes it instead
|
|
2460
2551
|
vibiz export [--code] [--db] [--csv] [--env production|development] [-o file.zip]
|
|
2461
2552
|
take the app elsewhere, or keep a backup: its source
|
|
2462
2553
|
with a guide (VIBIZ-EXPORT.md, .env.example), the
|
|
@@ -2833,6 +2924,22 @@ async function zoneFor(vibiz2, name) {
|
|
|
2833
2924
|
}
|
|
2834
2925
|
return zone;
|
|
2835
2926
|
}
|
|
2927
|
+
async function linkedProject(io) {
|
|
2928
|
+
let local;
|
|
2929
|
+
try {
|
|
2930
|
+
local = io.local();
|
|
2931
|
+
} catch {
|
|
2932
|
+
return void 0;
|
|
2933
|
+
}
|
|
2934
|
+
for (let dir = local.cwd(); ; dir = dirname6(dir)) {
|
|
2935
|
+
try {
|
|
2936
|
+
const linked = JSON.parse(await local.readFile(join7(dir, PROJECT_FILE), "utf8"));
|
|
2937
|
+
if (linked.project_id) return linked.project_id;
|
|
2938
|
+
} catch {
|
|
2939
|
+
}
|
|
2940
|
+
if (dirname6(dir) === dir) return void 0;
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2836
2943
|
async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
|
|
2837
2944
|
const d = vibiz2.domains;
|
|
2838
2945
|
const json = (v) => io.log(JSON.stringify(v, null, 2));
|
|
@@ -2849,7 +2956,7 @@ async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
|
|
|
2849
2956
|
};
|
|
2850
2957
|
if (sub === "search") {
|
|
2851
2958
|
if (!arg) throw new Error("usage: vibiz domains search <name>");
|
|
2852
|
-
const project = await io
|
|
2959
|
+
const project = await linkedProject(io);
|
|
2853
2960
|
const found = await d.search(positionalsAfter(arg, third), { projectId: project });
|
|
2854
2961
|
if (values.json) return json(found);
|
|
2855
2962
|
for (const x of found.data) {
|
|
@@ -2862,8 +2969,8 @@ async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
|
|
|
2862
2969
|
}
|
|
2863
2970
|
if (sub === "buy") {
|
|
2864
2971
|
const domain = need();
|
|
2865
|
-
const project = await io
|
|
2866
|
-
const q = await d.quote(domain, { years, projectId: project });
|
|
2972
|
+
const project = values.project ?? await linkedProject(io);
|
|
2973
|
+
const q = await d.quote(domain, { years, ...project ? { projectId: project } : {} });
|
|
2867
2974
|
if (!q.available || q.price_cents === void 0) {
|
|
2868
2975
|
if (values.json) return json(q);
|
|
2869
2976
|
throw new Error(`${q.domain} is taken. Try: vibiz domains search ${q.domain.split(".")[0]}`);
|
|
@@ -2890,15 +2997,21 @@ async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
|
|
|
2890
2997
|
q.agent_limit_cents === null ? "This key can't spend on domains yet. Confirm it in the console, or let agents and the CLI buy domains in Billing \u25B8 Domains bought by agents." : `That's over the ${dollarsOf(q.agent_limit_cents)} the owner lets agents spend per domain (Billing). Confirm it in the console:`
|
|
2891
2998
|
);
|
|
2892
2999
|
io.log(` ${q.buy_url}`);
|
|
3000
|
+
if (q.key_url) {
|
|
3001
|
+
io.log(
|
|
3002
|
+
`Or give this key full access, so it can buy from now on: ${q.key_url} (or run vibiz login again and choose Full access).`
|
|
3003
|
+
);
|
|
3004
|
+
}
|
|
2893
3005
|
if (values.open && q.buy_url) io.openUrl(q.buy_url);
|
|
2894
3006
|
return;
|
|
2895
3007
|
}
|
|
2896
3008
|
await sure(`Buy ${q.domain} for ${dollarsOf(q.price_cents)}?`);
|
|
2897
|
-
const bought = await
|
|
3009
|
+
const bought = await d.buy({
|
|
2898
3010
|
domain: q.domain,
|
|
2899
3011
|
years: q.years,
|
|
2900
3012
|
expected_price_cents: q.price_cents,
|
|
2901
|
-
...q.premium ? { confirm_premium: true } : {}
|
|
3013
|
+
...q.premium ? { confirm_premium: true } : {},
|
|
3014
|
+
project_id: project ?? null
|
|
2902
3015
|
});
|
|
2903
3016
|
if (values.json) return json(bought);
|
|
2904
3017
|
printOwned(io, bought);
|
|
@@ -3693,7 +3806,7 @@ ${await oneKeyLines(vibiz2, project.id)}`);
|
|
|
3693
3806
|
const local = io.local();
|
|
3694
3807
|
const vibiz2 = await io.client();
|
|
3695
3808
|
const id = values.project ?? await io.project();
|
|
3696
|
-
const dir =
|
|
3809
|
+
const dir = resolve2(local.cwd(), positionals[0] ?? ".");
|
|
3697
3810
|
const { deployment, uploaded, total } = await deployDirectory(vibiz2, id, dir, {
|
|
3698
3811
|
target: values.preview ? "preview" : "production",
|
|
3699
3812
|
onProgress: (m) => io.log(m)
|
|
@@ -3711,6 +3824,17 @@ ${await oneKeyLines(vibiz2, project.id)}`);
|
|
|
3711
3824
|
if (done.target === "preview") io.log(` Make it live: vibiz promote ${done.id}`);
|
|
3712
3825
|
return;
|
|
3713
3826
|
}
|
|
3827
|
+
case "code":
|
|
3828
|
+
return codeCommand(io, positionals, {
|
|
3829
|
+
json: values.json,
|
|
3830
|
+
...values.deployment ? { deployment: values.deployment } : {}
|
|
3831
|
+
});
|
|
3832
|
+
case "pull":
|
|
3833
|
+
return pullCommand(io, positionals, {
|
|
3834
|
+
json: values.json,
|
|
3835
|
+
force: values.force,
|
|
3836
|
+
...values.deployment ? { deployment: values.deployment } : {}
|
|
3837
|
+
});
|
|
3714
3838
|
case "promote": {
|
|
3715
3839
|
const depId = positionals[0];
|
|
3716
3840
|
if (!depId) throw new Error("usage: vibiz promote <deployment-id>");
|
|
@@ -4366,9 +4490,9 @@ ${link.url}`
|
|
|
4366
4490
|
return;
|
|
4367
4491
|
}
|
|
4368
4492
|
if (sub === "add") {
|
|
4369
|
-
let
|
|
4493
|
+
let manifest2;
|
|
4370
4494
|
if (values.file) {
|
|
4371
|
-
|
|
4495
|
+
manifest2 = JSON.parse(await io.local().readFile(values.file, "utf8"));
|
|
4372
4496
|
} else {
|
|
4373
4497
|
const [baseUrl, ...ops] = more;
|
|
4374
4498
|
if (!name || !baseUrl) {
|
|
@@ -4379,9 +4503,9 @@ ${link.url}`
|
|
|
4379
4503
|
const envName = values.var ?? `${name.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
|
|
4380
4504
|
const [kind = "none", where = ""] = (values.auth ?? "none").split(":");
|
|
4381
4505
|
const auth = kind === "bearer" ? { type: "bearer", env: envName } : kind === "header" ? { type: "header", header: where || "X-Api-Key", env: envName } : kind === "query" ? { type: "query", param: where || "api_key", env: envName } : { type: "none" };
|
|
4382
|
-
|
|
4506
|
+
manifest2 = { name, base_url: baseUrl, auth, operations: ops };
|
|
4383
4507
|
}
|
|
4384
|
-
const made = await c.create(id,
|
|
4508
|
+
const made = await c.create(id, manifest2);
|
|
4385
4509
|
out(made, () => {
|
|
4386
4510
|
io.log(`${dot("ready")} Added ${made.name} (${made.base_url})`);
|
|
4387
4511
|
printOps(made.operations);
|
|
@@ -4758,6 +4882,42 @@ ${await oneKeyLines(vibiz2, id)}`);
|
|
|
4758
4882
|
} else io.out(text);
|
|
4759
4883
|
return;
|
|
4760
4884
|
}
|
|
4885
|
+
const sub = positionals[0];
|
|
4886
|
+
if (sub === "set" || sub === "unset" || sub === "vars" || sub === "link") {
|
|
4887
|
+
const vibiz2 = await io.client();
|
|
4888
|
+
const id = await io.project();
|
|
4889
|
+
const environment = values.dev ? "development" : "production";
|
|
4890
|
+
if (sub === "vars") {
|
|
4891
|
+
const vars = await vibiz2.projects.vars.list(id);
|
|
4892
|
+
if (values.json) return io.log(JSON.stringify(vars, null, 2));
|
|
4893
|
+
if (!vars.length) return io.log("No variables of your own yet: vibiz env set <NAME>");
|
|
4894
|
+
for (const v2 of vars)
|
|
4895
|
+
io.log(` ${v2.name.padEnd(32)} ${v2.environment.padEnd(12)} set ${v2.updated_at}`);
|
|
4896
|
+
return;
|
|
4897
|
+
}
|
|
4898
|
+
const name = positionals[1];
|
|
4899
|
+
if (!name) throw new Error(`usage: vibiz env ${sub} <NAME> [--dev]`);
|
|
4900
|
+
if (sub === "unset") {
|
|
4901
|
+
await vibiz2.projects.vars.remove(id, name, environment);
|
|
4902
|
+
return io.log(`${dot("ready")} ${name} removed from ${environment}.`);
|
|
4903
|
+
}
|
|
4904
|
+
if (sub === "link") {
|
|
4905
|
+
const link = await vibiz2.projects.secretLink(id, { name, environment });
|
|
4906
|
+
if (values.json) return io.log(JSON.stringify(link, null, 2));
|
|
4907
|
+
return io.log(
|
|
4908
|
+
`Paste ${name} here: ${link.console_url} . It goes straight to Vibiz, never through a chat.`
|
|
4909
|
+
);
|
|
4910
|
+
}
|
|
4911
|
+
const value = io.env[name] ?? await io.promptHidden(`${name} (hidden): `);
|
|
4912
|
+
if (!value) throw secretNeeded(io, `A value for ${name}`, name, argv2);
|
|
4913
|
+
const v = await vibiz2.projects.vars.set(id, name, value, environment);
|
|
4914
|
+
if (values.json) return io.log(JSON.stringify(v, null, 2));
|
|
4915
|
+
io.log(`${dot("ready")} ${name} set in ${environment}. It is never shown again.`);
|
|
4916
|
+
io.log(
|
|
4917
|
+
` The app reads it as process.env.${name} (after await vibiz.loadEnv()); a running app gets it on its next start.`
|
|
4918
|
+
);
|
|
4919
|
+
return;
|
|
4920
|
+
}
|
|
4761
4921
|
const env = await (await io.client()).projects.env(await io.project());
|
|
4762
4922
|
if (values.write) {
|
|
4763
4923
|
const existing = await io.local().readFile(values.write, "utf8").catch(() => "");
|
|
@@ -5256,7 +5416,7 @@ Store the key now: it is not shown again.`
|
|
|
5256
5416
|
return;
|
|
5257
5417
|
}
|
|
5258
5418
|
case "docs": {
|
|
5259
|
-
const { DOC_TOPICS, DOCS } = await import("./src-
|
|
5419
|
+
const { DOC_TOPICS, DOCS } = await import("./src-QNWJABRQ.js");
|
|
5260
5420
|
const topic = positionals[0];
|
|
5261
5421
|
if (!topic || !DOC_TOPICS.includes(topic)) {
|
|
5262
5422
|
for (const t of DOC_TOPICS) io.log(` vibiz docs ${t.padEnd(13)} ${DOCS[t].title}`);
|
|
@@ -5281,7 +5441,7 @@ ${DOCS[topic].body}`);
|
|
|
5281
5441
|
if (positionals[0])
|
|
5282
5442
|
throw new Error('usage: vibiz mcp (serve over stdio) | vibiz mcp add --clients "<client>"');
|
|
5283
5443
|
io.local();
|
|
5284
|
-
const { serveStdio } = await import("./src-
|
|
5444
|
+
const { serveStdio } = await import("./src-QNWJABRQ.js");
|
|
5285
5445
|
await serveStdio({ version: cliVersion() });
|
|
5286
5446
|
return;
|
|
5287
5447
|
}
|
|
@@ -5415,7 +5575,7 @@ async function aiKeysCommand(io, args, values) {
|
|
|
5415
5575
|
|
|
5416
5576
|
// packages/cli/src/update-check.ts
|
|
5417
5577
|
import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
5418
|
-
import { join as
|
|
5578
|
+
import { join as join8 } from "node:path";
|
|
5419
5579
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
5420
5580
|
var LATEST_URL = "https://registry.npmjs.org/@vibiz/cli/latest";
|
|
5421
5581
|
function isNewer(latest, current) {
|
|
@@ -5437,7 +5597,7 @@ function updateNotice(latest, current) {
|
|
|
5437
5597
|
}
|
|
5438
5598
|
async function latestVersion(configDir, env, fetchImpl = fetch, now = Date.now()) {
|
|
5439
5599
|
if (env.VIBIZ_NO_UPDATE_CHECK || env.CI) return null;
|
|
5440
|
-
const file =
|
|
5600
|
+
const file = join8(configDir, "update-check.json");
|
|
5441
5601
|
let cache = null;
|
|
5442
5602
|
try {
|
|
5443
5603
|
cache = JSON.parse(await readFile2(file, "utf8"));
|
|
@@ -5535,10 +5695,10 @@ var terminal = {
|
|
|
5535
5695
|
});
|
|
5536
5696
|
},
|
|
5537
5697
|
project: async () => {
|
|
5538
|
-
for (let dir = process.cwd(); ; dir =
|
|
5539
|
-
const linked = await readJson2(
|
|
5698
|
+
for (let dir = process.cwd(); ; dir = dirname7(dir)) {
|
|
5699
|
+
const linked = await readJson2(join9(dir, PROJECT_FILE));
|
|
5540
5700
|
if (linked?.project_id) return linked.project_id;
|
|
5541
|
-
if (
|
|
5701
|
+
if (dirname7(dir) === dir) break;
|
|
5542
5702
|
}
|
|
5543
5703
|
const list2 = await new Vibiz(await login()).projects.list();
|
|
5544
5704
|
const wanted = process.env.VIBIZ_PROJECT?.trim().toLowerCase();
|
package/package.json
CHANGED