betterstart-cli 0.0.23 → 0.0.24
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 +51 -42
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -23984,44 +23984,46 @@ import fs34 from "fs";
|
|
|
23984
23984
|
import os from "os";
|
|
23985
23985
|
import path45 from "path";
|
|
23986
23986
|
var PROVISION_TIMEOUT_MS = 18e4;
|
|
23987
|
+
var INTERACTIVE_PROVISION_TIMEOUT_MS = 6e5;
|
|
23987
23988
|
var ENV_PULL_TIMEOUT_MS = 6e4;
|
|
23988
|
-
async function
|
|
23989
|
-
const addArgs = ["integration", "add", "neon", "--no-env-pull"
|
|
23989
|
+
async function provisionNeonInteractive(runner, cwd, options) {
|
|
23990
|
+
const addArgs = ["integration", "add", "neon", "--no-env-pull"];
|
|
23990
23991
|
if (options.plan) addArgs.push("--plan", options.plan);
|
|
23991
23992
|
const add = await runVercel(runner, addArgs, {
|
|
23992
23993
|
cwd,
|
|
23993
|
-
mode: "
|
|
23994
|
-
timeoutMs:
|
|
23994
|
+
mode: "inherit",
|
|
23995
|
+
timeoutMs: INTERACTIVE_PROVISION_TIMEOUT_MS,
|
|
23995
23996
|
env: options.env
|
|
23996
23997
|
});
|
|
23997
23998
|
if (!add.success) {
|
|
23998
|
-
const combined = `${add.stdout}
|
|
23999
|
-
${add.stderr}`;
|
|
24000
|
-
if (/terms/i.test(combined)) return { failure: "terms-required" };
|
|
24001
|
-
if (/claim/i.test(combined)) return { failure: "claim-required" };
|
|
24002
23999
|
return { failure: add.timedOut ? "timeout" : "provision-failed" };
|
|
24003
24000
|
}
|
|
24004
|
-
const meta = parseVercelJson(add.stdout);
|
|
24005
|
-
const resourceName = meta?.resourceName ?? meta?.name;
|
|
24006
24001
|
const databaseUrl = await pullDatabaseUrl(runner, cwd, options.env);
|
|
24007
|
-
if (!databaseUrl) return {
|
|
24008
|
-
return { databaseUrl
|
|
24002
|
+
if (!databaseUrl) return { failure: "env-pull-empty" };
|
|
24003
|
+
return { databaseUrl };
|
|
24009
24004
|
}
|
|
24010
|
-
async function
|
|
24011
|
-
const addArgs = ["integration", "add", "neon", "--no-env-pull", "--
|
|
24005
|
+
async function provisionNeon(runner, cwd, options) {
|
|
24006
|
+
const addArgs = ["integration", "add", "neon", "--no-env-pull", "--format", "json"];
|
|
24012
24007
|
if (options.plan) addArgs.push("--plan", options.plan);
|
|
24013
24008
|
const add = await runVercel(runner, addArgs, {
|
|
24014
24009
|
cwd,
|
|
24015
|
-
mode: "
|
|
24010
|
+
mode: "capture",
|
|
24016
24011
|
timeoutMs: PROVISION_TIMEOUT_MS,
|
|
24017
24012
|
env: options.env
|
|
24018
24013
|
});
|
|
24019
24014
|
if (!add.success) {
|
|
24020
|
-
|
|
24015
|
+
const combined = `${add.stdout}
|
|
24016
|
+
${add.stderr}`.trim();
|
|
24017
|
+
const detail = combined || void 0;
|
|
24018
|
+
if (/terms/i.test(combined)) return { failure: "terms-required", detail };
|
|
24019
|
+
if (/claim/i.test(combined)) return { failure: "claim-required", detail };
|
|
24020
|
+
return { failure: add.timedOut ? "timeout" : "provision-failed", detail };
|
|
24021
24021
|
}
|
|
24022
|
+
const meta = parseVercelJson(add.stdout);
|
|
24023
|
+
const resourceName = meta?.resourceName ?? meta?.name;
|
|
24022
24024
|
const databaseUrl = await pullDatabaseUrl(runner, cwd, options.env);
|
|
24023
|
-
if (!databaseUrl) return { failure: "env-pull-empty" };
|
|
24024
|
-
return { databaseUrl };
|
|
24025
|
+
if (!databaseUrl) return { resourceName, failure: "env-pull-empty" };
|
|
24026
|
+
return { databaseUrl, resourceName };
|
|
24025
24027
|
}
|
|
24026
24028
|
async function pullDatabaseUrl(runner, cwd, env) {
|
|
24027
24029
|
const tmpDir = fs34.mkdtempSync(path45.join(os.tmpdir(), "betterstart-vercel-"));
|
|
@@ -24113,23 +24115,19 @@ async function runVercelNeonFlow(options) {
|
|
|
24113
24115
|
if (auth.username) {
|
|
24114
24116
|
p13.log.success(`Signed in to Vercel as ${pc4.cyan(auth.username)}`);
|
|
24115
24117
|
}
|
|
24116
|
-
const
|
|
24117
|
-
|
|
24118
|
+
const projectSpinner = p13.spinner();
|
|
24119
|
+
projectSpinner.start(`Creating Vercel project ${pc4.cyan(options.projectName)}`);
|
|
24118
24120
|
const project2 = await createVercelProject(runner, options.cwd, options.projectName, env);
|
|
24119
|
-
|
|
24120
|
-
|
|
24121
|
-
|
|
24122
|
-
|
|
24123
|
-
neon = await provisionNeonInteractive(runner, options.cwd, { plan: options.plan, env });
|
|
24124
|
-
return finishInteractive(neon, project2.name, project2.projectId);
|
|
24125
|
-
}
|
|
24121
|
+
projectSpinner.stop(
|
|
24122
|
+
project2.linked ? `Linked Vercel project ${pc4.cyan(project2.name)}` : `Using Vercel project ${pc4.cyan(project2.name)}`
|
|
24123
|
+
);
|
|
24124
|
+
const neon = await provisionNeonForMode(runner, options);
|
|
24126
24125
|
if (neon.failure || !neon.databaseUrl) {
|
|
24127
|
-
|
|
24128
|
-
|
|
24129
|
-
);
|
|
24126
|
+
p13.log.warn(neonFailureMessage(neon.failure));
|
|
24127
|
+
if (neon.detail) p13.log.message(pc4.dim(neon.detail));
|
|
24130
24128
|
return { ok: false };
|
|
24131
24129
|
}
|
|
24132
|
-
|
|
24130
|
+
p13.log.success(`Provisioned Neon Postgres for ${pc4.cyan(project2.name)}`);
|
|
24133
24131
|
return {
|
|
24134
24132
|
ok: true,
|
|
24135
24133
|
databaseUrl: neon.databaseUrl,
|
|
@@ -24143,18 +24141,15 @@ async function runVercelNeonFlow(options) {
|
|
|
24143
24141
|
return { ok: false };
|
|
24144
24142
|
}
|
|
24145
24143
|
}
|
|
24146
|
-
function
|
|
24147
|
-
|
|
24148
|
-
|
|
24149
|
-
|
|
24150
|
-
|
|
24151
|
-
|
|
24152
|
-
|
|
24153
|
-
neonResourceName: neon.resourceName
|
|
24154
|
-
};
|
|
24144
|
+
function provisionNeonForMode(runner, options) {
|
|
24145
|
+
const opts = { plan: options.plan, env: options.env };
|
|
24146
|
+
if (options.interactive) {
|
|
24147
|
+
p13.log.info(
|
|
24148
|
+
`Create your Neon database in the Vercel prompts below ${pc4.dim("(the Free plan is recommended).")}`
|
|
24149
|
+
);
|
|
24150
|
+
return provisionNeonInteractive(runner, options.cwd, opts);
|
|
24155
24151
|
}
|
|
24156
|
-
|
|
24157
|
-
return { ok: false };
|
|
24152
|
+
return provisionNeon(runner, options.cwd, opts);
|
|
24158
24153
|
}
|
|
24159
24154
|
function authFailureMessage(reason) {
|
|
24160
24155
|
switch (reason) {
|
|
@@ -24170,6 +24165,20 @@ function authFailureMessage(reason) {
|
|
|
24170
24165
|
return "Could not sign in to Vercel.";
|
|
24171
24166
|
}
|
|
24172
24167
|
}
|
|
24168
|
+
function neonFailureMessage(reason) {
|
|
24169
|
+
switch (reason) {
|
|
24170
|
+
case "terms-required":
|
|
24171
|
+
return "Provisioning needs the Neon marketplace terms accepted \u2014 falling back to manual entry.";
|
|
24172
|
+
case "claim-required":
|
|
24173
|
+
return "The Neon resource needs to be claimed \u2014 falling back to manual entry.";
|
|
24174
|
+
case "env-pull-empty":
|
|
24175
|
+
return "Provisioned Neon, but no DATABASE_URL came back \u2014 falling back to manual entry.";
|
|
24176
|
+
case "timeout":
|
|
24177
|
+
return "Neon provisioning timed out \u2014 falling back to manual entry.";
|
|
24178
|
+
default:
|
|
24179
|
+
return "Neon provisioning did not complete \u2014 falling back to manual entry.";
|
|
24180
|
+
}
|
|
24181
|
+
}
|
|
24173
24182
|
|
|
24174
24183
|
// adapters/next/commands/init.ts
|
|
24175
24184
|
import pc5 from "picocolors";
|