@vite-hub/cli 0.5.0 → 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.
@@ -1,9 +1,9 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { F as featureHosts, H as installSpecifier, I as featureIds, L as featurePackages, R as featureSupport, V as impliedFeatures, m as cliErrorDiagnostics, z as features } from "./provision-DgT_lpyn.js";
3
- import { B as listMatchingFiles, F as setupStatus, G as insertViteHubConfig, H as readSetupProject, I as shellQuote, K as locateViteHubConfig, L as uninstallArgs, M as installArgs, N as installCommand, P as missingProviderOption, U as setupLockfiles, V as detectPackageManager, W as editViteHubConfig, c as linkSetupProject, j as formatInstallCommand, l as readLinkHostOption, m as unlinkSetupProject, o as gitignoreWithViteHub, r as SETUP_LINK_FILE, u as readSetupLinkState, z as hasDefinitionFiles } from "./env-MtXhP7A7.js";
4
- import { a as table, i as setupFailure, n as readSetupArgs, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-C7e408hm.js";
5
- import { l as whoamiCommand, o as loginCommand, s as logoutCommand } from "./console-auth-Dz9HHP2G.js";
6
- import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, o as liveLabel, s as readSetupLive, t as deployCommand } from "./deploy-CHW75le_.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
+ import { F as featureHosts, H as installSpecifier, I as featureIds, L as featurePackages, R as featureSupport, V as impliedFeatures, m as cliErrorDiagnostics, z as features } from "./provision-DlknnTAt.js";
3
+ import { B as listMatchingFiles, F as setupStatus, G as insertViteHubConfig, H as readSetupProject, I as shellQuote, K as locateViteHubConfig, L as uninstallArgs, M as installArgs, N as installCommand, P as missingProviderOption, U as setupLockfiles, V as detectPackageManager, W as editViteHubConfig, c as linkSetupProject, j as formatInstallCommand, l as readLinkHostOption, m as unlinkSetupProject, o as gitignoreWithViteHub, r as SETUP_LINK_FILE, u as readSetupLinkState, z as hasDefinitionFiles } from "./env-DRI0QH4-.js";
4
+ import { a as table, i as setupFailure, n as readSetupArgs, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-DbplCDko.js";
5
+ import { l as whoamiCommand, o as loginCommand, s as logoutCommand } from "./console-auth-CpOpbA7U.js";
6
+ import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, o as liveLabel, s as readSetupLive, t as deployCommand } from "./deploy-BZ2iQjZL.js";
7
7
  import { createRequire } from "node:module";
8
8
  import { existsSync, readFileSync } from "node:fs";
9
9
  import process from "node:process";
@@ -14,8 +14,8 @@ import { createInterface } from "node:readline/promises";
14
14
  import { pathToFileURL } from "node:url";
15
15
  import { createTwoFilesPatch } from "diff";
16
16
  import { isDeepStrictEqual, parseArgs } from "node:util";
