betterstart-cli 0.0.45 → 0.0.46
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 +22 -132
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -24889,11 +24889,9 @@ 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";
|
|
24894
24892
|
async function provisionNeonInteractive(runner, cwd, options) {
|
|
24895
|
-
const
|
|
24896
|
-
|
|
24893
|
+
const quietSpinner = spinner2();
|
|
24894
|
+
quietSpinner.start("Creating your Neon database");
|
|
24897
24895
|
const quiet = await runVercel(runner, neonAddArgs(options), {
|
|
24898
24896
|
cwd,
|
|
24899
24897
|
mode: "capture",
|
|
@@ -24901,72 +24899,25 @@ async function provisionNeonInteractive(runner, cwd, options) {
|
|
|
24901
24899
|
env: options.env
|
|
24902
24900
|
});
|
|
24903
24901
|
if (quiet.success) {
|
|
24904
|
-
|
|
24902
|
+
quietSpinner.clear();
|
|
24905
24903
|
return readNeonProvisionInfo(quiet.stdout);
|
|
24906
24904
|
}
|
|
24907
|
-
|
|
24905
|
+
quietSpinner.clear();
|
|
24906
|
+
p16.log.info(
|
|
24907
|
+
`Create your Neon database in the Vercel prompts below ${pc5.dim(
|
|
24908
|
+
"(the Free plan is recommended)."
|
|
24909
|
+
)}`
|
|
24910
|
+
);
|
|
24908
24911
|
const add = await runVercel(runner, connectedNeonAddArgs(options), {
|
|
24909
24912
|
cwd,
|
|
24910
|
-
mode: "
|
|
24913
|
+
mode: "inherit",
|
|
24911
24914
|
timeoutMs: INTERACTIVE_PROVISION_TIMEOUT_MS2,
|
|
24912
|
-
env: options.env
|
|
24913
|
-
streamLineFilter: (line) => {
|
|
24914
|
-
if (!showNeonSetupLine(line)) return false;
|
|
24915
|
-
if (!promptsShown) {
|
|
24916
|
-
promptsShown = true;
|
|
24917
|
-
provisionSpinner.clear();
|
|
24918
|
-
p16.log.info(
|
|
24919
|
-
`Finish the Neon database setup in the Vercel prompts below ${pc5.dim(
|
|
24920
|
-
"(the Free plan is recommended)."
|
|
24921
|
-
)}`
|
|
24922
|
-
);
|
|
24923
|
-
}
|
|
24924
|
-
return true;
|
|
24925
|
-
}
|
|
24915
|
+
env: options.env
|
|
24926
24916
|
});
|
|
24927
|
-
if (!promptsShown) provisionSpinner.clear();
|
|
24928
24917
|
if (!add.success) {
|
|
24929
|
-
|
|
24930
|
-
${add.stderr}`.trim();
|
|
24931
|
-
return {
|
|
24932
|
-
failure: add.timedOut ? "timeout" : "provision-failed",
|
|
24933
|
-
// Lines the user already saw are not repeated as detail.
|
|
24934
|
-
detail: promptsShown ? void 0 : combined || void 0
|
|
24935
|
-
};
|
|
24918
|
+
return { failure: add.timedOut ? "timeout" : "provision-failed" };
|
|
24936
24919
|
}
|
|
24937
|
-
|
|
24938
|
-
${add.stderr}`);
|
|
24939
|
-
if (promptsShown) info.usedTerminalFallback = true;
|
|
24940
|
-
return info;
|
|
24941
|
-
}
|
|
24942
|
-
var NEON_SETUP_NOISE = [
|
|
24943
|
-
/^$/,
|
|
24944
|
-
/^Vercel CLI \d/,
|
|
24945
|
-
/^>? ?Installing .+ under /,
|
|
24946
|
-
/^Provisioning resource/,
|
|
24947
|
-
/^Retrieving project/,
|
|
24948
|
-
/^>? ?Success!/,
|
|
24949
|
-
/^>? ?Guide: Run/,
|
|
24950
|
-
/^>? ?Dashboard: https:\/\//,
|
|
24951
|
-
/successfully connected to/i,
|
|
24952
|
-
/^>? ?Overwriting existing \.env/,
|
|
24953
|
-
/^>? ?Downloading/,
|
|
24954
|
-
/^Changes:/,
|
|
24955
|
-
/^\+ [A-Z][A-Z0-9_]*/,
|
|
24956
|
-
/^[✓√] +(Updated|Created)/
|
|
24957
|
-
];
|
|
24958
|
-
function showNeonSetupLine(line) {
|
|
24959
|
-
return !NEON_SETUP_NOISE.some((pattern) => pattern.test(line));
|
|
24960
|
-
}
|
|
24961
|
-
function readNeonFallbackInfo(output) {
|
|
24962
|
-
const info = {};
|
|
24963
|
-
const provisioned = output.match(/successfully provisioned: (\S+)/i)?.[1];
|
|
24964
|
-
if (provisioned) info.resourceName = provisioned;
|
|
24965
|
-
const dashboard = output.match(/Dashboard: (https:\/\/\S+)/i)?.[1];
|
|
24966
|
-
if (dashboard) info.dashboardUrl = dashboard;
|
|
24967
|
-
if (/failed to connect/i.test(output)) info.connectedToProject = false;
|
|
24968
|
-
else if (/successfully connected to/i.test(output)) info.connectedToProject = true;
|
|
24969
|
-
return info;
|
|
24920
|
+
return { usedTerminalFallback: true };
|
|
24970
24921
|
}
|
|
24971
24922
|
async function provisionNeon(runner, cwd, options) {
|
|
24972
24923
|
const provisionSpinner = spinner2();
|
|
@@ -25002,57 +24953,17 @@ function readNeonProvisionInfo(stdout) {
|
|
|
25002
24953
|
const info = {};
|
|
25003
24954
|
if (meta.dashboardUrl) info.dashboardUrl = meta.dashboardUrl;
|
|
25004
24955
|
if (meta.ssoUrl?.resource) info.resourceUrl = meta.ssoUrl.resource;
|
|
25005
|
-
if (meta.resource?.name) info.resourceName = meta.resource.name;
|
|
25006
|
-
const connectWarning = (meta.warnings ?? []).some((warning) => /failed to connect/i.test(warning));
|
|
25007
|
-
if (meta.envPulled === false || connectWarning) info.connectedToProject = false;
|
|
25008
|
-
else if (meta.envPulled === true) info.connectedToProject = true;
|
|
25009
24956
|
return info;
|
|
25010
24957
|
}
|
|
25011
|
-
async function replaceNeonProjectConnection(runner, cwd, resourceName, env) {
|
|
25012
|
-
const list = await runVercel(runner, ["integration", "list", "--format", "json"], {
|
|
25013
|
-
cwd,
|
|
25014
|
-
mode: "capture",
|
|
25015
|
-
timeoutMs: RESOURCE_CONNECT_TIMEOUT_MS,
|
|
25016
|
-
env
|
|
25017
|
-
});
|
|
25018
|
-
if (list.success) {
|
|
25019
|
-
const payload = parseVercelJson(list.stdout);
|
|
25020
|
-
for (const resource of payload?.resources ?? []) {
|
|
25021
|
-
if (!resource.name || resource.name === resourceName) continue;
|
|
25022
|
-
if (resource.product && !/neon/i.test(resource.product)) continue;
|
|
25023
|
-
await runVercel(runner, ["integration-resource", "disconnect", resource.name, "--yes"], {
|
|
25024
|
-
cwd,
|
|
25025
|
-
mode: "capture",
|
|
25026
|
-
timeoutMs: RESOURCE_CONNECT_TIMEOUT_MS,
|
|
25027
|
-
env
|
|
25028
|
-
});
|
|
25029
|
-
}
|
|
25030
|
-
}
|
|
25031
|
-
const connect = await runVercel(
|
|
25032
|
-
runner,
|
|
25033
|
-
["integration-resource", "connect", resourceName, "--yes"],
|
|
25034
|
-
{
|
|
25035
|
-
cwd,
|
|
25036
|
-
mode: "capture",
|
|
25037
|
-
timeoutMs: RESOURCE_CONNECT_TIMEOUT_MS,
|
|
25038
|
-
env
|
|
25039
|
-
}
|
|
25040
|
-
);
|
|
25041
|
-
return connect.success;
|
|
25042
|
-
}
|
|
25043
24958
|
function neonAddArgs(options) {
|
|
25044
|
-
|
|
25045
|
-
|
|
25046
|
-
|
|
25047
|
-
"neon",
|
|
25048
|
-
"--format",
|
|
25049
|
-
"json",
|
|
25050
|
-
"--plan",
|
|
25051
|
-
options.plan ?? NEON_FREE_PLAN_ID
|
|
25052
|
-
];
|
|
24959
|
+
const addArgs = ["integration", "add", "neon", "--format", "json"];
|
|
24960
|
+
if (options.plan) addArgs.push("--plan", options.plan);
|
|
24961
|
+
return addArgs;
|
|
25053
24962
|
}
|
|
25054
24963
|
function connectedNeonAddArgs(options) {
|
|
25055
|
-
|
|
24964
|
+
const addArgs = ["integration", "add", "neon"];
|
|
24965
|
+
if (options.plan) addArgs.push("--plan", options.plan);
|
|
24966
|
+
return addArgs;
|
|
25056
24967
|
}
|
|
25057
24968
|
|
|
25058
24969
|
// adapters/next/init/vercel/flow.ts
|
|
@@ -25069,28 +24980,14 @@ async function runVercelNeonFlow(options) {
|
|
|
25069
24980
|
p17.log.warn(authFailureMessage(auth.reason));
|
|
25070
24981
|
return { ok: false };
|
|
25071
24982
|
}
|
|
25072
|
-
const linkPreExisted = Boolean(readLinkedProjectId(options.cwd));
|
|
25073
24983
|
const linkLinePrinted = await ensureLinkedProject(runner, options.cwd, options.projectName, env);
|
|
25074
|
-
const preExistingDbUrl = linkPreExisted ? await pullPreExistingDbUrl(runner, options.cwd, env) : void 0;
|
|
25075
24984
|
const neon = await provisionNeonForMode(runner, options);
|
|
25076
24985
|
if (neon.failure) {
|
|
25077
24986
|
p17.log.warn(neonFailureMessage(neon.failure));
|
|
25078
24987
|
if (neon.detail) p17.log.message(pc6.dim(neon.detail));
|
|
25079
24988
|
return { ok: false };
|
|
25080
24989
|
}
|
|
25081
|
-
|
|
25082
|
-
const connectSpinner = spinner2();
|
|
25083
|
-
connectSpinner.start("Connecting the database to your Vercel project");
|
|
25084
|
-
await replaceNeonProjectConnection(runner, options.cwd, neon.resourceName, env);
|
|
25085
|
-
connectSpinner.clear();
|
|
25086
|
-
}
|
|
25087
|
-
let databaseUrl = await pullNeonDatabaseUrl(runner, options.cwd, env);
|
|
25088
|
-
if (databaseUrl && databaseUrl === preExistingDbUrl) {
|
|
25089
|
-
databaseUrl = void 0;
|
|
25090
|
-
p17.log.warn(
|
|
25091
|
-
"The linked Vercel project still returns its previous DATABASE_URL \u2014 the new database could not be connected."
|
|
25092
|
-
);
|
|
25093
|
-
}
|
|
24990
|
+
const databaseUrl = await pullNeonDatabaseUrl(runner, options.cwd, env);
|
|
25094
24991
|
const dismissSignedInNote = databaseUrl && auth.dismissNote && !neon.usedTerminalFallback ? () => auth.dismissNote?.({ linesBelow: linkLinePrinted ? 1 : 0 }) : void 0;
|
|
25095
24992
|
return {
|
|
25096
24993
|
ok: true,
|
|
@@ -25186,7 +25083,7 @@ async function runVercelDeployFlow(options) {
|
|
|
25186
25083
|
);
|
|
25187
25084
|
}
|
|
25188
25085
|
const deploySpinner = spinner2();
|
|
25189
|
-
deploySpinner.start("Deploying to Vercel
|
|
25086
|
+
deploySpinner.start("Deploying to Vercel (this may take a few minutes)");
|
|
25190
25087
|
let deploy;
|
|
25191
25088
|
try {
|
|
25192
25089
|
deploy = await deployVercelProject(runner, options.cwd, env);
|
|
@@ -25224,13 +25121,6 @@ async function ensureLinkedProject(runner, cwd, projectName, env) {
|
|
|
25224
25121
|
);
|
|
25225
25122
|
return true;
|
|
25226
25123
|
}
|
|
25227
|
-
async function pullPreExistingDbUrl(runner, cwd, env) {
|
|
25228
|
-
const snapshotSpinner = spinner2();
|
|
25229
|
-
snapshotSpinner.start("Checking the linked Vercel project");
|
|
25230
|
-
const url = await pullVercelEnvValue(runner, cwd, readDbUrlFromDotenv, env);
|
|
25231
|
-
snapshotSpinner.clear();
|
|
25232
|
-
return url;
|
|
25233
|
-
}
|
|
25234
25124
|
async function pullNeonDatabaseUrl(runner, cwd, env) {
|
|
25235
25125
|
const neonSpinner = spinner2();
|
|
25236
25126
|
neonSpinner.start("Retrieving DATABASE_URL from Vercel");
|
|
@@ -26072,7 +25962,7 @@ async function runInitCommand(name, options) {
|
|
|
26072
25962
|
}
|
|
26073
25963
|
const coreDependencyPlan = getDependencyPlan([], [], project2.linter.type === "none");
|
|
26074
25964
|
const cliDependencyPlan = getCliDependencySyncPlan(cwd);
|
|
26075
|
-
s.start("Installing dependencies
|
|
25965
|
+
s.start("Installing dependencies (this may take a minute)");
|
|
26076
25966
|
const depsResult = await installDependenciesAsync({
|
|
26077
25967
|
cwd,
|
|
26078
25968
|
pm,
|