@vite-hub/cli 0.5.0 → 0.6.0
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-W0ijB5R6.js → commands-D0WSlS7h.js} +41 -36
- package/dist/{console-env--3nqqpCV.js → console-env-CYHb4owT.js} +2 -5
- package/dist/{deploy-CHW75le_.js → deploy-DwNjKrHq.js} +98 -27
- package/dist/{env-MtXhP7A7.js → env-BiVwma4a.js} +1075 -834
- package/dist/index.d.ts +2 -3
- package/dist/index.js +64 -28
- package/dist/{provision-DgT_lpyn.js → provision-akHsvf-B.js} +1344 -250
- package/dist/{provision-bhi-xnCG.d.ts → provision-kiD8Emd7.d.ts} +0 -8
- package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
- package/dist/setup/index.d.ts +28 -57
- package/dist/setup/index.js +5 -8
- package/package.json +12 -12
- package/dist/console-auth-Dz9HHP2G.js +0 -312
- package/dist/envelope-C7e408hm.js +0 -88
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as ProvisionProvider, c as HostCliRun, i as ViteHubCliProvision, n as ViteHubCliCommandNamespace, t as ViteHubCliCommand } from "./provision-
|
|
2
|
-
//#region src/index.d.ts
|
|
1
|
+
import { a as ProvisionProvider, c as HostCliRun, i as ViteHubCliProvision, n as ViteHubCliCommandNamespace, t as ViteHubCliCommand } from "./provision-kiD8Emd7.js";
|
|
3
2
|
interface ViteHubCliSpawnResult {
|
|
4
3
|
exitCode: number | null;
|
|
5
4
|
signal?: NodeJS.Signals | null;
|
|
@@ -77,4 +76,4 @@ export interface RunViteHubCliEntrypointOptions extends Omit<RunViteHubCliOption
|
|
|
77
76
|
}
|
|
78
77
|
export declare function runViteHubCli(options?: RunViteHubCliOptions): Promise<number>;
|
|
79
78
|
export declare function runViteHubCliEntrypoint(options?: RunViteHubCliEntrypointOptions): void;
|
|
80
|
-
|
|
79
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as readProvisionStateSync, At as viteCliProjectConfig, B as readConsoleCredential, Ct as quoteSupportedInstallSpecifier, Dt as createCliDiscoveryNitroCloser, Et as collectViteHubCliContribution, Mt as isRecord, Ot as findViteHubDevServerUrl, Tt as appUrlError, X as PROVISION_STATE_FILE, Y as cliErrorDiagnostics, at as collectOperationContributions, ct as operationCliOptions, dt as parseOperationInput, ft as operationInputJsonSchema, ht as resolveViteHubProjectRoot, jt as withStdoutOnStderr, kt as getStableStdoutWrite, lt as operationCliPath, mt as setupCommandNames, nt as withViteStageEnvironment, ot as createOperationRegistry, pt as reservedOperationNamespaces, rt as callOperation, st as operationCall, t as createProvisionNamespace, tt as loadAllEnv, ut as operationsOf, v as consoleClient } from "./provision-akHsvf-B.js";
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
4
4
|
import process$1 from "node:process";
|
|
5
5
|
import { basename, dirname, relative, resolve } from "pathe";
|
|
6
6
|
import { createInterface } from "node:readline/promises";
|
|
7
7
|
import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
|
|
8
|
-
|
|
8
|
+
// ../internal/dist/inspect.js
|
|
9
9
|
async function collectContributors(plugins) {
|
|
10
10
|
const contributors = [];
|
|
11
11
|
for (const plugin of plugins) {
|
|
@@ -99,8 +99,7 @@ function redactInspectionValue(value, key) {
|
|
|
99
99
|
}
|
|
100
100
|
return visit(value, key);
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
//#region src/drain.ts
|
|
102
|
+
// src/drain.ts
|
|
104
103
|
/** `vitehub drain MAINPID [STATUS_URL]`, for a service manager that stops a Node server. It needs no project. */
|
|
105
104
|
const drainCommand = {
|
|
106
105
|
description: "Drain a running Node server before it stops, for systemd ExecStop. Needs no project.",
|
|
@@ -111,8 +110,7 @@ const drainCommand = {
|
|
|
111
110
|
},
|
|
112
111
|
usage: "vitehub drain MAINPID [STATUS_URL]"
|
|
113
112
|
};
|
|
114
|
-
|
|
115
|
-
//#region src/inspect.ts
|
|
113
|
+
// src/inspect.ts
|
|
116
114
|
const definitionsUsage = "vitehub inspect definitions [--kind <kind>] [--json]";
|
|
117
115
|
const providerOutputUsage = "vitehub inspect output [--json]";
|
|
118
116
|
const resourcesUsage = "vitehub inspect resources [--json]";
|
|
@@ -548,8 +546,7 @@ function createInspectNamespace(plugins, operations = [], handlers = []) {
|
|
|
548
546
|
name: "inspect"
|
|
549
547
|
};
|
|
550
548
|
}
|
|
551
|
-
|
|
552
|
-
//#region ../internal/dist/contributions.js
|
|
549
|
+
// ../internal/dist/contributions.js
|
|
553
550
|
function isThenable(value) {
|
|
554
551
|
return typeof value.then === "function";
|
|
555
552
|
}
|
|
@@ -576,8 +573,7 @@ async function flattenPluginOptions(plugins) {
|
|
|
576
573
|
await flattenPlugins(plugins ?? [], flattened, /* @__PURE__ */ new Set());
|
|
577
574
|
return flattened;
|
|
578
575
|
}
|
|
579
|
-
|
|
580
|
-
//#region src/operations.ts
|
|
576
|
+
// src/operations.ts
|
|
581
577
|
/** Reads every contributed operation of the resolved plugins. A module that fails to load is reported on stderr. */
|
|
582
578
|
async function loadCliOperations(plugins, stderr) {
|
|
583
579
|
const sources = [];
|
|
@@ -737,7 +733,7 @@ function helpOf(operation, flags) {
|
|
|
737
733
|
];
|
|
738
734
|
const described = flags.map((flag) => ` ${positional.includes(flag.key) ? `<${kebab(flag.key)}>` : `--${kebab(flag.key)}`} ${describeFlag(flag)}${flag.description ? `. ${flag.description}` : ""}`);
|
|
739
735
|
if (described.length) lines.push("Input:", ...described, "");
|
|
740
|
-
lines.push("Options:", " --input <json|@file> Pass the whole input as JSON or from a file. Flags override it.", " --json Print JSON.", ...operation.kind === "destructive" ? [" --yes Run without asking. This operation changes or removes data."] : [], " --url <origin> The app URL, such as https://app.example.com. Without it the command calls the running dev server.", " --timeout <ms> Wait this long for the answer. Default 30000.", " -h, --help Show this help.", "");
|
|
736
|
+
lines.push("Options:", " --input <json|@file> Pass the whole input as JSON or from a file. Flags override it.", " --json Print JSON.", ...operation.kind === "destructive" ? [" --yes Run without asking. This operation changes or removes data."] : [], " --url <origin> The app URL, such as https://app.example.com. Without it the command calls the running dev server.", " After `vitehub login`, the call to an app of the Console goes through the Console.", " --timeout <ms> Wait this long for the answer. Default 30000.", " -h, --help Show this help.", "");
|
|
741
737
|
return lines.join("\n");
|
|
742
738
|
}
|
|
743
739
|
function usageError(message) {
|
|
@@ -840,7 +836,7 @@ function parseCall(operation, flags, args, cwd) {
|
|
|
840
836
|
else if (name === "input") whole = readWholeInput(take(), cwd);
|
|
841
837
|
else if (name === "timeout") {
|
|
842
838
|
const timeout = Number(take());
|
|
843
|
-
if (!Number.isInteger(timeout) || timeout < 1) throw usageError("--timeout must be a whole number of milliseconds.");
|
|
839
|
+
if (!Number.isInteger(timeout) || timeout < 1 || timeout > 2147483647) throw usageError("--timeout must be a whole number of milliseconds between 1 and 2147483647.");
|
|
844
840
|
parsed.timeout = timeout;
|
|
845
841
|
} else {
|
|
846
842
|
const negated = name.startsWith("no-") && flags.some((flag) => flag.key === camel(name.slice(3)) && flag.type === "boolean");
|
|
@@ -909,6 +905,45 @@ async function confirm(operation, target) {
|
|
|
909
905
|
function acceptedRoots(rootDir) {
|
|
910
906
|
return [.../* @__PURE__ */ new Set([rootDir, resolveViteHubProjectRoot(rootDir)])];
|
|
911
907
|
}
|
|
908
|
+
async function throughConsole(url, context, signal) {
|
|
909
|
+
if (Object.keys(context.env).some((name) => name.startsWith("VITEHUB_CONSOLE_PRIVATE_KEY_") && context.env[name])) return;
|
|
910
|
+
const warnDiscoveryFailed = () => {
|
|
911
|
+
context.stderr.write("Warning: Console discovery failed. The CLI will call the app directly if time remains.\n");
|
|
912
|
+
};
|
|
913
|
+
try {
|
|
914
|
+
const credential = await readConsoleCredential(context.env, void 0, signal);
|
|
915
|
+
if (!credential) return;
|
|
916
|
+
const { body } = await consoleClient(context, credential, signal).request("/api/projects");
|
|
917
|
+
signal.throwIfAborted();
|
|
918
|
+
if (!Array.isArray(body.projects)) {
|
|
919
|
+
warnDiscoveryFailed();
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
if (body.cliForwarding !== true) return;
|
|
923
|
+
const projects = body.projects;
|
|
924
|
+
for (const project of projects) {
|
|
925
|
+
if (project === null || typeof project !== "object") continue;
|
|
926
|
+
const { id, publicKey, url: linked } = project;
|
|
927
|
+
if (typeof id === "string" && id && typeof publicKey === "string" && publicKey && typeof linked === "string" && sameApp(linked, url)) return {
|
|
928
|
+
authorization: `Bearer ${credential.token}`,
|
|
929
|
+
target: `${credential.origin}/p/${encodeURIComponent(id)}`
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
} catch {
|
|
933
|
+
warnDiscoveryFailed();
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
function sameApp(linked, url) {
|
|
937
|
+
const key = (value) => {
|
|
938
|
+
const parsed = new URL(value);
|
|
939
|
+
return `${parsed.origin}${parsed.pathname.replace(/\/+$/u, "")}`;
|
|
940
|
+
};
|
|
941
|
+
try {
|
|
942
|
+
return key(linked) === key(url);
|
|
943
|
+
} catch {
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
912
947
|
function resolveTarget(parsed, context) {
|
|
913
948
|
if (parsed.url) {
|
|
914
949
|
const message = appUrlError(parsed.url);
|
|
@@ -929,7 +964,7 @@ function resolveTarget(parsed, context) {
|
|
|
929
964
|
}
|
|
930
965
|
function featureOf(operation) {
|
|
931
966
|
const flags = flagsOf(operation);
|
|
932
|
-
const { command } = operationCliPath(operation);
|
|
967
|
+
const { command, namespace } = operationCliPath(operation);
|
|
933
968
|
return {
|
|
934
969
|
description: operation.description,
|
|
935
970
|
name: command,
|
|
@@ -961,14 +996,19 @@ function featureOf(operation) {
|
|
|
961
996
|
if (!(process.stdin.isTTY && process.stderr.isTTY) || !await confirm(operation, target)) return writeFailure(failureOf(cliErrorDiagnostics.CLI_R0004({ message: `${operation.name} changes or removes data and was not confirmed.` })), parsed, context);
|
|
962
997
|
confirmed = true;
|
|
963
998
|
}
|
|
964
|
-
const
|
|
999
|
+
const signal = AbortSignal.timeout(parsed.timeout ?? 3e4);
|
|
1000
|
+
const proxy = parsed.url ? await throughConsole(parsed.url, context, signal) : void 0;
|
|
1001
|
+
const rpcTarget = {
|
|
1002
|
+
...proxy ? { authorization: proxy.authorization } : {},
|
|
965
1003
|
confirmed,
|
|
966
1004
|
env: context.env,
|
|
967
1005
|
...context.fetch ? { fetch: context.fetch } : {},
|
|
968
1006
|
...resolved.roots ? { roots: resolved.roots } : {},
|
|
969
|
-
|
|
970
|
-
url: target
|
|
971
|
-
}
|
|
1007
|
+
signal,
|
|
1008
|
+
url: proxy?.target ?? target
|
|
1009
|
+
};
|
|
1010
|
+
let result = await callOperation(rpcTarget, operation.name, parsed.input);
|
|
1011
|
+
if (!result.ok && result.status === 404 && result.code === "CONSOLE_NOT_FOUND" && operation.name === "invocations.usage" && operation.kind === "read" && namespace === "agent" && command === "usage") result = await callOperation(rpcTarget, "usage.get", parsed.input);
|
|
972
1012
|
if (!result.ok) return writeFailure(result, parsed, context);
|
|
973
1013
|
const format = operationCliOptions(operation)?.format;
|
|
974
1014
|
const output = !parsed.json && format ? format(result.value) : `${JSON.stringify(result.value ?? null, null, 2)}\n`;
|
|
@@ -1071,8 +1111,7 @@ function mergeOperationNamespaces(written, generated) {
|
|
|
1071
1111
|
}
|
|
1072
1112
|
return merged;
|
|
1073
1113
|
}
|
|
1074
|
-
|
|
1075
|
-
//#region src/renamed-commands.ts
|
|
1114
|
+
// src/renamed-commands.ts
|
|
1076
1115
|
const renamedCommands = [
|
|
1077
1116
|
{
|
|
1078
1117
|
from: ["agents", "list"],
|
|
@@ -1214,8 +1253,7 @@ function renamedCommandMessage(args) {
|
|
|
1214
1253
|
if (!renamed) return;
|
|
1215
1254
|
return `[vitehub] \`vitehub ${renamed.from.join(" ")}\` is now \`${renamed.now}\`. ${renamed.migration ? `${renamed.migration} ` : ""}\`vitehub migrate\` updates compatible calls and reports manual steps in scripts and CI files.`;
|
|
1216
1255
|
}
|
|
1217
|
-
|
|
1218
|
-
//#region src/seed.ts
|
|
1256
|
+
// src/seed.ts
|
|
1219
1257
|
const usage = "vitehub seed [<primitive>...] [--remote [--url <url>]] [--stage <name>] [--database <name>] [--timeout <ms>]";
|
|
1220
1258
|
function writeUsage(seeds, stream) {
|
|
1221
1259
|
stream.write([
|
|
@@ -1351,8 +1389,7 @@ function createSeedNamespace(seeds) {
|
|
|
1351
1389
|
name: "seed"
|
|
1352
1390
|
};
|
|
1353
1391
|
}
|
|
1354
|
-
|
|
1355
|
-
//#region src/index.ts
|
|
1392
|
+
// src/index.ts
|
|
1356
1393
|
const BUILTIN_NAMESPACE_NAMES = new Set(reservedOperationNamespaces);
|
|
1357
1394
|
const ROOT_HELP_WITHOUT_CONFIG = "[vitehub] The project config did not load. Project namespaces are missing. Of the commands below, only `deploy`, `provision run`, and `provision status` load the config. Fix the error above to use those three commands and the project namespaces.";
|
|
1358
1395
|
const ENV_HELP_WITHOUT_CONFIG = "[vitehub] The project config did not load. The list below shows only the env commands that do not load the config. Fix the error above to see the project env commands.";
|
|
@@ -1362,7 +1399,7 @@ const hostEnvFeatures = {
|
|
|
1362
1399
|
{
|
|
1363
1400
|
description: "Compare the env names of the last build with the names on the linked host. Exits with 1 when a required name is missing. Never reads values.",
|
|
1364
1401
|
name: "diff",
|
|
1365
|
-
run: async (args, context) => await (await import("./env-
|
|
1402
|
+
run: async (args, context) => await (await import("./env-BiVwma4a.js").then((n) => n.n)).runEnvCommand({
|
|
1366
1403
|
...hostEnvFeatures.features[0],
|
|
1367
1404
|
name: "diff"
|
|
1368
1405
|
}, args, context),
|
|
@@ -1371,7 +1408,7 @@ const hostEnvFeatures = {
|
|
|
1371
1408
|
{
|
|
1372
1409
|
description: "Set the host variables of the build's env names from the shell and .env.<stage>, with the host CLI. Prints names, never values. Never deletes a host variable.",
|
|
1373
1410
|
name: "push",
|
|
1374
|
-
run: async (args, context) => await (await import("./env-
|
|
1411
|
+
run: async (args, context) => await (await import("./env-BiVwma4a.js").then((n) => n.n)).runEnvCommand({
|
|
1375
1412
|
...hostEnvFeatures.features[1],
|
|
1376
1413
|
name: "push"
|
|
1377
1414
|
}, args, context),
|
|
@@ -1380,14 +1417,14 @@ const hostEnvFeatures = {
|
|
|
1380
1417
|
{
|
|
1381
1418
|
description: "Write the env values of a stage from a self-hosted Console to .env.<stage>. Needs `vitehub login` and the owner or admin role.",
|
|
1382
1419
|
name: "pull",
|
|
1383
|
-
run: async (args, context) => await (await import("./console-env
|
|
1420
|
+
run: async (args, context) => await (await import("./console-env-CYHb4owT.js")).envPullFeature.run(args, context),
|
|
1384
1421
|
usage: "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]"
|
|
1385
1422
|
}
|
|
1386
1423
|
],
|
|
1387
1424
|
name: "env"
|
|
1388
1425
|
};
|
|
1389
1426
|
async function loadSetupCommands() {
|
|
1390
|
-
return (await import("./commands-
|
|
1427
|
+
return (await import("./commands-D0WSlS7h.js").then((n) => n.t)).setupCommands;
|
|
1391
1428
|
}
|
|
1392
1429
|
async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
1393
1430
|
if (![
|
|
@@ -1854,5 +1891,4 @@ function runViteHubCliEntrypoint(options = {}) {
|
|
|
1854
1891
|
process$1.exit(exitCode);
|
|
1855
1892
|
})();
|
|
1856
1893
|
}
|
|
1857
|
-
//#endregion
|
|
1858
1894
|
export { runViteHubCli, runViteHubCliEntrypoint };
|