apiblaze 0.1.5 → 0.1.6
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/index.js +24 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -119,7 +119,12 @@ async function apiFetch(path3, options = {}) {
|
|
|
119
119
|
return res.json();
|
|
120
120
|
}
|
|
121
121
|
async function getTeams() {
|
|
122
|
-
|
|
122
|
+
const res = await apiFetch("/api/cli/teams");
|
|
123
|
+
const raw = Array.isArray(res) ? res : res?.teams ?? res?.data ?? [];
|
|
124
|
+
return raw.map((t) => {
|
|
125
|
+
const teamId = t.teamId ?? t.team_id;
|
|
126
|
+
return { teamId: teamId ?? "", name: t.name ?? teamId ?? "" };
|
|
127
|
+
}).filter((t) => t.teamId);
|
|
123
128
|
}
|
|
124
129
|
async function getLocalhostTargets(teamId) {
|
|
125
130
|
return apiFetch(`/api/cli/localhost-targets?team_id=${encodeURIComponent(teamId)}`);
|
|
@@ -606,26 +611,24 @@ async function runProjects() {
|
|
|
606
611
|
`${import_chalk4.default.cyan("\u2192")} Logged in as ${import_chalk4.default.bold("@" + creds.githubHandle)}` + (creds.apiblazeUserId ? import_chalk4.default.dim(` (${creds.apiblazeUserId})`) : "")
|
|
607
612
|
);
|
|
608
613
|
}
|
|
609
|
-
let teamId;
|
|
610
|
-
let teamName;
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
teamId = chosen;
|
|
628
|
-
teamName = teams.find((t) => t.teamId === chosen)?.name;
|
|
614
|
+
let teamId = creds.teamId;
|
|
615
|
+
let teamName = creds.teamName;
|
|
616
|
+
if (!teamId) {
|
|
617
|
+
const teams = await getTeams().catch(() => []);
|
|
618
|
+
if (teams.length === 1) {
|
|
619
|
+
teamId = teams[0].teamId;
|
|
620
|
+
teamName = teams[0].name;
|
|
621
|
+
} else if (teams.length > 1) {
|
|
622
|
+
const { default: inquirer2 } = await import("inquirer");
|
|
623
|
+
const { chosen } = await inquirer2.prompt([{
|
|
624
|
+
type: "list",
|
|
625
|
+
name: "chosen",
|
|
626
|
+
message: "Which team do you want to use?",
|
|
627
|
+
choices: teams.map((t) => ({ name: t.name, value: t.teamId }))
|
|
628
|
+
}]);
|
|
629
|
+
teamId = chosen;
|
|
630
|
+
teamName = teams.find((t) => t.teamId === chosen)?.name;
|
|
631
|
+
}
|
|
629
632
|
}
|
|
630
633
|
if (!teamId) {
|
|
631
634
|
console.error(import_chalk4.default.red("No team found. Run `apiblaze login` to set up your team."));
|