@vite-hub/cli 0.5.1 → 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,9 +1,7 @@
1
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";
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";
7
5
  import { createRequire } from "node:module";
8
6
  import { existsSync, readFileSync } from "node:fs";
9
7
  import process from "node:process";
@@ -12,9 +10,9 @@ import { glob, mkdir, readFile, readdir, rm, rmdir, writeFile } from "node:fs/pr
12
10
  import { join as join$1 } from "node:path";
13
11
  import { createInterface } from "node:readline/promises";
14
12
  import { pathToFileURL } from "node:url";
15
- import { createTwoFilesPatch } from "diff";
16
13
  import { isDeepStrictEqual, parseArgs } from "node:util";
17
- import semver, { Range, minVersion, satisfies, subset, validRange } from "semver";
14
+ import { createTwoFilesPatch } from "diff";
15
+ import semver, { minVersion, satisfies, subset, validRange } from "semver";
18
16
  // ../internal/dist/feature-inputs.js
19
17
  function isLocaleTag(value) {
20
18
  try {
@@ -811,6 +809,14 @@ async function deriveSetupStack(project, status, validate) {
811
809
  path: id,
812
810
  reason: "disabled-feature"
813
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
+ }
814
820
  const name = basename(project.root);
815
821
  const args = [
816
822
  name.startsWith("-") ? `./${name}` : name || "vitehub-app",
@@ -821,6 +827,7 @@ async function deriveSetupStack(project, status, validate) {
821
827
  ...options.flatMap((option) => ["--option", option]),
822
828
  "--framework",
823
829
  status.framework === "nuxt" ? "nuxt" : "vite",
830
+ ...nuxtNightly ? ["--nuxt-nightly"] : [],
824
831
  "--pm",
825
832
  status.packageManager,
826
833
  "--yes"
@@ -855,7 +862,7 @@ async function deriveSetupStack(project, status, validate) {
855
862
  };
856
863
  }
857
864
  // src/setup/init.ts
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]";
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]";
859
866
  const initCommandPrefix = "pnpm dlx vite-hub init";
860
867
  const initHosts = [
861
868
  "cloudflare",
@@ -873,7 +880,7 @@ const packageManagers = [
873
880
  ];
874
881
  /**
875
882
  * The packages of a new app, as `getting-started/installation.md` installs them. The Nitro and H3 versions match the
876
- * 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
877
884
  * tutorials import H3 2. Valibot validates request bodies in the docs' route examples.
878
885
  */
879
886
  const initPackages = {
@@ -901,9 +908,15 @@ const initPackages = {
901
908
  };
902
909
  const nuxtNitroRange = "^3.0.261103-rc";
903
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";
904
917
  /** The pinned Nuxt CLI that creates a new Nuxt app. */
905
918
  const nuxiPackage = "nuxi@3.37.0";
906
- const nuxtTemplate = "gh:nuxt/starter#db01806fcb37f2e369fb09443c72cac696b31548";
919
+ const nuxtTemplate = "gh:nuxt/starter#d4367031fe43d93d4e2a339f73b519ec35e78b38";
907
920
  function isRecord(value) {
908
921
  return !!value && typeof value === "object" && !Array.isArray(value);
909
922
  }
@@ -922,6 +935,7 @@ function readInitArgs(args) {
922
935
  help: false,
923
936
  install: true,
924
937
  json: false,
938
+ nuxtNightly: false,
925
939
  options: [],
926
940
  yes: false
927
941
  };
@@ -938,6 +952,7 @@ function readInitArgs(args) {
938
952
  else if (flag === "--dry-run") parsed.dryRun = true;
939
953
  else if (flag === "--yes" || flag === "-y") parsed.yes = true;
940
954
  else if (flag === "--no-install") parsed.install = false;
955
+ else if (flag === "--nuxt-nightly") parsed.nuxtNightly = true;
941
956
  else if (flag === "-h" || flag === "--help") parsed.help = true;
942
957
  else if (flag === "--host") parsed.host = oneOf("--host", value(), initHosts);
943
958
  else if (flag === "--features") features = value();
@@ -949,6 +964,8 @@ function readInitArgs(args) {
949
964
  else throw invalid$2(`Pass one folder, not ${JSON.stringify(parsed.dir)} and ${JSON.stringify(arg)}.`);
950
965
  }
951
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";
952
969
  return parsed;
953
970
  }
954
971
  function addArgsOf(args) {
@@ -969,6 +986,7 @@ function initCommand(parts, extra) {
969
986
  shellQuote(parts.features?.join(",") ?? "<id,id,...>"),
970
987
  ...options.flatMap((option) => ["--option", shellQuote(option)]),
971
988
  ...parts.framework === "nuxt" ? ["--framework", "nuxt"] : [],
989
+ ...parts.nuxtNightly ? ["--nuxt-nightly"] : [],
972
990
  ...parts.pm && parts.pm !== "pnpm" ? ["--pm", parts.pm] : [],
973
991
  ...extra
974
992
  ].join(" ");
@@ -1135,7 +1153,9 @@ async function planInit(args, root, state, context) {
1135
1153
  found,
1136
1154
  framework
1137
1155
  }), setupExitCodes.conflict);
1138
- 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);
1139
1159
  const detected = state.kind === "adopt" ? state.project : detectPackageManager(root, void 0, context.env);
1140
1160
  const packageManager = args.pm ?? (detected.packageManagerSource === "default" ? "pnpm" : detected.packageManager);
1141
1161
  const base = /* @__PURE__ */ new Map();
@@ -1161,7 +1181,7 @@ async function planInit(args, root, state, context) {
1161
1181
  const basePackages = initPackages[framework];
1162
1182
  const install = {
1163
1183
  dev: basePackages.dev.filter((spec) => !declared(packageName$1(spec), true)),
1164
- 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)
1165
1185
  };
1166
1186
  if (nuxtNeedsNitro) install.prod.push(nuxtNitroPackage);
1167
1187
  const willInstall = new Set([...install.prod, ...install.dev].map(packageName$1));
@@ -1173,6 +1193,7 @@ async function planInit(args, root, state, context) {
1173
1193
  declared: (name, dev) => declared(name, dev) || willInstall.has(name),
1174
1194
  framework,
1175
1195
  installed: state.kind === "adopt" ? state.project.installed : () => false,
1196
+ ...nuxt === void 0 ? {} : { nuxt },
1176
1197
  packageManager,
1177
1198
  packageManagerSource: args.pm ? "manifest" : detected.packageManagerSource,
1178
1199
  root,
@@ -1191,6 +1212,7 @@ async function planInit(args, root, state, context) {
1191
1212
  features: [...args.features, ...extraFeatures.filter((id) => !args.features.includes(id))],
1192
1213
  framework,
1193
1214
  host: args.host,
1215
+ nuxtNightly: args.nuxtNightly,
1194
1216
  options: Object.entries(options).flatMap(([id, value]) => value ? flattenOptions(id, value) : []),
1195
1217
  pm: packageManager
1196
1218
  };
@@ -1211,6 +1233,8 @@ async function planInit(args, root, state, context) {
1211
1233
  after: gitignore === void 0 ? ".vitehub\n" : gitignoreWithViteHub(gitignore) ?? gitignore
1212
1234
  });
1213
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 });
1214
1238
  const scaffolded = state.kind === "create" && framework === "nuxt";
