@vite-hub/cli 0.8.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.
@@ -1,18 +1,19 @@
1
- import { _ as featureSupport, b as impliedFeatures, d as cliErrorDiagnostics, h as featureIds, m as featureHosts, v as features, w as isRecord, x as installSpecifier } from "./provision-9QsGgeiq.js";
2
- import { _ as setupLockfiles, b as locateViteHubConfig, c as logoutCommand, d as whoamiCommand, f as declaresNuxt5, g as readSetupProject, h as pnpmWorkspaceFile, m as nuxtReleases, p as detectPackageManager, s as loginCommand, v as editViteHubConfig, y as insertViteHubConfig } from "./console-auth-cCodgT_T.js";
3
- import { a as table, c as __exportAll, i as setupFailure, n as readSetupArgs, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-BJQ7xPyX.js";
4
- import { a as rateLimitUsesVercelKV, c as shellQuote, f as hasDefinitionFiles, i as missingProviderOption, l as uninstallArgs, n as installArgs, o as setupFeaturePackages, p as listMatchingFiles, r as installCommand, s as setupStatus, t as formatInstallCommand } from "./status-gjvZVutV.js";
5
- import { t as appsCommand } from "./console-apps-BQX-Np9Q.js";
6
- import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, o as liveLabel, s as readSetupLive, t as deployCommand } from "./deploy-CqR6pJa-.js";
7
- import { i as gitignoreWith, l as readLinkHostOption, m as unlinkSetupProject, o as ignoredFolders, s as linkSetupProject, t as SETUP_LINK_FILE, u as readSetupLinkState } from "./link-BRNWNqT9.js";
1
+ import { C as invariant, _ as featureSupport, b as impliedFeatures, d as cliErrorDiagnostics, h as featureIds, m as featureHosts, v as features, w as isRecord, x as installSpecifier } from "./provision-D0ct9RDq.js";
2
+ import { _ as setupLockfiles, b as locateViteHubConfig, c as logoutCommand, d as whoamiCommand, f as declaresNuxt5, g as readSetupProject, h as pnpmWorkspaceFile, m as nuxtReleases, p as detectPackageManager, s as loginCommand, v as editViteHubConfig, y as insertViteHubConfig } from "./console-auth-BunROd7u.js";
3
+ import { a as table, c as __exportAll, i as setupFailure, n as readSetupArgs, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-DXB-0EcA.js";
4
+ import { a as rateLimitUsesVercelKV, c as shellQuote, f as hasDefinitionFiles, i as missingProviderOption, l as uninstallArgs, n as installArgs, o as setupFeaturePackages, p as listMatchingFiles, r as installCommand, s as setupStatus, t as formatInstallCommand } from "./status-HXNfm9mB.js";
5
+ import { t as appsCommand } from "./console-apps-Cvzc6tY4.js";
6
+ import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, o as liveLabel, s as readSetupLive, t as deployCommand } from "./deploy-DxOKht-B.js";
7
+ import { i as gitignoreWith, l as readLinkHostOption, m as unlinkSetupProject, o as ignoredFolders, s as linkSetupProject, t as SETUP_LINK_FILE, u as readSetupLinkState } from "./link-B3NuFAyj.js";
8
8
  import { createRequire } from "node:module";
9
9
  import { existsSync, readFileSync } from "node:fs";
10
10
  import process from "node:process";
11
11
  import { pathToFileURL } from "node:url";
12
12
  import { basename, dirname, join, relative, resolve } from "pathe";
13
- import { glob, mkdir, readFile, readdir, rm, rmdir, writeFile } from "node:fs/promises";
13
+ import { cp, glob, mkdir, mkdtemp, readFile, readdir, rm, rmdir, writeFile } from "node:fs/promises";
14
14
  import { join as join$1, matchesGlob } from "node:path";
15
15
  import { createInterface } from "node:readline/promises";
16
+ import { tmpdir } from "node:os";
16
17
  import { createTwoFilesPatch } from "diff";
17
18
  import { isDeepStrictEqual, parseArgs, stripVTControlCharacters } from "node:util";
18
19
  import { isMap, parseDocument } from "yaml";
@@ -845,6 +846,61 @@ function setupCatalog() {
845
846
  schemaVersion: 1
846
847
  };
847
848
  }
849
+ // ../../templates/nuxt/agent/template.json
850
+ var title$2 = "Agent";
851
+ var description$2 = "A chat assistant with tools, memory, and channels. It reads web pages with Browser, which runs on Cloudflare only.";
852
+ // ../../templates/nuxt/dashboard/template.json
853
+ var title$1 = "Dashboard";
854
+ var description$1 = "A SaaS app with a public landing page, a blog, and a signed-in dashboard.";
855
+ // ../../templates/nuxt/jobs/template.json
856
+ var title = "Jobs";
857
+ var description = "A nightly repository reviewer that runs on a schedule.";
858
+ // src/setup/init-template.ts
859
+ /** The templates in `templates/nuxt/` that `vitehub init --template` starts from. */
860
+ const initTemplates = [
861
+ "dashboard",
862
+ "agent",
863
+ "jobs"
864
+ ];
865
+ /** The title and description of each template, as its `template.json` gives them. A test keeps both in sync. */
866
+ const initTemplateInfo = {
867
+ agent: {
868
+ description: description$2,
869
+ title: title$2
870
+ },
871
+ dashboard: {
872
+ description: description$1,
873
+ title: title$1
874
+ },
875
+ jobs: {
876
+ description,
877
+ title
878
+ }
879
+ };
880
+ const templatePnpmWorkspace = {
881
+ agent: "allowBuilds:\n esbuild: false\n \"@mongodb-js/zstd\": false\n node-liblzma: false\n",
882
+ dashboard: "allowBuilds:\n esbuild: false\n",
883
+ jobs: "allowBuilds:\n esbuild: false\n \"@swc/core\": false\n cbor-extract: false\n"
884
+ };
885
+ /** The pinned giget that downloads a template folder from GitHub. */
886
+ const gigetPackage = "giget@3.3.1";
887
+ /** The files that every complete template has. A release that has only the skeleton of a template has no README.md. */
888
+ const templateRequiredFiles = ["README.md", "package.json"];
889
+ /** The version of this CLI. A template comes from the release tag of the same version, so the app matches the CLI. */
890
+ function templateVersion() {
891
+ const manifest = JSON.parse(readFileSync(new URL(import.meta.resolve("@vite-hub/cli/package.json")), "utf8"));
892
+ const version = manifest && typeof manifest === "object" ? Reflect.get(manifest, "version") : void 0;
893
+ invariant(typeof version === "string", "the installed @vite-hub/cli package manifest has a version");
894
+ return version;
895
+ }
896
+ /** The giget source of a template at a release tag. */
897
+ function templateSource(template, version) {
898
+ return `gh:vite-hub/vitehub/templates/nuxt/${template}#v${version}`;
899
+ }
900
+ /** Whether a downloaded template folder is complete. */
901
+ function isCompleteTemplate(dir) {
902
+ return templateRequiredFiles.every((file) => existsSync(`${dir}/${file}`));
903
+ }
848
904
  // src/setup/init-wizard.ts
849
905
  function cancelled() {
850
906
  return setupFailure(cliErrorDiagnostics.CLI_R0004({ message: "[vitehub] The setup was cancelled. Nothing was written." }), setupExitCodes.error);
@@ -1082,7 +1138,8 @@ async function deriveSetupStack(project, status, validate) {
1082
1138
  };
1083
1139
  }
