betterstart-cli 0.0.43 → 0.0.44
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/cli.js +71 -6
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -24889,6 +24889,8 @@ import * as p16 from "@clack/prompts";
|
|
|
24889
24889
|
import pc5 from "picocolors";
|
|
24890
24890
|
var PROVISION_TIMEOUT_MS2 = 18e4;
|
|
24891
24891
|
var INTERACTIVE_PROVISION_TIMEOUT_MS2 = 6e5;
|
|
24892
|
+
var RESOURCE_CONNECT_TIMEOUT_MS = 6e4;
|
|
24893
|
+
var NEON_FREE_PLAN_ID = "free_v3";
|
|
24892
24894
|
async function provisionNeonInteractive(runner, cwd, options) {
|
|
24893
24895
|
const quietSpinner = spinner2();
|
|
24894
24896
|
quietSpinner.start("Creating your Neon database");
|
|
@@ -24953,12 +24955,54 @@ function readNeonProvisionInfo(stdout) {
|
|
|
24953
24955
|
const info = {};
|
|
24954
24956
|
if (meta.dashboardUrl) info.dashboardUrl = meta.dashboardUrl;
|
|
24955
24957
|
if (meta.ssoUrl?.resource) info.resourceUrl = meta.ssoUrl.resource;
|
|
24958
|
+
if (meta.resource?.name) info.resourceName = meta.resource.name;
|
|
24959
|
+
const connectWarning = (meta.warnings ?? []).some((warning) => /failed to connect/i.test(warning));
|
|
24960
|
+
if (meta.envPulled === false || connectWarning) info.connectedToProject = false;
|
|
24961
|
+
else if (meta.envPulled === true) info.connectedToProject = true;
|
|
24956
24962
|
return info;
|
|
24957
24963
|
}
|
|
24964
|
+
async function replaceNeonProjectConnection(runner, cwd, resourceName, env) {
|
|
24965
|
+
const list = await runVercel(runner, ["integration", "list", "--format", "json"], {
|
|
24966
|
+
cwd,
|
|
24967
|
+
mode: "capture",
|
|
24968
|
+
timeoutMs: RESOURCE_CONNECT_TIMEOUT_MS,
|
|
24969
|
+
env
|
|
24970
|
+
});
|
|
24971
|
+
if (list.success) {
|
|
24972
|
+
const payload = parseVercelJson(list.stdout);
|
|
24973
|
+
for (const resource of payload?.resources ?? []) {
|
|
24974
|
+
if (!resource.name || resource.name === resourceName) continue;
|
|
24975
|
+
if (resource.product && !/neon/i.test(resource.product)) continue;
|
|
24976
|
+
await runVercel(runner, ["integration-resource", "disconnect", resource.name, "--yes"], {
|
|
24977
|
+
cwd,
|
|
24978
|
+
mode: "capture",
|
|
24979
|
+
timeoutMs: RESOURCE_CONNECT_TIMEOUT_MS,
|
|
24980
|
+
env
|
|
24981
|
+
});
|
|
24982
|
+
}
|
|
24983
|
+
}
|
|
24984
|
+
const connect = await runVercel(
|
|
24985
|
+
runner,
|
|
24986
|
+
["integration-resource", "connect", resourceName, "--yes"],
|
|
24987
|
+
{
|
|
24988
|
+
cwd,
|
|
24989
|
+
mode: "capture",
|
|
24990
|
+
timeoutMs: RESOURCE_CONNECT_TIMEOUT_MS,
|
|
24991
|
+
env
|
|
24992
|
+
}
|
|
24993
|
+
);
|
|
24994
|
+
return connect.success;
|
|
24995
|
+
}
|
|
24958
24996
|
function neonAddArgs(options) {
|
|
24959
|
-
|
|
24960
|
-
|
|
24961
|
-
|
|
24997
|
+
return [
|
|
24998
|
+
"integration",
|
|
24999
|
+
"add",
|
|
25000
|
+
"neon",
|
|
25001
|
+
"--format",
|
|
25002
|
+
"json",
|
|
25003
|
+
"--plan",
|
|
25004
|
+
options.plan ?? NEON_FREE_PLAN_ID
|
|
25005
|
+
];
|
|
24962
25006
|
}
|
|
24963
25007
|
function connectedNeonAddArgs(options) {
|
|
24964
25008
|
const addArgs = ["integration", "add", "neon"];
|
|
@@ -24980,14 +25024,28 @@ async function runVercelNeonFlow(options) {
|
|
|
24980
25024
|
p17.log.warn(authFailureMessage(auth.reason));
|
|
24981
25025
|
return { ok: false };
|
|
24982
25026
|
}
|
|
25027
|
+
const linkPreExisted = Boolean(readLinkedProjectId(options.cwd));
|
|
24983
25028
|
const linkLinePrinted = await ensureLinkedProject(runner, options.cwd, options.projectName, env);
|
|
25029
|
+
const preExistingDbUrl = linkPreExisted ? await pullPreExistingDbUrl(runner, options.cwd, env) : void 0;
|
|
24984
25030
|
const neon = await provisionNeonForMode(runner, options);
|
|
24985
25031
|
if (neon.failure) {
|
|
24986
25032
|
p17.log.warn(neonFailureMessage(neon.failure));
|
|
24987
25033
|
if (neon.detail) p17.log.message(pc6.dim(neon.detail));
|
|
24988
25034
|
return { ok: false };
|
|
24989
25035
|
}
|
|
24990
|
-
|
|
25036
|
+
if (neon.connectedToProject === false && neon.resourceName) {
|
|
25037
|
+
const connectSpinner = spinner2();
|
|
25038
|
+
connectSpinner.start("Connecting the database to your Vercel project");
|
|
25039
|
+
await replaceNeonProjectConnection(runner, options.cwd, neon.resourceName, env);
|
|
25040
|
+
connectSpinner.clear();
|
|
25041
|
+
}
|
|
25042
|
+
let databaseUrl = await pullNeonDatabaseUrl(runner, options.cwd, env);
|
|
25043
|
+
if (databaseUrl && databaseUrl === preExistingDbUrl) {
|
|
25044
|
+
databaseUrl = void 0;
|
|
25045
|
+
p17.log.warn(
|
|
25046
|
+
"The linked Vercel project still returns its previous DATABASE_URL \u2014 the new database could not be connected."
|
|
25047
|
+
);
|
|
25048
|
+
}
|
|
24991
25049
|
const dismissSignedInNote = databaseUrl && auth.dismissNote && !neon.usedTerminalFallback ? () => auth.dismissNote?.({ linesBelow: linkLinePrinted ? 1 : 0 }) : void 0;
|
|
24992
25050
|
return {
|
|
24993
25051
|
ok: true,
|
|
@@ -25083,7 +25141,7 @@ async function runVercelDeployFlow(options) {
|
|
|
25083
25141
|
);
|
|
25084
25142
|
}
|
|
25085
25143
|
const deploySpinner = spinner2();
|
|
25086
|
-
deploySpinner.start("Deploying to Vercel
|
|
25144
|
+
deploySpinner.start("Deploying to Vercel, This may take a moment");
|
|
25087
25145
|
let deploy;
|
|
25088
25146
|
try {
|
|
25089
25147
|
deploy = await deployVercelProject(runner, options.cwd, env);
|
|
@@ -25121,6 +25179,13 @@ async function ensureLinkedProject(runner, cwd, projectName, env) {
|
|
|
25121
25179
|
);
|
|
25122
25180
|
return true;
|
|
25123
25181
|
}
|
|
25182
|
+
async function pullPreExistingDbUrl(runner, cwd, env) {
|
|
25183
|
+
const snapshotSpinner = spinner2();
|
|
25184
|
+
snapshotSpinner.start("Checking the linked Vercel project");
|
|
25185
|
+
const url = await pullVercelEnvValue(runner, cwd, readDbUrlFromDotenv, env);
|
|
25186
|
+
snapshotSpinner.clear();
|
|
25187
|
+
return url;
|
|
25188
|
+
}
|
|
25124
25189
|
async function pullNeonDatabaseUrl(runner, cwd, env) {
|
|
25125
25190
|
const neonSpinner = spinner2();
|
|
25126
25191
|
neonSpinner.start("Retrieving DATABASE_URL from Vercel");
|
|
@@ -25962,7 +26027,7 @@ async function runInitCommand(name, options) {
|
|
|
25962
26027
|
}
|
|
25963
26028
|
const coreDependencyPlan = getDependencyPlan([], [], project2.linter.type === "none");
|
|
25964
26029
|
const cliDependencyPlan = getCliDependencySyncPlan(cwd);
|
|
25965
|
-
s.start("Installing dependencies
|
|
26030
|
+
s.start("Installing dependencies, This may take a moment");
|
|
25966
26031
|
const depsResult = await installDependenciesAsync({
|
|
25967
26032
|
cwd,
|
|
25968
26033
|
pm,
|