17
- import semver, { Range, minVersion, subset, validRange } from "semver";
18
- //#region ../internal/dist/feature-inputs.js
17
+ import semver, { Range, minVersion, satisfies, subset, validRange } from "semver";
18
+ // ../internal/dist/feature-inputs.js
19
19
  function isLocaleTag(value) {
20
20
  try {
21
21
  return Intl.getCanonicalLocales(value).length === 1;
@@ -35,8 +35,7 @@ function i18nLocaleListProblem(locales) {
35
35
  function mcpPublicRouteNeedsSignedAuth(publicRoute, auth) {
36
36
  return !!publicRoute && auth !== true;
37
37
  }
38
- //#endregion
39
- //#region src/setup/add.ts
38
+ // src/setup/add.ts
40
39
  const usage$3 = "vitehub add <feature...> [--name <definition>] [--option <key=value>]... [--dry-run] [--yes] [--no-install] [--json]";
41
40
  const optionChoices = {
42
41
  "cache.driver": {
@@ -689,8 +688,7 @@ const addCommand = {
689
688
  run: runAdd,
690
689
  usage: usage$3
691
690
  };
692
- //#endregion
693
- //#region src/setup/catalog.ts
691
+ // src/setup/catalog.ts
694
692
  /** Every feature of `vitehub({...})` and how each host supports it. Needs no project. */
695
693
  function setupCatalog() {
696
694
  return {
@@ -699,8 +697,7 @@ function setupCatalog() {
699
697
  schemaVersion: 1
700
698
  };
701
699
  }
702
- //#endregion
703
- //#region src/setup/stack.ts
700
+ // src/setup/stack.ts
704
701
  function replayOption(id, keys, value) {
705
702
  if (keys.some((key) => !key || /[.=\0]/u.test(key) || [
706
703
  "__proto__",
@@ -857,8 +854,7 @@ async function deriveSetupStack(project, status, validate) {
857
854
  omits
858
855
  };
859
856
  }
860
- //#endregion
861
- //#region src/setup/init.ts
857
+ // src/setup/init.ts
862
858
  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]";
863
859
  const initCommandPrefix = "pnpm dlx vite-hub init";
864
860
  const initHosts = [
@@ -877,8 +873,8 @@ const packageManagers = [
877
873
  ];
878
874
  /**
879
875
  * The packages of a new app, as `getting-started/installation.md` installs them. The Nitro and H3 versions match the
880
- * server integration of ViteHub. Nuxt 5 supplies Nitro 3, and its tutorials import H3 2. Valibot validates request
881
- * bodies in the docs' route examples.
876
+ * server integration of ViteHub. Nuxt 5 supplies Nitro 3, and a Nuxt 4.7 app also gets `nuxtNitroPackage`. The
877
+ * tutorials import H3 2. Valibot validates request bodies in the docs' route examples.
882
878
  */
883
879
  const initPackages = {
884
880
  nuxt: {
@@ -903,6 +899,8 @@ const initPackages = {
903
899
  ]
904
900
  }
905
901
  };
902
+ const nuxtNitroRange = "^3.0.261103-rc";
903
+ const nuxtNitroPackage = `nitro@${nuxtNitroRange}`;
906
904
  /** The pinned Nuxt CLI that creates a new Nuxt app. */
907
905
  const nuxiPackage = "nuxi@3.37.0";
908
906
  const nuxtTemplate = "gh:nuxt/starter#db01806fcb37f2e369fb09443c72cac696b31548";
@@ -1137,7 +1135,7 @@ async function planInit(args, root, state, context) {
1137
1135
  found,
1138
1136
  framework
1139
1137
  }), setupExitCodes.conflict);
1140
- if (state.kind === "adopt" && framework === "nuxt") await validateNuxtVersion(root);
1138
+ const nuxtNeedsNitro = state.kind === "adopt" && framework === "nuxt" && (await checkNuxtVersion(root)).needsNitro;
1141
1139
  const detected = state.kind === "adopt" ? state.project : detectPackageManager(root, void 0, context.env);
1142
1140
  const packageManager = args.pm ?? (detected.packageManagerSource === "default" ? "pnpm" : detected.packageManager);
1143
1141
  const base = /* @__PURE__ */ new Map();
@@ -1165,6 +1163,7 @@ async function planInit(args, root, state, context) {
1165
1163
  dev: basePackages.dev.filter((spec) => !declared(packageName$1(spec), true)),
1166
1164
  prod: basePackages.prod.filter((spec) => !declared(packageName$1(spec), false))
1167
1165
  };
1166
+ if (nuxtNeedsNitro) install.prod.push(nuxtNitroPackage);
1168
1167
  const willInstall = new Set([...install.prod, ...install.dev].map(packageName$1));
1169
1168
  const configSource = base.get(configFile).after;
1170
1169
  const planned = {
@@ -1333,23 +1332,34 @@ async function scaffoldNuxt(planned, context) {
1333
1332
  exitCode: result.exitCode ?? result.signal,
1334
1333
  filesWritten: "possible"
1335
1334
  }), setupExitCodes.error);
1336
- await validateNuxtVersion(planned.plan.root, true);
1335
+ await checkNuxtVersion(planned.plan.root, true);
1337
1336
  }
1338
- function supportsNuxt5(nuxt) {
1339
- if (typeof nuxt !== "string") return false;
1337
+ function nuxtReleases(nuxt) {
1338
+ if (typeof nuxt !== "string") return void 0;
1340
1339
  const range = validRange(nuxt.replace(/^npm:nuxt(?:-nightly)?@/u, ""));
1341
- if (!range || !minVersion(range)) return false;
1342
- const releases = 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(" || ");
1343
- return subset(releases, ">=5.0.0 <6.0.0");
1340
+ if (!range || !minVersion(range)) return void 0;
1341
+ 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(" || ");
1344
1342
  }
1345
- async function validateNuxtVersion(root, scaffolded = false) {
1343
+ async function checkNuxtVersion(root, scaffolded = false) {
1346
1344
  const manifest = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
1347
1345
  const dependencies = isRecord(manifest) && isRecord(manifest.dependencies) ? manifest.dependencies : {};
1348
1346
  const devDependencies = isRecord(manifest) && isRecord(manifest.devDependencies) ? manifest.devDependencies : {};
1349
- if (!supportsNuxt5(dependencies.nuxt ?? devDependencies.nuxt)) throw setupFailure(cliErrorDiagnostics.SETUP_INIT_NUXT_VERSION({
1347
+ const releases = nuxtReleases(dependencies.nuxt ?? devDependencies.nuxt);
1348
+ if (!releases || !subset(releases, ">=4.7.0 <6.0.0")) throw setupFailure(cliErrorDiagnostics.SETUP_INIT_NUXT_VERSION({
1350
1349
  dir: root,
1351
1350
  scaffolded
1352
1351
  }), setupExitCodes.conflict);
1352
+ if (subset(releases, ">=5.0.0 <6.0.0")) return { needsNitro: false };
1353
+ const nitroDeclarations = [dependencies.nitro, devDependencies.nitro].filter((spec) => spec !== void 0);
1354
+ for (const spec of nitroDeclarations) {
1355
+ const range = typeof spec === "string" ? validRange(spec.replace(/^npm:nitro@/u, "")) : null;
1356
+ if (!range || !minVersion(range) || !range.split("||").every((branch) => satisfies(branch, nuxtNitroRange) || subset(branch, nuxtNitroRange))) throw setupFailure(cliErrorDiagnostics.SETUP_INIT_NITRO_VERSION({
1357
+ dir: root,
1358
+ range: nuxtNitroRange,
1359
+ scaffolded
1360
+ }), setupExitCodes.conflict);
1361
+ }
1362
+ return { needsNitro: nitroDeclarations.length === 0 };
1353
1363
  }
1354
1364
  function interactive(args) {
1355
1365
  return !args.json && !!process.stdin.isTTY && !!process.stderr.isTTY;
@@ -1495,8 +1505,7 @@ const initCommandDefinition = {
1495
1505
  run: runInit,
1496
1506
  usage: usage$2
1497
1507
  };
1498
- //#endregion
1499
- //#region src/setup/remove.ts
1508
+ // src/setup/remove.ts
1500
1509
  const usage$1 = "vitehub remove <feature...> [--dry-run] [--yes] [--keep-files] [--force] [--no-uninstall] [--json]";
1501
1510
  function invalid$1(message) {
1502
1511
  return cliErrorDiagnostics.CLI_R0003({ message: `[vitehub] ${message} Usage: ${usage$1}` });
@@ -1913,8 +1922,7 @@ const removeCommand = {
1913
1922
  run: runRemove,
1914
1923
  usage: usage$1
1915
1924
  };
1916
- //#endregion
1917
- //#region src/setup/update.ts
1925
+ // src/setup/update.ts
1918
1926
  const usage = "vitehub update [--preview <commit>] [--dry-run] [--no-install] [--json]";
1919
1927
  const previewBase = "https://pkg.pr.new/vite-hub/vitehub";
1920
1928
  const defaultRegistry = "https://registry.npmjs.org/";
@@ -2349,8 +2357,7 @@ const updateCommand = {
2349
2357
  run: runUpdate,
2350
2358
  usage
2351
2359
  };
2352
- //#endregion
2353
- //#region src/setup/commands.ts
2360
+ // src/setup/commands.ts
2354
2361
  var commands_exports = /* @__PURE__ */ __exportAll({ setupCommands: () => setupCommands });
2355
2362
  function supportLabel(support) {
2356
2363
  if (support.level === "unknown") return "unknown";
@@ -2623,5 +2630,4 @@ const setupCommands = [
2623
2630
  logoutCommand,
2624
2631
  whoamiCommand
2625
2632
  ];
2626
- //#endregion
2627
2633
  export { applySetupAdd as _, updateCommand as a, planSetupRemove as c, initCommandDefinition as d, initPackages as f, addCommand as g, setupCatalog as h, readUpdateArgs as i, readRemoveArgs as l, readInitArgs as m, setupCommands as n, updateInstallArgs as o, nuxiPackage as p, planSetupUpdate as r, applySetupRemove as s, commands_exports as t, removeCommand as u, planSetupAdd as v, readAddArgs as y };
@@ -1,10 +1,10 @@
1
- import { m as cliErrorDiagnostics } from "./provision-DgT_lpyn.js";
2
- import { o as writeSetupError, r as setupExitCodes, s as writeSetupJson } from "./envelope-C7e408hm.js";
1
+ import { m as cliErrorDiagnostics } from "./provision-DlknnTAt.js";
2
+ import { o as writeSetupError, r as setupExitCodes, s as writeSetupJson } from "./envelope-DbplCDko.js";
3
3
  import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { homedir, hostname } from "node:os";
6
6
  import { parseArgs } from "node:util";
7
- //#region src/setup/console-auth.ts
7
+ // src/setup/console-auth.ts
8
8
  /** The hosted Console. `--console` and `VITEHUB_CONSOLE_URL` name a self-hosted one. */
9
9
  const defaultConsoleUrl = "https://console.vitehub.dev";
10
10
  /** An API key for CI. It wins over the saved key, and `vitehub logout` does not remove it. */
@@ -308,5 +308,4 @@ const logoutCommand = {
308
308
  }
309
309
  }
310
310
  };
311
- //#endregion
312
311
  export { defaultConsoleUrl as a, readConsoleCredential as c, consoleUrlVariable as i, whoamiCommand as l, consoleOrigin as n, loginCommand as o, consoleTokenVariable as r, logoutCommand as s, consoleCredentialsFile as t };
@@ -1,11 +1,11 @@
1
- import { m as cliErrorDiagnostics } from "./provision-DgT_lpyn.js";
2
- import { o as writeSetupError, s as writeSetupJson } from "./envelope-C7e408hm.js";
3
- import { c as readConsoleCredential, n as consoleOrigin } from "./console-auth-Dz9HHP2G.js";
1
+ import { m as cliErrorDiagnostics } from "./provision-DlknnTAt.js";
2
+ import { c as readConsoleCredential, n as consoleOrigin } from "./console-auth-CpOpbA7U.js";
3
+ import { o as writeSetupError, s as writeSetupJson } from "./envelope-DbplCDko.js";
4
4
  import { execFile } from "node:child_process";
5
5
  import { mkdtemp, open, rename, rm } from "node:fs/promises";
6
6
  import { join } from "node:path";
7
7
  import { parseArgs } from "node:util";
8
- //#region src/setup/console-env.ts
8
+ // src/setup/console-env.ts
9
9
  const pullUsage = "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]";
10
10
  const stagePattern = /^[a-z0-9][a-z0-9_-]{0,62}$/;
11
11
  /** One line of a `.env` file. A value that a parser could read in two ways goes in quotes. */
@@ -189,5 +189,4 @@ const envPullFeature = {
189
189
  }
190
190
  }
191
191
  };
192
- //#endregion
193
192
  export { envPullFeature };
@@ -1,7 +1,7 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { C as callOperationFromCli, _ as readProvisionState, a as writeProvisionActions, d as planProvisionSteps, f as resolveHostCredentials, g as mergeProvisionState, h as PROVISION_STATE_FILE, i as provisionEnv, m as cliErrorDiagnostics, n as isProvisionHost, r as provisionActionStatus, y as writeProvisionState } from "./provision-DgT_lpyn.js";
3
- import { A as readDeployCommit, C as denoOrganization, D as build, E as listCloudflareDeployments, F as setupStatus, H as readSetupProject, O as readBuildOutput, R as hostFromNitroPreset, S as denoAdapter, T as cloudflareAdapter, _ as listVercelDeployments, a as ensureViteHubGitignore, b as netlifyAdapter, f as readSetupLinks, g as hasVercelLogin, h as writeSeparateResourcesNote, i as addSetupLink, k as createDeployRun, l as readLinkHostOption, p as selectSetupLink, s as hostRequired, t as checkDeployEnv, v as vercelAdapter, w as listDenoDeployments, x as abortable, y as listNetlifyDeployments } from "./env-MtXhP7A7.js";
4
- import { a as table, i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-C7e408hm.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
+ import { A as readDeployCommit, C as denoOrganization, D as build, E as listCloudflareDeployments, F as setupStatus, H as readSetupProject, O as readBuildOutput, R as hostFromNitroPreset, S as denoAdapter, T as cloudflareAdapter, _ as listVercelDeployments, a as ensureViteHubGitignore, b as netlifyAdapter, f as readSetupLinks, g as hasVercelLogin, h as writeSeparateResourcesNote, i as addSetupLink, k as createDeployRun, l as readLinkHostOption, p as selectSetupLink, s as hostRequired, t as checkDeployEnv, v as vercelAdapter, w as listDenoDeployments, x as abortable, y as listNetlifyDeployments } from "./env-DRI0QH4-.js";
3
+ import { C as callOperationFromCli, _ as readProvisionState, a as writeProvisionActions, d as planProvisionSteps, f as resolveHostCredentials, g as mergeProvisionState, h as PROVISION_STATE_FILE, i as provisionEnv, m as cliErrorDiagnostics, n as isProvisionHost, r as provisionActionStatus, y as writeProvisionState } from "./provision-DlknnTAt.js";
4
+ import { a as table, i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-DbplCDko.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { existsSync } from "node:fs";
7
7
  import process from "node:process";
@@ -10,7 +10,7 @@ import { readFile } from "node:fs/promises";
10
10
  import { createInterface } from "node:readline/promises";
11
11
  import { pathToFileURL } from "node:url";
12
12
  import { parseArgs } from "node:util";
13
- //#region src/setup/deploy/after.ts
13
+ // src/setup/deploy/after.ts
14
14
  /** Waits between the attempts of one path: a new version can take a few seconds to reach every edge location. */
15
15
  const checkRetryDelaysMs = [
16
16
  1e3,
@@ -192,8 +192,7 @@ async function submitIndexNow(indexNow, fetchImpl) {
192
192
  submitted: urlList.length
193
193
  };
194
194
  }
195
- //#endregion
196
- //#region src/setup/deploy/checkouts.ts
195
+ // src/setup/deploy/checkouts.ts
197
196
  const lockFile = "vitehub.lock";
198
197
  function isCheckoutModule(value) {
199
198
  return Object(value) === value && typeof Reflect.get(Object(value), "localCheckoutStatus") === "function" && typeof Reflect.get(Object(value), "pullWorkspaces") === "function" && typeof Reflect.get(Object(value), "pushWorkspaces") === "function";
@@ -345,8 +344,7 @@ function formatDeployCheckouts(pushed) {
345
344
  if (!pushed.changed.length) return text;
346
345
  return `${text}The push changed these files. Commit them:\n${pushed.changed.map((path) => ` ${path}`).join("\n")}\n`;
347
346
  }
348
- //#endregion
349
- //#region src/setup/deployments.ts
347
+ // src/setup/deployments.ts
350
348
  const usage$1 = "vitehub deployments [--host <host>] [--limit <n>] [--json]";
351
349
  const listers = {
352
350
  cloudflare: listCloudflareDeployments,
@@ -627,8 +625,7 @@ function liveLabel(status) {
627
625
  if (live.commit?.dirty) notes.push("with uncommitted changes");
628
626
  return `${name} (${notes.join(", ")})${live.url ? ` ${live.url}` : ""}`;
629
627
  }
630
- //#endregion
631
- //#region src/setup/deploy/provision.ts
628
+ // src/setup/deploy/provision.ts
632
629
  function declaresResources(step, env) {
633
630
  const described = step.recordedState?.({ env });
634
631
  return described === void 0 || described.some((category) => category.declared.length > 0);
@@ -718,13 +715,8 @@ async function provisionForDeploy(input, context) {
718
715
  ids: state[host] ?? {}
719
716
  };
720
717
  }
721
- //#endregion
722
- //#region src/setup/deploy.ts
723
- var deploy_exports = /* @__PURE__ */ __exportAll({
724
- deployCommand: () => deployCommand,
725
- readDeployArgs: () => readDeployArgs,
726
- resolveDefaultDeployTarget: () => resolveDefaultDeployTarget
727
- });
718
+ // src/setup/deploy.ts
719
+ var deploy_exports = /* @__PURE__ */ __exportAll({ resolveDefaultDeployTarget: () => resolveDefaultDeployTarget });
728
720
  const deployHosts = [
729
721
  "cloudflare",
730
722
  "vercel",
@@ -1121,5 +1113,4 @@ const deployCommand = {
1121
1113
  },
1122
1114
  usage
1123
1115
  };
1124
- //#endregion
1125
1116
  export { deploymentsCommand as a, STATUS_HOST_TIMEOUT_MS as i, deploy_exports as n, liveLabel as o, readDeployArgs as r, readSetupLive as s, deployCommand as t };