@vite-hub/cli 0.4.1 → 0.5.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/README.md +2 -1
- package/dist/{commands-BQucvYlq.js → commands-W0ijB5R6.js} +329 -134
- package/dist/{console-auth-B0HxFFiX.js → console-auth-Dz9HHP2G.js} +2 -5
- package/dist/{console-env-DSAuhgRZ.js → console-env--3nqqpCV.js} +3 -8
- package/dist/{deploy-C0RdI5OK.js → deploy-CHW75le_.js} +4 -32
- package/dist/{env-B1Gg-WnA.js → env-MtXhP7A7.js} +236 -748
- package/dist/{envelope-B4mPbSbj.js → envelope-C7e408hm.js} +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +235 -69
- package/dist/{provision-DXl97xG0.js → provision-DgT_lpyn.js} +742 -20
- package/dist/{provision-C9p1wSzq.d.ts → provision-bhi-xnCG.d.ts} +2 -2
- package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
- package/dist/setup/index.d.ts +16 -10
- package/dist/setup/index.js +7 -8
- package/package.json +5 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as cliErrorDiagnostics } from "./provision-
|
|
1
|
+
import { m as cliErrorDiagnostics } from "./provision-DgT_lpyn.js";
|
|
2
2
|
import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
|
|
3
3
|
//#region src/setup/envelope.ts
|
|
4
4
|
/** Exit codes of the setup commands. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ProvisionProvider, c as HostCliRun, i as ViteHubCliProvision, n as ViteHubCliCommandNamespace, t as ViteHubCliCommand } from "./provision-
|
|
1
|
+
import { a as ProvisionProvider, c as HostCliRun, i as ViteHubCliProvision, n as ViteHubCliCommandNamespace, t as ViteHubCliCommand } from "./provision-bhi-xnCG.js";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
3
|
interface ViteHubCliSpawnResult {
|
|
4
4
|
exitCode: number | null;
|
|
@@ -29,7 +29,6 @@ type ViteHubCliEntrypointStream = {
|
|
|
29
29
|
write: (chunk: string | Uint8Array) => void | PromiseLike<unknown>;
|
|
30
30
|
};
|
|
31
31
|
interface ViteHubCliLoadedConfig {
|
|
32
|
-
/** The Nitro config that the plugins wrote. `vitehub inspect routes` reads its `handlers`. */
|
|
33
32
|
nitro?: unknown;
|
|
34
33
|
plugins: readonly unknown[];
|
|
35
34
|
root: string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as isRecord, A as parseOperationInput, D as operationCliOptions, E as operationCall, G as appUrlError, J as findViteHubDevServerUrl, K as collectViteHubCliContribution, M as reservedOperationNamespaces, N as setupCommandNames, O as operationCliPath, P as resolveViteHubProjectRoot, S as callOperation, T as createOperationRegistry, U as quoteSupportedInstallSpecifier, X as viteCliProjectConfig, Y as getStableStdoutWrite, Z as withStdoutOnStderr, b as loadAllEnv, h as PROVISION_STATE_FILE, j as operationInputJsonSchema, k as operationsOf, m as cliErrorDiagnostics, q as createCliDiscoveryNitroCloser, t as createProvisionNamespace, v as readProvisionStateSync, w as collectOperationContributions, x as withViteStageEnvironment } from "./provision-DgT_lpyn.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";
|
|
@@ -153,7 +153,6 @@ function redactSummary(summary) {
|
|
|
153
153
|
}))
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
/** The operations of the app as one Definition kind. */
|
|
157
156
|
function operationInspector(operations) {
|
|
158
157
|
return {
|
|
159
158
|
kind: "operation",
|
|
@@ -174,7 +173,7 @@ function operationInspector(operations) {
|
|
|
174
173
|
},
|
|
175
174
|
{
|
|
176
175
|
label: "Command",
|
|
177
|
-
value:
|
|
176
|
+
value: operation.cli === false ? "none" : `vitehub ${operationCliPath(operation).namespace} ${operationCliPath(operation).command}`
|
|
178
177
|
}
|
|
179
178
|
],
|
|
180
179
|
file: "operations",
|
|
@@ -259,6 +258,27 @@ function readProviderOutputEntry(rootDir, entry) {
|
|
|
259
258
|
}
|
|
260
259
|
return report;
|
|
261
260
|
}
|
|
261
|
+
function restoreDeploymentEnvSecretFlags(report, redacted) {
|
|
262
|
+
if (report.owner !== "vite-hub" || report.type !== "file" || basename(report.path) !== "deployment.json") return redacted;
|
|
263
|
+
if (!isRecord(report.content) || !Array.isArray(report.content.env)) return redacted;
|
|
264
|
+
if (!isRecord(redacted) || !isRecord(redacted.content) || !Array.isArray(redacted.content.env)) return redacted;
|
|
265
|
+
const source = report.content.env;
|
|
266
|
+
const env = redacted.content.env.map((entry, index) => {
|
|
267
|
+
const original = source[index];
|
|
268
|
+
const secret = isRecord(original) ? original.secret : void 0;
|
|
269
|
+
return isRecord(entry) && (secret === true || secret === false) ? {
|
|
270
|
+
...entry,
|
|
271
|
+
secret
|
|
272
|
+
} : entry;
|
|
273
|
+
});
|
|
274
|
+
return {
|
|
275
|
+
...redacted,
|
|
276
|
+
content: {
|
|
277
|
+
...redacted.content,
|
|
278
|
+
env
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
262
282
|
async function runProviderOutput(args, context, plugins) {
|
|
263
283
|
const parsed = parseArgs$1(args, { kind: false });
|
|
264
284
|
if (parsed.help) {
|
|
@@ -296,7 +316,7 @@ async function runProviderOutput(args, context, plugins) {
|
|
|
296
316
|
content: provisionStateOutput
|
|
297
317
|
};
|
|
298
318
|
}
|
|
299
|
-
return redactInspectionValue(report);
|
|
319
|
+
return restoreDeploymentEnvSecretFlags(report, redactInspectionValue(report));
|
|
300
320
|
});
|
|
301
321
|
context.stdout.write(`${JSON.stringify({ providerOutput }, null, 2)}\n`);
|
|
302
322
|
return 0;
|
|
@@ -356,7 +376,7 @@ async function runResources(args, context, plugins) {
|
|
|
356
376
|
context.stdout.write([
|
|
357
377
|
`Usage: ${resourcesUsage}`,
|
|
358
378
|
"",
|
|
359
|
-
"Lists the host resources that Definitions and stores map to: D1, KV, R2, Queues, Vercel Blob, and the Sandbox Durable Object and Container.",
|
|
379
|
+
"Lists the host resources that Definitions and stores map to: D1, KV, R2, Queues, Workflows, Schedule cron triggers, Vercel Blob, the Agent state Durable Object, and the Sandbox Durable Object and Container.",
|
|
360
380
|
"Shows each resource name, its id, and where the id came from: config, env, Provision State, generated provider output, or the host binds it by name.",
|
|
361
381
|
"Reads local config and files only. It never calls a provider API.",
|
|
362
382
|
"",
|
|
@@ -590,7 +610,6 @@ const scalarTypes = /* @__PURE__ */ new Set([
|
|
|
590
610
|
"number",
|
|
591
611
|
"string"
|
|
592
612
|
]);
|
|
593
|
-
/** Reads the type of a JSON Schema node. Objects, unknown values, and lists of objects are JSON. */
|
|
594
613
|
function readType(schema) {
|
|
595
614
|
if (!isObject(schema)) return {
|
|
596
615
|
alternatives: [],
|
|
@@ -671,21 +690,21 @@ function readType(schema) {
|
|
|
671
690
|
}
|
|
672
691
|
function flagsOf(operation) {
|
|
673
692
|
const schema = operationInputJsonSchema(operation);
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
return properties.map(([key, property]) => {
|
|
693
|
+
const shapes = (Array.isArray(schema.anyOf) ? schema.anyOf : [schema]).filter(isObject);
|
|
694
|
+
return [...new Map(shapes.flatMap((shape) => isObject(shape.properties) ? Object.entries(shape.properties) : []))].map(([key, property]) => {
|
|
677
695
|
const description = isObject(property) ? property.description : void 0;
|
|
696
|
+
const required = shapes.every((shape) => Array.isArray(shape.required) && shape.required.includes(key));
|
|
678
697
|
return {
|
|
679
698
|
...readType(property),
|
|
680
699
|
key,
|
|
681
|
-
required
|
|
700
|
+
required,
|
|
682
701
|
...typeof description === "string" ? { description } : {}
|
|
683
702
|
};
|
|
684
703
|
});
|
|
685
704
|
}
|
|
686
705
|
function usageOf(operation, flags) {
|
|
687
706
|
const { command, namespace } = operationCliPath(operation);
|
|
688
|
-
const positional = operation
|
|
707
|
+
const positional = operationCliOptions(operation)?.positional ?? [];
|
|
689
708
|
const names = positional.map((key) => {
|
|
690
709
|
return flags.find((entry) => entry.key === key)?.required === false ? `[${kebab(key)}]` : `<${kebab(key)}>`;
|
|
691
710
|
});
|
|
@@ -709,7 +728,7 @@ function describeFlag(flag) {
|
|
|
709
728
|
return `${flag.type === "json" ? "JSON" : flag.type === "list" ? "list (repeat the flag or separate with commas)" : flag.type}${flag.nullable ? " or null" : ""}${flag.required ? ", required" : ""}`;
|
|
710
729
|
}
|
|
711
730
|
function helpOf(operation, flags) {
|
|
712
|
-
const positional = operation
|
|
731
|
+
const positional = operationCliOptions(operation)?.positional ?? [];
|
|
713
732
|
const lines = [
|
|
714
733
|
`Usage: ${usageOf(operation, flags)}`,
|
|
715
734
|
"",
|
|
@@ -772,7 +791,6 @@ function assign(input, flag, key, name, raw) {
|
|
|
772
791
|
}
|
|
773
792
|
input[key] = convert(flag, name, raw);
|
|
774
793
|
}
|
|
775
|
-
/** `--input '{"a":1}'` or `--input @file.json`. */
|
|
776
794
|
function readWholeInput(raw, cwd) {
|
|
777
795
|
let text = raw;
|
|
778
796
|
if (raw.startsWith("@")) try {
|
|
@@ -791,7 +809,7 @@ function parseCall(operation, flags, args, cwd) {
|
|
|
791
809
|
json: false,
|
|
792
810
|
yes: false
|
|
793
811
|
};
|
|
794
|
-
const positional = [...operation
|
|
812
|
+
const positional = [...operationCliOptions(operation)?.positional ?? []];
|
|
795
813
|
const { command, namespace } = operationCliPath(operation);
|
|
796
814
|
let whole = {};
|
|
797
815
|
for (let index = 0; index < args.length; index++) {
|
|
@@ -866,7 +884,6 @@ function writeFailure(failure, parsed, context) {
|
|
|
866
884
|
].join("\n"));
|
|
867
885
|
return 1;
|
|
868
886
|
}
|
|
869
|
-
/** A coded failure for a thrown diagnostic. */
|
|
870
887
|
function failureOf(error, status = 400) {
|
|
871
888
|
const code = Reflect.get(Object(error), "code");
|
|
872
889
|
const fix = Reflect.get(Object(error), "fix");
|
|
@@ -889,40 +906,26 @@ async function confirm(operation, target) {
|
|
|
889
906
|
terminal.close();
|
|
890
907
|
}
|
|
891
908
|
}
|
|
892
|
-
/** The roots that the CLI accepts a dev server for: the Vite root and the ViteHub project root. */
|
|
893
909
|
function acceptedRoots(rootDir) {
|
|
894
|
-
|
|
895
|
-
try {
|
|
896
|
-
roots.add(resolveViteHubProjectRoot(rootDir));
|
|
897
|
-
} catch {}
|
|
898
|
-
return [...roots];
|
|
910
|
+
return [.../* @__PURE__ */ new Set([rootDir, resolveViteHubProjectRoot(rootDir)])];
|
|
899
911
|
}
|
|
900
|
-
/**
|
|
901
|
-
* Where a command sends its call: `--url`, else the dev server that wrote `.vitehub/dev-server.json` in this project,
|
|
902
|
-
* else `VITEHUB_DEV_SERVER_URL`. There is no guess: another project may use port 5173.
|
|
903
|
-
*/
|
|
904
912
|
function resolveTarget(parsed, context) {
|
|
905
913
|
if (parsed.url) {
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
base = new URL(parsed.url);
|
|
909
|
-
} catch {
|
|
910
|
-
return { failure: failureOf(cliErrorDiagnostics.CLI_R0003({ message: "--url must be a URL." })) };
|
|
911
|
-
}
|
|
912
|
-
const local = base.hostname === "localhost" || base.hostname === "127.0.0.1" || base.hostname === "[::1]";
|
|
913
|
-
if (base.protocol !== "https:" && !(local && base.protocol === "http:")) return { failure: failureOf(cliErrorDiagnostics.CLI_R0003({ message: "--url must use HTTPS, except for localhost." })) };
|
|
914
|
-
if (base.username || base.password || base.search || base.hash) return { failure: failureOf(cliErrorDiagnostics.CLI_R0003({ message: "--url must not contain credentials, a query, or a fragment." })) };
|
|
915
|
-
const consolePath = /(?:^|\/)_vitehub(?:\/|$)/.exec(base.pathname);
|
|
916
|
-
if (consolePath) {
|
|
917
|
-
const app = `${base.origin}${base.pathname.slice(0, consolePath.index).replace(/\/$/, "")}`;
|
|
918
|
-
return { failure: failureOf(cliErrorDiagnostics.CLI_R0003({ message: `--url is the app URL, not the Console URL. Pass --url ${app}.` })) };
|
|
919
|
-
}
|
|
914
|
+
const message = appUrlError(parsed.url);
|
|
915
|
+
if (message) return { failure: failureOf(cliErrorDiagnostics.CLI_R0003({ message })) };
|
|
920
916
|
return { target: parsed.url };
|
|
921
917
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
918
|
+
try {
|
|
919
|
+
const roots = acceptedRoots(context.rootDir);
|
|
920
|
+
const found = findViteHubDevServerUrl(roots, context.env);
|
|
921
|
+
if (found) return {
|
|
922
|
+
target: found,
|
|
923
|
+
roots
|
|
924
|
+
};
|
|
925
|
+
return { failure: failureOf(cliErrorDiagnostics.CLI_R0005({ message: `No dev server is running for ${roots.at(-1)}.` }), 503) };
|
|
926
|
+
} catch (error) {
|
|
927
|
+
return { failure: failureOf(error) };
|
|
928
|
+
}
|
|
926
929
|
}
|
|
927
930
|
function featureOf(operation) {
|
|
928
931
|
const flags = flagsOf(operation);
|
|
@@ -962,12 +965,12 @@ function featureOf(operation) {
|
|
|
962
965
|
confirmed,
|
|
963
966
|
env: context.env,
|
|
964
967
|
...context.fetch ? { fetch: context.fetch } : {},
|
|
965
|
-
...
|
|
968
|
+
...resolved.roots ? { roots: resolved.roots } : {},
|
|
966
969
|
...parsed.timeout ? { timeout: parsed.timeout } : {},
|
|
967
970
|
url: target
|
|
968
971
|
}, operation.name, parsed.input);
|
|
969
972
|
if (!result.ok) return writeFailure(result, parsed, context);
|
|
970
|
-
const format = operation
|
|
973
|
+
const format = operationCliOptions(operation)?.format;
|
|
971
974
|
const output = !parsed.json && format ? format(result.value) : `${JSON.stringify(result.value ?? null, null, 2)}\n`;
|
|
972
975
|
context.stdout.write(output);
|
|
973
976
|
return 0;
|
|
@@ -975,7 +978,6 @@ function featureOf(operation) {
|
|
|
975
978
|
usage: usageOf(operation, flags)
|
|
976
979
|
};
|
|
977
980
|
}
|
|
978
|
-
/** `vitehub <namespace> <group> <command>`: one feature that runs the commands whose name starts with `<group> `. */
|
|
979
981
|
function groupOf(namespace, name, commands) {
|
|
980
982
|
const usage = `vitehub ${namespace} ${name} <${commands.map((command) => command.name).join("|")}> [args...]`;
|
|
981
983
|
const help = () => {
|
|
@@ -1017,6 +1019,7 @@ function createOperationNamespaces(operations) {
|
|
|
1017
1019
|
const namespaces = /* @__PURE__ */ new Map();
|
|
1018
1020
|
const groups = /* @__PURE__ */ new Map();
|
|
1019
1021
|
for (const operation of operations) {
|
|
1022
|
+
if (operation.cli === false) continue;
|
|
1020
1023
|
const { command, namespace: name } = operationCliPath(operation);
|
|
1021
1024
|
const namespace = namespaces.get(name) ?? {
|
|
1022
1025
|
description: `Run the ${name} operations of the app.`,
|
|
@@ -1039,7 +1042,7 @@ function createOperationNamespaces(operations) {
|
|
|
1039
1042
|
});
|
|
1040
1043
|
groups.set(key, group);
|
|
1041
1044
|
}
|
|
1042
|
-
if (operation
|
|
1045
|
+
if (operationCliOptions(operation)?.default) namespace.defaultFeature = command;
|
|
1043
1046
|
namespaces.set(name, namespace);
|
|
1044
1047
|
}
|
|
1045
1048
|
for (const group of groups.values()) {
|
|
@@ -1069,6 +1072,149 @@ function mergeOperationNamespaces(written, generated) {
|
|
|
1069
1072
|
return merged;
|
|
1070
1073
|
}
|
|
1071
1074
|
//#endregion
|
|
1075
|
+
//#region src/renamed-commands.ts
|
|
1076
|
+
const renamedCommands = [
|
|
1077
|
+
{
|
|
1078
|
+
from: ["agents", "list"],
|
|
1079
|
+
now: "vitehub agent list"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
from: ["agents", "invoke"],
|
|
1083
|
+
now: "vitehub agent invoke"
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
from: ["agents", "status"],
|
|
1087
|
+
now: "vitehub agent get <name>",
|
|
1088
|
+
migration: "Pass the Agent name instead of --agent and select the Console app with --url."
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
from: ["conversations", "export"],
|
|
1092
|
+
now: "vitehub agent conversations export"
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
from: ["invocations", "list"],
|
|
1096
|
+
now: "vitehub agent invocations list",
|
|
1097
|
+
migration: "Check --help for supported filters; the CLI JSON no longer includes a Console cursor."
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
from: ["invocations", "get"],
|
|
1101
|
+
now: "vitehub agent invocations get",
|
|
1102
|
+
migration: "Pass the Invocation ID; JSON is a flat record, and observation paging options are no longer supported by the CLI."
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
from: ["invocations", "cancel"],
|
|
1106
|
+
now: "vitehub agent invocations cancel",
|
|
1107
|
+
migration: "Pass the Invocation ID and --url <app> to use the same Console."
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
from: ["invocations", "undo"],
|
|
1111
|
+
now: "vitehub agent invocations undo",
|
|
1112
|
+
migration: "Pass the Invocation ID, --change <id>, and --url <app>."
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
from: ["invocations", "delete"],
|
|
1116
|
+
now: "vitehub agent invocations delete",
|
|
1117
|
+
migration: "Pass the Invocation ID and --url <app> to delete from the same Console. Without --url this deletes from the journal file."
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
from: ["invocations", "capabilities"],
|
|
1121
|
+
now: "vitehub agent invocations capabilities"
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
from: ["invocations", "workspace"],
|
|
1125
|
+
now: "vitehub agent invocations workspace"
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
from: ["agent", "info"],
|
|
1129
|
+
now: "vitehub agent get",
|
|
1130
|
+
migration: "Pass the name instead of --agent and use --dev --url for an explicit Dev Loop URL."
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
from: [
|
|
1134
|
+
"agent",
|
|
1135
|
+
"invocations",
|
|
1136
|
+
"show"
|
|
1137
|
+
],
|
|
1138
|
+
now: "vitehub agent invocations get"
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
from: ["content", "show"],
|
|
1142
|
+
now: "vitehub content get"
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
from: ["definitions", "list"],
|
|
1146
|
+
now: "vitehub inspect definitions",
|
|
1147
|
+
migration: "Use --kind <kind> for local definitions, or the Console for runtime records. The old section and URL arguments do not carry over."
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
from: [
|
|
1151
|
+
"email",
|
|
1152
|
+
"outbox",
|
|
1153
|
+
"show"
|
|
1154
|
+
],
|
|
1155
|
+
now: "vitehub email outbox get"
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
from: ["env", "inspect"],
|
|
1159
|
+
now: "vitehub env list"
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
from: ["env", "status"],
|
|
1163
|
+
now: "vitehub env list --url <app>",
|
|
1164
|
+
migration: "Pass the running app URL explicitly and add --json to keep JSON output. Review --input or --timeout manually; env list does not accept them."
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
from: ["project", "info"],
|
|
1168
|
+
now: "vitehub project get"
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
from: [
|
|
1172
|
+
"queue",
|
|
1173
|
+
"jobs",
|
|
1174
|
+
"show"
|
|
1175
|
+
],
|
|
1176
|
+
now: "vitehub queue jobs get"
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
from: ["schedule", "attempts"],
|
|
1180
|
+
now: "vitehub schedule runs get <run>"
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
from: ["schedule", "runs"],
|
|
1184
|
+
next: (word) => word !== void 0 && ![
|
|
1185
|
+
"get",
|
|
1186
|
+
"list",
|
|
1187
|
+
"-h",
|
|
1188
|
+
"--help"
|
|
1189
|
+
].includes(word),
|
|
1190
|
+
now: "vitehub schedule runs list <schedule>"
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
from: ["workflow", "get"],
|
|
1194
|
+
now: "vitehub workflow runs get",
|
|
1195
|
+
migration: "Add --json to keep JSON output."
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
from: [
|
|
1199
|
+
"workflow",
|
|
1200
|
+
"runs",
|
|
1201
|
+
"show"
|
|
1202
|
+
],
|
|
1203
|
+
now: "vitehub workflow runs get",
|
|
1204
|
+
migration: "Use --run-id instead of --id, and runId instead of id in --input JSON."
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
from: ["workspace", "show"],
|
|
1208
|
+
now: "vitehub workspace get"
|
|
1209
|
+
}
|
|
1210
|
+
];
|
|
1211
|
+
/** The message for an old command spelling, or undefined when `args` is a current command. */
|
|
1212
|
+
function renamedCommandMessage(args) {
|
|
1213
|
+
const renamed = renamedCommands.find((entry) => entry.from.every((word, index) => args[index] === word) && (entry.next?.(args[entry.from.length]) ?? true));
|
|
1214
|
+
if (!renamed) return;
|
|
1215
|
+
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
|
+
}
|
|
1217
|
+
//#endregion
|
|
1072
1218
|
//#region src/seed.ts
|
|
1073
1219
|
const usage = "vitehub seed [<primitive>...] [--remote [--url <url>]] [--stage <name>] [--database <name>] [--timeout <ms>]";
|
|
1074
1220
|
function writeUsage(seeds, stream) {
|
|
@@ -1133,7 +1279,6 @@ function parseArgs(args, seeds) {
|
|
|
1133
1279
|
if (parsed.database && parsed.names.some((name) => name !== "database")) return "--database seeds only the Database. Remove the other primitive names.";
|
|
1134
1280
|
return parsed;
|
|
1135
1281
|
}
|
|
1136
|
-
/** Runs the selected seeds in order and stops at the first failure. */
|
|
1137
1282
|
async function runSeeds(seeds, parsed, context) {
|
|
1138
1283
|
const selected = parsed.names.length || parsed.database ? seeds.filter((seed) => parsed.names.includes(seed.name) || parsed.database && seed.name === "database") : seeds;
|
|
1139
1284
|
if (parsed.database && !selected.length) {
|
|
@@ -1209,17 +1354,15 @@ function createSeedNamespace(seeds) {
|
|
|
1209
1354
|
//#endregion
|
|
1210
1355
|
//#region src/index.ts
|
|
1211
1356
|
const BUILTIN_NAMESPACE_NAMES = new Set(reservedOperationNamespaces);
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
* `vitehub env pull` reads a Console with the key of `vitehub login`, so they run before the project config loads. The
|
|
1215
|
-
* other `env` features come from `hubEnv()`.
|
|
1216
|
-
*/
|
|
1357
|
+
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
|
+
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.";
|
|
1217
1359
|
const hostEnvFeatures = {
|
|
1360
|
+
description: "Compare, push, and pull the env names of the app on a host.",
|
|
1218
1361
|
features: [
|
|
1219
1362
|
{
|
|
1220
1363
|
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.",
|
|
1221
1364
|
name: "diff",
|
|
1222
|
-
run: async (args, context) => await (await import("./env-
|
|
1365
|
+
run: async (args, context) => await (await import("./env-MtXhP7A7.js").then((n) => n.n)).runEnvCommand({
|
|
1223
1366
|
...hostEnvFeatures.features[0],
|
|
1224
1367
|
name: "diff"
|
|
1225
1368
|
}, args, context),
|
|
@@ -1228,7 +1371,7 @@ const hostEnvFeatures = {
|
|
|
1228
1371
|
{
|
|
1229
1372
|
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.",
|
|
1230
1373
|
name: "push",
|
|
1231
|
-
run: async (args, context) => await (await import("./env-
|
|
1374
|
+
run: async (args, context) => await (await import("./env-MtXhP7A7.js").then((n) => n.n)).runEnvCommand({
|
|
1232
1375
|
...hostEnvFeatures.features[1],
|
|
1233
1376
|
name: "push"
|
|
1234
1377
|
}, args, context),
|
|
@@ -1237,14 +1380,14 @@ const hostEnvFeatures = {
|
|
|
1237
1380
|
{
|
|
1238
1381
|
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.",
|
|
1239
1382
|
name: "pull",
|
|
1240
|
-
run: async (args, context) => await (await import("./console-env
|
|
1383
|
+
run: async (args, context) => await (await import("./console-env--3nqqpCV.js")).envPullFeature.run(args, context),
|
|
1241
1384
|
usage: "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]"
|
|
1242
1385
|
}
|
|
1243
1386
|
],
|
|
1244
1387
|
name: "env"
|
|
1245
1388
|
};
|
|
1246
1389
|
async function loadSetupCommands() {
|
|
1247
|
-
return (await import("./commands-
|
|
1390
|
+
return (await import("./commands-W0ijB5R6.js").then((n) => n.t)).setupCommands;
|
|
1248
1391
|
}
|
|
1249
1392
|
async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
1250
1393
|
if (![
|
|
@@ -1357,10 +1500,11 @@ function resolveRouteHandlers(nitro, projectRoot) {
|
|
|
1357
1500
|
}
|
|
1358
1501
|
function defaultSpawn(command, args, options = {}) {
|
|
1359
1502
|
return new Promise((resolveResult, reject) => {
|
|
1360
|
-
const
|
|
1503
|
+
const shell = process$1.platform === "win32" && command !== process$1.execPath;
|
|
1504
|
+
const child = spawn(command, shell ? args.map((arg) => quoteSupportedInstallSpecifier(arg) ?? arg) : args, {
|
|
1361
1505
|
cwd: options.cwd,
|
|
1362
1506
|
env: options.env,
|
|
1363
|
-
shell
|
|
1507
|
+
shell,
|
|
1364
1508
|
stdio: [
|
|
1365
1509
|
options.stdin || "inherit",
|
|
1366
1510
|
options.stdout === "stderr" ? process$1.stderr : options.stdout || "inherit",
|
|
@@ -1380,22 +1524,21 @@ function defaultSpawn(command, args, options = {}) {
|
|
|
1380
1524
|
}
|
|
1381
1525
|
async function loadViteConfig(rootDir, command, mode) {
|
|
1382
1526
|
const { resolveConfig } = await import("vite");
|
|
1527
|
+
const resolvedMode = mode ?? (command === "build" ? "production" : "development");
|
|
1528
|
+
const project = viteCliProjectConfig(rootDir);
|
|
1529
|
+
const nitro = createCliDiscoveryNitroCloser();
|
|
1383
1530
|
const inlineConfig = {
|
|
1384
|
-
|
|
1531
|
+
...project,
|
|
1385
1532
|
...mode ? { mode } : {},
|
|
1533
|
+
plugins: [...project.plugins, nitro.plugin],
|
|
1386
1534
|
vitehubCliDiscovery: true
|
|
1387
1535
|
};
|
|
1388
|
-
const nitro = createCliDiscoveryNitroCloser();
|
|
1389
1536
|
try {
|
|
1390
|
-
return await resolveConfig(
|
|
1391
|
-
...inlineConfig,
|
|
1392
|
-
plugins: [nitro.plugin]
|
|
1393
|
-
}, command, mode ?? (command === "build" ? "production" : "development"));
|
|
1537
|
+
return await resolveConfig(inlineConfig, command, resolvedMode);
|
|
1394
1538
|
} finally {
|
|
1395
1539
|
await nitro.close();
|
|
1396
1540
|
}
|
|
1397
1541
|
}
|
|
1398
|
-
/** Keeps at least two spaces between a help name and its description. */
|
|
1399
1542
|
function helpNameWidth(names) {
|
|
1400
1543
|
return Math.max(12, ...names.map((name) => name.length + 1));
|
|
1401
1544
|
}
|
|
@@ -1433,7 +1576,6 @@ function isRootHelp(args) {
|
|
|
1433
1576
|
function isHelpFlag(arg) {
|
|
1434
1577
|
return arg === "-h" || arg === "--help";
|
|
1435
1578
|
}
|
|
1436
|
-
/** The namespace that answers `vitehub <namespace> [<feature>] --help` without the project, if one does. */
|
|
1437
1579
|
async function loadHelpNamespace(args, helpNamespaces) {
|
|
1438
1580
|
const [name, feature, ...rest] = args;
|
|
1439
1581
|
if (!name || !helpNamespaces || !Object.hasOwn(helpNamespaces, name) || BUILTIN_NAMESPACE_NAMES.has(name)) return;
|
|
@@ -1447,7 +1589,6 @@ function readPackageVersion() {
|
|
|
1447
1589
|
if (!version) throw cliErrorDiagnostics.CLI_R0002({ message: "[vitehub] The installed @vite-hub/cli package manifest has no valid version." });
|
|
1448
1590
|
return version;
|
|
1449
1591
|
}
|
|
1450
|
-
/** The last `--stage <name>` or `--stage=<name>` of the command. */
|
|
1451
1592
|
function readStageArg(args) {
|
|
1452
1593
|
let stage;
|
|
1453
1594
|
for (let index = 0; index < args.length; index++) {
|
|
@@ -1470,6 +1611,11 @@ async function runViteHubCli(options = {}) {
|
|
|
1470
1611
|
const cwd = options.cwd || process$1.cwd();
|
|
1471
1612
|
const env = options.env || process$1.env;
|
|
1472
1613
|
const stderr = options.stderr || { write: (chunk, encoding, callback) => typeof encoding === "function" ? process$1.stderr.write(chunk, encoding) : process$1.stderr.write(chunk, encoding, callback) };
|
|
1614
|
+
const renamed = renamedCommandMessage(args);
|
|
1615
|
+
if (renamed) {
|
|
1616
|
+
stderr.write(`${renamed}\n`);
|
|
1617
|
+
return 1;
|
|
1618
|
+
}
|
|
1473
1619
|
const spawn = options.spawn || defaultSpawn;
|
|
1474
1620
|
const stage = args[0] === "channels" && (args[1] === "sync" || args[1] === "history") || args[0] === "seed" ? readStageArg(args) : void 0;
|
|
1475
1621
|
const loadProject = (command) => withStdoutOnStderr(async () => {
|
|
@@ -1559,8 +1705,28 @@ async function runViteHubCli(options = {}) {
|
|
|
1559
1705
|
stdout
|
|
1560
1706
|
});
|
|
1561
1707
|
const command = args[0] === "inspect" && (args[1] === "output" || args[1] === "resources" || args[1] === "routes") ? "build" : "serve";
|
|
1562
|
-
const { contribution, handlers, operations, plugins, rootDir } = await (stage ? withViteStageEnvironment(env, () => loadProject(command)) : loadProject(command));
|
|
1563
1708
|
const runtimeNamespaces = (options.runtimeNamespaces ?? []).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name));
|
|
1709
|
+
let project;
|
|
1710
|
+
try {
|
|
1711
|
+
project = await (stage ? withViteStageEnvironment(env, () => loadProject(command)) : loadProject(command));
|
|
1712
|
+
} catch (error) {
|
|
1713
|
+
const envHelp = args[0] === hostEnvFeatures.name && isHelpFlag(args[1]);
|
|
1714
|
+
if (args.length && !isRootHelp(args) && !envHelp) throw error;
|
|
1715
|
+
stderr.write(`${formatRuntimeDiagnosticError(error)}\n`);
|
|
1716
|
+
if (envHelp) {
|
|
1717
|
+
stderr.write(`${ENV_HELP_WITHOUT_CONFIG}\n\n`);
|
|
1718
|
+
writeNamespaceHelp(hostEnvFeatures, stdout);
|
|
1719
|
+
return 1;
|
|
1720
|
+
}
|
|
1721
|
+
stderr.write(`${ROOT_HELP_WITHOUT_CONFIG}\n\n`);
|
|
1722
|
+
writeRootHelp([
|
|
1723
|
+
provisionNamespace,
|
|
1724
|
+
...runtimeNamespaces,
|
|
1725
|
+
hostEnvFeatures
|
|
1726
|
+
], await loadCommands(), stdout);
|
|
1727
|
+
return 1;
|
|
1728
|
+
}
|
|
1729
|
+
const { contribution, handlers, operations, plugins, rootDir } = project;
|
|
1564
1730
|
const runtimeNames = new Set(runtimeNamespaces.map((namespace) => namespace.name));
|
|
1565
1731
|
const namespaces = [
|
|
1566
1732
|
...mergeOperationNamespaces(contribution.namespaces, createOperationNamespaces(operations)).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name) && !runtimeNames.has(namespace.name)),
|