betterstart-cli 0.0.81 → 0.0.83
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 +41 -2
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -22588,7 +22588,7 @@ import * as p13 from "@clack/prompts";
|
|
|
22588
22588
|
async function promptProject(defaultName) {
|
|
22589
22589
|
const projectName = await p13.text({
|
|
22590
22590
|
message: "What is your project named?",
|
|
22591
|
-
placeholder: defaultName ?? "(
|
|
22591
|
+
placeholder: defaultName ?? "(Press Enter to use default)",
|
|
22592
22592
|
defaultValue: defaultName ?? ".",
|
|
22593
22593
|
validate: (value) => {
|
|
22594
22594
|
if (!value?.trim()) return void 0;
|
|
@@ -25961,6 +25961,14 @@ function versionedVercelProjectName(base, attempt) {
|
|
|
25961
25961
|
}
|
|
25962
25962
|
async function createVercelProject(runner, cwd, name, options = {}) {
|
|
25963
25963
|
const base = sanitizeVercelProjectName(name);
|
|
25964
|
+
const scoped = await createAndLinkProject(runner, cwd, base, options);
|
|
25965
|
+
if (scoped.linked || !options.scope) return scoped;
|
|
25966
|
+
return createAndLinkProject(runner, cwd, base, {
|
|
25967
|
+
env: options.env,
|
|
25968
|
+
preferredScope: options.scope
|
|
25969
|
+
});
|
|
25970
|
+
}
|
|
25971
|
+
async function createAndLinkProject(runner, cwd, base, options) {
|
|
25964
25972
|
let projectName = base;
|
|
25965
25973
|
for (let attempt = 1; attempt <= MAX_NAME_ATTEMPTS; attempt++) {
|
|
25966
25974
|
const candidate = versionedVercelProjectName(base, attempt);
|
|
@@ -25990,7 +25998,7 @@ ${add.stderr}`)) continue;
|
|
|
25990
25998
|
fs37.rmSync(path48.join(cwd, ".vercel", "project.json"), { force: true });
|
|
25991
25999
|
} catch {
|
|
25992
26000
|
}
|
|
25993
|
-
|
|
26001
|
+
let link = await runVercel(
|
|
25994
26002
|
runner,
|
|
25995
26003
|
withScope(["link", "--project", projectName, "--yes"], options.scope),
|
|
25996
26004
|
{
|
|
@@ -25999,6 +26007,24 @@ ${add.stderr}`)) continue;
|
|
|
25999
26007
|
env: options.env
|
|
26000
26008
|
}
|
|
26001
26009
|
);
|
|
26010
|
+
if (!link.success) {
|
|
26011
|
+
const fallbackScope = resolveMissingScopeChoice(
|
|
26012
|
+
`${link.stdout}
|
|
26013
|
+
${link.stderr}`,
|
|
26014
|
+
options.scope ?? options.preferredScope
|
|
26015
|
+
);
|
|
26016
|
+
if (fallbackScope && fallbackScope !== options.scope) {
|
|
26017
|
+
link = await runVercel(
|
|
26018
|
+
runner,
|
|
26019
|
+
withScope(["link", "--project", projectName, "--yes"], fallbackScope),
|
|
26020
|
+
{
|
|
26021
|
+
cwd,
|
|
26022
|
+
mode: "capture",
|
|
26023
|
+
env: options.env
|
|
26024
|
+
}
|
|
26025
|
+
);
|
|
26026
|
+
}
|
|
26027
|
+
}
|
|
26002
26028
|
return {
|
|
26003
26029
|
name: projectName,
|
|
26004
26030
|
linked: link.success,
|
|
@@ -26008,6 +26034,19 @@ ${add.stderr}`)) continue;
|
|
|
26008
26034
|
function withScope(args, scope) {
|
|
26009
26035
|
return scope ? [...args, "--scope", scope] : args;
|
|
26010
26036
|
}
|
|
26037
|
+
function resolveMissingScopeChoice(output, preferred) {
|
|
26038
|
+
if (!/missing_scope/.test(output)) return void 0;
|
|
26039
|
+
const payload = parseVercelJson(output);
|
|
26040
|
+
if (payload?.reason !== "missing_scope") return void 0;
|
|
26041
|
+
const names = (payload.choices ?? []).map((choice) => choice.name).filter((name) => typeof name === "string" && name.length > 0);
|
|
26042
|
+
if (names.length === 0) return void 0;
|
|
26043
|
+
if (names.length === 1) return names[0];
|
|
26044
|
+
if (preferred) {
|
|
26045
|
+
const match = names.find((name) => name === preferred || name.startsWith(preferred));
|
|
26046
|
+
if (match) return match;
|
|
26047
|
+
}
|
|
26048
|
+
return names[0];
|
|
26049
|
+
}
|
|
26011
26050
|
function readLinkedProjectId(cwd) {
|
|
26012
26051
|
return readLinkedProjectJson(cwd)?.projectId;
|
|
26013
26052
|
}
|