@vite-hub/cli 0.7.0 → 0.9.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-o_CHzNS9.js → commands-CzNBAR-E.js} +308 -74
- package/dist/console-apps-Cvzc6tY4.js +271 -0
- package/dist/console-auth-BunROd7u.js +2813 -0
- package/dist/{console-env-MPzeOLqu.js → console-env-BCw039oZ.js} +4 -14
- package/dist/{deploy-CGRf9Pq-.js → deploy-DxOKht-B.js} +9 -4
- package/dist/{env-DSPUdOVC.js → env-BvSnsKMg.js} +8 -9
- package/dist/envelope-DXB-0EcA.js +99 -0
- package/dist/help-cache-BI6y5pN8.js +195 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +64 -174
- package/dist/link-B3NuFAyj.js +663 -0
- package/dist/provision-D0ct9RDq.js +1743 -0
- package/dist/provision-DVuxa-yY.js +1389 -0
- package/dist/setup/index.d.ts +5 -0
- package/dist/setup/index.js +8 -7
- package/dist/status-HXNfm9mB.js +599 -0
- package/dist/vercel-ClYz5iI7.js +701 -0
- package/package.json +4 -4
- package/dist/provision-DWEZYLWJ.js +0 -8091
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as getStableStdoutWrite, C as setupCommandNames, D as createCliDiscoveryNitroCloser, E as collectViteHubCliContribution, M as rethrowCliViteImportError, N as viteCliProjectConfig, O as createNuxtConfigImport, P as withStdoutOnStderr, S as reservedOperationNamespaces, T as appUrlError, _ as operationCliOptions, b as parseOperationInput, f as callOperation, g as operationCall, h as createOperationRegistry, j as isCliViteMissing, k as findViteHubDevServerUrl, m as collectOperationContributions, s as PROVISION_STATE_FILE, t as createProvisionNamespace, u as readProvisionStateSync, v as operationCliPath, w as resolveViteHubProjectRoot, x as operationInputJsonSchema, y as operationsOf } from "./provision-DVuxa-yY.js";
|
|
2
|
+
import { S as quoteSupportedInstallSpecifier, T as isRecordOrFunction, d as cliErrorDiagnostics, f as loadAllEnv, p as withViteStageEnvironment, w as isRecord } from "./provision-D0ct9RDq.js";
|
|
2
3
|
import { spawn } from "node:child_process";
|
|
3
4
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
4
5
|
import process$1 from "node:process";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
7
|
import { basename, dirname, relative, resolve } from "pathe";
|
|
6
8
|
import { isAbsolute, resolve as resolve$1 } from "node:path";
|
|
7
9
|
import { createInterface } from "node:readline/promises";
|
|
8
|
-
import { pathToFileURL } from "node:url";
|
|
9
|
-
import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
|
|
10
10
|
// ../internal/dist/inspect.js
|
|
11
11
|
async function collectContributors(plugins) {
|
|
12
12
|
const contributors = [];
|
|
@@ -607,7 +607,7 @@ async function importWithVite(modules, resolution) {
|
|
|
607
607
|
const code = `export default await Promise.allSettled([${modules.map((module) => `import(${JSON.stringify(module)})`).join(", ")}])`;
|
|
608
608
|
const { runnerImport } = await import("vite");
|
|
609
609
|
try {
|
|
610
|
-
const { module } = await runnerImport(entry, {
|
|
610
|
+
const { dependencies, module } = await runnerImport(entry, {
|
|
611
611
|
configFile: false,
|
|
612
612
|
logLevel: "silent",
|
|
613
613
|
plugins: [{
|
|
@@ -621,6 +621,7 @@ async function importWithVite(modules, resolution) {
|
|
|
621
621
|
},
|
|
622
622
|
root: resolution.root
|
|
623
623
|
});
|
|
624
|
+
resolution.onViteDependencies?.(dependencies);
|
|
624
625
|
return new Map(modules.map((name, index) => [name, module.default[index]]));
|
|
625
626
|
} catch (reason) {
|
|
626
627
|
return new Map(modules.map((name) => [name, {
|
|
@@ -639,6 +640,7 @@ async function loadCliOperations(plugins, resolution, stderr) {
|
|
|
639
640
|
const contributions = await collectOperationContributions(await flattenPluginOptions(plugins));
|
|
640
641
|
const loaded = await loadOperationContributions(contributions, resolution);
|
|
641
642
|
const sources = [];
|
|
643
|
+
let complete = true;
|
|
642
644
|
for (const [index, contribution] of contributions.entries()) {
|
|
643
645
|
const result = loaded[index];
|
|
644
646
|
if (result.status === "fulfilled") {
|
|
@@ -648,15 +650,19 @@ async function loadCliOperations(plugins, resolution, stderr) {
|
|
|
648
650
|
});
|
|
649
651
|
continue;
|
|
650
652
|
}
|
|
653
|
+
complete = false;
|
|
651
654
|
const reason = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
|
652
|
-
stderr.write(`${formatRuntimeDiagnosticError(cliErrorDiagnostics.CLI_OPERATIONS_LOAD_FAILED({
|
|
655
|
+
stderr.write(`${(await import("@vite-hub/runtime")).formatRuntimeDiagnosticError(cliErrorDiagnostics.CLI_OPERATIONS_LOAD_FAILED({
|
|
653
656
|
export: contribution.export,
|
|
654
657
|
module: contribution.module,
|
|
655
658
|
plugin: contribution.plugin,
|
|
656
659
|
reason
|
|
657
660
|
}))}\n`);
|
|
658
661
|
}
|
|
659
|
-
return
|
|
662
|
+
return {
|
|
663
|
+
complete,
|
|
664
|
+
operations: createOperationRegistry(sources).list()
|
|
665
|
+
};
|
|
660
666
|
}
|
|
661
667
|
function kebab(key) {
|
|
662
668
|
return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
@@ -664,9 +670,6 @@ function kebab(key) {
|
|
|
664
670
|
function camel(flag) {
|
|
665
671
|
return flag.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
|
|
666
672
|
}
|
|
667
|
-
function isObject(value) {
|
|
668
|
-
return value !== null && Object(value) === value && !Array.isArray(value);
|
|
669
|
-
}
|
|
670
673
|
const scalarTypes = /* @__PURE__ */ new Set([
|
|
671
674
|
"boolean",
|
|
672
675
|
"integer",
|
|
@@ -674,7 +677,7 @@ const scalarTypes = /* @__PURE__ */ new Set([
|
|
|
674
677
|
"string"
|
|
675
678
|
]);
|
|
676
679
|
function readType(schema) {
|
|
677
|
-
if (!
|
|
680
|
+
if (!isRecordOrFunction(schema)) return {
|
|
678
681
|
alternatives: [],
|
|
679
682
|
nullable: false,
|
|
680
683
|
type: "json"
|
|
@@ -682,8 +685,8 @@ function readType(schema) {
|
|
|
682
685
|
const options = Array.isArray(schema.anyOf) ? schema.anyOf : Array.isArray(schema.oneOf) ? schema.oneOf : void 0;
|
|
683
686
|
if (options) {
|
|
684
687
|
const parts = options.map(readType);
|
|
685
|
-
const nulls = options.filter((option) =>
|
|
686
|
-
const present = parts.filter((_part, index) => !(
|
|
688
|
+
const nulls = options.filter((option) => isRecordOrFunction(option) && option.type === "null").length;
|
|
689
|
+
const present = parts.filter((_part, index) => !(isRecordOrFunction(options[index]) && options[index].type === "null"));
|
|
687
690
|
const nullable = nulls > 0 || parts.some((part) => part.nullable);
|
|
688
691
|
if (present.length === 1) return {
|
|
689
692
|
...present[0],
|
|
@@ -753,9 +756,9 @@ function readType(schema) {
|
|
|
753
756
|
}
|
|
754
757
|
function flagsOf(operation) {
|
|
755
758
|
const schema = operationInputJsonSchema(operation);
|
|
756
|
-
const shapes = (Array.isArray(schema.anyOf) ? schema.anyOf : [schema]).filter(
|
|
757
|
-
return [...new Map(shapes.flatMap((shape) =>
|
|
758
|
-
const description =
|
|
759
|
+
const shapes = (Array.isArray(schema.anyOf) ? schema.anyOf : [schema]).filter(isRecordOrFunction);
|
|
760
|
+
return [...new Map(shapes.flatMap((shape) => isRecordOrFunction(shape.properties) ? Object.entries(shape.properties) : []))].map(([key, property]) => {
|
|
761
|
+
const description = isRecordOrFunction(property) ? property.description : void 0;
|
|
759
762
|
const required = shapes.every((shape) => Array.isArray(shape.required) && shape.required.includes(key));
|
|
760
763
|
return {
|
|
761
764
|
...readType(property),
|
|
@@ -862,7 +865,7 @@ function readWholeInput(raw, cwd) {
|
|
|
862
865
|
throw usageError(`--input could not read ${raw.slice(1)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
863
866
|
}
|
|
864
867
|
const value = parseJson(text, "input");
|
|
865
|
-
if (!
|
|
868
|
+
if (!isRecordOrFunction(value)) throw usageError("--input must be a JSON object.");
|
|
866
869
|
return value;
|
|
867
870
|
}
|
|
868
871
|
function positionalKeysSkippingLeadingOptionals(positional, flags, named, count) {
|
|
@@ -997,6 +1000,7 @@ async function throughConsole(url, context, signal) {
|
|
|
997
1000
|
context.stderr.write("Warning: Console discovery failed. The CLI will call the app directly if time remains.\n");
|
|
998
1001
|
};
|
|
999
1002
|
try {
|
|
1003
|
+
const [{ selectConsole }, { consoleClient }] = await Promise.all([import("./console-auth-BunROd7u.js").then((n) => n.a), import("./console-apps-Cvzc6tY4.js").then((n) => n.o)]);
|
|
1000
1004
|
const { credential } = await selectConsole(context, void 0, signal);
|
|
1001
1005
|
if (!credential) return;
|
|
1002
1006
|
const { body } = await consoleClient(context, credential, signal).request("/api/projects");
|
|
@@ -1197,148 +1201,6 @@ function mergeOperationNamespaces(written, generated) {
|
|
|
1197
1201
|
}
|
|
1198
1202
|
return merged;
|
|
1199
1203
|
}
|
|
1200
|
-
// src/renamed-commands.ts
|
|
1201
|
-
const renamedCommands = [
|
|
1202
|
-
{
|
|
1203
|
-
from: ["agents", "list"],
|
|
1204
|
-
now: "vitehub agent list"
|
|
1205
|
-
},
|
|
1206
|
-
{
|
|
1207
|
-
from: ["agents", "invoke"],
|
|
1208
|
-
now: "vitehub agent invoke"
|
|
1209
|
-
},
|
|
1210
|
-
{
|
|
1211
|
-
from: ["agents", "status"],
|
|
1212
|
-
now: "vitehub agent get <name>",
|
|
1213
|
-
migration: "Pass the Agent name instead of --agent and select the Console app with --url."
|
|
1214
|
-
},
|
|
1215
|
-
{
|
|
1216
|
-
from: ["conversations", "export"],
|
|
1217
|
-
now: "vitehub agent conversations export"
|
|
1218
|
-
},
|
|
1219
|
-
{
|
|
1220
|
-
from: ["invocations", "list"],
|
|
1221
|
-
now: "vitehub agent invocations list",
|
|
1222
|
-
migration: "Check --help for supported filters; the CLI JSON no longer includes a Console cursor."
|
|
1223
|
-
},
|
|
1224
|
-
{
|
|
1225
|
-
from: ["invocations", "get"],
|
|
1226
|
-
now: "vitehub agent invocations get",
|
|
1227
|
-
migration: "Pass the Invocation ID; JSON is a flat record, and observation paging options are no longer supported by the CLI."
|
|
1228
|
-
},
|
|
1229
|
-
{
|
|
1230
|
-
from: ["invocations", "cancel"],
|
|
1231
|
-
now: "vitehub agent invocations cancel",
|
|
1232
|
-
migration: "Pass the Invocation ID and --url <app> to use the same Console."
|
|
1233
|
-
},
|
|
1234
|
-
{
|
|
1235
|
-
from: ["invocations", "undo"],
|
|
1236
|
-
now: "vitehub agent invocations undo",
|
|
1237
|
-
migration: "Pass the Invocation ID, --change <id>, and --url <app>."
|
|
1238
|
-
},
|
|
1239
|
-
{
|
|
1240
|
-
from: ["invocations", "delete"],
|
|
1241
|
-
now: "vitehub agent invocations delete",
|
|
1242
|
-
migration: "Pass the Invocation ID and --url <app> to delete from the same Console. Without --url this deletes from the journal file."
|
|
1243
|
-
},
|
|
1244
|
-
{
|
|
1245
|
-
from: ["invocations", "capabilities"],
|
|
1246
|
-
now: "vitehub agent invocations capabilities"
|
|
1247
|
-
},
|
|
1248
|
-
{
|
|
1249
|
-
from: ["invocations", "workspace"],
|
|
1250
|
-
now: "vitehub agent invocations workspace"
|
|
1251
|
-
},
|
|
1252
|
-
{
|
|
1253
|
-
from: ["agent", "info"],
|
|
1254
|
-
now: "vitehub agent get",
|
|
1255
|
-
migration: "Pass the name instead of --agent and use --dev --url for an explicit Dev Loop URL."
|
|
1256
|
-
},
|
|
1257
|
-
{
|
|
1258
|
-
from: [
|
|
1259
|
-
"agent",
|
|
1260
|
-
"invocations",
|
|
1261
|
-
"show"
|
|
1262
|
-
],
|
|
1263
|
-
now: "vitehub agent invocations get"
|
|
1264
|
-
},
|
|
1265
|
-
{
|
|
1266
|
-
from: ["content", "show"],
|
|
1267
|
-
now: "vitehub content get"
|
|
1268
|
-
},
|
|
1269
|
-
{
|
|
1270
|
-
from: ["definitions", "list"],
|
|
1271
|
-
now: "vitehub inspect definitions",
|
|
1272
|
-
migration: "Use --kind <kind> for local definitions, or the Console for runtime records. The old section and URL arguments do not carry over."
|
|
1273
|
-
},
|
|
1274
|
-
{
|
|
1275
|
-
from: [
|
|
1276
|
-
"email",
|
|
1277
|
-
"outbox",
|
|
1278
|
-
"show"
|
|
1279
|
-
],
|
|
1280
|
-
now: "vitehub email outbox get"
|
|
1281
|
-
},
|
|
1282
|
-
{
|
|
1283
|
-
from: ["env", "inspect"],
|
|
1284
|
-
now: "vitehub env list"
|
|
1285
|
-
},
|
|
1286
|
-
{
|
|
1287
|
-
from: ["env", "status"],
|
|
1288
|
-
now: "vitehub env list --url <app>",
|
|
1289
|
-
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."
|
|
1290
|
-
},
|
|
1291
|
-
{
|
|
1292
|
-
from: ["project", "info"],
|
|
1293
|
-
now: "vitehub project get"
|
|
1294
|
-
},
|
|
1295
|
-
{
|
|
1296
|
-
from: [
|
|
1297
|
-
"queue",
|
|
1298
|
-
"jobs",
|
|
1299
|
-
"show"
|
|
1300
|
-
],
|
|
1301
|
-
now: "vitehub queue jobs get"
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
from: ["schedule", "attempts"],
|
|
1305
|
-
now: "vitehub schedule runs get <run>"
|
|
1306
|
-
},
|
|
1307
|
-
{
|
|
1308
|
-
from: ["schedule", "runs"],
|
|
1309
|
-
next: (word) => word !== void 0 && ![
|
|
1310
|
-
"get",
|
|
1311
|
-
"list",
|
|
1312
|
-
"-h",
|
|
1313
|
-
"--help"
|
|
1314
|
-
].includes(word),
|
|
1315
|
-
now: "vitehub schedule runs list <schedule>"
|
|
1316
|
-
},
|
|
1317
|
-
{
|
|
1318
|
-
from: ["workflow", "get"],
|
|
1319
|
-
now: "vitehub workflow runs get",
|
|
1320
|
-
migration: "Add --json to keep JSON output."
|
|
1321
|
-
},
|
|
1322
|
-
{
|
|
1323
|
-
from: [
|
|
1324
|
-
"workflow",
|
|
1325
|
-
"runs",
|
|
1326
|
-
"show"
|
|
1327
|
-
],
|
|
1328
|
-
now: "vitehub workflow runs get",
|
|
1329
|
-
migration: "Use --run-id instead of --id, and runId instead of id in --input JSON."
|
|
1330
|
-
},
|
|
1331
|
-
{
|
|
1332
|
-
from: ["workspace", "show"],
|
|
1333
|
-
now: "vitehub workspace get"
|
|
1334
|
-
}
|
|
1335
|
-
];
|
|
1336
|
-
/** The message for an old command spelling, or undefined when `args` is a current command. */
|
|
1337
|
-
function renamedCommandMessage(args) {
|
|
1338
|
-
const renamed = renamedCommands.find((entry) => entry.from.every((word, index) => args[index] === word) && (entry.next?.(args[entry.from.length]) ?? true));
|
|
1339
|
-
if (!renamed) return;
|
|
1340
|
-
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.`;
|
|
1341
|
-
}
|
|
1342
1204
|
// src/seed.ts
|
|
1343
1205
|
const usage = "vitehub seed [<primitive>...] [--remote [--url <url>]] [--stage <name>] [--database <name>] [--timeout <ms>]";
|
|
1344
1206
|
function writeUsage(seeds, stream) {
|
|
@@ -1486,7 +1348,7 @@ const hostEnvFeatures = {
|
|
|
1486
1348
|
{
|
|
1487
1349
|
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.",
|
|
1488
1350
|
name: "diff",
|
|
1489
|
-
run: async (args, context) => await (await import("./env-
|
|
1351
|
+
run: async (args, context) => await (await import("./env-BvSnsKMg.js").then((n) => n.n)).runEnvCommand({
|
|
1490
1352
|
...hostEnvFeatures.features[0],
|
|
1491
1353
|
name: "diff"
|
|
1492
1354
|
}, args, context),
|
|
@@ -1495,7 +1357,7 @@ const hostEnvFeatures = {
|
|
|
1495
1357
|
{
|
|
1496
1358
|
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.",
|
|
1497
1359
|
name: "push",
|
|
1498
|
-
run: async (args, context) => await (await import("./env-
|
|
1360
|
+
run: async (args, context) => await (await import("./env-BvSnsKMg.js").then((n) => n.n)).runEnvCommand({
|
|
1499
1361
|
...hostEnvFeatures.features[1],
|
|
1500
1362
|
name: "push"
|
|
1501
1363
|
}, args, context),
|
|
@@ -1504,14 +1366,14 @@ const hostEnvFeatures = {
|
|
|
1504
1366
|
{
|
|
1505
1367
|
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.",
|
|
1506
1368
|
name: "pull",
|
|
1507
|
-
run: async (args, context) => await (await import("./console-env-
|
|
1369
|
+
run: async (args, context) => await (await import("./console-env-BCw039oZ.js").then((n) => n.t)).envPullFeature.run(args, context),
|
|
1508
1370
|
usage: "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]"
|
|
1509
1371
|
}
|
|
1510
1372
|
],
|
|
1511
1373
|
name: "env"
|
|
1512
1374
|
};
|
|
1513
1375
|
async function loadSetupCommands() {
|
|
1514
|
-
return (await import("./commands-
|
|
1376
|
+
return (await import("./commands-CzNBAR-E.js").then((n) => n.t)).setupCommands;
|
|
1515
1377
|
}
|
|
1516
1378
|
async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
1517
1379
|
if (![
|
|
@@ -1529,9 +1391,11 @@ async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
|
1529
1391
|
} catch {
|
|
1530
1392
|
throw cliErrorDiagnostics.CLI_R0001({ message: "[vitehub] Nuxt config was found, but Nuxt could not be loaded for CLI discovery." });
|
|
1531
1393
|
}
|
|
1394
|
+
const importConfig = await createNuxtConfigImport(rootDir, fileURLToPath(import.meta.resolve("nuxt/kit")));
|
|
1532
1395
|
const options = {
|
|
1533
1396
|
cwd: rootDir,
|
|
1534
1397
|
dev: command === "serve",
|
|
1398
|
+
...importConfig ? { import: importConfig.import } : {},
|
|
1535
1399
|
envName: mode ?? (command === "build" ? "production" : "development"),
|
|
1536
1400
|
overrides: {
|
|
1537
1401
|
devtools: { enabled: false },
|
|
@@ -1567,6 +1431,7 @@ async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
|
1567
1431
|
vitehubCliDiscovery: true
|
|
1568
1432
|
}, command, mode ?? (command === "build" ? "production" : "development"));
|
|
1569
1433
|
return {
|
|
1434
|
+
inputs: [...nuxt.options._layers.map((layer) => layer.config.rootDir), ...importConfig?.files ?? []],
|
|
1570
1435
|
nitro: { handlers: [...resolveRouteHandlers({
|
|
1571
1436
|
...Object(Reflect.get(config, "nitro")),
|
|
1572
1437
|
alias: {
|
|
@@ -1667,7 +1532,11 @@ async function loadViteConfig(rootDir, command, mode) {
|
|
|
1667
1532
|
vitehubCliDiscovery: true
|
|
1668
1533
|
};
|
|
1669
1534
|
try {
|
|
1670
|
-
|
|
1535
|
+
const config = await resolveConfig(inlineConfig, command, resolvedMode);
|
|
1536
|
+
return {
|
|
1537
|
+
...config,
|
|
1538
|
+
inputs: config.configFileDependencies
|
|
1539
|
+
};
|
|
1671
1540
|
} finally {
|
|
1672
1541
|
await nitro.close();
|
|
1673
1542
|
}
|
|
@@ -1750,14 +1619,9 @@ async function runViteHubCli(options = {}) {
|
|
|
1750
1619
|
const cwd = options.cwd || process$1.cwd();
|
|
1751
1620
|
const env = options.env || process$1.env;
|
|
1752
1621
|
const stderr = options.stderr || { write: (chunk, encoding, callback) => typeof encoding === "function" ? process$1.stderr.write(chunk, encoding) : process$1.stderr.write(chunk, encoding, callback) };
|
|
1753
|
-
const renamed = renamedCommandMessage(args);
|
|
1754
|
-
if (renamed) {
|
|
1755
|
-
stderr.write(`${renamed}\n`);
|
|
1756
|
-
return 1;
|
|
1757
|
-
}
|
|
1758
1622
|
const spawn = options.spawn || defaultSpawn;
|
|
1759
1623
|
const stage = args[0] === "channels" && (args[1] === "sync" || args[1] === "history") || args[0] === "seed" ? readStageArg(args) : void 0;
|
|
1760
|
-
const loadProject = (command) => withStdoutOnStderr(async () => {
|
|
1624
|
+
const loadProject = (command, recordHelpInputs = false) => withStdoutOnStderr(async () => {
|
|
1761
1625
|
const loadConfig = options.loadConfig || loadViteConfig;
|
|
1762
1626
|
const loadNuxtConfig = options.loadNuxtViteConfig || loadNuxtViteConfig;
|
|
1763
1627
|
const config = await (stage ? loadConfig(cwd, command, stage) : loadConfig(cwd, command));
|
|
@@ -1765,11 +1629,18 @@ async function runViteHubCli(options = {}) {
|
|
|
1765
1629
|
const plugins = nuxtConfig?.plugins ?? config.plugins;
|
|
1766
1630
|
const rootDir = resolve(nuxtConfig?.root || config.root || cwd);
|
|
1767
1631
|
const { alias, tsconfigPaths } = (nuxtConfig ?? config).resolve ?? {};
|
|
1632
|
+
const inputs = [
|
|
1633
|
+
...config.inputs ?? [],
|
|
1634
|
+
...nuxtConfig?.inputs ?? [],
|
|
1635
|
+
rootDir
|
|
1636
|
+
];
|
|
1768
1637
|
return {
|
|
1638
|
+
inputs,
|
|
1769
1639
|
contribution: await collectViteHubCliContribution(plugins),
|
|
1770
1640
|
handlers: resolveRouteHandlers(nuxtConfig ? nuxtConfig.nitro : config.nitro, nuxtConfig?.root || config.root || cwd),
|
|
1771
|
-
|
|
1641
|
+
discovery: await loadCliOperations(plugins, {
|
|
1772
1642
|
alias,
|
|
1643
|
+
...recordHelpInputs ? { onViteDependencies: (files) => inputs.push(...files) } : {},
|
|
1773
1644
|
root: rootDir,
|
|
1774
1645
|
tsconfigPaths
|
|
1775
1646
|
}, stderr),
|
|
@@ -1858,16 +1729,29 @@ async function runViteHubCli(options = {}) {
|
|
|
1858
1729
|
stderr,
|
|
1859
1730
|
stdout
|
|
1860
1731
|
});
|
|
1732
|
+
const helpCache = options.helpCache && !stage && (!args.length || isRootHelp(args) || args.length === 2 && isHelpFlag(args[1])) ? await import("./help-cache-BI6y5pN8.js") : void 0;
|
|
1733
|
+
const cached = helpCache?.readHelpCache(cwd, env);
|
|
1734
|
+
if (cached && args.length < 2) {
|
|
1735
|
+
writeRootHelp(cached.namespaces, cached.commands, stdout);
|
|
1736
|
+
return 0;
|
|
1737
|
+
}
|
|
1738
|
+
const cachedNamespace = cached?.namespaces.find((namespace) => namespace.name === args[0]);
|
|
1739
|
+
if (cachedNamespace && !(cachedNamespace.defaultFeature === cachedNamespace.name && cachedNamespace.features.length === 1)) {
|
|
1740
|
+
writeNamespaceHelp(cachedNamespace, stdout);
|
|
1741
|
+
return 0;
|
|
1742
|
+
}
|
|
1743
|
+
const helpRecording = cached ? void 0 : helpCache?.recordHelpCache(cwd, env);
|
|
1861
1744
|
const command = args[0] === "inspect" && (args[1] === "output" || args[1] === "resources" || args[1] === "routes") ? "build" : "serve";
|
|
1862
1745
|
const runtimeNamespaces = (options.runtimeNamespaces ?? []).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name));
|
|
1863
1746
|
let project;
|
|
1864
1747
|
try {
|
|
1865
|
-
project = await (stage ? withViteStageEnvironment(env, () => loadProject(command)) : loadProject(command));
|
|
1748
|
+
project = await (stage ? withViteStageEnvironment(env, () => loadProject(command)) : loadProject(command, !!helpRecording));
|
|
1866
1749
|
} catch (error) {
|
|
1750
|
+
helpRecording?.stop();
|
|
1867
1751
|
const envHelp = args[0] === hostEnvFeatures.name && isHelpFlag(args[1]);
|
|
1868
1752
|
const helpWithoutVite = isCliViteMissing(error) && isDiscoveryHelp(args);
|
|
1869
1753
|
if (!helpWithoutVite && args.length && !isRootHelp(args) && !envHelp) throw error;
|
|
1870
|
-
stderr.write(helpWithoutVite ? `${HELP_WITHOUT_VITE}\n\n` : `${formatRuntimeDiagnosticError(error)}\n${envHelp ? ENV_HELP_WITHOUT_CONFIG : ROOT_HELP_WITHOUT_CONFIG}\n\n`);
|
|
1754
|
+
stderr.write(helpWithoutVite ? `${HELP_WITHOUT_VITE}\n\n` : `${(await import("@vite-hub/runtime")).formatRuntimeDiagnosticError(error)}\n${envHelp ? ENV_HELP_WITHOUT_CONFIG : ROOT_HELP_WITHOUT_CONFIG}\n\n`);
|
|
1871
1755
|
if (envHelp) writeNamespaceHelp(hostEnvFeatures, stdout);
|
|
1872
1756
|
else writeRootHelp([
|
|
1873
1757
|
provisionNamespace,
|
|
@@ -1876,7 +1760,8 @@ async function runViteHubCli(options = {}) {
|
|
|
1876
1760
|
], await loadCommands(), stdout);
|
|
1877
1761
|
return helpWithoutVite ? 0 : 1;
|
|
1878
1762
|
}
|
|
1879
|
-
const { contribution,
|
|
1763
|
+
const { contribution, discovery: { complete, operations }, handlers, inputs, plugins, rootDir } = project;
|
|
1764
|
+
if (!complete) helpRecording?.stop();
|
|
1880
1765
|
const runtimeNames = new Set(runtimeNamespaces.map((namespace) => namespace.name));
|
|
1881
1766
|
const namespaces = [
|
|
1882
1767
|
...mergeOperationNamespaces(contribution.namespaces, createOperationNamespaces(operations)).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name) && !runtimeNames.has(namespace.name)),
|
|
@@ -1904,6 +1789,10 @@ async function runViteHubCli(options = {}) {
|
|
|
1904
1789
|
stderr,
|
|
1905
1790
|
stdout
|
|
1906
1791
|
};
|
|
1792
|
+
if (complete) helpRecording?.write(namespaces, (await loadCommands()).map(({ description, name }) => ({
|
|
1793
|
+
description,
|
|
1794
|
+
name
|
|
1795
|
+
})), inputs);
|
|
1907
1796
|
if (!args.length || isRootHelp(args)) {
|
|
1908
1797
|
writeRootHelp(namespaces, await loadCommands(), stdout);
|
|
1909
1798
|
return 0;
|
|
@@ -1991,13 +1880,14 @@ function runViteHubCliEntrypoint(options = {}) {
|
|
|
1991
1880
|
let exitCode;
|
|
1992
1881
|
try {
|
|
1993
1882
|
exitCode = await runViteHubCli({
|
|
1883
|
+
helpCache: true,
|
|
1994
1884
|
...options,
|
|
1995
1885
|
stderr: stderr.stream,
|
|
1996
1886
|
stdout: stdout.stream
|
|
1997
1887
|
});
|
|
1998
1888
|
} catch (error) {
|
|
1999
1889
|
try {
|
|
2000
|
-
stderr.stream.write(`${formatRuntimeDiagnosticError(error)}\n`);
|
|
1890
|
+
stderr.stream.write(`${(await import("@vite-hub/runtime")).formatRuntimeDiagnosticError(error)}\n`);
|
|
2001
1891
|
} catch {}
|
|
2002
1892
|
exitCode = 1;
|
|
2003
1893
|
}
|