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.
Files changed (2) hide show
  1. package/dist/index.js +24 -21
  2. 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
- return apiFetch("/api/cli/teams");
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
- const teams = await getTeams().catch(() => []);
612
- if (teams.length === 0) {
613
- teamId = creds.teamId;
614
- teamName = creds.teamName;
615
- } else if (teams.length === 1) {
616
- teamId = teams[0].teamId;
617
- teamName = teams[0].name;
618
- } else {
619
- const { default: inquirer2 } = await import("inquirer");
620
- const { chosen } = await inquirer2.prompt([{
621
- type: "list",
622
- name: "chosen",
623
- message: "Which team?",
624
- default: creds.teamId,
625
- choices: teams.map((t) => ({ name: t.name, value: t.teamId }))
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."));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Dev tunnel CLI for APIblaze — route localhost projects through Cloudflare tunnels",
5
5
  "keywords": [
6
6
  "apiblaze",