1215
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]) => ({
1216
1240
  path,
@@ -1222,8 +1246,7 @@ async function planInit(args, root, state, context) {
1222
1246
  basename(root),
1223
1247
  "--template",
1224
1248
  nuxtTemplate,
1225
- "--nightly",
1226
- "5x",
1249
+ ...args.nuxtNightly ? ["--nightly", "5x"] : [],
1227
1250
  "--packageManager",
1228
1251
  packageManager,
1229
1252
  "--no-install",
@@ -1267,7 +1290,8 @@ async function planInit(args, root, state, context) {
1267
1290
  rerun: rerunInit(args, parts()),
1268
1291
  stackProject,
1269
1292
  writes,
1270
- ...scaffold ? { scaffold } : {}
1293
+ ...scaffold ? { scaffold } : {},
1294
+ ...workspaceFile ? { workspaceFile } : {}
1271
1295
  };
1272
1296
  }
1273
1297
  function setupStack(project, status) {
@@ -1298,7 +1322,8 @@ async function applyInit(planned, install, context, scaffolded = false) {
1298
1322
  if (result.exitCode !== 0) throw setupFailure(cliErrorDiagnostics.SETUP_INSTALL_FAILED({
1299
1323
  command: formatInstallCommand(plan.packageManager, commandArgs),
1300
1324
  exitCode: result.exitCode ?? result.signal,
1301
- filesWritten: scaffolded || plan.mode === "create"
1325
+ filesWritten: scaffolded || plan.mode === "create",
1326
+ workspaceFile: planned.workspaceFile
1302
1327
  }), setupExitCodes.error);
1303
1328
  }
1304
1329
  };
@@ -1334,12 +1359,6 @@ async function scaffoldNuxt(planned, context) {
1334
1359
  }), setupExitCodes.error);
