@vite-hub/cli 0.6.1 → 0.8.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/README.md +6 -3
- package/dist/{commands-FOmqEZUi.js → commands-w7tEEJph.js} +469 -160
- package/dist/console-apps-BQX-Np9Q.js +271 -0
- package/dist/console-auth-cCodgT_T.js +2813 -0
- package/dist/{console-env-lQ3_eMOy.js → console-env-eXdVI6kw.js} +7 -4
- package/dist/{deploy-DDen0JC0.js → deploy-CqR6pJa-.js} +49 -17
- package/dist/dist-CEIUyD15.js +2495 -0
- package/dist/env-D_CN5DyX.js +2169 -0
- package/dist/envelope-BJQ7xPyX.js +99 -0
- package/dist/help-cache-BI6y5pN8.js +195 -0
- package/dist/index.d.ts +13 -14
- package/dist/index.js +217 -66
- package/dist/link-BRNWNqT9.js +663 -0
- package/dist/provision-9QsGgeiq.js +1741 -0
- package/dist/{provision-kiD8Emd7.d.ts → provision-ByxmUa19.d.ts} +16 -1
- package/dist/provision-Fiosv3Un.js +1391 -0
- package/dist/setup/index.d.ts +37 -15
- package/dist/setup/index.js +12 -9
- package/dist/status-gjvZVutV.js +599 -0
- package/dist/vercel-B5CJLsT0.js +701 -0
- package/package.json +5 -4
- package/dist/env-DzYHxq9A.js +0 -5657
- package/dist/provision-YzxNsbhs.js +0 -4139
- package/dist/rolldown-runtime-BJohB4LM.js +0 -13
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
2
4
|
import { execFile } from "node:child_process";
|
|
3
5
|
import { mkdtemp, open, rename, rm } from "node:fs/promises";
|
|
4
6
|
import { join } from "node:path";
|
|
5
7
|
import { parseArgs } from "node:util";
|
|
6
8
|
// src/setup/console-env.ts
|
|
9
|
+
var console_env_exports = /* @__PURE__ */ __exportAll({ envPullFeature: () => envPullFeature });
|
|
7
10
|
const pullUsage = "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]";
|
|
8
11
|
const stagePattern = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
9
12
|
/** One line of a `.env` file. A value that a parser could read in two ways goes in quotes. */
|
|
@@ -121,8 +124,8 @@ const envPullFeature = {
|
|
|
121
124
|
const file = `.env.${values.stage}`;
|
|
122
125
|
const target = join(context.cwd, file);
|
|
123
126
|
await checkIgnored(context.cwd, file);
|
|
124
|
-
const credential = await
|
|
125
|
-
if (!credential) throw cliErrorDiagnostics.CLI_CONSOLE_SIGNED_OUT({ console:
|
|
127
|
+
const { origin, credential } = await selectConsole(context, values.console);
|
|
128
|
+
if (!credential) throw cliErrorDiagnostics.CLI_CONSOLE_SIGNED_OUT({ console: origin });
|
|
126
129
|
const request = async (path, init = {}) => {
|
|
127
130
|
const response = await (context.fetch ?? fetch)(`${credential.origin}${path}`, {
|
|
128
131
|
...init,
|
|
@@ -187,4 +190,4 @@ const envPullFeature = {
|
|
|
187
190
|
}
|
|
188
191
|
}
|
|
189
192
|
};
|
|
190
|
-
export {
|
|
193
|
+
export { dotenvLine as n, console_env_exports as t };
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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";
|
|
4
9
|
import { createRequire } from "node:module";
|
|
5
10
|
import { existsSync } from "node:fs";
|
|
6
11
|
import process from "node:process";
|
|
12
|
+
import { pathToFileURL } from "node:url";
|
|
7
13
|
import { basename, join } from "pathe";
|
|
8
14
|
import { readFile } from "node:fs/promises";
|
|
9
15
|
import { createInterface } from "node:readline/promises";
|
|
10
|
-
import { pathToFileURL } from "node:url";
|
|
11
16
|
import { parseArgs } from "node:util";
|
|
12
17
|
// src/setup/deploy/after.ts
|
|
13
18
|
/** Waits between the attempts of one path: a new version can take a few seconds to reach every edge location. */
|
|
@@ -626,13 +631,17 @@ function liveLabel(status) {
|
|
|
626
631
|
}
|
|
627
632
|
// src/setup/deploy/provision.ts
|
|
628
633
|
function declaresResources(step, env) {
|
|
634
|
+
if (step.hasResources) return step.hasResources({ env });
|
|
629
635
|
const described = step.recordedState?.({ env });
|
|
630
636
|
return described === void 0 || described.some((category) => category.declared.length > 0);
|
|
631
637
|
}
|
|
632
|
-
function missingCredential(host, env) {
|
|
638
|
+
function missingCredential(host, env, link) {
|
|
633
639
|
if (host === "cloudflare" && !env.CLOUDFLARE_ACCOUNT_ID?.trim()) return "Set CLOUDFLARE_ACCOUNT_ID, or run `vitehub link --host cloudflare --account <id>`. A `wrangler login` with several accounts does not say which one to use.";
|
|
634
640
|
if (host === "vercel" && !env.VERCEL_TOKEN?.trim()) return "A saved `vercel login` cannot create Vercel resources. Set VERCEL_TOKEN to a token from https://vercel.com/account/tokens.";
|
|
635
|
-
if (host === "vercel" && !env.VERCEL_PROJECT_ID?.trim())
|
|
641
|
+
if (host === "vercel" && !env.VERCEL_PROJECT_ID?.trim()) {
|
|
642
|
+
if (link) return "Run `vitehub link --host vercel` with VERCEL_TOKEN to verify the project and store its id.";
|
|
643
|
+
return "Run `vitehub link --host vercel` or `vercel link` to store the project id, or set VERCEL_PROJECT_ID.";
|
|
644
|
+
}
|
|
636
645
|
return "Fix the cause of the warnings.";
|
|
637
646
|
}
|
|
638
647
|
async function confirmProvision(count, host) {
|
|
@@ -654,11 +663,12 @@ async function confirmProvision(count, host) {
|
|
|
654
663
|
async function provisionForDeploy(input, context) {
|
|
655
664
|
const { host } = input;
|
|
656
665
|
if (!isProvisionHost(host) || !context.loadProvision) return;
|
|
657
|
-
const env = provisionEnv(context.env, input.credentials, {
|
|
658
|
-
...input.link?.account?.id ? { accountId: input.link.account.id } : {},
|
|
659
|
-
...input.link?.project.id ? { projectId: input.link.project.id } : {}
|
|
660
|
-
});
|
|
661
666
|
const loaded = await context.loadProvision(host);
|
|
667
|
+
const credentialEnv = provisionHostEnv(context.env, input.credentials, input.link);
|
|
668
|
+
const env = {
|
|
669
|
+
...loaded.env,
|
|
670
|
+
...credentialEnv
|
|
671
|
+
};
|
|
662
672
|
const steps = loaded.steps.filter((step) => step.provider === host && declaresResources(step, env));
|
|
663
673
|
if (!steps.length) return;
|
|
664
674
|
const root = loaded.rootDir;
|
|
@@ -673,7 +683,7 @@ async function provisionForDeploy(input, context) {
|
|
|
673
683
|
});
|
|
674
684
|
if (!plan.checked) throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_PROVISION_UNCHECKED({
|
|
675
685
|
host,
|
|
676
|
-
missing: missingCredential(host, env),
|
|
686
|
+
missing: missingCredential(host, env, input.link),
|
|
677
687
|
warnings: plan.warnings.join(" ")
|
|
678
688
|
}), setupExitCodes.inputNeeded, { rerun: input.rerun });
|
|
679
689
|
const changes = plan.actions.flatMap((planned) => {
|
|
@@ -703,7 +713,7 @@ async function provisionForDeploy(input, context) {
|
|
|
703
713
|
} finally {
|
|
704
714
|
if (Object.keys(state).length) await writeProvisionState(root, state);
|
|
705
715
|
}
|
|
706
|
-
if (changes.length && !input.json) context.stdout.write(`Provisioned ${changes.length} ${changes.length === 1 ? "resource" : "resources"} on ${host}. Ids are in ${
|
|
716
|
+
if (changes.length && !input.json) context.stdout.write(`Provisioned ${changes.length} ${changes.length === 1 ? "resource" : "resources"} on ${host}. Ids are in ${provisionStateFile(root, context.cwd)}.\n`);
|
|
707
717
|
return {
|
|
708
718
|
changed: changes.map(({ planned, status }) => ({
|
|
709
719
|
kind: planned.action.kind,
|
|
@@ -941,10 +951,10 @@ async function recordLink(root, host, result, fallbackName) {
|
|
|
941
951
|
...project.id ? { id: project.id } : {},
|
|
942
952
|
name: project.name
|
|
943
953
|
},
|
|
954
|
+
...host === "cloudflare" ? { resourceScope: fallbackName } : {},
|
|
944
955
|
verified: false,
|
|
945
956
|
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
946
957
|
});
|
|
947
|
-
await ensureViteHubGitignore(root);
|
|
948
958
|
}
|
|
949
959
|
function writeDeployed(output, name, context) {
|
|
950
960
|
context.stdout.write(`Deployed ${name} to ${output.host}${output.url ? `: ${output.url}` : "."}\n`);
|
|
@@ -984,7 +994,7 @@ async function pushCheckouts(checkouts, deployed, args, context) {
|
|
|
984
994
|
async function runDeploy(args, context) {
|
|
985
995
|
const project = await readSetupProject(context.rootDir, context.env);
|
|
986
996
|
const links = await readSetupLinks(project.root);
|
|
987
|
-
const { host, link } = deployTarget(project, links, args.host, context.env);
|
|
997
|
+
const { host, link: savedLink } = deployTarget(project, links, args.host, context.env);
|
|
988
998
|
if (args.preview && host === "deno") throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_PREVIEW_UNSUPPORTED({ host }), setupExitCodes.conflict);
|
|
989
999
|
const credentials = await resolveHostCredentials(host, {
|
|
990
1000
|
cwd: project.root,
|
|
@@ -995,6 +1005,7 @@ async function runDeploy(args, context) {
|
|
|
995
1005
|
if (args.temporary && vercelLogin) throw temporaryUnsupported("It is for a machine without a vercel login, and a saved CLI login was found.");
|
|
996
1006
|
if (args.temporary) assertTemporary(host, args, credentials, project, context.env);
|
|
997
1007
|
else if (!credentials.ok && !vercelLogin) throw credentialsMissing(host, credentials, args);
|
|
1008
|
+
const link = host === "vercel" && !args.temporary ? await resolveVercelTarget(project.root, context.env, savedLink) : savedLink;
|
|
998
1009
|
const interactive = !args.json && !!process.stdin.isTTY && !!process.stderr.isTTY;
|
|
999
1010
|
if (!args.yes) {
|
|
1000
1011
|
if (!interactive) throw setupFailure(cliErrorDiagnostics.CLI_R0004({ message: "[vitehub] `vitehub deploy` publishes the app and was not confirmed. Without a terminal, pass --yes." }), setupExitCodes.inputNeeded, { rerun: rerunCommand(args) });
|
|
@@ -1014,10 +1025,12 @@ async function runDeploy(args, context) {
|
|
|
1014
1025
|
if (args.build) await build(project, host, context);
|
|
1015
1026
|
const output = await readBuildOutput(project.root, host);
|
|
1016
1027
|
const projectName = link?.project.name ?? output.identityName;
|
|
1028
|
+
if (!args.temporary && savedLink && link && output.identityName && output.identityName !== link.project.name) writeLinkedNameNote(context, host, link, output.identityName);
|
|
1017
1029
|
if (!projectName) throw setupFailure(cliErrorDiagnostics.SETUP_LINK_NAME_REQUIRED(), setupExitCodes.inputNeeded, {
|
|
1018
1030
|
missing: [{ field: "project" }],
|
|
1019
1031
|
rerun: "vitehub link --project <name>"
|
|
1020
1032
|
});
|
|
1033
|
+
const deployLink = host === "vercel" && !args.temporary ? link ?? vercelDeployLink(projectName, context.env) : link;
|
|
1021
1034
|
const secrets = credentials.ok ? [credentials.token] : [];
|
|
1022
1035
|
const run = createDeployRun(context.stderr, secrets);
|
|
1023
1036
|
const consoleStep = args.console && !args.temporary && readsConsoleKey(output.env) ? await openDeployConsole(context) : void 0;
|
|
@@ -1030,7 +1043,7 @@ async function runDeploy(args, context) {
|
|
|
1030
1043
|
envDir: output.envDir,
|
|
1031
1044
|
host,
|
|
1032
1045
|
interactive,
|
|
1033
|
-
link: args.temporary ? void 0 :
|
|
1046
|
+
link: args.temporary ? void 0 : deployLink,
|
|
1034
1047
|
outputDir: output.outputDir,
|
|
1035
1048
|
preview: args.preview,
|
|
1036
1049
|
pushEnv: args.pushEnv,
|
|
@@ -1044,7 +1057,7 @@ async function runDeploy(args, context) {
|
|
|
1044
1057
|
credentials,
|
|
1045
1058
|
env: context.env,
|
|
1046
1059
|
fetch: context.fetch ?? globalThis.fetch,
|
|
1047
|
-
link,
|
|
1060
|
+
link: deployLink,
|
|
1048
1061
|
outputDir: output.outputDir,
|
|
1049
1062
|
preview: args.preview,
|
|
1050
1063
|
projectName,
|
|
@@ -1059,7 +1072,10 @@ async function runDeploy(args, context) {
|
|
|
1059
1072
|
const checkPaths = args.check ? output.deploy.check : [];
|
|
1060
1073
|
const previous = checkPaths.length && !args.preview && !args.temporary ? await previousDeployment(project.root, link, credentials, context, run) : void 0;
|
|
1061
1074
|
let result = await adapter.deploy();
|
|
1062
|
-
if (!
|
|
1075
|
+
if (!args.temporary) {
|
|
1076
|
+
if (!savedLink) await recordLink(project.root, host, result, projectName);
|
|
1077
|
+
await ensureViteHubGitignore(project.root, host);
|
|
1078
|
+
}
|
|
1063
1079
|
const consoleDeploy = availableConsole && !args.preview ? await deployConsole(availableConsole, result, {
|
|
1064
1080
|
context,
|
|
1065
1081
|
deployContext,
|
|
@@ -1100,6 +1116,22 @@ async function runDeploy(args, context) {
|
|
|
1100
1116
|
if (args.json) writeSetupJson(context, final);
|
|
1101
1117
|
return setupExitCodes.done;
|
|
1102
1118
|
}
|
|
1119
|
+
function writeLinkedNameNote(context, host, link, built) {
|
|
1120
|
+
const linked = JSON.stringify(link.project.name);
|
|
1121
|
+
const buildName = JSON.stringify(built);
|
|
1122
|
+
const selector = {
|
|
1123
|
+
cloudflare: "account-id",
|
|
1124
|
+
deno: "organization",
|
|
1125
|
+
netlify: "team-slug",
|
|
1126
|
+
vercel: "team-id"
|
|
1127
|
+
}[host];
|
|
1128
|
+
const account = host === "netlify" ? void 0 : link.account?.id;
|
|
1129
|
+
const placeholder = `<${selector}>`;
|
|
1130
|
+
const command = `vitehub link --host ${host} --project ${shellQuote(built)} --account ${account ? shellQuote(account) : placeholder}${host === "deno" ? "" : " --create"}`;
|
|
1131
|
+
const chooseAccount = account ? "" : ` Replace ${placeholder} with the ${host} ${selector.replaceAll("-", " ")} you want to use.`;
|
|
1132
|
+
const createFirst = host === "deno" ? "create the app in Deno Deploy first, then " : "";
|
|
1133
|
+
context.stderr.write(`[vitehub] Deploying to the ${host} project ${linked} of .vitehub/link.json. The build names the app ${buildName}, but the link wins. To deploy to ${buildName}, ${createFirst}run \`${command}\` and deploy again.${chooseAccount} To keep ${linked}, set \`name: ${linked}\` in the ViteHub options.\n`);
|
|
1134
|
+
}
|
|
1103
1135
|
async function deployConsole(step, initial, options) {
|
|
1104
1136
|
const { context, deployContext, host } = options;
|
|
1105
1137
|
const productionUrl = (result) => host === "vercel" ? result.productionUrl : result.url;
|