@vite-hub/cli 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{commands-W0ijB5R6.js → commands-D0WSlS7h.js} +41 -36
- package/dist/{console-env--3nqqpCV.js → console-env-CYHb4owT.js} +2 -5
- package/dist/{deploy-CHW75le_.js → deploy-DwNjKrHq.js} +98 -27
- package/dist/{env-MtXhP7A7.js → env-BiVwma4a.js} +1075 -834
- package/dist/index.d.ts +2 -3
- package/dist/index.js +64 -28
- package/dist/{provision-DgT_lpyn.js → provision-akHsvf-B.js} +1344 -250
- package/dist/{provision-bhi-xnCG.d.ts → provision-kiD8Emd7.d.ts} +0 -8
- package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
- package/dist/setup/index.d.ts +28 -57
- package/dist/setup/index.js +5 -8
- package/package.json +12 -12
- package/dist/console-auth-Dz9HHP2G.js +0 -312
- package/dist/envelope-C7e408hm.js +0 -88
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import {
|
|
3
|
-
import { B as
|
|
4
|
-
import { a as
|
|
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 { C as installArgs, D as shellQuote, E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, K as table, M as listMatchingFiles, O as uninstallArgs, R as loginCommand, S as formatInstallCommand, St as installSpecifier, T as missingProviderOption, U as readSetupArgs, V as whoamiCommand, W as setupExitCodes, Y as cliErrorDiagnostics, _t as featureIds, bt as features, gt as featureHosts, j as hasDefinitionFiles, m as appsCommand, q as writeSetupError, vt as featurePackages, w as installCommand, xt as impliedFeatures, yt as featureSupport, z as logoutCommand } from "./provision-akHsvf-B.js";
|
|
3
|
+
import { B as insertViteHubConfig, I as detectPackageManager, L as readSetupProject, R as setupLockfiles, V as locateViteHubConfig, d as readSetupLinkState, h as unlinkSetupProject, i as SETUP_LINK_FILE, l as linkSetupProject, s as gitignoreWithViteHub, u as readLinkHostOption, z as editViteHubConfig } from "./env-BiVwma4a.js";
|
|
4
|
+
import { a as deploymentsCommand, i as STATUS_HOST_TIMEOUT_MS, o as liveLabel, s as readSetupLive, t as deployCommand } from "./deploy-DwNjKrHq.js";
|
|
7
5
|
import { createRequire } from "node:module";
|
|
8
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
7
|
import process from "node:process";
|
|
@@ -12,10 +10,10 @@ 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
|
|
18
|
-
|
|
14
|
+
import { createTwoFilesPatch } from "diff";
|
|
15
|
+
import semver, { Range, minVersion, satisfies, subset, validRange } from "semver";
|
|
16
|
+
// ../internal/dist/feature-inputs.js
|
|
19
17
|
function isLocaleTag(value) {
|
|
20
18
|
try {
|
|
21
19
|
return Intl.getCanonicalLocales(value).length === 1;
|
|
@@ -35,8 +33,7 @@ function i18nLocaleListProblem(locales) {
|
|
|
35
33
|
function mcpPublicRouteNeedsSignedAuth(publicRoute, auth) {
|
|
36
34
|
return !!publicRoute && auth !== true;
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
//#region src/setup/add.ts
|
|
36
|
+
// src/setup/add.ts
|
|
40
37
|
const usage$3 = "vitehub add <feature...> [--name <definition>] [--option <key=value>]... [--dry-run] [--yes] [--no-install] [--json]";
|
|
41
38
|
const optionChoices = {
|
|
42
39
|
"cache.driver": {
|
|
@@ -689,8 +686,7 @@ const addCommand = {
|
|
|
689
686
|
run: runAdd,
|
|
690
687
|
usage: usage$3
|
|
691
688
|
};
|
|
692
|
-
|
|
693
|
-
//#region src/setup/catalog.ts
|
|
689
|
+
// src/setup/catalog.ts
|
|
694
690
|
/** Every feature of `vitehub({...})` and how each host supports it. Needs no project. */
|
|
695
691
|
function setupCatalog() {
|
|
696
692
|
return {
|
|
@@ -699,8 +695,7 @@ function setupCatalog() {
|
|
|
699
695
|
schemaVersion: 1
|
|
700
696
|
};
|
|
701
697
|
}
|
|
702
|
-
|
|
703
|
-
//#region src/setup/stack.ts
|
|
698
|
+
// src/setup/stack.ts
|
|
704
699
|
function replayOption(id, keys, value) {
|
|
705
700
|
if (keys.some((key) => !key || /[.=\0]/u.test(key) || [
|
|
706
701
|
"__proto__",
|
|
@@ -857,8 +852,7 @@ async function deriveSetupStack(project, status, validate) {
|
|
|
857
852
|
omits
|
|
858
853
|
};
|
|
859
854
|
}
|
|
860
|
-
|
|
861
|
-
//#region src/setup/init.ts
|
|
855
|
+
// src/setup/init.ts
|
|
862
856
|
const usage$2 = "vitehub init <dir> --host <host> --features <id,id,...> [--option <feature.key=value>]... [--framework vite|nuxt] [--pm pnpm|npm|yarn|bun] [--no-install] [--dry-run] --yes [--json]";
|
|
863
857
|
const initCommandPrefix = "pnpm dlx vite-hub init";
|
|
864
858
|
const initHosts = [
|
|
@@ -877,8 +871,8 @@ const packageManagers = [
|
|
|
877
871
|
];
|
|
878
872
|
/**
|
|
879
873
|
* 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
|
|
881
|
-
* bodies in the docs' route examples.
|
|
874
|
+
* server integration of ViteHub. Nuxt 5 supplies Nitro 3, and a Nuxt 4.7 app also gets `nuxtNitroPackage`. The
|
|
875
|
+
* tutorials import H3 2. Valibot validates request bodies in the docs' route examples.
|
|
882
876
|
*/
|
|
883
877
|
const initPackages = {
|
|
884
878
|
nuxt: {
|
|
@@ -903,6 +897,8 @@ const initPackages = {
|
|
|
903
897
|
]
|
|
904
898
|
}
|
|
905
899
|
};
|
|
900
|
+
const nuxtNitroRange = "^3.0.261103-rc";
|
|
901
|
+
const nuxtNitroPackage = `nitro@${nuxtNitroRange}`;
|
|
906
902
|
/** The pinned Nuxt CLI that creates a new Nuxt app. */
|
|
907
903
|
const nuxiPackage = "nuxi@3.37.0";
|
|
908
904
|
const nuxtTemplate = "gh:nuxt/starter#db01806fcb37f2e369fb09443c72cac696b31548";
|
|
@@ -1137,7 +1133,7 @@ async function planInit(args, root, state, context) {
|
|
|
1137
1133
|
found,
|
|
1138
1134
|
framework
|
|
1139
1135
|
}), setupExitCodes.conflict);
|
|
1140
|
-
|
|
1136
|
+
const nuxtNeedsNitro = state.kind === "adopt" && framework === "nuxt" && (await checkNuxtVersion(root)).needsNitro;
|
|
1141
1137
|
const detected = state.kind === "adopt" ? state.project : detectPackageManager(root, void 0, context.env);
|
|
1142
1138
|
const packageManager = args.pm ?? (detected.packageManagerSource === "default" ? "pnpm" : detected.packageManager);
|
|
1143
1139
|
const base = /* @__PURE__ */ new Map();
|
|
@@ -1165,6 +1161,7 @@ async function planInit(args, root, state, context) {
|
|
|
1165
1161
|
dev: basePackages.dev.filter((spec) => !declared(packageName$1(spec), true)),
|
|
1166
1162
|
prod: basePackages.prod.filter((spec) => !declared(packageName$1(spec), false))
|
|
1167
1163
|
};
|
|
1164
|
+
if (nuxtNeedsNitro) install.prod.push(nuxtNitroPackage);
|
|
1168
1165
|
const willInstall = new Set([...install.prod, ...install.dev].map(packageName$1));
|
|
1169
1166
|
const configSource = base.get(configFile).after;
|
|
1170
1167
|
const planned = {
|
|
@@ -1333,23 +1330,34 @@ async function scaffoldNuxt(planned, context) {
|
|
|
1333
1330
|
exitCode: result.exitCode ?? result.signal,
|
|
1334
1331
|
filesWritten: "possible"
|
|
1335
1332
|
}), setupExitCodes.error);
|
|
1336
|
-
await
|
|
1333
|
+
await checkNuxtVersion(planned.plan.root, true);
|
|
1337
1334
|
}
|
|
1338
|
-
function
|
|
1339
|
-
if (typeof nuxt !== "string") return
|
|
1335
|
+
function nuxtReleases(nuxt) {
|
|
1336
|
+
if (typeof nuxt !== "string") return void 0;
|
|
1340
1337
|
const range = validRange(nuxt.replace(/^npm:nuxt(?:-nightly)?@/u, ""));
|
|
1341
|
-
if (!range || !minVersion(range)) return
|
|
1342
|
-
|
|
1343
|
-
return subset(releases, ">=5.0.0 <6.0.0");
|
|
1338
|
+
if (!range || !minVersion(range)) return void 0;
|
|
1339
|
+
return new Range(range).set.map((comparators) => comparators.map(({ operator, semver, value }) => typeof semver !== "symbol" && semver.major === 5 && semver.prerelease.length > 0 ? `${operator}5.${semver.minor}.${semver.patch}` : value).join(" ")).join(" || ");
|
|
1344
1340
|
}
|
|
1345
|
-
async function
|
|
1341
|
+
async function checkNuxtVersion(root, scaffolded = false) {
|
|
1346
1342
|
const manifest = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
1347
1343
|
const dependencies = isRecord(manifest) && isRecord(manifest.dependencies) ? manifest.dependencies : {};
|
|
1348
1344
|
const devDependencies = isRecord(manifest) && isRecord(manifest.devDependencies) ? manifest.devDependencies : {};
|
|
1349
|
-
|
|
1345
|
+
const releases = nuxtReleases(dependencies.nuxt ?? devDependencies.nuxt);
|
|
1346
|
+
if (!releases || !subset(releases, ">=4.7.0 <6.0.0")) throw setupFailure(cliErrorDiagnostics.SETUP_INIT_NUXT_VERSION({
|
|
1350
1347
|
dir: root,
|
|
1351
1348
|
scaffolded
|
|
1352
1349
|
}), setupExitCodes.conflict);
|
|
1350
|
+
if (subset(releases, ">=5.0.0 <6.0.0")) return { needsNitro: false };
|
|
1351
|
+
const nitroDeclarations = [dependencies.nitro, devDependencies.nitro].filter((spec) => spec !== void 0);
|
|
1352
|
+
for (const spec of nitroDeclarations) {
|
|
1353
|
+
const range = typeof spec === "string" ? validRange(spec.replace(/^npm:nitro@/u, "")) : null;
|
|
1354
|
+
if (!range || !minVersion(range) || !range.split("||").every((branch) => satisfies(branch, nuxtNitroRange) || subset(branch, nuxtNitroRange))) throw setupFailure(cliErrorDiagnostics.SETUP_INIT_NITRO_VERSION({
|
|
1355
|
+
dir: root,
|
|
1356
|
+
range: nuxtNitroRange,
|
|
1357
|
+
scaffolded
|
|
1358
|
+
}), setupExitCodes.conflict);
|
|
1359
|
+
}
|
|
1360
|
+
return { needsNitro: nitroDeclarations.length === 0 };
|
|
1353
1361
|
}
|
|
1354
1362
|
function interactive(args) {
|
|
1355
1363
|
return !args.json && !!process.stdin.isTTY && !!process.stderr.isTTY;
|
|
@@ -1495,8 +1503,7 @@ const initCommandDefinition = {
|
|
|
1495
1503
|
run: runInit,
|
|
1496
1504
|
usage: usage$2
|
|
1497
1505
|
};
|
|
1498
|
-
|
|
1499
|
-
//#region src/setup/remove.ts
|
|
1506
|
+
// src/setup/remove.ts
|
|
1500
1507
|
const usage$1 = "vitehub remove <feature...> [--dry-run] [--yes] [--keep-files] [--force] [--no-uninstall] [--json]";
|
|
1501
1508
|
function invalid$1(message) {
|
|
1502
1509
|
return cliErrorDiagnostics.CLI_R0003({ message: `[vitehub] ${message} Usage: ${usage$1}` });
|
|
@@ -1913,8 +1920,7 @@ const removeCommand = {
|
|
|
1913
1920
|
run: runRemove,
|
|
1914
1921
|
usage: usage$1
|
|
1915
1922
|
};
|
|
1916
|
-
|
|
1917
|
-
//#region src/setup/update.ts
|
|
1923
|
+
// src/setup/update.ts
|
|
1918
1924
|
const usage = "vitehub update [--preview <commit>] [--dry-run] [--no-install] [--json]";
|
|
1919
1925
|
const previewBase = "https://pkg.pr.new/vite-hub/vitehub";
|
|
1920
1926
|
const defaultRegistry = "https://registry.npmjs.org/";
|
|
@@ -2349,8 +2355,7 @@ const updateCommand = {
|
|
|
2349
2355
|
run: runUpdate,
|
|
2350
2356
|
usage
|
|
2351
2357
|
};
|
|
2352
|
-
|
|
2353
|
-
//#region src/setup/commands.ts
|
|
2358
|
+
// src/setup/commands.ts
|
|
2354
2359
|
var commands_exports = /* @__PURE__ */ __exportAll({ setupCommands: () => setupCommands });
|
|
2355
2360
|
function supportLabel(support) {
|
|
2356
2361
|
if (support.level === "unknown") return "unknown";
|
|
@@ -2621,7 +2626,7 @@ const setupCommands = [
|
|
|
2621
2626
|
deploymentsCommand,
|
|
2622
2627
|
loginCommand,
|
|
2623
2628
|
logoutCommand,
|
|
2624
|
-
whoamiCommand
|
|
2629
|
+
whoamiCommand,
|
|
2630
|
+
appsCommand
|
|
2625
2631
|
];
|
|
2626
|
-
//#endregion
|
|
2627
2632
|
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,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
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 { B as readConsoleCredential, J as writeSetupJson, P as consoleOrigin, Y as cliErrorDiagnostics, q as writeSetupError } from "./provision-akHsvf-B.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";
|
|
7
5
|
import { parseArgs } from "node:util";
|
|
8
|
-
|
|
6
|
+
// src/setup/console-env.ts
|
|
9
7
|
const pullUsage = "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]";
|
|
10
8
|
const stagePattern = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
11
9
|
/** One line of a `.env` file. A value that a parser could read in two ways goes in quotes. */
|
|
@@ -189,5 +187,4 @@ const envPullFeature = {
|
|
|
189
187
|
}
|
|
190
188
|
}
|
|
191
189
|
};
|
|
192
|
-
//#endregion
|
|
193
190
|
export { envPullFeature };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import {
|
|
3
|
-
import { A as
|
|
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 { E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, K as table, Q as readProvisionState, W as setupExitCodes, X as PROVISION_STATE_FILE, Y as cliErrorDiagnostics, Z as mergeProvisionState, a as writeProvisionActions, d as planProvisionSteps, et as writeProvisionState, f as resolveHostCredentials, i as provisionEnv, it as callOperationFromCli, k as hostFromNitroPreset, n as isProvisionHost, q as writeSetupError, r as provisionActionStatus } from "./provision-akHsvf-B.js";
|
|
3
|
+
import { A as openDeployConsole, C as denoAdapter, D as listCloudflareDeployments, E as cloudflareAdapter, F as readDeployCommit, L as readSetupProject, M as build, N as readBuildOutput, O as formatDeployConsole, P as createDeployRun, S as abortable, T as listDenoDeployments, _ as hasVercelLogin, a as addSetupLink, b as listNetlifyDeployments, c as hostRequired, g as writeSeparateResourcesNote, j as readsConsoleKey, k as linkDeployedApp, m as selectSetupLink, o as ensureViteHubGitignore, p as readSetupLinks, r as hostEnvs, t as checkDeployEnv, u as readLinkHostOption, v as listVercelDeployments, w as denoOrganization, x as netlifyAdapter, y as vercelAdapter } from "./env-BiVwma4a.js";
|
|
5
4
|
import { createRequire } from "node:module";
|
|
6
5
|
import { existsSync } from "node:fs";
|
|
7
6
|
import process from "node:process";
|
|
@@ -10,7 +9,7 @@ import { readFile } from "node:fs/promises";
|
|
|
10
9
|
import { createInterface } from "node:readline/promises";
|
|
11
10
|
import { pathToFileURL } from "node:url";
|
|
12
11
|
import { parseArgs } from "node:util";
|
|
13
|
-
|
|
12
|
+
// src/setup/deploy/after.ts
|
|
14
13
|
/** Waits between the attempts of one path: a new version can take a few seconds to reach every edge location. */
|
|
15
14
|
const checkRetryDelaysMs = [
|
|
16
15
|
1e3,
|
|
@@ -192,8 +191,7 @@ async function submitIndexNow(indexNow, fetchImpl) {
|
|
|
192
191
|
submitted: urlList.length
|
|
193
192
|
};
|
|
194
193
|
}
|
|
195
|
-
|
|
196
|
-
//#region src/setup/deploy/checkouts.ts
|
|
194
|
+
// src/setup/deploy/checkouts.ts
|
|
197
195
|
const lockFile = "vitehub.lock";
|
|
198
196
|
function isCheckoutModule(value) {
|
|
199
197
|
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 +343,7 @@ function formatDeployCheckouts(pushed) {
|
|
|
345
343
|
if (!pushed.changed.length) return text;
|
|
346
344
|
return `${text}The push changed these files. Commit them:\n${pushed.changed.map((path) => ` ${path}`).join("\n")}\n`;
|
|
347
345
|
}
|
|
348
|
-
|
|
349
|
-
//#region src/setup/deployments.ts
|
|
346
|
+
// src/setup/deployments.ts
|
|
350
347
|
const usage$1 = "vitehub deployments [--host <host>] [--limit <n>] [--json]";
|
|
351
348
|
const listers = {
|
|
352
349
|
cloudflare: listCloudflareDeployments,
|
|
@@ -627,8 +624,7 @@ function liveLabel(status) {
|
|
|
627
624
|
if (live.commit?.dirty) notes.push("with uncommitted changes");
|
|
628
625
|
return `${name} (${notes.join(", ")})${live.url ? ` ${live.url}` : ""}`;
|
|
629
626
|
}
|
|
630
|
-
|
|
631
|
-
//#region src/setup/deploy/provision.ts
|
|
627
|
+
// src/setup/deploy/provision.ts
|
|
632
628
|
function declaresResources(step, env) {
|
|
633
629
|
const described = step.recordedState?.({ env });
|
|
634
630
|
return described === void 0 || described.some((category) => category.declared.length > 0);
|
|
@@ -718,13 +714,8 @@ async function provisionForDeploy(input, context) {
|
|
|
718
714
|
ids: state[host] ?? {}
|
|
719
715
|
};
|
|
720
716
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
var deploy_exports = /* @__PURE__ */ __exportAll({
|
|
724
|
-
deployCommand: () => deployCommand,
|
|
725
|
-
readDeployArgs: () => readDeployArgs,
|
|
726
|
-
resolveDefaultDeployTarget: () => resolveDefaultDeployTarget
|
|
727
|
-
});
|
|
717
|
+
// src/setup/deploy.ts
|
|
718
|
+
var deploy_exports = /* @__PURE__ */ __exportAll({ resolveDefaultDeployTarget: () => resolveDefaultDeployTarget });
|
|
728
719
|
const deployHosts = [
|
|
729
720
|
"cloudflare",
|
|
730
721
|
"vercel",
|
|
@@ -732,7 +723,7 @@ const deployHosts = [
|
|
|
732
723
|
"deno"
|
|
733
724
|
];
|
|
734
725
|
const temporaryHosts = ["cloudflare", "vercel"];
|
|
735
|
-
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]";
|
|
736
727
|
const help = `--host picks a host target of .vitehub/link.json. Without it, deploy uses the default target. The build runs
|
|
737
728
|
with VITEHUB_HOST set to that host, which wins over \`host\` in vitehub(). Each host has its own resources, such as D1,
|
|
738
729
|
KV, R2, and libSQL.
|
|
@@ -754,8 +745,16 @@ omitted secret cannot inherit from another stage. With --yes, a missing VITEHUB_
|
|
|
754
745
|
|
|
755
746
|
After the upload, deploy requests the paths of \`deploy.check\` in vitehub(), and the health route with \`health\`, on
|
|
756
747
|
the deployed URL. When one does not answer with a 2xx status, deploy exits with 1 and prints the command that rolls
|
|
757
|
-
production back to the deployment it replaced. --no-check skips the checks.
|
|
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
|
|
758
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.
|
|
759
758
|
`;
|
|
760
759
|
function readDeployArgs(args) {
|
|
761
760
|
try {
|
|
@@ -780,6 +779,10 @@ function readDeployArgs(args) {
|
|
|
780
779
|
type: "boolean",
|
|
781
780
|
default: false
|
|
782
781
|
},
|
|
782
|
+
"no-console": {
|
|
783
|
+
type: "boolean",
|
|
784
|
+
default: false
|
|
785
|
+
},
|
|
783
786
|
"no-index-now": {
|
|
784
787
|
type: "boolean",
|
|
785
788
|
default: false
|
|
@@ -815,6 +818,7 @@ function readDeployArgs(args) {
|
|
|
815
818
|
return {
|
|
816
819
|
build: !values["no-build"],
|
|
817
820
|
check: !values["no-check"],
|
|
821
|
+
console: !values["no-console"],
|
|
818
822
|
help: values.help,
|
|
819
823
|
indexNow: !values["no-index-now"],
|
|
820
824
|
...values.host === void 0 ? {} : { host: values.host },
|
|
@@ -841,6 +845,7 @@ function rerunCommand(args, extra = {}) {
|
|
|
841
845
|
...args.push ? [] : ["--no-push"],
|
|
842
846
|
...args.check ? [] : ["--no-check"],
|
|
843
847
|
...args.indexNow ? [] : ["--no-index-now"],
|
|
848
|
+
...args.console ? [] : ["--no-console"],
|
|
844
849
|
...args.temporary || extra.temporary ? ["--temporary"] : [],
|
|
845
850
|
"--yes",
|
|
846
851
|
...args.json ? ["--json"] : []
|
|
@@ -942,11 +947,12 @@ async function recordLink(root, host, result, fallbackName) {
|
|
|
942
947
|
await ensureViteHubGitignore(root);
|
|
943
948
|
}
|
|
944
949
|
function writeDeployed(output, name, context) {
|
|
945
|
-
context.stdout.write(`Deployed ${name} to ${output.host}
|
|
950
|
+
context.stdout.write(`Deployed ${name} to ${output.host}${output.url ? `: ${output.url}` : "."}\n`);
|
|
946
951
|
if (output.deploymentId) context.stdout.write(`Deployment: ${output.deploymentId}\n`);
|
|
947
952
|
if (output.version) context.stdout.write(`Version: ${output.version}\n`);
|
|
948
953
|
if (output.commit) context.stdout.write(`Commit: ${output.commit.sha}${output.commit.dirty ? " (with uncommitted changes)" : ""}\n`);
|
|
949
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));
|
|
950
956
|
if (output.temporary) {
|
|
951
957
|
const window = output.host === "cloudflare" ? "within 60 minutes" : output.temporary.expiresAt ? `before ${output.temporary.expiresAt}` : "soon";
|
|
952
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`);
|
|
@@ -1014,8 +1020,12 @@ async function runDeploy(args, context) {
|
|
|
1014
1020
|
});
|
|
1015
1021
|
const secrets = credentials.ok ? [credentials.token] : [];
|
|
1016
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;
|
|
1017
1025
|
const env = await checkDeployEnv({
|
|
1018
1026
|
context,
|
|
1027
|
+
...availableConsole ? { consoleKeys: availableConsole.keys } : {},
|
|
1028
|
+
deferConsoleKey: !!consoleStep && !args.preview,
|
|
1019
1029
|
entries: output.env,
|
|
1020
1030
|
envDir: output.envDir,
|
|
1021
1031
|
host,
|
|
@@ -1048,12 +1058,22 @@ async function runDeploy(args, context) {
|
|
|
1048
1058
|
await env.apply();
|
|
1049
1059
|
const checkPaths = args.check ? output.deploy.check : [];
|
|
1050
1060
|
const previous = checkPaths.length && !args.preview && !args.temporary ? await previousDeployment(project.root, link, credentials, context, run) : void 0;
|
|
1051
|
-
|
|
1061
|
+
let result = await adapter.deploy();
|
|
1052
1062
|
if (!link && !args.temporary) await recordLink(project.root, host, result, projectName);
|
|
1053
|
-
const
|
|
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;
|
|
1054
1074
|
const deployed = {
|
|
1055
1075
|
host,
|
|
1056
|
-
url: result.url,
|
|
1076
|
+
...result.url ? { url: result.url } : {},
|
|
1057
1077
|
...result.deploymentId ? { deploymentId: result.deploymentId } : {},
|
|
1058
1078
|
...result.version ? { version: result.version } : {},
|
|
1059
1079
|
...result.claim ? { temporary: {
|
|
@@ -1063,12 +1083,15 @@ async function runDeploy(args, context) {
|
|
|
1063
1083
|
...deployContext.commit ? { commit: deployContext.commit } : {},
|
|
1064
1084
|
env: env.output,
|
|
1065
1085
|
...provisioned ? { provision: provisioned } : {},
|
|
1066
|
-
...checks ? { checks } : {}
|
|
1086
|
+
...checks ? { checks } : {},
|
|
1087
|
+
...linkedConsole ? { console: linkedConsole } : {}
|
|
1067
1088
|
};
|
|
1068
1089
|
if (checks?.some((check) => !check.ok)) throw checkFailed(deployed, host, previous, projectName, link, result, args.preview);
|
|
1069
1090
|
if (!args.json) writeDeployed(deployed, projectName, context);
|
|
1070
1091
|
const pushed = checkouts ? await pushCheckouts(checkouts, deployed, args, context) : deployed;
|
|
1071
|
-
const
|
|
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;
|
|
1072
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`);
|
|
1073
1096
|
const final = indexNow ? {
|
|
1074
1097
|
...pushed,
|
|
@@ -1077,6 +1100,55 @@ async function runDeploy(args, context) {
|
|
|
1077
1100
|
if (args.json) writeSetupJson(context, final);
|
|
1078
1101
|
return setupExitCodes.done;
|
|
1079
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
|
+
}
|
|
1080
1152
|
async function previousDeployment(root, link, credentials, context, run) {
|
|
1081
1153
|
if (!link) return { failed: "the project was not linked before this deploy." };
|
|
1082
1154
|
if (!credentials.ok) return { failed: `deploy used the saved ${link.host} CLI login, which gives no API token.` };
|
|
@@ -1121,5 +1193,4 @@ const deployCommand = {
|
|
|
1121
1193
|
},
|
|
1122
1194
|
usage
|
|
1123
1195
|
};
|
|
1124
|
-
//#endregion
|
|
1125
1196
|
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 };
|