1335
1360
  await checkNuxtVersion(planned.plan.root, true);
1336
1361
  }
1337
- function nuxtReleases(nuxt) {
1338
- if (typeof nuxt !== "string") return void 0;
1339
- const range = validRange(nuxt.replace(/^npm:nuxt(?:-nightly)?@/u, ""));
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(" || ");
1342
- }
1343
1362
  async function checkNuxtVersion(root, scaffolded = false) {
1344
1363
  const manifest = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
1345
1364
  const dependencies = isRecord(manifest) && isRecord(manifest.dependencies) ? manifest.dependencies : {};
@@ -1349,7 +1368,7 @@ async function checkNuxtVersion(root, scaffolded = false) {
1349
1368
  dir: root,
1350
1369
  scaffolded
1351
1370
  }), setupExitCodes.conflict);
1352
- if (subset(releases, ">=5.0.0 <6.0.0")) return { needsNitro: false };
1371
+ if (declaresNuxt5(dependencies.nuxt ?? devDependencies.nuxt)) return { needsNitro: false };
1353
1372
  const nitroDeclarations = [dependencies.nitro, devDependencies.nitro].filter((spec) => spec !== void 0);
1354
1373
  for (const spec of nitroDeclarations) {
1355
1374
  const range = typeof spec === "string" ? validRange(spec.replace(/^npm:nitro@/u, "")) : null;
@@ -1413,6 +1432,7 @@ async function readInputs(args) {
1413
1432
  missing: missing.map(({ sentence: _sentence, ...item }) => item),
1414
1433
  rerun: rerunInit(args, {
1415
1434
  dir: args.dir ?? "<dir>",
1435
+ nuxtNightly: args.nuxtNightly,
1416
1436
  options: args.options,
1417
1437
  ...args.features ? { features: args.features } : {},
1418
1438
  ...args.host ? { host: args.host } : {},
@@ -1478,6 +1498,7 @@ async function runInit(rawArgs, context) {
1478
1498
  }
1479
1499
  if (planned.scaffold) {
1480
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);
1481
1502
  planned = await planInit({
1482
1503
  ...args,
1483
1504
  pm: plan.packageManager
@@ -2628,6 +2649,7 @@ const setupCommands = [
2628
2649
  deploymentsCommand,
2629
2650
  loginCommand,
2630
2651
  logoutCommand,
2631
- whoamiCommand
2652
+ whoamiCommand,
2653
+ appsCommand
2632
2654
  ];
2633
2655
  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,6 +1,4 @@
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";
1
+ import { B as readConsoleCredential, J as writeSetupJson, P as consoleOrigin, Y as cliErrorDiagnostics, q as writeSetupError } from "./provision-YzxNsbhs.js";
4
2
  import { execFile } from "node:child_process";
5
3
  import { mkdtemp, open, rename, rm } from "node:fs/promises";
6
4
  import { join } from "node:path";
@@ -1,7 +1,6 @@
1
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";
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";
5
4
  import { createRequire } from "node:module";
6
5
  import { existsSync } from "node:fs";
7
6
  import process from "node:process";
@@ -724,7 +723,7 @@ const deployHosts = [
724
723
  "deno"
725
724
  ];
726
725
  const temporaryHosts = ["cloudflare", "vercel"];
727
- const usage = "vitehub deploy [--host <host>] [--preview] [--push-env] [--no-build] [--no-provision] [--no-push] [--no-check] [--no-index-now] [--temporary] [--yes] [--json]";
726
+ const usage = "vitehub deploy [--host <host>] [--preview] [--push-env] [--no-build] [--no-provision] [--no-push] [--no-check] [--no-index-now] [--no-console] [--temporary] [--yes] [--json]";
728
727
  const help = `--host picks a host target of .vitehub/link.json. Without it, deploy uses the default target. The build runs
729
728
  with VITEHUB_HOST set to that host, which wins over \`host\` in vitehub(). Each host has its own resources, such as D1,
730
729
  KV, R2, and libSQL.
@@ -746,8 +745,16 @@ omitted secret cannot inherit from another stage. With --yes, a missing VITEHUB_
746
745
 
747
746
  After the upload, deploy requests the paths of \`deploy.check\` in vitehub(), and the health route with \`health\`, on
748
747
  the deployed URL. When one does not answer with a 2xx status, deploy exits with 1 and prints the command that rolls
749
- production back to the deployment it replaced. --no-check skips the checks. With \`deploy.indexNow\`, a production
748
+ production back to the deployment it replaced. --no-check skips the checks. When the host reports no URL, such as a
749
+ Worker whose routes have a wildcard host or a narrower path, deploy skips the checks and IndexNow with a warning. With \`deploy.indexNow\`, a production
750
750
  deploy that passed its checks then sends the URLs of /sitemap.xml to IndexNow. --no-index-now skips it.
751
+
752
+ With \`console: true\` in vitehub() and a \`vitehub login\`, a production deploy links the app in that Console. It
753
+ links the deployed URL, sets the \`VITEHUB_CONSOLE_KEY_<NAME>\` key of the link on the host when the host lacks it,
754
+ checks that the app answers a signed request of the Console, and prints the Console page of the app. A second deploy
755
+ keeps the same link. On Cloudflare, it also re-supplies the key of the Console with each version. Other hosts read a
756
+ new variable on the next deploy, so the first deploy there deploys a second time. Without a login, deploy needs the
757
+ key on the host or in a local value, as for any other env name. --no-console skips the Console.
751
758
  `;
752
759
  function readDeployArgs(args) {
753
760
  try {
@@ -772,6 +779,10 @@ function readDeployArgs(args) {
772
779
  type: "boolean",
773
780
  default: false
774
781
  },
782
+ "no-console": {
783
+ type: "boolean",
784
+ default: false
785
+ },
775
786
  "no-index-now": {
776
787
  type: "boolean",
777
788
  default: false
@@ -807,6 +818,7 @@ function readDeployArgs(args) {
807
818
  return {
808
819
  build: !values["no-build"],
809
820
  check: !values["no-check"],
821
+ console: !values["no-console"],
810
822
  help: values.help,
811
823
  indexNow: !values["no-index-now"],
812
824
  ...values.host === void 0 ? {} : { host: values.host },
@@ -833,6 +845,7 @@ function rerunCommand(args, extra = {}) {
833
845
  ...args.push ? [] : ["--no-push"],
834
846
  ...args.check ? [] : ["--no-check"],
835
847
  ...args.indexNow ? [] : ["--no-index-now"],
848
+ ...args.console ? [] : ["--no-console"],
836
849
  ...args.temporary || extra.temporary ? ["--temporary"] : [],
837
850
  "--yes",
838
851
  ...args.json ? ["--json"] : []
@@ -934,11 +947,12 @@ async function recordLink(root, host, result, fallbackName) {
934
947
  await ensureViteHubGitignore(root);
935
948
  }
936
949
  function writeDeployed(output, name, context) {
937
- context.stdout.write(`Deployed ${name} to ${output.host}: ${output.url}\n`);
950
+ context.stdout.write(`Deployed ${name} to ${output.host}${output.url ? `: ${output.url}` : "."}\n`);
938
951
  if (output.deploymentId) context.stdout.write(`Deployment: ${output.deploymentId}\n`);
939
952
  if (output.version) context.stdout.write(`Version: ${output.version}\n`);
940
953
  if (output.commit) context.stdout.write(`Commit: ${output.commit.sha}${output.commit.dirty ? " (with uncommitted changes)" : ""}\n`);
941
954
  for (const check of output.checks ?? []) context.stdout.write(`Checked ${check.path}: ${check.status ?? check.error}\n`);
955
+ if (output.console) context.stdout.write(formatDeployConsole(output.console));
942
956
  if (output.temporary) {
943
957
  const window = output.host === "cloudflare" ? "within 60 minutes" : output.temporary.expiresAt ? `before ${output.temporary.expiresAt}` : "soon";
944
958
  context.stdout.write(`This is a temporary deploy. Claim it ${window}, or the host deletes it. Do not share the claim link:\n${output.temporary.claimUrl}\n`);
@@ -1006,8 +1020,12 @@ async function runDeploy(args, context) {
1006
1020
  });
1007
1021
  const secrets = credentials.ok ? [credentials.token] : [];
1008
1022
  const run = createDeployRun(context.stderr, secrets);
1023
+ const consoleStep = args.console && !args.temporary && readsConsoleKey(output.env) ? await openDeployConsole(context) : void 0;
1024
+ const availableConsole = consoleStep === "unavailable" ? void 0 : consoleStep;
1009
1025
  const env = await checkDeployEnv({
1010
1026
  context,
1027
+ ...availableConsole ? { consoleKeys: availableConsole.keys } : {},
1028
+ deferConsoleKey: !!consoleStep && !args.preview,
1011
1029
  entries: output.env,
1012
1030
  envDir: output.envDir,
1013
1031
  host,
@@ -1040,12 +1058,22 @@ async function runDeploy(args, context) {
1040
1058
  await env.apply();
1041
1059
  const checkPaths = args.check ? output.deploy.check : [];
1042
1060
  const previous = checkPaths.length && !args.preview && !args.temporary ? await previousDeployment(project.root, link, credentials, context, run) : void 0;
1043
- const result = await adapter.deploy();
1061
+ let result = await adapter.deploy();
1044
1062
  if (!link && !args.temporary) await recordLink(project.root, host, result, projectName);
1045
- const checks = checkPaths.length ? await runDeployChecks(result.url, checkPaths, deployContext.fetch) : void 0;
1063
+ const consoleDeploy = availableConsole && !args.preview ? await deployConsole(availableConsole, result, {
1064
+ context,
1065
+ deployContext,
1066
+ host,
1067
+ onHost: env.onHost,
1068
+ projectName
1069
+ }) : void 0;
1070
+ if (consoleDeploy) result = consoleDeploy.result;
1071
+ const linkedConsole = consoleDeploy?.output;
1072
+ if (checkPaths.length && !result.url) context.stderr.write(`Deploy checks skipped: ${host} reported no URL to request, such as a workers.dev URL, a custom domain, or a \`<host>/*\` route. The deploy is done.\n`);
1073
+ const checks = checkPaths.length && result.url ? await runDeployChecks(result.url, checkPaths, deployContext.fetch) : void 0;
1046
1074
  const deployed = {
1047
1075
  host,
1048
- url: result.url,
1076
+ ...result.url ? { url: result.url } : {},
1049
1077
  ...result.deploymentId ? { deploymentId: result.deploymentId } : {},
1050
1078
  ...result.version ? { version: result.version } : {},
1051
1079
  ...result.claim ? { temporary: {
@@ -1055,12 +1083,15 @@ async function runDeploy(args, context) {
1055
1083
  ...deployContext.commit ? { commit: deployContext.commit } : {},
1056
1084
  env: env.output,
1057
1085
  ...provisioned ? { provision: provisioned } : {},
1058
- ...checks ? { checks } : {}
1086
+ ...checks ? { checks } : {},
1087
+ ...linkedConsole ? { console: linkedConsole } : {}
1059
1088
  };
1060
1089
  if (checks?.some((check) => !check.ok)) throw checkFailed(deployed, host, previous, projectName, link, result, args.preview);
1061
1090
  if (!args.json) writeDeployed(deployed, projectName, context);
1062
1091
  const pushed = checkouts ? await pushCheckouts(checkouts, deployed, args, context) : deployed;
1063
- const indexNow = output.deploy.indexNow && args.indexNow && !args.preview && !args.temporary ? await submitIndexNow(output.deploy.indexNow, deployContext.fetch) : void 0;
1092
+ const indexNowConfig = args.indexNow && !args.preview && !args.temporary ? output.deploy.indexNow : void 0;
1093
+ if (indexNowConfig && !result.url) context.stderr.write(`IndexNow: nothing was sent, because ${host} reported no URL for this deploy.\n`);
1094
+ const indexNow = indexNowConfig && result.url ? await submitIndexNow(indexNowConfig, deployContext.fetch) : void 0;
1064
1095
  if (indexNow && !args.json) context.stderr.write("submitted" in indexNow ? `IndexNow: sent ${indexNow.submitted} URLs (${indexNow.status}).\n` : `IndexNow: nothing was sent. ${indexNow.error} The deploy is done.\n`);
1065
1096
  const final = indexNow ? {
1066
1097
  ...pushed,
@@ -1069,6 +1100,55 @@ async function runDeploy(args, context) {
1069
1100
  if (args.json) writeSetupJson(context, final);
1070
1101
  return setupExitCodes.done;
1071
1102
  }
1103
+ async function deployConsole(step, initial, options) {
1104
+ const { context, deployContext, host } = options;
1105
+ const productionUrl = (result) => host === "vercel" ? result.productionUrl : result.url;
1106
+ const url = productionUrl(initial);
1107
+ if (!url) {
1108
+ context.stderr.write(`The app was not linked in the Console, because ${host} reported no production URL. Run \`vitehub apps link <url>\` with the production URL of the app.\n`);
1109
+ return;
1110
+ }
1111
+ let result = initial;
1112
+ return {
1113
+ output: await linkDeployedApp({
1114
+ console: step,
1115
+ context,
1116
+ label: options.projectName,
1117
+ onHost: options.onHost,
1118
+ async setKey(name, value) {
1119
+ const link = deployContext.link ?? (await readSetupLinks(deployContext.root)).targets.find((target) => target.host === host);
1120
+ if (!link) throw cliErrorDiagnostics.SETUP_ENV_VALUE_UNSUPPORTED({
1121
+ host,
1122
+ name,
1123
+ reason: "The project has no host target in .vitehub/link.json."
1124
+ });
1125
+ await hostEnvs[host]({
1126
+ env: context.env,
1127
+ fetch: deployContext.fetch,
1128
+ link,
1129
+ root: deployContext.root,
1130
+ run: deployContext.run,
1131
+ secrets: deployContext.secrets,
1132
+ target: "production"
1133
+ }).setSecret(name, value, { secret: host === "cloudflare" });
1134
+ if (host === "cloudflare") {
1135
+ const { version: _version, ...live } = result;
1136
+ result = live;
1137
+ } else {
1138
+ context.stderr.write(`Deploying again, so ${host} reads ${name}.\n`);
1139
+ result = await (await hostAdapter(host, {
1140
+ ...deployContext,
1141
+ link,
1142
+ upload: {}
1143
+ })).deploy();
1144
+ }
1145
+ return productionUrl(result);
1146
+ },
1147
+ url
1148
+ }),
1149
+ result
1150
+ };
1151
+ }
1072
1152
  async function previousDeployment(root, link, credentials, context, run) {
1073
1153
  if (!link) return { failed: "the project was not linked before this deploy." };
1074
1154
  if (!credentials.ok) return { failed: `deploy used the saved ${link.host} CLI login, which gives no API token.` };