@vite-hub/cli 0.6.0 → 0.6.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.
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
- import { C as installArgs, D as shellQuote, E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, K as table, M as listMatchingFiles, O as uninstallArgs, R as loginCommand, S as formatInstallCommand, St as installSpecifier, T as missingProviderOption, U as readSetupArgs, V as whoamiCommand, W as setupExitCodes, Y as cliErrorDiagnostics, _t as featureIds, bt as features, gt as featureHosts, j as hasDefinitionFiles, m as appsCommand, q as writeSetupError, vt as featurePackages, w as installCommand, xt as impliedFeatures, yt as featureSupport, z as logoutCommand } from "./provision-akHsvf-B.js";
3
- import { B as insertViteHubConfig, I as detectPackageManager, L as readSetupProject, R as setupLockfiles, V as locateViteHubConfig, d as readSetupLinkState, h as unlinkSetupProject, i as SETUP_LINK_FILE, l as linkSetupProject, s as gitignoreWithViteHub, u as readLinkHostOption, z as editViteHubConfig } from "./env-BiVwma4a.js";
4
- import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, o as liveLabel, s as readSetupLive, t as deployCommand } from "./deploy-DwNjKrHq.js";
2
+ import { C as installArgs, D as shellQuote, E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, K as table, M as listMatchingFiles, O as uninstallArgs, R as loginCommand, S as formatInstallCommand, St as installSpecifier, T as missingProviderOption, U as readSetupArgs, V as whoamiCommand, W as setupExitCodes, Y as cliErrorDiagnostics, _t as featureIds, bt as features, gt as featureHosts, j as hasDefinitionFiles, m as appsCommand, q as writeSetupError, vt as featurePackages, w as installCommand, xt as impliedFeatures, yt as featureSupport, z as logoutCommand } from "./provision-YzxNsbhs.js";
3
+ import { B as readSetupProject, H as editViteHubConfig, I as declaresNuxt5, L as detectPackageManager, R as nuxtReleases, U as insertViteHubConfig, V as setupLockfiles, W as locateViteHubConfig, d as readSetupLinkState, h as unlinkSetupProject, i as SETUP_LINK_FILE, l as linkSetupProject, s as gitignoreWithViteHub, u as readLinkHostOption, z as pnpmWorkspaceFile } from "./env-DzYHxq9A.js";
4
+ import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, o as liveLabel, s as readSetupLive, t as deployCommand } from "./deploy-DDen0JC0.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { existsSync, readFileSync } from "node:fs";
7
7
  import process from "node:process";
@@ -12,7 +12,7 @@ import { createInterface } from "node:readline/promises";
12
12
  import { pathToFileURL } from "node:url";
13
13
  import { isDeepStrictEqual, parseArgs } from "node:util";
14
14
  import { createTwoFilesPatch } from "diff";
15
- import semver, { Range, minVersion, satisfies, subset, validRange } from "semver";
15
+ import semver, { minVersion, satisfies, subset, validRange } from "semver";
16
16
  // ../internal/dist/feature-inputs.js
