@vite-hub/cli 0.4.1 → 0.5.1
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-C003KqWY.js} +359 -158
- package/dist/{console-auth-B0HxFFiX.js → console-auth-CpOpbA7U.js} +3 -7
- package/dist/{console-env-DSAuhgRZ.js → console-env-CsBruJnE.js} +4 -10
- package/dist/{deploy-C0RdI5OK.js → deploy-BZ2iQjZL.js} +10 -47
- package/dist/{env-B1Gg-WnA.js → env-DRI0QH4-.js} +1160 -1099
- package/dist/{envelope-B4mPbSbj.js → envelope-DbplCDko.js} +2 -3
- package/dist/index.d.ts +2 -4
- package/dist/index.js +241 -83
- package/dist/{provision-DXl97xG0.js → provision-DlknnTAt.js} +916 -204
- package/dist/{provision-C9p1wSzq.d.ts → provision-kiD8Emd7.d.ts} +1 -9
- package/dist/rolldown-runtime-BJohB4LM.js +13 -0
- package/dist/setup/index.d.ts +16 -61
- package/dist/setup/index.js +8 -10
- package/package.json +13 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as cliErrorDiagnostics } from "./provision-
|
|
1
|
+
import { m as cliErrorDiagnostics } from "./provision-DlknnTAt.js";
|
|
2
2
|
import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
|
|
3
|
-
|
|
3
|
+
// src/setup/envelope.ts
|
|
4
4
|
/** Exit codes of the setup commands. */
|
|
5
5
|
const setupExitCodes = {
|
|
6
6
|
done: 0,
|
|
@@ -84,5 +84,4 @@ function table(rows) {
|
|
|
84
84
|
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
85
85
|
return rows.map((row) => row.map((cell, column) => cell.padEnd(widths[column])).join(" ").trimEnd()).join("\n");
|
|
86
86
|
}
|
|
87
|
-
//#endregion
|
|
88
87
|
export { table as a, setupFailure as i, readSetupArgs as n, writeSetupError as o, setupExitCodes as r, writeSetupJson as s, isSetupFailure as t };
|
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;
|
|
@@ -29,7 +28,6 @@ type ViteHubCliEntrypointStream = {
|
|
|
29
28
|
write: (chunk: string | Uint8Array) => void | PromiseLike<unknown>;
|
|
30
29
|
};
|
|
31
30
|
interface ViteHubCliLoadedConfig {
|
|
32
|
-
/** The Nitro config that the plugins wrote. `vitehub inspect routes` reads its `handlers`. */
|
|
33
31
|
nitro?: unknown;
|
|
34
32
|
plugins: readonly unknown[];
|
|
35
33
|
root: string;
|
|
@@ -78,4 +76,4 @@ export interface RunViteHubCliEntrypointOptions extends Omit<RunViteHubCliOption
|
|
|
78
76
|
}
|
|
79
77
|
export declare function runViteHubCli(options?: RunViteHubCliOptions): Promise<number>;
|
|
80
78
|
export declare function runViteHubCliEntrypoint(options?: RunViteHubCliEntrypointOptions): void;
|
|
81
|
-
|
|
79
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { 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, Q as isRecord, 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-DlknnTAt.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]";
|
|
@@ -153,7 +151,6 @@ function redactSummary(summary) {
|
|
|
153
151
|
}))
|
|
154
152
|
};
|
|
155
153
|
}
|
|
156
|
-
/** The operations of the app as one Definition kind. */
|
|
157
154
|
function operationInspector(operations) {
|
|
158
155
|
return {
|
|
159
156
|
kind: "operation",
|
|
@@ -174,7 +171,7 @@ function operationInspector(operations) {
|
|
|
174
171
|
},
|
|
175
172
|
{
|
|
176
173
|
label: "Command",
|
|
177
|
-
value:
|
|
174
|
+
value: operation.cli === false ? "none" : `vitehub ${operationCliPath(operation).namespace} ${operationCliPath(operation).command}`
|
|
178
175
|
}
|
|
179
176
|
],
|
|
180
177
|
file: "operations",
|
|
@@ -259,6 +256,27 @@ function readProviderOutputEntry(rootDir, entry) {
|
|
|
259
256
|
}
|
|
260
257
|
return report;
|
|
261
258
|
}
|
|
259
|
+
function restoreDeploymentEnvSecretFlags(report, redacted) {
|
|
260
|
+
if (report.owner !== "vite-hub" || report.type !== "file" || basename(report.path) !== "deployment.json") return redacted;
|
|
261
|
+
if (!isRecord(report.content) || !Array.isArray(report.content.env)) return redacted;
|
|
262
|
+
if (!isRecord(redacted) || !isRecord(redacted.content) || !Array.isArray(redacted.content.env)) return redacted;
|
|
263
|
+
const source = report.content.env;
|
|
264
|
+
const env = redacted.content.env.map((entry, index) => {
|
|
265
|
+
const original = source[index];
|
|
266
|
+
const secret = isRecord(original) ? original.secret : void 0;
|
|
267
|
+
return isRecord(entry) && (secret === true || secret === false) ? {
|
|
268
|
+
...entry,
|
|
269
|
+
secret
|
|
270
|
+
} : entry;
|
|
271
|
+
});
|
|
272
|
+
return {
|
|
273
|
+
...redacted,
|
|
274
|
+
content: {
|
|
275
|
+
...redacted.content,
|
|
276
|
+
env
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
262
280
|
async function runProviderOutput(args, context, plugins) {
|
|
263
281
|
const parsed = parseArgs$1(args, { kind: false });
|
|
264
282
|
if (parsed.help) {
|
|
@@ -296,7 +314,7 @@ async function runProviderOutput(args, context, plugins) {
|
|
|
296
314
|
content: provisionStateOutput
|
|
297
315
|
};
|
|
298
316
|
}
|
|
299
|
-
return redactInspectionValue(report);
|
|
317
|
+
return restoreDeploymentEnvSecretFlags(report, redactInspectionValue(report));
|
|
300
318
|
});
|
|
301
319
|
context.stdout.write(`${JSON.stringify({ providerOutput }, null, 2)}\n`);
|
|
302
320
|
return 0;
|
|
@@ -356,7 +374,7 @@ async function runResources(args, context, plugins) {
|
|
|
356
374
|
context.stdout.write([
|
|
357
375
|
`Usage: ${resourcesUsage}`,
|
|
358
376
|
"",
|
|
359
|
-
"Lists the host resources that Definitions and stores map to: D1, KV, R2, Queues, Vercel Blob, and the Sandbox Durable Object and Container.",
|
|
377
|
+
"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
378
|
"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
379
|
"Reads local config and files only. It never calls a provider API.",
|
|
362
380
|
"",
|
|
@@ -528,8 +546,7 @@ function createInspectNamespace(plugins, operations = [], handlers = []) {
|
|
|
528
546
|
name: "inspect"
|
|
529
547
|
};
|
|
530
548
|
}
|
|
531
|
-
|
|
532
|
-
//#region ../internal/dist/contributions.js
|
|
549
|
+
// ../internal/dist/contributions.js
|
|
533
550
|
function isThenable(value) {
|
|
534
551
|
return typeof value.then === "function";
|
|
535
552
|
}
|
|
@@ -556,8 +573,7 @@ async function flattenPluginOptions(plugins) {
|
|
|
556
573
|
await flattenPlugins(plugins ?? [], flattened, /* @__PURE__ */ new Set());
|
|
557
574
|
return flattened;
|
|
558
575
|
}
|
|
559
|
-
|
|
560
|
-
//#region src/operations.ts
|
|
576
|
+
// src/operations.ts
|
|
561
577
|
/** Reads every contributed operation of the resolved plugins. A module that fails to load is reported on stderr. */
|
|
562
578
|
async function loadCliOperations(plugins, stderr) {
|
|
563
579
|
const sources = [];
|
|
@@ -590,7 +606,6 @@ const scalarTypes = /* @__PURE__ */ new Set([
|
|
|
590
606
|
"number",
|
|
591
607
|
"string"
|
|
592
608
|
]);
|
|
593
|
-
/** Reads the type of a JSON Schema node. Objects, unknown values, and lists of objects are JSON. */
|
|
594
609
|
function readType(schema) {
|
|
595
610
|
if (!isObject(schema)) return {
|
|
596
611
|
alternatives: [],
|
|
@@ -671,21 +686,21 @@ function readType(schema) {
|
|
|
671
686
|
}
|
|
672
687
|
function flagsOf(operation) {
|
|
673
688
|
const schema = operationInputJsonSchema(operation);
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
return properties.map(([key, property]) => {
|
|
689
|
+
const shapes = (Array.isArray(schema.anyOf) ? schema.anyOf : [schema]).filter(isObject);
|
|
690
|
+
return [...new Map(shapes.flatMap((shape) => isObject(shape.properties) ? Object.entries(shape.properties) : []))].map(([key, property]) => {
|
|
677
691
|
const description = isObject(property) ? property.description : void 0;
|
|
692
|
+
const required = shapes.every((shape) => Array.isArray(shape.required) && shape.required.includes(key));
|
|
678
693
|
return {
|
|
679
694
|
...readType(property),
|
|
680
695
|
key,
|
|
681
|
-
required
|
|
696
|
+
required,
|
|
682
697
|
...typeof description === "string" ? { description } : {}
|
|
683
698
|
};
|
|
684
699
|
});
|
|
685
700
|
}
|
|
686
701
|
function usageOf(operation, flags) {
|
|
687
702
|
const { command, namespace } = operationCliPath(operation);
|
|
688
|
-
const positional = operation
|
|
703
|
+
const positional = operationCliOptions(operation)?.positional ?? [];
|
|
689
704
|
const names = positional.map((key) => {
|
|
690
705
|
return flags.find((entry) => entry.key === key)?.required === false ? `[${kebab(key)}]` : `<${kebab(key)}>`;
|
|
691
706
|
});
|
|
@@ -709,7 +724,7 @@ function describeFlag(flag) {
|
|
|
709
724
|
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
725
|
}
|
|
711
726
|
function helpOf(operation, flags) {
|
|
712
|
-
const positional = operation
|
|
727
|
+
const positional = operationCliOptions(operation)?.positional ?? [];
|
|
713
728
|
const lines = [
|
|
714
729
|
`Usage: ${usageOf(operation, flags)}`,
|
|
715
730
|
"",
|
|
@@ -772,7 +787,6 @@ function assign(input, flag, key, name, raw) {
|
|
|
772
787
|
}
|
|
773
788
|
input[key] = convert(flag, name, raw);
|
|
774
789
|
}
|
|
775
|
-
/** `--input '{"a":1}'` or `--input @file.json`. */
|
|
776
790
|
function readWholeInput(raw, cwd) {
|
|
777
791
|
let text = raw;
|
|
778
792
|
if (raw.startsWith("@")) try {
|
|
@@ -791,7 +805,7 @@ function parseCall(operation, flags, args, cwd) {
|
|
|
791
805
|
json: false,
|
|
792
806
|
yes: false
|
|
793
807
|
};
|
|
794
|
-
const positional = [...operation
|
|
808
|
+
const positional = [...operationCliOptions(operation)?.positional ?? []];
|
|
795
809
|
const { command, namespace } = operationCliPath(operation);
|
|
796
810
|
let whole = {};
|
|
797
811
|
for (let index = 0; index < args.length; index++) {
|
|
@@ -866,7 +880,6 @@ function writeFailure(failure, parsed, context) {
|
|
|
866
880
|
].join("\n"));
|
|
867
881
|
return 1;
|
|
868
882
|
}
|
|
869
|
-
/** A coded failure for a thrown diagnostic. */
|
|
870
883
|
function failureOf(error, status = 400) {
|
|
871
884
|
const code = Reflect.get(Object(error), "code");
|
|
872
885
|
const fix = Reflect.get(Object(error), "fix");
|
|
@@ -889,40 +902,26 @@ async function confirm(operation, target) {
|
|
|
889
902
|
terminal.close();
|
|
890
903
|
}
|
|
891
904
|
}
|
|
892
|
-
/** The roots that the CLI accepts a dev server for: the Vite root and the ViteHub project root. */
|
|
893
905
|
function acceptedRoots(rootDir) {
|
|
894
|
-
|
|
895
|
-
try {
|
|
896
|
-
roots.add(resolveViteHubProjectRoot(rootDir));
|
|
897
|
-
} catch {}
|
|
898
|
-
return [...roots];
|
|
906
|
+
return [.../* @__PURE__ */ new Set([rootDir, resolveViteHubProjectRoot(rootDir)])];
|
|
899
907
|
}
|
|
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
908
|
function resolveTarget(parsed, context) {
|
|
905
909
|
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
|
-
}
|
|
910
|
+
const message = appUrlError(parsed.url);
|
|
911
|
+
if (message) return { failure: failureOf(cliErrorDiagnostics.CLI_R0003({ message })) };
|
|
920
912
|
return { target: parsed.url };
|
|
921
913
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
914
|
+
try {
|
|
915
|
+
const roots = acceptedRoots(context.rootDir);
|
|
916
|
+
const found = findViteHubDevServerUrl(roots, context.env);
|
|
917
|
+
if (found) return {
|
|
918
|
+
target: found,
|
|
919
|
+
roots
|
|
920
|
+
};
|
|
921
|
+
return { failure: failureOf(cliErrorDiagnostics.CLI_R0005({ message: `No dev server is running for ${roots.at(-1)}.` }), 503) };
|
|
922
|
+
} catch (error) {
|
|
923
|
+
return { failure: failureOf(error) };
|
|
924
|
+
}
|
|
926
925
|
}
|
|
927
926
|
function featureOf(operation) {
|
|
928
927
|
const flags = flagsOf(operation);
|
|
@@ -962,12 +961,12 @@ function featureOf(operation) {
|
|
|
962
961
|
confirmed,
|
|
963
962
|
env: context.env,
|
|
964
963
|
...context.fetch ? { fetch: context.fetch } : {},
|
|
965
|
-
...
|
|
964
|
+
...resolved.roots ? { roots: resolved.roots } : {},
|
|
966
965
|
...parsed.timeout ? { timeout: parsed.timeout } : {},
|
|
967
966
|
url: target
|
|
968
967
|
}, operation.name, parsed.input);
|
|
969
968
|
if (!result.ok) return writeFailure(result, parsed, context);
|
|
970
|
-
const format = operation
|
|
969
|
+
const format = operationCliOptions(operation)?.format;
|
|
971
970
|
const output = !parsed.json && format ? format(result.value) : `${JSON.stringify(result.value ?? null, null, 2)}\n`;
|
|
972
971
|
context.stdout.write(output);
|
|
973
972
|
return 0;
|
|
@@ -975,7 +974,6 @@ function featureOf(operation) {
|
|
|
975
974
|
usage: usageOf(operation, flags)
|
|
976
975
|
};
|
|
977
976
|
}
|
|
978
|
-
/** `vitehub <namespace> <group> <command>`: one feature that runs the commands whose name starts with `<group> `. */
|
|
979
977
|
function groupOf(namespace, name, commands) {
|
|
980
978
|
const usage = `vitehub ${namespace} ${name} <${commands.map((command) => command.name).join("|")}> [args...]`;
|
|
981
979
|
const help = () => {
|
|
@@ -1017,6 +1015,7 @@ function createOperationNamespaces(operations) {
|
|
|
1017
1015
|
const namespaces = /* @__PURE__ */ new Map();
|
|
1018
1016
|
const groups = /* @__PURE__ */ new Map();
|
|
1019
1017
|
for (const operation of operations) {
|
|
1018
|
+
if (operation.cli === false) continue;
|
|
1020
1019
|
const { command, namespace: name } = operationCliPath(operation);
|
|
1021
1020
|
const namespace = namespaces.get(name) ?? {
|
|
1022
1021
|
description: `Run the ${name} operations of the app.`,
|
|
@@ -1039,7 +1038,7 @@ function createOperationNamespaces(operations) {
|
|
|
1039
1038
|
});
|
|
1040
1039
|
groups.set(key, group);
|
|
1041
1040
|
}
|
|
1042
|
-
if (operation
|
|
1041
|
+
if (operationCliOptions(operation)?.default) namespace.defaultFeature = command;
|
|
1043
1042
|
namespaces.set(name, namespace);
|
|
1044
1043
|
}
|
|
1045
1044
|
for (const group of groups.values()) {
|
|
@@ -1068,8 +1067,149 @@ function mergeOperationNamespaces(written, generated) {
|
|
|
1068
1067
|
}
|
|
1069
1068
|
return merged;
|
|
1070
1069
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1070
|
+
// src/renamed-commands.ts
|
|
1071
|
+
const renamedCommands = [
|
|
1072
|
+
{
|
|
1073
|
+
from: ["agents", "list"],
|
|
1074
|
+
now: "vitehub agent list"
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
from: ["agents", "invoke"],
|
|
1078
|
+
now: "vitehub agent invoke"
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
from: ["agents", "status"],
|
|
1082
|
+
now: "vitehub agent get <name>",
|
|
1083
|
+
migration: "Pass the Agent name instead of --agent and select the Console app with --url."
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
from: ["conversations", "export"],
|
|
1087
|
+
now: "vitehub agent conversations export"
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
from: ["invocations", "list"],
|
|
1091
|
+
now: "vitehub agent invocations list",
|
|
1092
|
+
migration: "Check --help for supported filters; the CLI JSON no longer includes a Console cursor."
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
from: ["invocations", "get"],
|
|
1096
|
+
now: "vitehub agent invocations get",
|
|
1097
|
+
migration: "Pass the Invocation ID; JSON is a flat record, and observation paging options are no longer supported by the CLI."
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
from: ["invocations", "cancel"],
|
|
1101
|
+
now: "vitehub agent invocations cancel",
|
|
1102
|
+
migration: "Pass the Invocation ID and --url <app> to use the same Console."
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
from: ["invocations", "undo"],
|
|
1106
|
+
now: "vitehub agent invocations undo",
|
|
1107
|
+
migration: "Pass the Invocation ID, --change <id>, and --url <app>."
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
from: ["invocations", "delete"],
|
|
1111
|
+
now: "vitehub agent invocations delete",
|
|
1112
|
+
migration: "Pass the Invocation ID and --url <app> to delete from the same Console. Without --url this deletes from the journal file."
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
from: ["invocations", "capabilities"],
|
|
1116
|
+
now: "vitehub agent invocations capabilities"
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
from: ["invocations", "workspace"],
|
|
1120
|
+
now: "vitehub agent invocations workspace"
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
from: ["agent", "info"],
|
|
1124
|
+
now: "vitehub agent get",
|
|
1125
|
+
migration: "Pass the name instead of --agent and use --dev --url for an explicit Dev Loop URL."
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
from: [
|
|
1129
|
+
"agent",
|
|
1130
|
+
"invocations",
|
|
1131
|
+
"show"
|
|
1132
|
+
],
|
|
1133
|
+
now: "vitehub agent invocations get"
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
from: ["content", "show"],
|
|
1137
|
+
now: "vitehub content get"
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
from: ["definitions", "list"],
|
|
1141
|
+
now: "vitehub inspect definitions",
|
|
1142
|
+
migration: "Use --kind <kind> for local definitions, or the Console for runtime records. The old section and URL arguments do not carry over."
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
from: [
|
|
1146
|
+
"email",
|
|
1147
|
+
"outbox",
|
|
1148
|
+
"show"
|
|
1149
|
+
],
|
|
1150
|
+
now: "vitehub email outbox get"
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
from: ["env", "inspect"],
|
|
1154
|
+
now: "vitehub env list"
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
from: ["env", "status"],
|
|
1158
|
+
now: "vitehub env list --url <app>",
|
|
1159
|
+
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."
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
from: ["project", "info"],
|
|
1163
|
+
now: "vitehub project get"
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
from: [
|
|
1167
|
+
"queue",
|
|
1168
|
+
"jobs",
|
|
1169
|
+
"show"
|
|
1170
|
+
],
|
|
1171
|
+
now: "vitehub queue jobs get"
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
from: ["schedule", "attempts"],
|
|
1175
|
+
now: "vitehub schedule runs get <run>"
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
from: ["schedule", "runs"],
|
|
1179
|
+
next: (word) => word !== void 0 && ![
|
|
1180
|
+
"get",
|
|
1181
|
+
"list",
|
|
1182
|
+
"-h",
|
|
1183
|
+
"--help"
|
|
1184
|
+
].includes(word),
|
|
1185
|
+
now: "vitehub schedule runs list <schedule>"
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
from: ["workflow", "get"],
|
|
1189
|
+
now: "vitehub workflow runs get",
|
|
1190
|
+
migration: "Add --json to keep JSON output."
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
from: [
|
|
1194
|
+
"workflow",
|
|
1195
|
+
"runs",
|
|
1196
|
+
"show"
|
|
1197
|
+
],
|
|
1198
|
+
now: "vitehub workflow runs get",
|
|
1199
|
+
migration: "Use --run-id instead of --id, and runId instead of id in --input JSON."
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
from: ["workspace", "show"],
|
|
1203
|
+
now: "vitehub workspace get"
|
|
1204
|
+
}
|
|
1205
|
+
];
|
|
1206
|
+
/** The message for an old command spelling, or undefined when `args` is a current command. */
|
|
1207
|
+
function renamedCommandMessage(args) {
|
|
1208
|
+
const renamed = renamedCommands.find((entry) => entry.from.every((word, index) => args[index] === word) && (entry.next?.(args[entry.from.length]) ?? true));
|
|
1209
|
+
if (!renamed) return;
|
|
1210
|
+
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.`;
|
|
1211
|
+
}
|
|
1212
|
+
// src/seed.ts
|
|
1073
1213
|
const usage = "vitehub seed [<primitive>...] [--remote [--url <url>]] [--stage <name>] [--database <name>] [--timeout <ms>]";
|
|
1074
1214
|
function writeUsage(seeds, stream) {
|
|
1075
1215
|
stream.write([
|
|
@@ -1133,7 +1273,6 @@ function parseArgs(args, seeds) {
|
|
|
1133
1273
|
if (parsed.database && parsed.names.some((name) => name !== "database")) return "--database seeds only the Database. Remove the other primitive names.";
|
|
1134
1274
|
return parsed;
|
|
1135
1275
|
}
|
|
1136
|
-
/** Runs the selected seeds in order and stops at the first failure. */
|
|
1137
1276
|
async function runSeeds(seeds, parsed, context) {
|
|
1138
1277
|
const selected = parsed.names.length || parsed.database ? seeds.filter((seed) => parsed.names.includes(seed.name) || parsed.database && seed.name === "database") : seeds;
|
|
1139
1278
|
if (parsed.database && !selected.length) {
|
|
@@ -1206,20 +1345,17 @@ function createSeedNamespace(seeds) {
|
|
|
1206
1345
|
name: "seed"
|
|
1207
1346
|
};
|
|
1208
1347
|
}
|
|
1209
|
-
|
|
1210
|
-
//#region src/index.ts
|
|
1348
|
+
// src/index.ts
|
|
1211
1349
|
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
|
-
*/
|
|
1350
|
+
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.";
|
|
1351
|
+
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
1352
|
const hostEnvFeatures = {
|
|
1353
|
+
description: "Compare, push, and pull the env names of the app on a host.",
|
|
1218
1354
|
features: [
|
|
1219
1355
|
{
|
|
1220
1356
|
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
1357
|
name: "diff",
|
|
1222
|
-
run: async (args, context) => await (await import("./env-
|
|
1358
|
+
run: async (args, context) => await (await import("./env-DRI0QH4-.js").then((n) => n.n)).runEnvCommand({
|
|
1223
1359
|
...hostEnvFeatures.features[0],
|
|
1224
1360
|
name: "diff"
|
|
1225
1361
|
}, args, context),
|
|
@@ -1228,7 +1364,7 @@ const hostEnvFeatures = {
|
|
|
1228
1364
|
{
|
|
1229
1365
|
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
1366
|
name: "push",
|
|
1231
|
-
run: async (args, context) => await (await import("./env-
|
|
1367
|
+
run: async (args, context) => await (await import("./env-DRI0QH4-.js").then((n) => n.n)).runEnvCommand({
|
|
1232
1368
|
...hostEnvFeatures.features[1],
|
|
1233
1369
|
name: "push"
|
|
1234
1370
|
}, args, context),
|
|
@@ -1237,14 +1373,14 @@ const hostEnvFeatures = {
|
|
|
1237
1373
|
{
|
|
1238
1374
|
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
1375
|
name: "pull",
|
|
1240
|
-
run: async (args, context) => await (await import("./console-env-
|
|
1376
|
+
run: async (args, context) => await (await import("./console-env-CsBruJnE.js")).envPullFeature.run(args, context),
|
|
1241
1377
|
usage: "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]"
|
|
1242
1378
|
}
|
|
1243
1379
|
],
|
|
1244
1380
|
name: "env"
|
|
1245
1381
|
};
|
|
1246
1382
|
async function loadSetupCommands() {
|
|
1247
|
-
return (await import("./commands-
|
|
1383
|
+
return (await import("./commands-C003KqWY.js").then((n) => n.t)).setupCommands;
|
|
1248
1384
|
}
|
|
1249
1385
|
async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
1250
1386
|
if (![
|
|
@@ -1357,10 +1493,11 @@ function resolveRouteHandlers(nitro, projectRoot) {
|
|
|
1357
1493
|
}
|
|
1358
1494
|
function defaultSpawn(command, args, options = {}) {
|
|
1359
1495
|
return new Promise((resolveResult, reject) => {
|
|
1360
|
-
const
|
|
1496
|
+
const shell = process$1.platform === "win32" && command !== process$1.execPath;
|
|
1497
|
+
const child = spawn(command, shell ? args.map((arg) => quoteSupportedInstallSpecifier(arg) ?? arg) : args, {
|
|
1361
1498
|
cwd: options.cwd,
|
|
1362
1499
|
env: options.env,
|
|
1363
|
-
shell
|
|
1500
|
+
shell,
|
|
1364
1501
|
stdio: [
|
|
1365
1502
|
options.stdin || "inherit",
|
|
1366
1503
|
options.stdout === "stderr" ? process$1.stderr : options.stdout || "inherit",
|
|
@@ -1380,22 +1517,21 @@ function defaultSpawn(command, args, options = {}) {
|
|
|
1380
1517
|
}
|
|
1381
1518
|
async function loadViteConfig(rootDir, command, mode) {
|
|
1382
1519
|
const { resolveConfig } = await import("vite");
|
|
1520
|
+
const resolvedMode = mode ?? (command === "build" ? "production" : "development");
|
|
1521
|
+
const project = viteCliProjectConfig(rootDir);
|
|
1522
|
+
const nitro = createCliDiscoveryNitroCloser();
|
|
1383
1523
|
const inlineConfig = {
|
|
1384
|
-
|
|
1524
|
+
...project,
|
|
1385
1525
|
...mode ? { mode } : {},
|
|
1526
|
+
plugins: [...project.plugins, nitro.plugin],
|
|
1386
1527
|
vitehubCliDiscovery: true
|
|
1387
1528
|
};
|
|
1388
|
-
const nitro = createCliDiscoveryNitroCloser();
|
|
1389
1529
|
try {
|
|
1390
|
-
return await resolveConfig(
|
|
1391
|
-
...inlineConfig,
|
|
1392
|
-
plugins: [nitro.plugin]
|
|
1393
|
-
}, command, mode ?? (command === "build" ? "production" : "development"));
|
|
1530
|
+
return await resolveConfig(inlineConfig, command, resolvedMode);
|
|
1394
1531
|
} finally {
|
|
1395
1532
|
await nitro.close();
|
|
1396
1533
|
}
|
|
1397
1534
|
}
|
|
1398
|
-
/** Keeps at least two spaces between a help name and its description. */
|
|
1399
1535
|
function helpNameWidth(names) {
|
|
1400
1536
|
return Math.max(12, ...names.map((name) => name.length + 1));
|
|
1401
1537
|
}
|
|
@@ -1433,7 +1569,6 @@ function isRootHelp(args) {
|
|
|
1433
1569
|
function isHelpFlag(arg) {
|
|
1434
1570
|
return arg === "-h" || arg === "--help";
|
|
1435
1571
|
}
|
|
1436
|
-
/** The namespace that answers `vitehub <namespace> [<feature>] --help` without the project, if one does. */
|
|
1437
1572
|
async function loadHelpNamespace(args, helpNamespaces) {
|
|
1438
1573
|
const [name, feature, ...rest] = args;
|
|
1439
1574
|
if (!name || !helpNamespaces || !Object.hasOwn(helpNamespaces, name) || BUILTIN_NAMESPACE_NAMES.has(name)) return;
|
|
@@ -1447,7 +1582,6 @@ function readPackageVersion() {
|
|
|
1447
1582
|
if (!version) throw cliErrorDiagnostics.CLI_R0002({ message: "[vitehub] The installed @vite-hub/cli package manifest has no valid version." });
|
|
1448
1583
|
return version;
|
|
1449
1584
|
}
|
|
1450
|
-
/** The last `--stage <name>` or `--stage=<name>` of the command. */
|
|
1451
1585
|
function readStageArg(args) {
|
|
1452
1586
|
let stage;
|
|
1453
1587
|
for (let index = 0; index < args.length; index++) {
|
|
@@ -1470,6 +1604,11 @@ async function runViteHubCli(options = {}) {
|
|
|
1470
1604
|
const cwd = options.cwd || process$1.cwd();
|
|
1471
1605
|
const env = options.env || process$1.env;
|
|
1472
1606
|
const stderr = options.stderr || { write: (chunk, encoding, callback) => typeof encoding === "function" ? process$1.stderr.write(chunk, encoding) : process$1.stderr.write(chunk, encoding, callback) };
|
|
1607
|
+
const renamed = renamedCommandMessage(args);
|
|
1608
|
+
if (renamed) {
|
|
1609
|
+
stderr.write(`${renamed}\n`);
|
|
1610
|
+
return 1;
|
|
1611
|
+
}
|
|
1473
1612
|
const spawn = options.spawn || defaultSpawn;
|
|
1474
1613
|
const stage = args[0] === "channels" && (args[1] === "sync" || args[1] === "history") || args[0] === "seed" ? readStageArg(args) : void 0;
|
|
1475
1614
|
const loadProject = (command) => withStdoutOnStderr(async () => {
|
|
@@ -1559,8 +1698,28 @@ async function runViteHubCli(options = {}) {
|
|
|
1559
1698
|
stdout
|
|
1560
1699
|
});
|
|
1561
1700
|
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
1701
|
const runtimeNamespaces = (options.runtimeNamespaces ?? []).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name));
|
|
1702
|
+
let project;
|
|
1703
|
+
try {
|
|
1704
|
+
project = await (stage ? withViteStageEnvironment(env, () => loadProject(command)) : loadProject(command));
|
|
1705
|
+
} catch (error) {
|
|
1706
|
+
const envHelp = args[0] === hostEnvFeatures.name && isHelpFlag(args[1]);
|
|
1707
|
+
if (args.length && !isRootHelp(args) && !envHelp) throw error;
|
|
1708
|
+
stderr.write(`${formatRuntimeDiagnosticError(error)}\n`);
|
|
1709
|
+
if (envHelp) {
|
|
1710
|
+
stderr.write(`${ENV_HELP_WITHOUT_CONFIG}\n\n`);
|
|
1711
|
+
writeNamespaceHelp(hostEnvFeatures, stdout);
|
|
1712
|
+
return 1;
|
|
1713
|
+
}
|
|
1714
|
+
stderr.write(`${ROOT_HELP_WITHOUT_CONFIG}\n\n`);
|
|
1715
|
+
writeRootHelp([
|
|
1716
|
+
provisionNamespace,
|
|
1717
|
+
...runtimeNamespaces,
|
|
1718
|
+
hostEnvFeatures
|
|
1719
|
+
], await loadCommands(), stdout);
|
|
1720
|
+
return 1;
|
|
1721
|
+
}
|
|
1722
|
+
const { contribution, handlers, operations, plugins, rootDir } = project;
|
|
1564
1723
|
const runtimeNames = new Set(runtimeNamespaces.map((namespace) => namespace.name));
|
|
1565
1724
|
const namespaces = [
|
|
1566
1725
|
...mergeOperationNamespaces(contribution.namespaces, createOperationNamespaces(operations)).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name) && !runtimeNames.has(namespace.name)),
|
|
@@ -1688,5 +1847,4 @@ function runViteHubCliEntrypoint(options = {}) {
|
|
|
1688
1847
|
process$1.exit(exitCode);
|
|
1689
1848
|
})();
|
|
1690
1849
|
}
|
|
1691
|
-
//#endregion
|
|
1692
1850
|
export { runViteHubCli, runViteHubCliEntrypoint };
|