1084
1140
  // src/setup/init.ts
1085
- 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]";
1141
+ 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]
1142
+ vitehub init <dir> --template ${initTemplates.join("|")} [--pm pnpm|npm|yarn|bun] [--no-install] [--dry-run] --yes [--json]`;
1086
1143
  const initCommandPrefix = "pnpm dlx vite-hub init";
1087
1144
  const initHosts = [
1088
1145
  "cloudflare",
@@ -1171,10 +1228,12 @@ function readInitArgs(args) {
1171
1228
  else if (flag === "--option") parsed.options.push(value());
1172
1229
  else if (flag === "--framework") parsed.framework = oneOf("--framework", value(), frameworks);
1173
1230
  else if (flag === "--pm") parsed.pm = oneOf("--pm", value(), packageManagers);
1231
+ else if (flag === "--template") parsed.template = oneOf("--template", value(), initTemplates);
1174
1232
  else if (arg.startsWith("-")) throw invalid$2(`Unknown argument ${JSON.stringify(arg)}.`);
1175
1233
  else if (parsed.dir === void 0) parsed.dir = arg;
1176
1234
  else throw invalid$2(`Pass one folder, not ${JSON.stringify(parsed.dir)} and ${JSON.stringify(arg)}.`);
1177
1235
  }
1236
+ if (parsed.template && (parsed.framework || parsed.host || features !== void 0 || parsed.options.length || parsed.nuxtNightly)) throw invalid$2("--template cannot be used with --framework, --host, --features, --option, or --nuxt-nightly. The template sets them.");
1178
1237
  if (features !== void 0) parsed.features = readAddArgs(features.split(",").map((item) => item.trim()).filter(Boolean)).features;
1179
1238
  if (parsed.nuxtNightly && parsed.framework === "vite") throw invalid$2("--nuxt-nightly needs --framework nuxt.");
1180
1239
  if (parsed.nuxtNightly) parsed.framework = "nuxt";
@@ -1310,6 +1369,9 @@ function lockedHost(project, env) {
1310
1369
  const status = setupStatus(project, env);
1311
1370
  if (status.features.some((feature) => feature.id !== "env" && feature.enabled !== "off")) return status.host.name;
1312
1371
  }
1372
+ function isTemplateInputs(inputs) {
1373
+ return inputs.template !== void 0;
1374
+ }
1313
1375
  function changeOf(path, before, after) {
1314
1376
  return before === void 0 ? {
1315
1377
  after,
@@ -1528,6 +1590,7 @@ async function planInit(args, root, state, context) {
1528
1590
  function setupStack(project, status) {
1529
1591
  return deriveSetupStack(project, status, async (args) => {
1530
1592
  const inputs = await readInputs(readInitArgs(args));
1593
+ if (isTemplateInputs(inputs)) return;
1531
1594
  const rootDir = dirname(project.root);
1532
1595
  await planInit(inputs, resolve(rootDir, inputs.dir), {
1533
1596
  exists: false,
@@ -1667,18 +1730,40 @@ function askFeatures(prompts, host) {
1667
1730
  }
1668
1731
  async function askInputs(args, prompts, context) {
1669
1732
  const { dir, state } = await askDir(args, prompts, context);
1733
+ if (args.template) return {
1734
+ ...args,
1735
+ dir,
1736
+ template: args.template
1737
+ };
1670
1738
  const found = state.kind === "adopt" && state.project.framework !== "none" ? state.project.framework : void 0;
1671
- const framework = args.framework ?? (found === "nuxt" || found === "vite" ? found : await prompts.select({
1739
+ const offerTemplates = state.kind === "create" && args.host === void 0 && args.features === void 0 && !args.options.length && !args.nuxtNightly;
1740
+ const start = args.framework ?? (found === "nuxt" || found === "vite" ? found : await prompts.select({
1672
1741
  initialValue: "vite",
1673
- message: "Framework",
1674
- options: [{
1675
- label: "Vite",
1676
- value: "vite"
1677
- }, {
1678
- label: "Nuxt",
1679
- value: "nuxt"
1680
- }]
1742
+ message: "Start from",
1743
+ options: [
1744
+ {
1745
+ hint: "an empty app",
1746
+ label: "Vite",
1747
+ value: "vite"
1748
+ },
1749
+ {
1750
+ hint: "an empty app",
1751
+ label: "Nuxt",
1752
+ value: "nuxt"
1753
+ },
1754
+ ...offerTemplates ? initTemplates.map((value) => ({
1755
+ hint: initTemplateInfo[value].description,
1756
+ label: `${initTemplateInfo[value].title} (Nuxt)`,
1757
+ value
1758
+ })) : []
1759
+ ]
1681
1760
  }));
1761
+ if (start !== "vite" && start !== "nuxt") return {
1762
+ ...args,
1763
+ dir,
1764
+ template: start
1765
+ };
1766
+ const framework = start;
1682
1767
  const currentHost = state.kind === "adopt" ? lockedHost(state.project, context.env) : void 0;
1683
1768
  const host = args.host ?? currentHost ?? await prompts.select({
1684
1769
  message: "Host",
@@ -1705,6 +1790,21 @@ async function readInputs(args, prompts, context = {
1705
1790
  rootDir: process.cwd()
1706
1791
  }) {
1707
1792
  if (prompts) return askInputs(args, prompts, context);
1793
+ if (args.template) {
1794
+ if (args.dir !== void 0) return {
1795
+ ...args,
1796
+ dir: args.dir,
1797
+ template: args.template
1798
+ };
1799
+ throw setupFailure(cliErrorDiagnostics.SETUP_INPUT_NEEDED({ message: `[vitehub] Pass the app folder, such as \`vitehub init my-app --template ${args.template}\`, when running without an interactive terminal.${npmCreateHint(context.env)}` }), setupExitCodes.inputNeeded, {
1800
+ missing: [{ field: "dir" }],
1801
+ rerun: templateCommand({
1802
+ ...args,
1803
+ dir: "<dir>",
1804
+ template: args.template
1805
+ })
1806
+ });
1807
+ }
1708
1808
  const missing = [];
