betterstart-cli 0.0.50 → 0.0.52
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 +63 -25
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -24167,16 +24167,30 @@ function runVercel(runner, args, options) {
|
|
|
24167
24167
|
let stdout = "";
|
|
24168
24168
|
let stderr = "";
|
|
24169
24169
|
let timedOut = false;
|
|
24170
|
+
const onOutputLine = options.onOutputLine;
|
|
24171
|
+
const createOutputObserver = () => {
|
|
24172
|
+
if (!onOutputLine) return void 0;
|
|
24173
|
+
return createFilteredLineForwarder(
|
|
24174
|
+
(line) => line.length > 0,
|
|
24175
|
+
(text7) => onOutputLine(stripVTControlCharacters2(text7).trim())
|
|
24176
|
+
);
|
|
24177
|
+
};
|
|
24178
|
+
const stdoutObserver = createOutputObserver();
|
|
24179
|
+
const stderrObserver = createOutputObserver();
|
|
24170
24180
|
if (options.mode === "capture" && options.stdinInput !== void 0) {
|
|
24171
24181
|
child.stdin?.write(options.stdinInput);
|
|
24172
24182
|
child.stdin?.end();
|
|
24173
24183
|
}
|
|
24174
24184
|
if (options.mode === "capture") {
|
|
24175
24185
|
child.stdout?.on("data", (chunk) => {
|
|
24176
|
-
|
|
24186
|
+
const text7 = chunk.toString();
|
|
24187
|
+
stdout += text7;
|
|
24188
|
+
stdoutObserver?.push(text7);
|
|
24177
24189
|
});
|
|
24178
24190
|
child.stderr?.on("data", (chunk) => {
|
|
24179
|
-
|
|
24191
|
+
const text7 = chunk.toString();
|
|
24192
|
+
stderr += text7;
|
|
24193
|
+
stderrObserver?.push(text7);
|
|
24180
24194
|
});
|
|
24181
24195
|
} else if (options.mode === "stream") {
|
|
24182
24196
|
const shouldShow = options.streamLineFilter ?? (() => true);
|
|
@@ -24192,11 +24206,13 @@ function runVercel(runner, args, options) {
|
|
|
24192
24206
|
const text7 = chunk.toString();
|
|
24193
24207
|
stdout += text7;
|
|
24194
24208
|
outForwarder.push(text7);
|
|
24209
|
+
stdoutObserver?.push(text7);
|
|
24195
24210
|
});
|
|
24196
24211
|
child.stderr?.on("data", (chunk) => {
|
|
24197
24212
|
const text7 = chunk.toString();
|
|
24198
24213
|
stderr += text7;
|
|
24199
24214
|
errForwarder.push(text7);
|
|
24215
|
+
stderrObserver?.push(text7);
|
|
24200
24216
|
});
|
|
24201
24217
|
child.on("close", () => {
|
|
24202
24218
|
outForwarder.flush();
|
|
@@ -24209,6 +24225,8 @@ function runVercel(runner, args, options) {
|
|
|
24209
24225
|
}, timeoutMs);
|
|
24210
24226
|
child.on("close", (code, signal) => {
|
|
24211
24227
|
clearTimeout(timeout);
|
|
24228
|
+
stdoutObserver?.flush();
|
|
24229
|
+
stderrObserver?.flush();
|
|
24212
24230
|
if (timedOut) {
|
|
24213
24231
|
resolve({
|
|
24214
24232
|
success: false,
|
|
@@ -24233,6 +24251,8 @@ function runVercel(runner, args, options) {
|
|
|
24233
24251
|
});
|
|
24234
24252
|
child.on("error", (err) => {
|
|
24235
24253
|
clearTimeout(timeout);
|
|
24254
|
+
stdoutObserver?.flush();
|
|
24255
|
+
stderrObserver?.flush();
|
|
24236
24256
|
resolve({
|
|
24237
24257
|
success: false,
|
|
24238
24258
|
code: null,
|
|
@@ -24406,23 +24426,27 @@ function versionedVercelProjectName(base, attempt) {
|
|
|
24406
24426
|
const suffix = `-v${attempt}`;
|
|
24407
24427
|
return `${base.slice(0, 100 - suffix.length)}${suffix}`;
|
|
24408
24428
|
}
|
|
24409
|
-
async function createVercelProject(runner, cwd, name,
|
|
24429
|
+
async function createVercelProject(runner, cwd, name, options = {}) {
|
|
24410
24430
|
const base = sanitizeVercelProjectName(name);
|
|
24411
24431
|
let projectName = base;
|
|
24412
24432
|
for (let attempt = 1; attempt <= MAX_NAME_ATTEMPTS; attempt++) {
|
|
24413
24433
|
const candidate = versionedVercelProjectName(base, attempt);
|
|
24414
24434
|
projectName = candidate;
|
|
24415
|
-
const inspect = await runVercel(
|
|
24416
|
-
|
|
24417
|
-
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24435
|
+
const inspect = await runVercel(
|
|
24436
|
+
runner,
|
|
24437
|
+
withScope(["project", "inspect", candidate], options.scope),
|
|
24438
|
+
{
|
|
24439
|
+
cwd,
|
|
24440
|
+
mode: "capture",
|
|
24441
|
+
timeoutMs: INSPECT_TIMEOUT_MS,
|
|
24442
|
+
env: options.env
|
|
24443
|
+
}
|
|
24444
|
+
);
|
|
24421
24445
|
if (inspect.success) continue;
|
|
24422
|
-
const add = await runVercel(runner, ["projects", "add", candidate], {
|
|
24446
|
+
const add = await runVercel(runner, withScope(["projects", "add", candidate], options.scope), {
|
|
24423
24447
|
cwd,
|
|
24424
24448
|
mode: "capture",
|
|
24425
|
-
env
|
|
24449
|
+
env: options.env
|
|
24426
24450
|
});
|
|
24427
24451
|
if (add.success) break;
|
|
24428
24452
|
if (/already exists/i.test(`${add.stdout}
|
|
@@ -24433,17 +24457,24 @@ ${add.stderr}`)) continue;
|
|
|
24433
24457
|
fs35.rmSync(path46.join(cwd, ".vercel", "project.json"), { force: true });
|
|
24434
24458
|
} catch {
|
|
24435
24459
|
}
|
|
24436
|
-
const link = await runVercel(
|
|
24437
|
-
|
|
24438
|
-
|
|
24439
|
-
|
|
24440
|
-
|
|
24460
|
+
const link = await runVercel(
|
|
24461
|
+
runner,
|
|
24462
|
+
withScope(["link", "--project", projectName, "--yes"], options.scope),
|
|
24463
|
+
{
|
|
24464
|
+
cwd,
|
|
24465
|
+
mode: "capture",
|
|
24466
|
+
env: options.env
|
|
24467
|
+
}
|
|
24468
|
+
);
|
|
24441
24469
|
return {
|
|
24442
24470
|
name: projectName,
|
|
24443
24471
|
linked: link.success,
|
|
24444
24472
|
projectId: readLinkedProjectId(cwd)
|
|
24445
24473
|
};
|
|
24446
24474
|
}
|
|
24475
|
+
function withScope(args, scope) {
|
|
24476
|
+
return scope ? [...args, "--scope", scope] : args;
|
|
24477
|
+
}
|
|
24447
24478
|
function readLinkedProjectId(cwd) {
|
|
24448
24479
|
return readLinkedProjectJson(cwd)?.projectId;
|
|
24449
24480
|
}
|
|
@@ -24793,12 +24824,13 @@ function parseDeployedUrl(stdout, stderr) {
|
|
|
24793
24824
|
const fromStdout = stripVTControlCharacters3(stdout).match(/https:\/\/\S+/)?.[0];
|
|
24794
24825
|
return fromStdout;
|
|
24795
24826
|
}
|
|
24796
|
-
async function deployVercelProject(runner, cwd,
|
|
24827
|
+
async function deployVercelProject(runner, cwd, options = {}) {
|
|
24797
24828
|
const deploy = await runVercel(runner, ["deploy", "--prod", "--yes"], {
|
|
24798
24829
|
cwd,
|
|
24799
24830
|
mode: "capture",
|
|
24800
24831
|
timeoutMs: DEPLOY_TIMEOUT_MS,
|
|
24801
|
-
env
|
|
24832
|
+
env: options.env,
|
|
24833
|
+
onOutputLine: options.onLogLine
|
|
24802
24834
|
});
|
|
24803
24835
|
if (deploy.success) {
|
|
24804
24836
|
return { url: parseDeployedUrl(deploy.stdout, deploy.stderr) };
|
|
@@ -24938,7 +24970,7 @@ async function runVercelNeonFlow(options) {
|
|
|
24938
24970
|
p17.log.warn(authFailureMessage(auth.reason));
|
|
24939
24971
|
return { ok: false };
|
|
24940
24972
|
}
|
|
24941
|
-
await ensureLinkedProject(runner, options.cwd, options.projectName, env);
|
|
24973
|
+
await ensureLinkedProject(runner, options.cwd, options.projectName, env, auth.username);
|
|
24942
24974
|
const neon = await provisionNeonForMode(runner, options);
|
|
24943
24975
|
if (neon.failure) {
|
|
24944
24976
|
p17.log.warn(neonFailureMessage(neon.failure));
|
|
@@ -24976,7 +25008,7 @@ async function runVercelBlobFlow(options) {
|
|
|
24976
25008
|
p17.log.warn(authFailureMessage(auth.reason));
|
|
24977
25009
|
return { ok: false };
|
|
24978
25010
|
}
|
|
24979
|
-
await ensureLinkedProject(runner, options.cwd, options.projectName, env);
|
|
25011
|
+
await ensureLinkedProject(runner, options.cwd, options.projectName, env, auth.username);
|
|
24980
25012
|
const blob = await provisionBlobForMode(runner, options);
|
|
24981
25013
|
if (blob.failure || !blob.token) {
|
|
24982
25014
|
p17.log.warn(blobFailureMessage(blob.failure));
|
|
@@ -25011,7 +25043,7 @@ async function runVercelDeployFlow(options) {
|
|
|
25011
25043
|
printManualDeployHint();
|
|
25012
25044
|
return { ok: false };
|
|
25013
25045
|
}
|
|
25014
|
-
await ensureLinkedProject(runner, options.cwd, options.projectName, env);
|
|
25046
|
+
await ensureLinkedProject(runner, options.cwd, options.projectName, env, auth.username);
|
|
25015
25047
|
const envSpinner = spinner2();
|
|
25016
25048
|
envSpinner.start("Syncing environment variables to Vercel");
|
|
25017
25049
|
const sync = await syncVercelProductionEnv(runner, options.cwd, env);
|
|
@@ -25037,10 +25069,13 @@ async function runVercelDeployFlow(options) {
|
|
|
25037
25069
|
);
|
|
25038
25070
|
}
|
|
25039
25071
|
const deploySpinner = spinner2();
|
|
25040
|
-
deploySpinner.start("Deploying to Vercel
|
|
25072
|
+
deploySpinner.start("Deploying to Vercel");
|
|
25041
25073
|
let deploy;
|
|
25042
25074
|
try {
|
|
25043
|
-
deploy = await deployVercelProject(runner, options.cwd,
|
|
25075
|
+
deploy = await deployVercelProject(runner, options.cwd, {
|
|
25076
|
+
env,
|
|
25077
|
+
onLogLine: (line) => deploySpinner.message(line)
|
|
25078
|
+
});
|
|
25044
25079
|
} finally {
|
|
25045
25080
|
packageGuard.restore();
|
|
25046
25081
|
}
|
|
@@ -25065,12 +25100,15 @@ async function runVercelDeployFlow(options) {
|
|
|
25065
25100
|
function printManualDeployHint() {
|
|
25066
25101
|
p17.log.info(`You can deploy manually: ${pc6.cyan("vercel deploy --prod")}`);
|
|
25067
25102
|
}
|
|
25068
|
-
async function ensureLinkedProject(runner, cwd, projectName, env) {
|
|
25103
|
+
async function ensureLinkedProject(runner, cwd, projectName, env, scope) {
|
|
25069
25104
|
if (readLinkedProjectId(cwd)) return;
|
|
25070
25105
|
const projectSpinner = spinner2();
|
|
25071
25106
|
projectSpinner.start(`Creating a Vercel project ${pc6.cyan(projectName)}`);
|
|
25072
|
-
await createVercelProject(runner, cwd, projectName, env);
|
|
25107
|
+
const project2 = await createVercelProject(runner, cwd, projectName, { env, scope });
|
|
25073
25108
|
projectSpinner.clear();
|
|
25109
|
+
if (!project2.linked || !project2.projectId) {
|
|
25110
|
+
throw new Error(`Could not link Vercel project ${project2.name} to this directory.`);
|
|
25111
|
+
}
|
|
25074
25112
|
}
|
|
25075
25113
|
async function pullNeonDatabaseUrl(runner, cwd, env) {
|
|
25076
25114
|
const neonSpinner = spinner2();
|