@vite-hub/cli 0.6.1 → 0.7.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 +4 -2
- package/dist/{commands-FOmqEZUi.js → commands-o_CHzNS9.js} +421 -107
- package/dist/{console-env-lQ3_eMOy.js → console-env-MPzeOLqu.js} +17 -4
- package/dist/{deploy-DDen0JC0.js → deploy-CGRf9Pq-.js} +43 -16
- package/dist/dist-CEIUyD15.js +2495 -0
- package/dist/env-DSPUdOVC.js +2163 -0
- package/dist/index.d.ts +10 -14
- package/dist/index.js +163 -49
- package/dist/{provision-kiD8Emd7.d.ts → provision-ByxmUa19.d.ts} +16 -1
- package/dist/{provision-YzxNsbhs.js → provision-DWEZYLWJ.js} +5245 -1293
- package/dist/setup/index.d.ts +37 -15
- package/dist/setup/index.js +7 -5
- package/package.json +5 -4
- package/dist/env-DzYHxq9A.js +0 -5657
- package/dist/rolldown-runtime-BJohB4LM.js +0 -13
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Lt as writeSetupError, Rt as writeSetupJson, xt as selectConsole, zt as cliErrorDiagnostics } from "./provision-DWEZYLWJ.js";
|
|
2
|
+
import "node:module";
|
|
2
3
|
import { execFile } from "node:child_process";
|
|
3
4
|
import { mkdtemp, open, rename, rm } from "node:fs/promises";
|
|
4
5
|
import { join } from "node:path";
|
|
5
6
|
import { parseArgs } from "node:util";
|
|
7
|
+
// \0rolldown/runtime.js
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
6
18
|
// src/setup/console-env.ts
|
|
19
|
+
var console_env_exports = /* @__PURE__ */ __exportAll({ envPullFeature: () => envPullFeature });
|
|
7
20
|
const pullUsage = "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]";
|
|
8
21
|
const stagePattern = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
9
22
|
/** One line of a `.env` file. A value that a parser could read in two ways goes in quotes. */
|
|
@@ -121,8 +134,8 @@ const envPullFeature = {
|
|
|
121
134
|
const file = `.env.${values.stage}`;
|
|
122
135
|
const target = join(context.cwd, file);
|
|
123
136
|
await checkIgnored(context.cwd, file);
|
|
124
|
-
const credential = await
|
|
125
|
-
if (!credential) throw cliErrorDiagnostics.CLI_CONSOLE_SIGNED_OUT({ console:
|
|
137
|
+
const { origin, credential } = await selectConsole(context, values.console);
|
|
138
|
+
if (!credential) throw cliErrorDiagnostics.CLI_CONSOLE_SIGNED_OUT({ console: origin });
|
|
126
139
|
const request = async (path, init = {}) => {
|
|
127
140
|
const response = await (context.fetch ?? fetch)(`${credential.origin}${path}`, {
|
|
128
141
|
...init,
|
|
@@ -187,4 +200,4 @@ const envPullFeature = {
|
|
|
187
200
|
}
|
|
188
201
|
}
|
|
189
202
|
};
|
|
190
|
-
export {
|
|
203
|
+
export { dotenvLine as n, __exportAll as r, console_env_exports as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { r as __exportAll } from "./console-env-MPzeOLqu.js";
|
|
2
|
+
import { A as createDeployRun, C as resolveVercelTarget, Dt as readSetupProject, Ft as setupFailure, It as table, J as resolveHostCredentials, Kt as writeProvisionState, Lt as writeSetupError, Mt as isSetupFailure, Pt as setupExitCodes, Rt as writeSetupJson, S as listVercelDeployments, T as vercelDeployLink, U as abortable, Ut as mergeProvisionState, Wt as readProvisionState, Xt as callOperationFromCli, _ as readSetupLinks, a as provisionStateFile, b as writeSeparateResourcesNote, c as addSetupLink, ct as setupStatus, d as hostRequired, dt as hostFromNitroPreset, i as provisionHostEnv, l as ensureViteHubGitignore, lt as shellQuote, m as readLinkHostOption, n as isProvisionHost, o as writeProvisionActions, q as planProvisionSteps, r as provisionActionStatus, v as selectSetupLink, w as vercelAdapter, x as hasVercelLogin, z as readDeployCommit, zt as cliErrorDiagnostics } from "./provision-DWEZYLWJ.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-DSPUdOVC.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import process from "node:process";
|
|
@@ -626,13 +626,17 @@ function liveLabel(status) {
|
|
|
626
626
|
}
|
|
627
627
|
// src/setup/deploy/provision.ts
|
|
628
628
|
function declaresResources(step, env) {
|
|
629
|
+
if (step.hasResources) return step.hasResources({ env });
|
|
629
630
|
const described = step.recordedState?.({ env });
|
|
630
631
|
return described === void 0 || described.some((category) => category.declared.length > 0);
|
|
631
632
|
}
|
|
632
|
-
function missingCredential(host, env) {
|
|
633
|
+
function missingCredential(host, env, link) {
|
|
633
634
|
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
635
|
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())
|
|
636
|
+
if (host === "vercel" && !env.VERCEL_PROJECT_ID?.trim()) {
|
|
637
|
+
if (link) return "Run `vitehub link --host vercel` with VERCEL_TOKEN to verify the project and store its id.";
|
|
638
|
+
return "Run `vitehub link --host vercel` or `vercel link` to store the project id, or set VERCEL_PROJECT_ID.";
|
|
639
|
+
}
|
|
636
640
|
return "Fix the cause of the warnings.";
|
|
637
641
|
}
|
|
638
642
|
async function confirmProvision(count, host) {
|
|
@@ -654,11 +658,12 @@ async function confirmProvision(count, host) {
|
|
|
654
658
|
async function provisionForDeploy(input, context) {
|
|
655
659
|
const { host } = input;
|
|
656
660
|
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
661
|
const loaded = await context.loadProvision(host);
|
|
662
|
+
const credentialEnv = provisionHostEnv(context.env, input.credentials, input.link);
|
|
663
|
+
const env = {
|
|
664
|
+
...loaded.env,
|
|
665
|
+
...credentialEnv
|
|
666
|
+
};
|
|
662
667
|
const steps = loaded.steps.filter((step) => step.provider === host && declaresResources(step, env));
|
|
663
668
|
if (!steps.length) return;
|
|
664
669
|
const root = loaded.rootDir;
|
|
@@ -673,7 +678,7 @@ async function provisionForDeploy(input, context) {
|
|
|
673
678
|
});
|
|
674
679
|
if (!plan.checked) throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_PROVISION_UNCHECKED({
|
|
675
680
|
host,
|
|
676
|
-
missing: missingCredential(host, env),
|
|
681
|
+
missing: missingCredential(host, env, input.link),
|
|
677
682
|
warnings: plan.warnings.join(" ")
|
|
678
683
|
}), setupExitCodes.inputNeeded, { rerun: input.rerun });
|
|
679
684
|
const changes = plan.actions.flatMap((planned) => {
|
|
@@ -703,7 +708,7 @@ async function provisionForDeploy(input, context) {
|
|
|
703
708
|
} finally {
|
|
704
709
|
if (Object.keys(state).length) await writeProvisionState(root, state);
|
|
705
710
|
}
|
|
706
|
-
if (changes.length && !input.json) context.stdout.write(`Provisioned ${changes.length} ${changes.length === 1 ? "resource" : "resources"} on ${host}. Ids are in ${
|
|
711
|
+
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
712
|
return {
|
|
708
713
|
changed: changes.map(({ planned, status }) => ({
|
|
709
714
|
kind: planned.action.kind,
|
|
@@ -941,10 +946,10 @@ async function recordLink(root, host, result, fallbackName) {
|
|
|
941
946
|
...project.id ? { id: project.id } : {},
|
|
942
947
|
name: project.name
|
|
943
948
|
},
|
|
949
|
+
...host === "cloudflare" ? { resourceScope: fallbackName } : {},
|
|
944
950
|
verified: false,
|
|
945
951
|
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
946
952
|
});
|
|
947
|
-
await ensureViteHubGitignore(root);
|
|
948
953
|
}
|
|
949
954
|
function writeDeployed(output, name, context) {
|
|
950
955
|
context.stdout.write(`Deployed ${name} to ${output.host}${output.url ? `: ${output.url}` : "."}\n`);
|
|
@@ -984,7 +989,7 @@ async function pushCheckouts(checkouts, deployed, args, context) {
|
|
|
984
989
|
async function runDeploy(args, context) {
|
|
985
990
|
const project = await readSetupProject(context.rootDir, context.env);
|
|
986
991
|
const links = await readSetupLinks(project.root);
|
|
987
|
-
const { host, link } = deployTarget(project, links, args.host, context.env);
|
|
992
|
+
const { host, link: savedLink } = deployTarget(project, links, args.host, context.env);
|
|
988
993
|
if (args.preview && host === "deno") throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_PREVIEW_UNSUPPORTED({ host }), setupExitCodes.conflict);
|
|
989
994
|
const credentials = await resolveHostCredentials(host, {
|
|
990
995
|
cwd: project.root,
|
|
@@ -995,6 +1000,7 @@ async function runDeploy(args, context) {
|
|
|
995
1000
|
if (args.temporary && vercelLogin) throw temporaryUnsupported("It is for a machine without a vercel login, and a saved CLI login was found.");
|
|
996
1001
|
if (args.temporary) assertTemporary(host, args, credentials, project, context.env);
|
|
997
1002
|
else if (!credentials.ok && !vercelLogin) throw credentialsMissing(host, credentials, args);
|
|
1003
|
+
const link = host === "vercel" && !args.temporary ? await resolveVercelTarget(project.root, context.env, savedLink) : savedLink;
|
|
998
1004
|
const interactive = !args.json && !!process.stdin.isTTY && !!process.stderr.isTTY;
|
|
999
1005
|
if (!args.yes) {
|
|
1000
1006
|
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 +1020,12 @@ async function runDeploy(args, context) {
|
|
|
1014
1020
|
if (args.build) await build(project, host, context);
|
|
1015
1021
|
const output = await readBuildOutput(project.root, host);
|
|
1016
1022
|
const projectName = link?.project.name ?? output.identityName;
|
|
1023
|
+
if (!args.temporary && savedLink && link && output.identityName && output.identityName !== link.project.name) writeLinkedNameNote(context, host, link, output.identityName);
|
|
1017
1024
|
if (!projectName) throw setupFailure(cliErrorDiagnostics.SETUP_LINK_NAME_REQUIRED(), setupExitCodes.inputNeeded, {
|
|
1018
1025
|
missing: [{ field: "project" }],
|
|
1019
1026
|
rerun: "vitehub link --project <name>"
|
|
1020
1027
|
});
|
|
1028
|
+
const deployLink = host === "vercel" && !args.temporary ? link ?? vercelDeployLink(projectName, context.env) : link;
|
|
1021
1029
|
const secrets = credentials.ok ? [credentials.token] : [];
|
|
1022
1030
|
const run = createDeployRun(context.stderr, secrets);
|
|
1023
1031
|
const consoleStep = args.console && !args.temporary && readsConsoleKey(output.env) ? await openDeployConsole(context) : void 0;
|
|
@@ -1030,7 +1038,7 @@ async function runDeploy(args, context) {
|
|
|
1030
1038
|
envDir: output.envDir,
|
|
1031
1039
|
host,
|
|
1032
1040
|
interactive,
|
|
1033
|
-
link: args.temporary ? void 0 :
|
|
1041
|
+
link: args.temporary ? void 0 : deployLink,
|
|
1034
1042
|
outputDir: output.outputDir,
|
|
1035
1043
|
preview: args.preview,
|
|
1036
1044
|
pushEnv: args.pushEnv,
|
|
@@ -1044,7 +1052,7 @@ async function runDeploy(args, context) {
|
|
|
1044
1052
|
credentials,
|
|
1045
1053
|
env: context.env,
|
|
1046
1054
|
fetch: context.fetch ?? globalThis.fetch,
|
|
1047
|
-
link,
|
|
1055
|
+
link: deployLink,
|
|
1048
1056
|
outputDir: output.outputDir,
|
|
1049
1057
|
preview: args.preview,
|
|
1050
1058
|
projectName,
|
|
@@ -1059,7 +1067,10 @@ async function runDeploy(args, context) {
|
|
|
1059
1067
|
const checkPaths = args.check ? output.deploy.check : [];
|
|
1060
1068
|
const previous = checkPaths.length && !args.preview && !args.temporary ? await previousDeployment(project.root, link, credentials, context, run) : void 0;
|
|
1061
1069
|
let result = await adapter.deploy();
|
|
1062
|
-
if (!
|
|
1070
|
+
if (!args.temporary) {
|
|
1071
|
+
if (!savedLink) await recordLink(project.root, host, result, projectName);
|
|
1072
|
+
await ensureViteHubGitignore(project.root, host);
|
|
1073
|
+
}
|
|
1063
1074
|
const consoleDeploy = availableConsole && !args.preview ? await deployConsole(availableConsole, result, {
|
|
1064
1075
|
context,
|
|
1065
1076
|
deployContext,
|
|
@@ -1100,6 +1111,22 @@ async function runDeploy(args, context) {
|
|
|
1100
1111
|
if (args.json) writeSetupJson(context, final);
|
|
1101
1112
|
return setupExitCodes.done;
|
|
1102
1113
|
}
|
|
1114
|
+
function writeLinkedNameNote(context, host, link, built) {
|
|
1115
|
+
const linked = JSON.stringify(link.project.name);
|
|
1116
|
+
const buildName = JSON.stringify(built);
|
|
1117
|
+
const selector = {
|
|
1118
|
+
cloudflare: "account-id",
|
|
1119
|
+
deno: "organization",
|
|
1120
|
+
netlify: "team-slug",
|
|
1121
|
+
vercel: "team-id"
|
|
1122
|
+
}[host];
|
|
1123
|
+
const account = host === "netlify" ? void 0 : link.account?.id;
|
|
1124
|
+
const placeholder = `<${selector}>`;
|
|
1125
|
+
const command = `vitehub link --host ${host} --project ${shellQuote(built)} --account ${account ? shellQuote(account) : placeholder}${host === "deno" ? "" : " --create"}`;
|
|
1126
|
+
const chooseAccount = account ? "" : ` Replace ${placeholder} with the ${host} ${selector.replaceAll("-", " ")} you want to use.`;
|
|
1127
|
+
const createFirst = host === "deno" ? "create the app in Deno Deploy first, then " : "";
|
|
1128
|
+
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`);
|
|
1129
|
+
}
|
|
1103
1130
|
async function deployConsole(step, initial, options) {
|
|
1104
1131
|
const { context, deployContext, host } = options;
|
|
1105
1132
|
const productionUrl = (result) => host === "vercel" ? result.productionUrl : result.url;
|