17
17
  function isLocaleTag(value) {
18
18
  try {
@@ -809,6 +809,14 @@ async function deriveSetupStack(project, status, validate) {
809
809
  path: id,
810
810
  reason: "disabled-feature"
811
811
  });
812
+ const nuxtNightly = status.framework === "nuxt" && declaresNuxt5(project.nuxt);
813
+ if (status.framework === "nuxt" && !nuxtNightly) {
814
+ const releases = nuxtReleases(project.nuxt);
815
+ if (!releases || !subset(releases, ">=4.7.0 <5.0.0")) omits.push({
816
+ path: "nuxt",
817
+ reason: "unresolved-nuxt-version"
818
+ });
819
+ }
812
820
  const name = basename(project.root);
813
821
  const args = [
814
822
  name.startsWith("-") ? `./${name}` : name || "vitehub-app",
@@ -819,6 +827,7 @@ async function deriveSetupStack(project, status, validate) {
819
827
  ...options.flatMap((option) => ["--option", option]),
820
828
  "--framework",
821
829
  status.framework === "nuxt" ? "nuxt" : "vite",
830
+ ...nuxtNightly ? ["--nuxt-nightly"] : [],
822
831
  "--pm",
823
832
  status.packageManager,
824
833
  "--yes"
@@ -853,7 +862,7 @@ async function deriveSetupStack(project, status, validate) {
853
862
  };
854
863
  }
855
864
  // src/setup/init.ts
856
- const usage$2 = "vitehub init <dir> --host <host> --features <id,id,...> [--option <feature.key=value>]... [--framework vite|nuxt] [--pm pnpm|npm|yarn|bun] [--no-install] [--dry-run] --yes [--json]";
865
+ const usage$2 = "vitehub init <dir> --host <host> --features <id,id,...> [--option <feature.key=value>]... [--framework vite|nuxt] [--nuxt-nightly] [--pm pnpm|npm|yarn|bun] [--no-install] [--dry-run] --yes [--json]";
857
866
  const initCommandPrefix = "pnpm dlx vite-hub init";
858
867
  const initHosts = [
859
868
  "cloudflare",
@@ -871,7 +880,7 @@ const packageManagers = [
871
880
  ];
872
881
  /**
873
882
  * The packages of a new app, as `getting-started/installation.md` installs them. The Nitro and H3 versions match the
874
- * server integration of ViteHub. Nuxt 5 supplies Nitro 3, and a Nuxt 4.7 app also gets `nuxtNitroPackage`. The
883
+ * server integration of ViteHub. A new Nuxt app is Nuxt 4.7, so it also gets `nuxtNitroPackage`. Nuxt 5 supplies Nitro 3. The
875
884
  * tutorials import H3 2. Valibot validates request bodies in the docs' route examples.
876
885
  */
877
886
  const initPackages = {
@@ -899,9 +908,15 @@ const initPackages = {
899
908
  };
900
909
  const nuxtNitroRange = "^3.0.261103-rc";
901
910
  const nuxtNitroPackage = `nitro@${nuxtNitroRange}`;
911
+ const nuxt47ViteHub = "vite-hub@>=0.5.1 <1";
912
+ /**
913
+ * Nuxt 4 installs esbuild, and pnpm 11 and later fail the install while the esbuild build script waits for
914
+ * approval. esbuild runs without that script, so a new Nuxt 4.7 app declines it.
915
+ */
916
+ const nuxtPnpmWorkspace = "allowBuilds:\n esbuild: false\n";
902
917
  /** The pinned Nuxt CLI that creates a new Nuxt app. */
903
918
  const nuxiPackage = "nuxi@3.37.0";
904
- const nuxtTemplate = "gh:nuxt/starter#db01806fcb37f2e369fb09443c72cac696b31548";
919
+ const nuxtTemplate = "gh:nuxt/starter#d4367031fe43d93d4e2a339f73b519ec35e78b38";
905
920
  function isRecord(value) {
906
921
  return !!value && typeof value === "object" && !Array.isArray(value);
907
922
  }
@@ -920,6 +935,7 @@ function readInitArgs(args) {
920
935
  help: false,
921
936
  install: true,
922
937
  json: false,
938
+ nuxtNightly: false,
923
939
  options: [],
924
940
  yes: false
925
941
  };
@@ -936,6 +952,7 @@ function readInitArgs(args) {
936
952
  else if (flag === "--dry-run") parsed.dryRun = true;
937
953
  else if (flag === "--yes" || flag === "-y") parsed.yes = true;
938
954
  else if (flag === "--no-install") parsed.install = false;
955
+ else if (flag === "--nuxt-nightly") parsed.nuxtNightly = true;
939
956
  else if (flag === "-h" || flag === "--help") parsed.help = true;
940
957
  else if (flag === "--host") parsed.host = oneOf("--host", value(), initHosts);
941
958
  else if (flag === "--features") features = value();
@@ -947,6 +964,8 @@ function readInitArgs(args) {
947
964
  else throw invalid$2(`Pass one folder, not ${JSON.stringify(parsed.dir)} and ${JSON.stringify(arg)}.`);
948
965
  }
949
966
  if (features !== void 0) parsed.features = readAddArgs(features.split(",").map((item) => item.trim()).filter(Boolean)).features;
967
+ if (parsed.nuxtNightly && parsed.framework === "vite") throw invalid$2("--nuxt-nightly needs --framework nuxt.");
968
+ if (parsed.nuxtNightly) parsed.framework = "nuxt";
950
969
  return parsed;
951
970
  }
952
971
  function addArgsOf(args) {
@@ -967,6 +986,7 @@ function initCommand(parts, extra) {
967
986
  shellQuote(parts.features?.join(",") ?? "<id,id,...>"),
968
987
  ...options.flatMap((option) => ["--option", shellQuote(option)]),
969
988
  ...parts.framework === "nuxt" ? ["--framework", "nuxt"] : [],
989
+ ...parts.nuxtNightly ? ["--nuxt-nightly"] : [],
970
990
  ...parts.pm && parts.pm !== "pnpm" ? ["--pm", parts.pm] : [],
971
991
  ...extra
972
992
  ].join(" ");
@@ -1133,7 +1153,9 @@ async function planInit(args, root, state, context) {
1133
1153
  found,
1134
1154
  framework
1135
1155
  }), setupExitCodes.conflict);
1136
- const nuxtNeedsNitro = state.kind === "adopt" && framework === "nuxt" && (await checkNuxtVersion(root)).needsNitro;
1156
+ const nuxt = framework !== "nuxt" ? void 0 : state.kind === "adopt" ? state.project.nuxt : args.nuxtNightly ? "npm:nuxt-nightly@5x" : "^4.7.0";
1157
+ const nuxtNeedsNitro = framework === "nuxt" && (state.kind === "adopt" ? (await checkNuxtVersion(root)).needsNitro : !args.nuxtNightly);
1158
+ const allowsNuxt4 = framework === "nuxt" && !declaresNuxt5(nuxt);
1137
1159
  const detected = state.kind === "adopt" ? state.project : detectPackageManager(root, void 0, context.env);
1138
1160
  const packageManager = args.pm ?? (detected.packageManagerSource === "default" ? "pnpm" : detected.packageManager);
1139
1161
  const base = /* @__PURE__ */ new Map();
@@ -1159,7 +1181,7 @@ async function planInit(args, root, state, context) {
1159
1181
  const basePackages = initPackages[framework];
1160
1182
  const install = {
1161
1183
  dev: basePackages.dev.filter((spec) => !declared(packageName$1(spec), true)),
1162
- prod: basePackages.prod.filter((spec) => !declared(packageName$1(spec), false))
1184
+ prod: basePackages.prod.filter((spec) => !declared(packageName$1(spec), false)).map((spec) => allowsNuxt4 && spec === "vite-hub" ? nuxt47ViteHub : spec)
1163
1185
  };
1164
1186
  if (nuxtNeedsNitro) install.prod.push(nuxtNitroPackage);
1165
1187
  const willInstall = new Set([...install.prod, ...install.dev].map(packageName$1));
@@ -1171,6 +1193,7 @@ async function planInit(args, root, state, context) {
1171
1193
  declared: (name, dev) => declared(name, dev) || willInstall.has(name),
1172
1194
  framework,
1173
1195
  installed: state.kind === "adopt" ? state.project.installed : () => false,
1196
+ ...nuxt === void 0 ? {} : { nuxt },
1174
1197
  packageManager,
1175
1198
  packageManagerSource: args.pm ? "manifest" : detected.packageManagerSource,
1176
1199
  root,
@@ -1189,6 +1212,7 @@ async function planInit(args, root, state, context) {
1189
1212
  features: [...args.features, ...extraFeatures.filter((id) => !args.features.includes(id))],
1190
1213
  framework,
1191
1214
  host: args.host,
1215
+ nuxtNightly: args.nuxtNightly,
1192
1216
  options: Object.entries(options).flatMap(([id, value]) => value ? flattenOptions(id, value) : []),
1193
1217
  pm: packageManager
1194
1218
  };
@@ -1209,6 +1233,8 @@ async function planInit(args, root, state, context) {
1209
1233
  after: gitignore === void 0 ? ".vitehub\n" : gitignoreWithViteHub(gitignore) ?? gitignore
1210
1234
  });
1211
1235
  }
1236
+ const workspaceFile = allowsNuxt4 && packageManager === "pnpm" ? pnpmWorkspaceFile(root) : void 0;
1237
+ if (state.kind === "create" && allowsNuxt4 && packageManager === "pnpm" && !workspaceFile) base.set("pnpm-workspace.yaml", { after: nuxtPnpmWorkspace });
1212
1238
  const scaffolded = state.kind === "create" && framework === "nuxt";
1213
1239
  const writes = [...base.entries()].filter(([path]) => !scaffolded || !Object.hasOwn(nuxtAppFiles(name, args.host), path)).sort(([left], [right]) => Number(left === configFile) - Number(right === configFile)).filter(([, file]) => file.before !== file.after).map(([path, file]) => ({
1214
1240
  path,
@@ -1220,8 +1246,7 @@ async function planInit(args, root, state, context) {
1220
1246
  basename(root),
1221
1247
  "--template",
1222
1248
  nuxtTemplate,
1223
- "--nightly",
1224
- "5x",
1249
+ ...args.nuxtNightly ? ["--nightly", "5x"] : [],
1225
1250
  "--packageManager",
1226
1251
  packageManager,
1227
1252
  "--no-install",
@@ -1265,7 +1290,8 @@ async function planInit(args, root, state, context) {
1265
1290
  rerun: rerunInit(args, parts()),
1266
1291
  stackProject,
1267
1292
  writes,
1268
- ...scaffold ? { scaffold } : {}
1293
+ ...scaffold ? { scaffold } : {},
1294
+ ...workspaceFile ? { workspaceFile } : {}
1269
1295
  };
1270
1296
  }
1271
1297
  function setupStack(project, status) {
@@ -1296,7 +1322,8 @@ async function applyInit(planned, install, context, scaffolded = false) {
1296
1322
  if (result.exitCode !== 0) throw setupFailure(cliErrorDiagnostics.SETUP_INSTALL_FAILED({
1297
1323
  command: formatInstallCommand(plan.packageManager, commandArgs),
1298
1324
  exitCode: result.exitCode ?? result.signal,
1299
- filesWritten: scaffolded || plan.mode === "create"
1325
+ filesWritten: scaffolded || plan.mode === "create",
1326
+ workspaceFile: planned.workspaceFile
1300
1327
  }), setupExitCodes.error);
1301
1328
  }
1302
1329
  };
@@ -1332,12 +1359,6 @@ async function scaffoldNuxt(planned, context) {
1332
1359
  }), setupExitCodes.error);
1333
1360
  await checkNuxtVersion(planned.plan.root, true);
1334
1361
  }
1335
- function nuxtReleases(nuxt) {
1336
- if (typeof nuxt !== "string") return void 0;
1337
- const range = validRange(nuxt.replace(/^npm:nuxt(?:-nightly)?@/u, ""));
1338
- if (!range || !minVersion(range)) return void 0;
1339
- return new Range(range).set.map((comparators) => comparators.map(({ operator, semver, value }) => typeof semver !== "symbol" && semver.major === 5 && semver.prerelease.length > 0 ? `${operator}5.${semver.minor}.${semver.patch}` : value).join(" ")).join(" || ");
1340
- }
1341
1362
  async function checkNuxtVersion(root, scaffolded = false) {
1342
1363
  const manifest = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
1343
1364
  const dependencies = isRecord(manifest) && isRecord(manifest.dependencies) ? manifest.dependencies : {};
@@ -1347,7 +1368,7 @@ async function checkNuxtVersion(root, scaffolded = false) {
1347
1368
  dir: root,
1348
1369
  scaffolded
1349
1370
  }), setupExitCodes.conflict);
1350
- if (subset(releases, ">=5.0.0 <6.0.0")) return { needsNitro: false };
1371
+ if (declaresNuxt5(dependencies.nuxt ?? devDependencies.nuxt)) return { needsNitro: false };
1351
1372
  const nitroDeclarations = [dependencies.nitro, devDependencies.nitro].filter((spec) => spec !== void 0);
1352
1373
  for (const spec of nitroDeclarations) {
1353
1374
  const range = typeof spec === "string" ? validRange(spec.replace(/^npm:nitro@/u, "")) : null;
@@ -1411,6 +1432,7 @@ async function readInputs(args) {
1411
1432
  missing: missing.map(({ sentence: _sentence, ...item }) => item),
1412
1433
  rerun: rerunInit(args, {
1413
1434
  dir: args.dir ?? "<dir>",
1435
+ nuxtNightly: args.nuxtNightly,
1414
1436
  options: args.options,
1415
1437
  ...args.features ? { features: args.features } : {},
1416
1438
  ...args.host ? { host: args.host } : {},
@@ -1476,6 +1498,7 @@ async function runInit(rawArgs, context) {
1476
1498
  }
1477
1499
  if (planned.scaffold) {
1478
1500
  await scaffoldNuxt(planned, context);
1501
+ for (const write of planned.writes.filter((write) => write.path === "pnpm-workspace.yaml")) await writeFile(join(root, write.path), write.after);
1479
1502
  planned = await planInit({
1480
1503
  ...args,
1481
1504
  pm: plan.packageManager
@@ -1,4 +1,4 @@
1
- import { B as readConsoleCredential, J as writeSetupJson, P as consoleOrigin, Y as cliErrorDiagnostics, q as writeSetupError } from "./provision-akHsvf-B.js";
1
+ import { B as readConsoleCredential, J as writeSetupJson, P as consoleOrigin, Y as cliErrorDiagnostics, q as writeSetupError } from "./provision-YzxNsbhs.js";
2
2
  import { execFile } from "node:child_process";
3
3
  import { mkdtemp, open, rename, rm } from "node:fs/promises";
4
4
  import { join } from "node:path";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
- import { E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, K as table, Q as readProvisionState, W as setupExitCodes, X as PROVISION_STATE_FILE, Y as cliErrorDiagnostics, Z as mergeProvisionState, a as writeProvisionActions, d as planProvisionSteps, et as writeProvisionState, f as resolveHostCredentials, i as provisionEnv, it as callOperationFromCli, k as hostFromNitroPreset, n as isProvisionHost, q as writeSetupError, r as provisionActionStatus } from "./provision-akHsvf-B.js";
3
- import { A as openDeployConsole, C as denoAdapter, D as listCloudflareDeployments, E as cloudflareAdapter, F as readDeployCommit, L as readSetupProject, M as build, N as readBuildOutput, O as formatDeployConsole, P as createDeployRun, S as abortable, T as listDenoDeployments, _ as hasVercelLogin, a as addSetupLink, b as listNetlifyDeployments, c as hostRequired, g as writeSeparateResourcesNote, j as readsConsoleKey, k as linkDeployedApp, m as selectSetupLink, o as ensureViteHubGitignore, p as readSetupLinks, r as hostEnvs, t as checkDeployEnv, u as readLinkHostOption, v as listVercelDeployments, w as denoOrganization, x as netlifyAdapter, y as vercelAdapter } from "./env-BiVwma4a.js";
2
+ import { E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, K as table, Q as readProvisionState, W as setupExitCodes, X as PROVISION_STATE_FILE, Y as cliErrorDiagnostics, Z as mergeProvisionState, a as writeProvisionActions, d as planProvisionSteps, et as writeProvisionState, f as resolveHostCredentials, i as provisionEnv, it as callOperationFromCli, k as hostFromNitroPreset, n as isProvisionHost, q as writeSetupError, r as provisionActionStatus } from "./provision-YzxNsbhs.js";
3
+ import { A as openDeployConsole, B as readSetupProject, C as denoAdapter, D as listCloudflareDeployments, E as cloudflareAdapter, F as readDeployCommit, M as build, N as readBuildOutput, O as formatDeployConsole, P as createDeployRun, S as abortable, T as listDenoDeployments, _ as hasVercelLogin, a as addSetupLink, b as listNetlifyDeployments, c as hostRequired, g as writeSeparateResourcesNote, j as readsConsoleKey, k as linkDeployedApp, m as selectSetupLink, o as ensureViteHubGitignore, p as readSetupLinks, r as hostEnvs, t as checkDeployEnv, u as readLinkHostOption, v as listVercelDeployments, w as denoOrganization, x as netlifyAdapter, y as vercelAdapter } from "./env-DzYHxq9A.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { existsSync } from "node:fs";
6
6
  import process from "node:process";
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
- import { A as resolveDeploymentPlan, B as readConsoleCredential, D as shellQuote, E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, Mt as isRecord, W as setupExitCodes, Y as cliErrorDiagnostics, _ as consoleAppUrl, b as listConsoleApps, c as createNetlifyApiClient, f as resolveHostCredentials, g as checkProblem, h as checkConsoleApp, k as hostFromNitroPreset, l as createVercelProvisionClient, nt as withViteStageEnvironment, o as createCloudflareApiClient, p as runHostCli, q as writeSetupError, s as createCloudflareProvisionClient, tt as loadAllEnv, u as isProvisionRequestError, wt as invariant, x as openConsole, y as linkConsoleApp } from "./provision-akHsvf-B.js";
2
+ import { A as resolveDeploymentPlan, B as readConsoleCredential, D as shellQuote, E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, Mt as isRecord, W as setupExitCodes, Y as cliErrorDiagnostics, _ as consoleAppUrl, b as listConsoleApps, c as createNetlifyApiClient, f as resolveHostCredentials, g as checkProblem, h as checkConsoleApp, k as hostFromNitroPreset, l as createVercelProvisionClient, nt as withViteStageEnvironment, o as createCloudflareApiClient, p as runHostCli, q as writeSetupError, s as createCloudflareProvisionClient, tt as loadAllEnv, u as isProvisionRequestError, wt as invariant, x as openConsole, y as linkConsoleApp } from "./provision-YzxNsbhs.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { spawn } from "node:child_process";
5
5
  import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
@@ -12,6 +12,8 @@ import { constants, homedir, tmpdir } from "node:os";
12
12
  import { parseArgs, parseEnv } from "node:util";
13
13
  import { parse as parse$1 } from "@babel/parser";
14
14
  import { parse as parse$2 } from "rc9";
15
+ import { Range, minVersion, subset, validRange } from "semver";
16
+ import { parseDocument } from "yaml";
15
17
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
16
18
  import { normalizeConsoleProjectUrl } from "@vite-hub/runtime/internal/console";
17
19
  import { createPublicKey, diffieHellman, generateKeyPairSync, randomBytes } from "node:crypto";
@@ -2243,6 +2245,22 @@ function insertViteHubConfig(file, code, options) {
2243
2245
  };
2244
2246
  }
2245
2247
  // src/setup/project.ts
2248
+ /**
2249
+ * The Nuxt releases that a `nuxt` range allows, as a semver range. A Nuxt 5 nightly counts as its release, so
2250
+ * `npm:nuxt-nightly@5.0.0-2611071848-2d8337c` is `5.0.0`. The `5x` channel tag of `nuxt-nightly` is `5.x`.
2251
+ * `undefined` for another tag or a range without a version.
2252
+ */
2253
+ function nuxtReleases(nuxt) {
2254
+ if (typeof nuxt !== "string") return void 0;
2255
+ const range = validRange(nuxt.replace(/^npm:nuxt-nightly@(\d+)x$/u, "$1.x").replace(/^npm:nuxt(?:-nightly)?@/u, ""));
2256
+ if (!range || !minVersion(range)) return void 0;
2257
+ return new Range(range).set.map((comparators) => comparators.map(({ operator, semver, value }) => typeof semver !== "symbol" && semver.major === 5 && semver.prerelease.length > 0 ? `${operator}5.${semver.minor}.${semver.patch}` : value).join(" ")).join(" || ");
2258
+ }
2259
+ /** True when a `nuxt` range allows only Nuxt 5, so `vitehub init --nuxt-nightly` creates the same app. */
2260
+ function declaresNuxt5(nuxt) {
2261
+ const releases = nuxtReleases(nuxt);
2262
+ return !!releases && subset(releases, ">=5.0.0 <6.0.0");
2263
+ }
2246
2264
  const nuxtConfigFiles = [
2247
2265
  "nuxt.config.ts",
2248
2266
  "nuxt.config.mts",
@@ -2274,6 +2292,24 @@ function parentFolders(root) {
2274
2292
  for (let folder = dirname(root); folder !== folders.at(-1); folder = dirname(folder)) folders.push(folder);
2275
2293
  return folders;
2276
2294
  }
2295
+ function pnpmWorkspaceFile(root) {
2296
+ return parentFolders(root).map((folder) => join(folder, "pnpm-workspace.yaml")).find(existsSync);
2297
+ }
2298
+ async function resolveNuxtSpecifier(root, specifier) {
2299
+ if (typeof specifier !== "string") return void 0;
2300
+ if (!specifier.startsWith("catalog:")) return specifier;
2301
+ const file = pnpmWorkspaceFile(root);
2302
+ if (!file) return void 0;
2303
+ const workspace = parseDocument(await readFile(file, "utf8"));
2304
+ if (workspace.errors.length) return void 0;
2305
+ const catalog = specifier.slice(8);
2306
+ const entry = workspace.getIn(catalog && catalog !== "default" ? [
2307
+ "catalogs",
2308
+ catalog,
2309
+ "nuxt"
2310
+ ] : ["catalog", "nuxt"]);
2311
+ return typeof entry === "string" ? entry : void 0;
2312
+ }
2277
2313
  async function readManifest(root) {
2278
2314
  const file = join(root, "package.json");
2279
2315
  if (!existsSync(file)) return;
@@ -2391,6 +2427,7 @@ async function readSetupProject(root, env) {
2391
2427
  };
2392
2428
  const folders = parentFolders(root);
2393
2429
  const require = createRequire(join(root, "package.json"));
2430
+ const nuxt = await resolveNuxtSpecifier(root, dependencies.nuxt);
2394
2431
  return {
2395
2432
  config,
2396
2433
  ...configFile ? {
@@ -2409,6 +2446,7 @@ async function readSetupProject(root, env) {
2409
2446
  return false;
2410
2447
  },
2411
2448
  ...detectPackageManager(root, manifest, env),
2449
+ ...nuxt === void 0 ? {} : { nuxt },
2412
2450
  root,
2413
2451
  serverDirs: framework === "nuxt" ? await nuxtServerDirs(root, config, env) : [join(root, "server")]
2414
2452
  };
@@ -5616,4 +5654,4 @@ async function runEnvCommand(feature, args, context) {
5616
5654
  return writeSetupError(context, json, error);
5617
5655
  }
5618
5656
  }
5619
- export { openDeployConsole as A, insertViteHubConfig as B, denoAdapter as C, listCloudflareDeployments as D, cloudflareAdapter as E, readDeployCommit as F, detectPackageManager as I, readSetupProject as L, build as M, readBuildOutput as N, formatDeployConsole as O, createDeployRun as P, setupLockfiles as R, abortable as S, listDenoDeployments as T, locateViteHubConfig as V, hasVercelLogin as _, addSetupLink as a, listNetlifyDeployments as b, hostRequired as c, readSetupLinkState as d, readSetupLinkStatus as f, writeSeparateResourcesNote as g, unlinkSetupProject as h, SETUP_LINK_FILE as i, readsConsoleKey as j, linkDeployedApp as k, linkSetupProject as l, selectSetupLink as m, env_exports as n, ensureViteHubGitignore as o, readSetupLinks as p, hostEnvs as r, gitignoreWithViteHub as s, checkDeployEnv as t, readLinkHostOption as u, listVercelDeployments as v, denoOrganization as w, netlifyAdapter as x, vercelAdapter as y, editViteHubConfig as z };
5657
+ export { openDeployConsole as A, readSetupProject as B, denoAdapter as C, listCloudflareDeployments as D, cloudflareAdapter as E, readDeployCommit as F, editViteHubConfig as H, declaresNuxt5 as I, detectPackageManager as L, build as M, readBuildOutput as N, formatDeployConsole as O, createDeployRun as P, nuxtReleases as R, abortable as S, listDenoDeployments as T, insertViteHubConfig as U, setupLockfiles as V, locateViteHubConfig as W, hasVercelLogin as _, addSetupLink as a, listNetlifyDeployments as b, hostRequired as c, readSetupLinkState as d, readSetupLinkStatus as f, writeSeparateResourcesNote as g, unlinkSetupProject as h, SETUP_LINK_FILE as i, readsConsoleKey as j, linkDeployedApp as k, linkSetupProject as l, selectSetupLink as m, env_exports as n, ensureViteHubGitignore as o, readSetupLinks as p, hostEnvs as r, gitignoreWithViteHub as s, checkDeployEnv as t, readLinkHostOption as u, listVercelDeployments as v, denoOrganization as w, netlifyAdapter as x, vercelAdapter as y, pnpmWorkspaceFile as z };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
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";
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-YzxNsbhs.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";
@@ -1399,7 +1399,7 @@ const hostEnvFeatures = {
1399
1399
  {
1400
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.",
1401
1401
  name: "diff",
1402
- run: async (args, context) => await (await import("./env-BiVwma4a.js").then((n) => n.n)).runEnvCommand({
1402
+ run: async (args, context) => await (await import("./env-DzYHxq9A.js").then((n) => n.n)).runEnvCommand({
1403
1403
  ...hostEnvFeatures.features[0],
1404
1404
  name: "diff"
1405
1405
  }, args, context),
@@ -1408,7 +1408,7 @@ const hostEnvFeatures = {
1408
1408
  {
1409
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.",
1410
1410
  name: "push",
1411
- run: async (args, context) => await (await import("./env-BiVwma4a.js").then((n) => n.n)).runEnvCommand({
1411
+ run: async (args, context) => await (await import("./env-DzYHxq9A.js").then((n) => n.n)).runEnvCommand({
1412
1412
  ...hostEnvFeatures.features[1],
1413
1413
  name: "push"
1414
1414
  }, args, context),
@@ -1417,14 +1417,14 @@ const hostEnvFeatures = {
1417
1417
  {
1418
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.",
1419
1419
  name: "pull",
1420
- run: async (args, context) => await (await import("./console-env-CYHb4owT.js")).envPullFeature.run(args, context),
1420
+ run: async (args, context) => await (await import("./console-env-lQ3_eMOy.js")).envPullFeature.run(args, context),
1421
1421
  usage: "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]"
1422
1422
  }
1423
1423
  ],
1424
1424
  name: "env"
1425
1425
  };
1426
1426
  async function loadSetupCommands() {
1427
- return (await import("./commands-D0WSlS7h.js").then((n) => n.t)).setupCommands;
1427
+ return (await import("./commands-FOmqEZUi.js").then((n) => n.t)).setupCommands;
1428
1428
  }
1429
1429
  async function loadNuxtViteConfig(rootDir, command, mode) {
1430
1430
  if (![
@@ -2034,7 +2034,7 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
2034
2034
  why: ({ message }) => message === void 0 ? "" : String(message)
2035
2035
  },
2036
2036
  SETUP_INSTALL_FAILED: {
2037
- fix: ({ filesWritten }) => `Run the install command by hand to see the error, then run the command again. ${filesWritten === "possible" ? "Scaffolding may have left new app files on disk; inspect the target folder before retrying." : filesWritten ? "The new app files were written before installation failed; keep them when retrying." : "ViteHub did not write starter or config files; the package manager may have changed package manifests or lockfiles."}`,
2037
+ fix: ({ filesWritten, workspaceFile }) => `Run the install command by hand to see the error, then run the command again. ${filesWritten === "possible" ? "Scaffolding may have left new app files on disk; inspect the target folder before retrying." : filesWritten ? "The new app files were written before installation failed; keep them when retrying." : "ViteHub did not write starter or config files; the package manager may have changed package manifests or lockfiles."}${workspaceFile ? ` If pnpm reports an ignored esbuild build script, set \`allowBuilds: { esbuild: false }\` in \`${workspaceFile}\` before retrying.` : ""}`,
2038
2038
  why: ({ command, exitCode }) => `\`${String(command)}\` exited with code ${String(exitCode)}.`
2039
2039
  },
2040
2040
  SETUP_FEATURE_IMPLIED: {
@@ -3878,7 +3878,7 @@ async function resolveHost(command, parsed, context) {
3878
3878
  let host = parsed.host;
3879
3879
  let link;
3880
3880
  if (host === void 0) {
3881
- const { resolveDefaultDeployTarget } = await import("./deploy-DwNjKrHq.js").then((n) => n.n);
3881
+ const { resolveDefaultDeployTarget } = await import("./deploy-DDen0JC0.js").then((n) => n.n);
3882
3882
  try {
3883
3883
  const target = await resolveDefaultDeployTarget(resolveViteHubProjectRoot(context.rootDir), context.env, `vitehub provision ${command}`);
3884
3884
  host = target.host;
@@ -149,6 +149,8 @@ interface SetupProject {
149
149
  configSource?: string;
150
150
  /** True when the target manifest declares `name` for production, or for development when `dev` is true. */
151
151
  declared: (name: string, dev: boolean) => boolean;
152
+ /** The `nuxt` range from the manifest or its pnpm catalog. */
153
+ nuxt?: string;
152
154
  /** Static discovery directories; undefined when Nuxt directories or layers need evaluation. */
153
155
  serverDirs?: readonly string[];
154
156
  /** True when `name` is resolvable from the project or present in an ancestor's node_modules. */
@@ -685,7 +687,7 @@ interface SetupStack {
685
687
  command: string | null;
686
688
  omits: readonly {
687
689
  path: string;
688
- reason: "opaque-config" | "spread" | "expression" | "unresolved-host" | "unresolved-feature" | "disabled-feature" | "unsupported-feature" | "non-replayable-option" | "credential-option" | "required-option" | "unplannable-stack";
690
+ reason: "opaque-config" | "spread" | "expression" | "unresolved-host" | "unresolved-feature" | "disabled-feature" | "unsupported-feature" | "non-replayable-option" | "credential-option" | "required-option" | "unplannable-stack" | "unresolved-nuxt-version";
689
691
  }[];
690
692
  }
691
693
  declare const initHosts: readonly ["cloudflare", "vercel", "netlify", "deno", "node"];
@@ -693,7 +695,7 @@ type InitHost = typeof initHosts[number];
693
695
  type InitFramework = "vite" | "nuxt";
694
696
  /**
695
697
  * The packages of a new app, as `getting-started/installation.md` installs them. The Nitro and H3 versions match the
696
- * server integration of ViteHub. Nuxt 5 supplies Nitro 3, and a Nuxt 4.7 app also gets `nuxtNitroPackage`. The
698
+ * server integration of ViteHub. A new Nuxt app is Nuxt 4.7, so it also gets `nuxtNitroPackage`. Nuxt 5 supplies Nitro 3. The
697
699
  * tutorials import H3 2. Valibot validates request bodies in the docs' route examples.
698
700
  */
699
701
  export declare const initPackages: Readonly<Record<InitFramework, {
@@ -710,6 +712,8 @@ interface SetupInitArgs {
710
712
  /** Raw `--option` values, such as `email.driver=resend`. */
711
713
  options: string[];
712
714
  framework?: InitFramework;
715
+ /** A new Nuxt app gets the Nuxt 5 nightly instead of Nuxt 4.7. An existing app keeps its Nuxt version. */
716
+ nuxtNightly: boolean;
713
717
  pm?: SetupPackageManager;
714
718
  install: boolean;
715
719
  dryRun: boolean;
@@ -1,7 +1,7 @@
1
- import { _ as applySetupAdd, a as updateCommand, c as planSetupRemove, d as initCommandDefinition, f as initPackages, g as addCommand, h as setupCatalog, i as readUpdateArgs, l as readRemoveArgs, m as readInitArgs, n as setupCommands, o as updateInstallArgs, p as nuxiPackage, r as planSetupUpdate, s as applySetupRemove, u as removeCommand, v as planSetupAdd, y as readAddArgs } from "../commands-D0WSlS7h.js";
2
- import { B as readConsoleCredential, D as shellQuote, E as setupStatus, F as consoleTokenVariable, G as setupFailure, I as consoleUrlVariable, L as defaultConsoleUrl, N as consoleCredentialsFile, P as consoleOrigin, R as loginCommand, V as whoamiCommand, W as setupExitCodes, Y as cliErrorDiagnostics, q as writeSetupError, z as logoutCommand } from "../provision-akHsvf-B.js";
3
- import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, r as readDeployArgs, s as readSetupLive, t as deployCommand } from "../deploy-DwNjKrHq.js";
4
- import { L as readSetupProject, d as readSetupLinkState, f as readSetupLinkStatus, h as unlinkSetupProject, i as SETUP_LINK_FILE, l as linkSetupProject, m as selectSetupLink, p as readSetupLinks } from "../env-BiVwma4a.js";
1
+ import { _ as applySetupAdd, a as updateCommand, c as planSetupRemove, d as initCommandDefinition, f as initPackages, g as addCommand, h as setupCatalog, i as readUpdateArgs, l as readRemoveArgs, m as readInitArgs, n as setupCommands, o as updateInstallArgs, p as nuxiPackage, r as planSetupUpdate, s as applySetupRemove, u as removeCommand, v as planSetupAdd, y as readAddArgs } from "../commands-FOmqEZUi.js";
2
+ import { B as readConsoleCredential, D as shellQuote, E as setupStatus, F as consoleTokenVariable, G as setupFailure, I as consoleUrlVariable, L as defaultConsoleUrl, N as consoleCredentialsFile, P as consoleOrigin, R as loginCommand, V as whoamiCommand, W as setupExitCodes, Y as cliErrorDiagnostics, q as writeSetupError, z as logoutCommand } from "../provision-YzxNsbhs.js";
3
+ import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, r as readDeployArgs, s as readSetupLive, t as deployCommand } from "../deploy-DDen0JC0.js";
4
+ import { B as readSetupProject, d as readSetupLinkState, f as readSetupLinkStatus, h as unlinkSetupProject, i as SETUP_LINK_FILE, l as linkSetupProject, m as selectSetupLink, p as readSetupLinks } from "../env-DzYHxq9A.js";
5
5
  import { join } from "pathe";
6
6
  import { readFile } from "node:fs/promises";
7
7
  import { createHash, randomUUID } from "node:crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Command-line workflows for ViteHub projects.",
5
5
  "keywords": [
6
6
  "agent",
@@ -46,18 +46,19 @@
46
46
  "@dotenvx/primitives": "^4.4.0",
47
47
  "@noble/ciphers": "^2.4.0",
48
48
  "@noble/hashes": "^2.4.0",
49
- "@vite-hub/runtime": "0.6.0",
49
+ "@vite-hub/runtime": "0.6.1",
50
50
  "birpc": "^4.2.0",
51
51
  "diff": "^9.0.0",
52
52
  "nostics": "1.4.0",
53
53
  "pathe": "^2.0.3",
54
54
  "rc9": "^3.1.0",
55
- "semver": "^7.8.6"
55
+ "semver": "^7.8.6",
56
+ "yaml": "^2.9.1"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@types/node": "^24.19.2",
59
60
  "@types/semver": "^7.8.0",
60
- "@vite-hub/forge": "0.6.0",
61
+ "@vite-hub/forge": "0.6.1",
61
62
  "@vite-hub/internal": "0.0.1",
62
63
  "nuxt": "npm:nuxt-nightly@5.0.0-2611222336-0ed8910",
63
64
  "typescript": "^6.0.3",
@@ -67,7 +68,7 @@
67
68
  "vitest": "5.1.0"
68
69
  },
69
70
  "peerDependencies": {
70
- "@vite-hub/forge": "0.6.0",
71
+ "@vite-hub/forge": "0.6.1",
71
72
  "nuxt": "^4.7.0 || >=5.0.0-0",
72
73
  "vite": ">=8.0.0"
73
74
  },