1709
1809
  if (args.dir === void 0) missing.push({
1710
1810
  field: "dir",
@@ -1762,6 +1862,144 @@ function writeResult$1(plan, context) {
1762
1862
  context.stdout.write(`${stackLines(plan.stack).join("\n")}\n`);
1763
1863
  context.stdout.write(`\nNext steps:\n${plan.nextSteps.map((step) => `- ${step}`).join("\n")}\n`);
1764
1864
  }
1865
+ function templateCommand(args) {
1866
+ return [
1867
+ initCommandPrefix,
1868
+ shellQuote(args.dir),
1869
+ "--template",
1870
+ args.template,
1871
+ ...args.pm && args.pm !== "pnpm" ? ["--pm", args.pm] : [],
1872
+ ...args.install ? [] : ["--no-install"],
1873
+ "--yes",
1874
+ ...args.json ? ["--json"] : []
1875
+ ].join(" ");
1876
+ }
1877
+ async function checkTemplateDir(root) {
1878
+ if (!existsSync(root)) return;
1879
+ if ((await readdir(root)).filter((entry) => entry !== ".git").length) throw setupFailure(cliErrorDiagnostics.SETUP_INIT_TEMPLATE_DIR({ dir: root }), setupExitCodes.conflict);
1880
+ }
1881
+ function planTemplate(args, root, context, version) {
1882
+ const detected = detectPackageManager(root, void 0, context.env);
1883
+ const packageManager = args.pm ?? (detected.packageManagerSource === "default" ? "pnpm" : detected.packageManager);
1884
+ const source = templateSource(args.template, version);
1885
+ const [command, commandArgs] = dlx(packageManager, gigetPackage, [source, args.dir]);
1886
+ const install = `${packageManager} install`;
1887
+ return {
1888
+ download: { command: [command, ...commandArgs.map(shellQuote)].join(" ") },
1889
+ framework: "nuxt",
1890
+ install: { command: install },
1891
+ mode: "create",
1892
+ nextSteps: [
1893
+ ...root === resolve(context.rootDir) ? [] : [`cd ${shellQuote(args.dir)}`],
1894
+ ...args.install ? [] : [`Install the packages: ${install}`],
1895
+ "Read README.md for the rest of the setup, such as database migrations and the owner claim.",
1896
+ `Start the dev server: ${runScript(packageManager, "dev")}`
1897
+ ],
1898
+ packageManager,
1899
+ root,
1900
+ source,
1901
+ status: "planned",
1902
+ template: args.template
1903
+ };
1904
+ }
1905
+ async function applyTemplate(plan, version, install, context) {
1906
+ const work = await mkdtemp(join(tmpdir(), "vitehub-template-"));
1907
+ try {
1908
+ const target = join(work, "app");
1909
+ const [command, commandArgs] = dlx(plan.packageManager, gigetPackage, [plan.source, target]);
1910
+ const result = await context.spawn(command, commandArgs, {
1911
+ cwd: work,
1912
+ env: context.env,
1913
+ stdout: "stderr"
1914
+ });
1915
+ if (result.exitCode !== 0) throw setupFailure(cliErrorDiagnostics.SETUP_INIT_TEMPLATE_DOWNLOAD_FAILED({
1916
+ command: plan.download.command,
1917
+ exitCode: result.exitCode ?? result.signal
1918
+ }), setupExitCodes.error);
1919
+ if (!isCompleteTemplate(target)) throw setupFailure(cliErrorDiagnostics.SETUP_INIT_TEMPLATE_MISSING({
1920
+ source: plan.source,
1921
+ template: plan.template,
1922
+ version
1923
+ }), setupExitCodes.error);
1924
+ const manifestFile = join(target, "package.json");
1925
+ const manifest = JSON.parse(await readFile(manifestFile, "utf8"));
1926
+ if (isRecord(manifest)) {
1927
+ const updated = {
1928
+ ...manifest,
1929
+ name: packageNameOf(plan.root)
1930
+ };
1931
+ for (const field of [
1932
+ "dependencies",
1933
+ "devDependencies",
1934
+ "optionalDependencies"
1935
+ ]) {
1936
+ const dependencies = manifest[field];
1937
+ if (!isRecord(dependencies)) continue;
1938
+ updated[field] = Object.fromEntries(Object.entries(dependencies).map(([name, range]) => [name, name === "vite-hub" || name.startsWith("@vite-hub/") ? version : range]));
1939
+ }
1940
+ await writeFile(manifestFile, `${JSON.stringify(updated, null, 2)}\n`);
1941
+ }
1942
+ if (plan.packageManager === "pnpm" && !pnpmWorkspaceFile(target)) await writeFile(join(target, "pnpm-workspace.yaml"), templatePnpmWorkspace[plan.template]);
1943
+ await mkdir(plan.root, { recursive: true });
1944
+ for (const entry of await readdir(target)) await cp(join(target, entry), join(plan.root, entry), {
1945
+ errorOnExist: true,
1946
+ force: false,
1947
+ recursive: true
1948
+ });
1949
+ } finally {
1950
+ await rm(work, {
1951
+ force: true,
1952
+ recursive: true
1953
+ });
1954
+ }
1955
+ if (!install) return;
1956
+ const result = await context.spawn(plan.packageManager, ["install"], {
1957
+ cwd: plan.root,
1958
+ env: context.env,
1959
+ stdout: "stderr"
1960
+ });
1961
+ if (result.exitCode !== 0) throw setupFailure(cliErrorDiagnostics.SETUP_INSTALL_FAILED({
1962
+ command: plan.install.command,
1963
+ exitCode: result.exitCode ?? result.signal,
1964
+ filesWritten: true
1965
+ }), setupExitCodes.error);
1966
+ }
1967
+ function writeTemplatePlan(plan, install, context) {
1968
+ context.stdout.write(`Download: ${plan.download.command}\n${install ? `Install: ${plan.install.command}\n` : ""}`);
1969
+ }
1970
+ async function runTemplate(args, prompts, context) {
1971
+ const root = resolve(context.rootDir, args.dir);
1972
+ await checkTemplateDir(root);
1973
+ const version = templateVersion();
1974
+ const plan = planTemplate(args, root, context, version);
1975
+ if (args.dryRun) {
1976
+ if (args.json) writeSetupJson(context, plan);
1977
+ else writeTemplatePlan(plan, args.install, context);
1978
+ return setupExitCodes.done;
1979
+ }
1980
+ if (!args.yes) {
1981
+ if (!prompts) {
1982
+ if (!args.json) writeTemplatePlan(plan, args.install, context);
1983
+ throw setupFailure(cliErrorDiagnostics.CLI_R0004({ message: "[vitehub] `vitehub init` writes files and was not confirmed. Without a terminal, pass --yes." }), setupExitCodes.inputNeeded, {
1984
+ data: plan,
1985
+ rerun: templateCommand(args)
1986
+ });
1987
+ }
1988
+ writeTemplatePlan(plan, args.install, context);
1989
+ if (!await prompts.confirm({
1990
+ initialValue: true,
1991
+ message: "Create the app?"
1992
+ })) throw setupFailure(cliErrorDiagnostics.CLI_R0004({ message: "[vitehub] The change was not confirmed. Nothing was written." }), setupExitCodes.error);
1993
+ }
1994
+ await applyTemplate(plan, version, args.install, context);
1995
+ const applied = {
1996
+ ...plan,
1997
+ status: "applied"
1998
+ };
1999
+ if (args.json) writeSetupJson(context, applied);
2000
+ else context.stdout.write(`Created ${root} from the ${initTemplateInfo[args.template].title} template of ViteHub v${version}.\n\nNext steps:\n${applied.nextSteps.map((step) => `- ${step}`).join("\n")}\n`);
2001
+ return setupExitCodes.done;
2002
+ }
1765
2003
  /** Runs `vitehub init`. `wizard` gives the prompts for a person at a terminal; tests pass fake prompts. */
1766
2004
  async function runInit(rawArgs, context, wizard = terminalWizard) {
1767
2005
  let json = rawArgs.includes("--json");
@@ -1774,6 +2012,7 @@ async function runInit(rawArgs, context, wizard = terminalWizard) {
1774
2012
  }
1775
2013
  const prompts = parsed.json ? void 0 : await wizard();
1776
2014
  const args = await readInputs(parsed, prompts, context);
2015
+ if (isTemplateInputs(args)) return await runTemplate(args, prompts, context);
1777
2016
  const root = resolve(context.rootDir, args.dir);
1778
2017
  let planned = await planWithAnswers(args, root, await readDir(root, context.env), context, prompts, parsed.features === void 0);
1779
2018
  const plan = {
@@ -1827,7 +2066,7 @@ async function runInit(rawArgs, context, wizard = terminalWizard) {
1827
2066
  }
1828
2067
  }
1829
2068
  const initCommandDefinition = {
1830
- description: "Create a ViteHub app in a folder, or set up an existing Vite or Nuxt app, with a host and features.",
2069
+ description: "Create a ViteHub app in a folder, or set up an existing Vite or Nuxt app, with a host and features. --template starts a new app from a ViteHub template.",
1831
2070
  name: "init",
1832
2071
  run: (args, context) => runInit(args, context),
1833
2072
  usage: usage$2
@@ -1,7 +1,7 @@
1
- import { d as cliErrorDiagnostics } from "./provision-9QsGgeiq.js";
2
- import { u as selectConsole } from "./console-auth-cCodgT_T.js";
3
- import { a as table, c as __exportAll, o as writeSetupError, r as setupExitCodes, s as writeSetupJson } from "./envelope-BJQ7xPyX.js";
4
- import { c as shellQuote } from "./status-gjvZVutV.js";
1
+ import { d as cliErrorDiagnostics } from "./provision-D0ct9RDq.js";
2
+ import { u as selectConsole } from "./console-auth-BunROd7u.js";
3
+ import { a as table, c as __exportAll, o as writeSetupError, r as setupExitCodes, s as writeSetupJson } from "./envelope-DXB-0EcA.js";
4
+ import { c as shellQuote } from "./status-HXNfm9mB.js";
5
5
  import { parseArgs } from "node:util";
6
6
  // src/setup/console-apps.ts
7
7
  var console_apps_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
- import { C as invariant, d as cliErrorDiagnostics } from "./provision-9QsGgeiq.js";
2
- import { c as __exportAll, o as writeSetupError, r as setupExitCodes, s as writeSetupJson } from "./envelope-BJQ7xPyX.js";
1
+ import { C as invariant, d as cliErrorDiagnostics } from "./provision-D0ct9RDq.js";
2
+ import { c as __exportAll, o as writeSetupError, r as setupExitCodes, s as writeSetupJson } from "./envelope-DXB-0EcA.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { existsSync, realpathSync } from "node:fs";
5
5
  import process$1 from "node:process";
@@ -1,6 +1,6 @@
1
- import { d as cliErrorDiagnostics } from "./provision-9QsGgeiq.js";
2
- import { u as selectConsole } from "./console-auth-cCodgT_T.js";
3
- import { c as __exportAll, o as writeSetupError, s as writeSetupJson } from "./envelope-BJQ7xPyX.js";
1
+ import { d as cliErrorDiagnostics } from "./provision-D0ct9RDq.js";
2
+ import { u as selectConsole } from "./console-auth-BunROd7u.js";
3
+ import { c as __exportAll, o as writeSetupError, s as writeSetupJson } from "./envelope-DXB-0EcA.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";
@@ -1,11 +1,11 @@
1
- import { c as shellQuote, s as setupStatus, u as hostFromNitroPreset } from "./status-gjvZVutV.js";
2
- import { d as cliErrorDiagnostics, l as resolveHostCredentials, o as planProvisionSteps } from "./provision-9QsGgeiq.js";
3
- import { a as netlifyAdapter, c as listDenoDeployments, d as formatDeployConsole, f as linkDeployedApp, g as readBuildOutput, h as build, i as listNetlifyDeployments, l as cloudflareAdapter, m as readsConsoleKey, o as denoAdapter, p as openDeployConsole, r as hostEnvs, s as denoOrganization, t as checkDeployEnv, u as listCloudflareDeployments } from "./env-D_CN5DyX.js";
4
- import { a as provisionStateFile, c as mergeProvisionState, d as writeProvisionState, i as provisionHostEnv, l as readProvisionState, n as isProvisionHost, o as writeProvisionActions, p as callOperationFromCli, r as provisionActionStatus } from "./provision-Fiosv3Un.js";
5
- import { a as table, c as __exportAll, i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-BJQ7xPyX.js";
6
- import { a as vercelDeployLink, f as createDeployRun, i as vercelAdapter, l as abortable, n as listVercelDeployments, r as resolveVercelTarget, t as hasVercelLogin, x as readDeployCommit } from "./vercel-B5CJLsT0.js";
7
- import { a as hostRequired, f as readSetupLinks, h as writeSeparateResourcesNote, l as readLinkHostOption, n as addSetupLink, p as selectSetupLink, r as ensureViteHubGitignore } from "./link-BRNWNqT9.js";
8
- import { g as readSetupProject } from "./console-auth-cCodgT_T.js";
1
+ import { c as shellQuote, s as setupStatus, u as hostFromNitroPreset } from "./status-HXNfm9mB.js";
2
+ import { d as cliErrorDiagnostics, l as resolveHostCredentials, o as planProvisionSteps } from "./provision-D0ct9RDq.js";
3
+ import { a as netlifyAdapter, c as listDenoDeployments, d as formatDeployConsole, f as linkDeployedApp, g as readBuildOutput, h as build, i as listNetlifyDeployments, l as cloudflareAdapter, m as readsConsoleKey, o as denoAdapter, p as openDeployConsole, r as hostEnvs, s as denoOrganization, t as checkDeployEnv, u as listCloudflareDeployments } from "./env-BvSnsKMg.js";
4
+ import { a as provisionStateFile, c as mergeProvisionState, d as writeProvisionState, i as provisionHostEnv, l as readProvisionState, n as isProvisionHost, o as writeProvisionActions, p as callOperationFromCli, r as provisionActionStatus } from "./provision-DVuxa-yY.js";
5
+ import { a as table, c as __exportAll, i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-DXB-0EcA.js";
6
+ import { a as vercelDeployLink, f as createDeployRun, i as vercelAdapter, l as abortable, n as listVercelDeployments, r as resolveVercelTarget, t as hasVercelLogin, x as readDeployCommit } from "./vercel-ClYz5iI7.js";
7
+ import { a as hostRequired, f as readSetupLinks, h as writeSeparateResourcesNote, l as readLinkHostOption, n as addSetupLink, p as selectSetupLink, r as ensureViteHubGitignore } from "./link-B3NuFAyj.js";
8
+ import { g as readSetupProject } from "./console-auth-BunROd7u.js";
9
9
  import { createRequire } from "node:module";
10
10
  import { existsSync } from "node:fs";
11
11
  import process from "node:process";
@@ -1,11 +1,11 @@
1
- import { a as isProvisionRequestError, d as cliErrorDiagnostics, f as loadAllEnv, l as resolveHostCredentials, n as createCloudflareProvisionClient, p as withViteStageEnvironment, r as createNetlifyApiClient, w as isRecord } from "./provision-9QsGgeiq.js";
2
- import { c as shellQuote, d as resolveDeploymentPlan } from "./status-gjvZVutV.js";
3
- import { C as splitManifestCommand, S as redact, _ as isoTime, b as parseCommitMessage, d as commitMessage, f as createDeployRun, g as hostListFailed, h as hostCliFailed, m as hostCli, o as vercelEnv, p as findUrl, s as vercelProject, u as commandRejected, v as lastJsonObject, w as untilInterrupted, y as optionalString } from "./vercel-B5CJLsT0.js";
4
- import { c as __exportAll, i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-BJQ7xPyX.js";
5
- import { n as dotenvLine$1 } from "./console-env-eXdVI6kw.js";
6
- import { a as consoleClient, c as listConsoleApps, i as consoleAppUrl, n as checkConsoleApp, r as checkProblem, s as linkConsoleApp } from "./console-apps-BQX-Np9Q.js";
7
- import { g as readSetupProject, u as selectConsole } from "./console-auth-cCodgT_T.js";
8
- import { a as hostRequired, f as readSetupLinks, l as readLinkHostOption, p as selectSetupLink } from "./link-BRNWNqT9.js";
1
+ import { a as isProvisionRequestError, d as cliErrorDiagnostics, f as loadAllEnv, l as resolveHostCredentials, n as createCloudflareProvisionClient, p as withViteStageEnvironment, r as createNetlifyApiClient, w as isRecord } from "./provision-D0ct9RDq.js";
2
+ import { c as shellQuote, d as resolveDeploymentPlan } from "./status-HXNfm9mB.js";
3
+ import { C as splitManifestCommand, S as redact, _ as isoTime, b as parseCommitMessage, d as commitMessage, f as createDeployRun, g as hostListFailed, h as hostCliFailed, m as hostCli, o as vercelEnv, p as findUrl, s as vercelProject, u as commandRejected, v as lastJsonObject, w as untilInterrupted, y as optionalString } from "./vercel-ClYz5iI7.js";
4
+ import { c as __exportAll, i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-DXB-0EcA.js";
5
+ import { n as dotenvLine$1 } from "./console-env-BCw039oZ.js";
6
+ import { a as consoleClient, c as listConsoleApps, i as consoleAppUrl, n as checkConsoleApp, r as checkProblem, s as linkConsoleApp } from "./console-apps-Cvzc6tY4.js";
7
+ import { g as readSetupProject, u as selectConsole } from "./console-auth-BunROd7u.js";
8
+ import { a as hostRequired, f as readSetupLinks, l as readLinkHostOption, p as selectSetupLink } from "./link-B3NuFAyj.js";
9
9
  import { constants, existsSync, lstatSync, statSync } from "node:fs";
10
10
  import process from "node:process";
11
11
  import { basename, dirname, join, relative } from "pathe";
@@ -242,7 +242,6 @@ async function wranglerVarNames(outputDir) {
242
242
  const wrangler = await readWranglerConfig(outputDir, config);
243
243
  return isRecord(wrangler.vars) ? Object.keys(wrangler.vars) : [];
244
244
  }
245
- /** The Wrangler config that the `--config` flag of `commands.deploy` names. */
246
245
  async function readWranglerConfig(outputDir, config) {
247
246
  const file = join(outputDir, config);
248
247
  let value;
@@ -253,11 +252,6 @@ async function readWranglerConfig(outputDir, config) {
253
252
  }
254
253
  return isRecord(value) ? value : {};
255
254
  }
256
- /**
257
- * The D1 bindings of the Wrangler config whose `migrations_dir` holds `.sql` files, except the bindings that the deploy
258
- * command migrates. Wrangler reads `migrations_dir` relative to the config file, and its default pattern is `*.sql`
259
- * without dot files. A binding with `migrations_pattern` selects other files, and ViteHub's build never writes one.
260
- */
261
255
  async function unmigratedD1Bindings(outputDir, config, wrangler, migrated) {
262
256
  const found = [];
263
257
  for (const entry of Array.isArray(wrangler.d1_databases) ? wrangler.d1_databases : []) {
@@ -289,7 +283,6 @@ function d1BindingsWithoutId(wrangler) {
289
283
  return !id || isPlaceholderCloudflareId(id) ? [entry] : [];
290
284
  });
291
285
  }
292
- /** The `results` rows of `wrangler d1 execute --json`, which prints one `{ results, success, meta }` per statement. */
293
286
  function d1ResultNames(result) {
294
287
  let value;
295
288
  try {
@@ -1,4 +1,4 @@
1
- import { d as cliErrorDiagnostics } from "./provision-9QsGgeiq.js";
1
+ import { d as cliErrorDiagnostics } from "./provision-D0ct9RDq.js";
2
2
  import "node:module";
3
3
  import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
4
4
  // \0rolldown/runtime.js
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
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-Fiosv3Un.js";
2
- import { S as quoteSupportedInstallSpecifier, T as isRecordOrFunction, d as cliErrorDiagnostics, f as loadAllEnv, p as withViteStageEnvironment, w as isRecord } from "./provision-9QsGgeiq.js";
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";
3
3
  import { spawn } from "node:child_process";
4
4
  import { existsSync, readFileSync, statSync } from "node:fs";
5
5
  import process$1 from "node:process";
@@ -1000,7 +1000,7 @@ async function throughConsole(url, context, signal) {
1000
1000
  context.stderr.write("Warning: Console discovery failed. The CLI will call the app directly if time remains.\n");
1001
1001
  };
1002
1002
  try {
1003
- const [{ selectConsole }, { consoleClient }] = await Promise.all([import("./console-auth-cCodgT_T.js").then((n) => n.a), import("./console-apps-BQX-Np9Q.js").then((n) => n.o)]);
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)]);
1004
1004
  const { credential } = await selectConsole(context, void 0, signal);
1005
1005
  if (!credential) return;
1006
1006
  const { body } = await consoleClient(context, credential, signal).request("/api/projects");
@@ -1201,148 +1201,6 @@ function mergeOperationNamespaces(written, generated) {
1201
1201
  }
1202
1202
  return merged;
1203
1203
  }
1204
- // src/renamed-commands.ts
1205
- const renamedCommands = [
1206
- {
1207
- from: ["agents", "list"],
1208
- now: "vitehub agent list"
1209
- },
1210
- {
1211
- from: ["agents", "invoke"],
1212
- now: "vitehub agent invoke"
1213
- },
1214
- {
1215
- from: ["agents", "status"],
1216
- now: "vitehub agent get <name>",
1217
- migration: "Pass the Agent name instead of --agent and select the Console app with --url."
1218
- },
1219
- {
1220
- from: ["conversations", "export"],
1221
- now: "vitehub agent conversations export"
1222
- },
1223
- {
1224
- from: ["invocations", "list"],
1225
- now: "vitehub agent invocations list",
1226
- migration: "Check --help for supported filters; the CLI JSON no longer includes a Console cursor."
1227
- },
1228
- {
1229
- from: ["invocations", "get"],
1230
- now: "vitehub agent invocations get",
1231
- migration: "Pass the Invocation ID; JSON is a flat record, and observation paging options are no longer supported by the CLI."
1232
- },
1233
- {
1234
- from: ["invocations", "cancel"],
1235
- now: "vitehub agent invocations cancel",
1236
- migration: "Pass the Invocation ID and --url <app> to use the same Console."
1237
- },
1238
- {
1239
- from: ["invocations", "undo"],
1240
- now: "vitehub agent invocations undo",
1241
- migration: "Pass the Invocation ID, --change <id>, and --url <app>."
1242
- },
1243
- {
1244
- from: ["invocations", "delete"],
1245
- now: "vitehub agent invocations delete",
1246
- migration: "Pass the Invocation ID and --url <app> to delete from the same Console. Without --url this deletes from the journal file."
1247
- },
1248
- {
1249
- from: ["invocations", "capabilities"],
1250
- now: "vitehub agent invocations capabilities"
1251
- },
1252
- {
1253
- from: ["invocations", "workspace"],
1254
- now: "vitehub agent invocations workspace"
1255
- },
1256
- {
1257
- from: ["agent", "info"],
1258
- now: "vitehub agent get",
1259
- migration: "Pass the name instead of --agent and use --dev --url for an explicit Dev Loop URL."
1260
- },
1261
- {
1262
- from: [
1263
- "agent",
1264
- "invocations",
1265
- "show"
1266
- ],
1267
- now: "vitehub agent invocations get"
1268
- },
1269
- {
1270
- from: ["content", "show"],
1271
- now: "vitehub content get"
1272
- },
1273
- {
1274
- from: ["definitions", "list"],
1275
- now: "vitehub inspect definitions",
1276
- migration: "Use --kind <kind> for local definitions, or the Console for runtime records. The old section and URL arguments do not carry over."
1277
- },
1278
- {
1279
- from: [
1280
- "email",
1281
- "outbox",
1282
- "show"
1283
- ],
1284
- now: "vitehub email outbox get"
1285
- },
1286
- {
1287
- from: ["env", "inspect"],
1288
- now: "vitehub env list"
1289
- },
1290
- {
1291
- from: ["env", "status"],
1292
- now: "vitehub env list --url <app>",
1293
- 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."
1294
- },
1295
- {
1296
- from: ["project", "info"],
1297
- now: "vitehub project get"
1298
- },
1299
- {
1300
- from: [
1301
- "queue",
1302
- "jobs",
1303
- "show"
1304
- ],
1305
- now: "vitehub queue jobs get"
1306
- },
1307
- {
1308
- from: ["schedule", "attempts"],
1309
- now: "vitehub schedule runs get <run>"
1310
- },
1311
- {
1312
- from: ["schedule", "runs"],
1313
- next: (word) => word !== void 0 && ![
1314
- "get",
1315
- "list",
1316
- "-h",
1317
- "--help"
1318
- ].includes(word),
1319
- now: "vitehub schedule runs list <schedule>"
1320
- },
1321
- {
1322
- from: ["workflow", "get"],
1323
- now: "vitehub workflow runs get",
1324
- migration: "Add --json to keep JSON output."
1325
- },
1326
- {
1327
- from: [
1328
- "workflow",
1329
- "runs",
1330
- "show"
1331
- ],
1332
- now: "vitehub workflow runs get",
1333
- migration: "Use --run-id instead of --id, and runId instead of id in --input JSON."
1334
- },
1335
- {
1336
- from: ["workspace", "show"],
1337
- now: "vitehub workspace get"
1338
- }
1339
- ];
1340
- /** The message for an old command spelling, or undefined when `args` is a current command. */
1341
- function renamedCommandMessage(args) {
1342
- const renamed = renamedCommands.find((entry) => entry.from.every((word, index) => args[index] === word) && (entry.next?.(args[entry.from.length]) ?? true));
1343
- if (!renamed) return;
1344
- 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.`;
1345
- }
1346
1204
  // src/seed.ts
1347
1205
  const usage = "vitehub seed [<primitive>...] [--remote [--url <url>]] [--stage <name>] [--database <name>] [--timeout <ms>]";
1348
1206
  function writeUsage(seeds, stream) {
@@ -1490,7 +1348,7 @@ const hostEnvFeatures = {
1490
1348
  {
1491
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.",
1492
1350
  name: "diff",
1493
- run: async (args, context) => await (await import("./env-D_CN5DyX.js").then((n) => n.n)).runEnvCommand({
1351
+ run: async (args, context) => await (await import("./env-BvSnsKMg.js").then((n) => n.n)).runEnvCommand({
1494
1352
  ...hostEnvFeatures.features[0],
1495
1353
  name: "diff"
1496
1354
  }, args, context),
@@ -1499,7 +1357,7 @@ const hostEnvFeatures = {
1499
1357
  {
1500
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.",
1501
1359
  name: "push",
1502
- run: async (args, context) => await (await import("./env-D_CN5DyX.js").then((n) => n.n)).runEnvCommand({
1360
+ run: async (args, context) => await (await import("./env-BvSnsKMg.js").then((n) => n.n)).runEnvCommand({
1503
1361
  ...hostEnvFeatures.features[1],
1504
1362
  name: "push"
1505
1363
  }, args, context),
@@ -1508,14 +1366,14 @@ const hostEnvFeatures = {
1508
1366
  {
1509
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.",
1510
1368
  name: "pull",
1511
- run: async (args, context) => await (await import("./console-env-eXdVI6kw.js").then((n) => n.t)).envPullFeature.run(args, context),
1369
+ run: async (args, context) => await (await import("./console-env-BCw039oZ.js").then((n) => n.t)).envPullFeature.run(args, context),
1512
1370
  usage: "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]"
1513
1371
  }
1514
1372
  ],
1515
1373
  name: "env"
1516
1374
  };
1517
1375
  async function loadSetupCommands() {
1518
- return (await import("./commands-w7tEEJph.js").then((n) => n.t)).setupCommands;
1376
+ return (await import("./commands-CzNBAR-E.js").then((n) => n.t)).setupCommands;
1519
1377
  }
1520
1378
  async function loadNuxtViteConfig(rootDir, command, mode) {
1521
1379
  if (![
@@ -1761,11 +1619,6 @@ async function runViteHubCli(options = {}) {
1761
1619
  const cwd = options.cwd || process$1.cwd();
1762
1620
  const env = options.env || process$1.env;
1763
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) };
1764
- const renamed = renamedCommandMessage(args);
1765
- if (renamed) {
1766
- stderr.write(`${renamed}\n`);
1767
- return 1;
1768
- }
1769
1622
  const spawn = options.spawn || defaultSpawn;
1770
1623
  const stage = args[0] === "channels" && (args[1] === "sync" || args[1] === "history") || args[0] === "seed" ? readStageArg(args) : void 0;
1771
1624
  const loadProject = (command, recordHelpInputs = false) => withStdoutOnStderr(async () => {
@@ -1,7 +1,7 @@
1
- import { f as createDeployRun, h as hostCliFailed, l as abortable, m as hostCli, t as hasVercelLogin } from "./vercel-B5CJLsT0.js";
2
- import { s as setupStatus, u as hostFromNitroPreset } from "./status-gjvZVutV.js";
3
- import { a as isProvisionRequestError, d as cliErrorDiagnostics, i as createVercelProvisionClient, l as resolveHostCredentials, n as createCloudflareProvisionClient, r as createNetlifyApiClient, t as createCloudflareApiClient, u as runHostCli, w as isRecord } from "./provision-9QsGgeiq.js";
4
- import { c as __exportAll, i as setupFailure, r as setupExitCodes } from "./envelope-BJQ7xPyX.js";
1
+ import { f as createDeployRun, h as hostCliFailed, l as abortable, m as hostCli, t as hasVercelLogin } from "./vercel-ClYz5iI7.js";
2
+ import { s as setupStatus, u as hostFromNitroPreset } from "./status-HXNfm9mB.js";
3
+ import { a as isProvisionRequestError, d as cliErrorDiagnostics, i as createVercelProvisionClient, l as resolveHostCredentials, n as createCloudflareProvisionClient, r as createNetlifyApiClient, t as createCloudflareApiClient, u as runHostCli, w as isRecord } from "./provision-D0ct9RDq.js";
4
+ import { c as __exportAll, i as setupFailure, r as setupExitCodes } from "./envelope-DXB-0EcA.js";
5
5
  import { existsSync } from "node:fs";
6
6
  import { dirname, join } from "pathe";
7
7
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
@@ -398,14 +398,9 @@ const sourceExtensions = [
398
398
  "cts",
399
399
  "cjs"
400
400
  ];
401
- /** `<base>.<ext>` for each source extension. */
402
401
  function sourceFiles(base) {
403
402
  return sourceExtensions.map((extension) => `${base}.${extension}`);
404
403
  }
405
- /**
406
- * A starter for Definitions in `dir`, one `<name>.ts` file each. With `suffix`, the owner also discovers the Vite
407
- * form `src/<name>.<suffix>.ts`, and a Definition folder `<dir>/<name>/` when `folder` names its entry file.
408
- */
409
404
  function starter(dir, template, options = {}) {
410
405
  return {
411
406
  conflicts: (name) => [
@@ -884,10 +879,6 @@ const sandboxDriverPackages = {
884
879
  cloudflare: "@cloudflare/sandbox",
885
880
  vercel: "@vercel/sandbox"
886
881
  };
887
- /**
888
- * The SDKs of the Vercel provider. Native Vercel Workflows also need `workflow` and `@workflow/builders`, but only
889
- * `@vite-hub/workflow` knows when a Workflow is native, so it checks those two itself.
890
- */
891
882
  const vercelProviderPackages = {
892
883
  queue: ["@vercel/queue", "@vercel/functions"],
893
884
  workflow: ["@vercel/functions"]
@@ -1107,6 +1098,18 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1107
1098
  fix: "Delete or move the files in `references`, then run the command again. Pass --force to turn the feature off and keep the files.",
1108
1099
  why: ({ features, references }) => `The app still uses ${String(features)}:\n${String(references)}`
1109
1100
  },
1101
+ SETUP_INIT_TEMPLATE_DIR: {
1102
+ fix: "Choose a new or empty folder for the template. To add ViteHub to the app that is there, run `vitehub init` without --template.",
1103
+ why: ({ dir }) => `${String(dir)} is not empty. A template starts a new app, and ViteHub never overwrites a file.`
1104
+ },
1105
+ SETUP_INIT_TEMPLATE_DOWNLOAD_FAILED: {
1106
+ fix: "Check the network connection, then run the command again. Nothing was written.",
1107
+ why: ({ command, exitCode }) => `The template download \`${String(command)}\` exited with code ${String(exitCode)}.`
1108
+ },
1109
+ SETUP_INIT_TEMPLATE_MISSING: {
1110
+ fix: ({ source }) => `Update the CLI with \`pnpm create vitehub@latest\` and run the command again. To download the newest template without the CLI, run \`pnpm dlx giget@latest ${String(source).replace(/#.*$/u, "")}\`. Nothing was written.`,
1111
+ why: ({ template, version }) => `The ${String(template)} template is not in ViteHub v${String(version)}. Release v${String(version)} has no complete template with that name.`
1112
+ },
1110
1113
  SETUP_UNINSTALL_FAILED: {
1111
1114
  fix: ({ configWritten }) => `Run the uninstall command by hand to see the error. ${configWritten === false ? "ViteHub kept the config unchanged; starter files may already be deleted. Plan the removal again after fixing the uninstall." : "ViteHub already changed the config and deleted the starter files."}`,
1112
1115
  why: ({ command, exitCode }) => `\`${String(command)}\` exited with code ${String(exitCode)}.`
@@ -1455,7 +1458,6 @@ async function runJson(context, command, args) {
1455
1458
  return;
1456
1459
  }
1457
1460
  }
1458
- /** Resolve a project dependency before changing cwd, as package-manager invocations do. */
1459
1461
  function localWrangler(cwd) {
1460
1462
  if (!cwd) return;
1461
1463
  const require = createRequire(join(resolve(cwd), "package.json"));
@@ -1,4 +1,4 @@
1
- import { E as internalErrorDiagnostics, T as isRecordOrFunction, c as resolveVercelProvisionConfig, l as resolveHostCredentials, o as planProvisionSteps, s as resolveCloudflareProvisionConfig, w as isRecord } from "./provision-9QsGgeiq.js";
1
+ import { E as internalErrorDiagnostics, T as isRecordOrFunction, c as resolveVercelProvisionConfig, l as resolveHostCredentials, o as planProvisionSteps, s as resolveCloudflareProvisionConfig, w as isRecord } from "./provision-D0ct9RDq.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { existsSync, readFileSync, statSync } from "node:fs";
4
4
  import { pathToFileURL } from "node:url";
@@ -223,7 +223,7 @@ function findViteHubDevServerUrl(roots, env) {
223
223
  }
224
224
  return env["VITEHUB_DEV_SERVER_URL"] || void 0;
225
225
  }
226
- // ../internal/dist/vite-DyksG6Kl.js
226
+ // ../internal/dist/vite-C-_n6FDw.js
227
227
  const projectRootDirectoryMarkers = [
228
228
  ["server", "agents"],
229
229
  ["server", "channels"],
@@ -412,7 +412,6 @@ function base64url(bytes) {
412
412
  for (const byte of bytes) binary += String.fromCharCode(byte);
413
413
  return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
414
414
  }
415
- /** The bytes of a base64url value, or `undefined` when it is not canonical base64url without padding. */
416
415
  function fromBase64url(value) {
417
416
  if (!/^[\w-]*$/.test(value) || value.length % 4 === 1) return void 0;
418
417
  const bytes = Uint8Array.from(atob(value.replace(/-/g, "+").replace(/_/g, "/")), (character) => character.charCodeAt(0));
@@ -439,7 +438,6 @@ function consoleSignedText(fields) {
439
438
  fields.caller
440
439
  ].join("\n");
441
440
  }
442
- /** The path and query of a URL, the part of the request target that the signature covers. */
443
441
  function requestTarget(url) {
444
442
  return `${url.pathname}${url.search}`;
445
443
  }
@@ -1126,7 +1124,7 @@ async function resolveHost(command, parsed, context) {
1126
1124
  let host = parsed.host;
1127
1125
  let link;
1128
1126
  if (host === void 0) {
1129
- const { resolveDefaultDeployTarget } = await import("./deploy-CqR6pJa-.js").then((n) => n.n);
1127
+ const { resolveDefaultDeployTarget } = await import("./deploy-DxOKht-B.js").then((n) => n.n);
1130
1128
  try {
1131
1129
  const target = await resolveDefaultDeployTarget(resolveViteHubProjectRoot(context.rootDir), context.env, `vitehub provision ${command}`);
1132
1130
  host = target.host;
@@ -1145,7 +1143,7 @@ async function resolveHost(command, parsed, context) {
1145
1143
  writeUsage(command, context.stderr);
1146
1144
  return { exitCode: 1 };
1147
1145
  }
1148
- if (parsed.host === "vercel") link = (await (await import("./link-BRNWNqT9.js").then((n) => n.c)).readSetupLinks(context.rootDir)).targets.find((target) => target.host === "vercel");
1146
+ if (parsed.host === "vercel") link = (await (await import("./link-B3NuFAyj.js").then((n) => n.c)).readSetupLinks(context.rootDir)).targets.find((target) => target.host === "vercel");
1149
1147
  return {
1150
1148
  host,
1151
1149
  ...link ? { link } : {}
@@ -1160,7 +1158,7 @@ async function withHostCredentials(host, context, projectRoot, link) {
1160
1158
  env: context.env,
1161
1159
  ...context.runHostCli ? { run: context.runHostCli } : {}
1162
1160
  });
1163
- const target = host === "vercel" ? await (await import("./vercel-B5CJLsT0.js").then((n) => n.c)).resolveVercelTarget(projectRoot, context.env, link) : link;
1161
+ const target = host === "vercel" ? await (await import("./vercel-ClYz5iI7.js").then((n) => n.c)).resolveVercelTarget(projectRoot, context.env, link) : link;
1164
1162
  return {
1165
1163
  ...context,
1166
1164
  env: provisionHostEnv(context.env, credentials, target)
@@ -705,6 +705,9 @@ export declare function readSetupLive(root: string, link: SetupLink | undefined,
705
705
  offline: boolean;
706
706
  signal?: AbortSignal;
707
707
  }): Promise<SetupLiveStatus>;
708
+ /** The templates in `templates/nuxt/` that `vitehub init --template` starts from. */
709
+ declare const initTemplates: readonly ["dashboard", "agent", "jobs"];
710
+ type InitTemplate = typeof initTemplates[number];
708
711
  interface SetupStack {
709
712
  command: string | null;
710
713
  omits: readonly {
@@ -734,6 +737,8 @@ interface SetupInitArgs {
734
737
  /** Raw `--option` values, such as `email.driver=resend`. */
735
738
  options: string[];
736
739
  framework?: InitFramework;
740
+ /** Start from a ViteHub template instead of an empty app. It sets the framework, the host config, and the features. */
741
+ template?: InitTemplate;
737
742
  /** A new Nuxt app gets the Nuxt 5 nightly instead of Nuxt 4.7. An existing app keeps its Nuxt version. */
738
743
  nuxtNightly: boolean;
739
744
  pm?: SetupPackageManager;
@@ -1,10 +1,10 @@
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-w7tEEJph.js";
2
- import { c as logoutCommand, d as whoamiCommand, g as readSetupProject, i as consoleUrlVariable, l as readConsoleCredential, n as consoleOrigin, o as defaultConsoleUrl, r as consoleTokenVariable, s as loginCommand, t as consoleCredentialsFile } from "../console-auth-cCodgT_T.js";
3
- import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, r as readDeployArgs, s as readSetupLive, t as deployCommand } from "../deploy-CqR6pJa-.js";
4
- import { i as setupFailure, o as writeSetupError, r as setupExitCodes } from "../envelope-BJQ7xPyX.js";
5
- import { d as readSetupLinkStatus, f as readSetupLinks, m as unlinkSetupProject, p as selectSetupLink, s as linkSetupProject, t as SETUP_LINK_FILE, u as readSetupLinkState } from "../link-BRNWNqT9.js";
6
- import { c as shellQuote, s as setupStatus } from "../status-gjvZVutV.js";
7
- import { d as cliErrorDiagnostics, w as isRecord } from "../provision-9QsGgeiq.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-CzNBAR-E.js";
2
+ import { c as logoutCommand, d as whoamiCommand, g as readSetupProject, i as consoleUrlVariable, l as readConsoleCredential, n as consoleOrigin, o as defaultConsoleUrl, r as consoleTokenVariable, s as loginCommand, t as consoleCredentialsFile } from "../console-auth-BunROd7u.js";
3
+ import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, r as readDeployArgs, s as readSetupLive, t as deployCommand } from "../deploy-DxOKht-B.js";
4
+ import { i as setupFailure, o as writeSetupError, r as setupExitCodes } from "../envelope-DXB-0EcA.js";
5
+ import { d as readSetupLinkStatus, f as readSetupLinks, m as unlinkSetupProject, p as selectSetupLink, s as linkSetupProject, t as SETUP_LINK_FILE, u as readSetupLinkState } from "../link-B3NuFAyj.js";
6
+ import { c as shellQuote, s as setupStatus } from "../status-HXNfm9mB.js";
7
+ import { d as cliErrorDiagnostics, w as isRecord } from "../provision-D0ct9RDq.js";
8
8
  import { join } from "pathe";
9
9
  import { readFile } from "node:fs/promises";
10
10
  import { createHash, randomUUID } from "node:crypto";
@@ -1,4 +1,4 @@
1
- import { E as internalErrorDiagnostics, _ as featureSupport, b as impliedFeatures, g as featurePackages, h as featureIds, v as features, w as isRecord, x as installSpecifier, y as formatInstallArgument } from "./provision-9QsGgeiq.js";
1
+ import { E as internalErrorDiagnostics, _ as featureSupport, b as impliedFeatures, g as featurePackages, h as featureIds, v as features, w as isRecord, x as installSpecifier, y as formatInstallArgument } from "./provision-D0ct9RDq.js";
2
2
  import { existsSync, readdirSync, statSync } from "node:fs";
3
3
  import { join, relative, resolve } from "pathe";
4
4
  import "node:fs/promises";
@@ -1,5 +1,5 @@
1
- import { d as cliErrorDiagnostics, i as createVercelProvisionClient, w as isRecord } from "./provision-9QsGgeiq.js";
2
- import { c as __exportAll, i as setupFailure, r as setupExitCodes } from "./envelope-BJQ7xPyX.js";
1
+ import { d as cliErrorDiagnostics, i as createVercelProvisionClient, w as isRecord } from "./provision-D0ct9RDq.js";
2
+ import { c as __exportAll, i as setupFailure, r as setupExitCodes } from "./envelope-DXB-0EcA.js";
3
3
  import { spawn } from "node:child_process";
4
4
  import { existsSync, readFileSync } from "node:fs";
5
5
  import process from "node:process";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/cli",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Command-line workflows for ViteHub projects.",
5
5
  "keywords": [
6
6
  "agent",
@@ -46,7 +46,7 @@
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.8.0",
49
+ "@vite-hub/runtime": "0.9.0",
50
50
  "birpc": "^4.2.0",
51
51
  "diff": "^9.0.0",
52
52
  "nostics": "1.4.0",
@@ -59,7 +59,7 @@
59
59
  "@clack/prompts": "^1.9.0",
60
60
  "@types/node": "^24.19.2",
61
61
  "@types/semver": "^7.8.0",
62
- "@vite-hub/forge": "0.8.0",
62
+ "@vite-hub/forge": "0.9.0",
63
63
  "@vite-hub/internal": "0.0.1",
64
64
  "nuxt": "npm:nuxt-nightly@5.0.0-2611222336-0ed8910",
65
65
  "typescript": "^6.0.3",
@@ -69,7 +69,7 @@
69
69
  "vitest": "5.1.0"
70
70
  },
71
71
  "peerDependencies": {
72
- "@vite-hub/forge": "0.8.0",
72
+ "@vite-hub/forge": "0.9.0",
73
73
  "nuxt": "^4.7.0 || >=5.0.0-0",
74
74
  "vite": ">=8.0.0"
75
75
  },