apiblaze 0.1.8 → 0.1.9

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 +53 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -164,7 +164,7 @@ var init_api = __esm({
164
164
 
165
165
  // src/index.ts
166
166
  var import_commander = require("commander");
167
- var import_chalk6 = __toESM(require("chalk"));
167
+ var import_chalk7 = __toESM(require("chalk"));
168
168
  init_types();
169
169
 
170
170
  // src/commands/login.ts
@@ -189,12 +189,13 @@ async function runLogin() {
189
189
  throw new Error(`Failed to start login: ${codeRes.status}`);
190
190
  }
191
191
  const deviceAuth = await codeRes.json();
192
+ const loginUrl = deviceAuth.verification_uri_complete ?? deviceAuth.verification_uri;
192
193
  console.log(`${import_chalk.default.cyan("\u2192")} Open this URL in your browser to confirm login:`);
193
- console.log(` ${import_chalk.default.bold.underline(deviceAuth.verification_uri)}
194
+ console.log(` ${import_chalk.default.bold.underline(loginUrl)}
194
195
  `);
195
196
  console.log(`${import_chalk.default.cyan("\u2192")} Your code: ${import_chalk.default.bold(deviceAuth.user_code)}
196
197
  `);
197
- openBrowser(deviceAuth.verification_uri_complete ?? deviceAuth.verification_uri);
198
+ openBrowser(loginUrl);
198
199
  const spinner = (0, import_ora.default)("Waiting for authorization in browser...").start();
199
200
  let accessToken;
200
201
  let pollInterval = (deviceAuth.interval ?? 5) * 1e3;
@@ -779,6 +780,44 @@ async function runCreate() {
779
780
  console.log();
780
781
  }
781
782
 
783
+ // src/commands/team.ts
784
+ var import_chalk6 = __toESM(require("chalk"));
785
+ init_auth();
786
+ init_api();
787
+ async function runTeam() {
788
+ const creds = loadCredentials();
789
+ if (!creds) {
790
+ console.error(import_chalk6.default.red("Not logged in. Run `apiblaze login` first."));
791
+ process.exit(1);
792
+ }
793
+ const teams = await getTeams().catch(() => []);
794
+ if (teams.length === 0) {
795
+ console.log(import_chalk6.default.yellow("No teams found for your account."));
796
+ return;
797
+ }
798
+ let teamId;
799
+ let teamName;
800
+ if (teams.length === 1) {
801
+ teamId = teams[0].teamId;
802
+ teamName = teams[0].name;
803
+ console.log(`${import_chalk6.default.cyan("\u2192")} You only have one team: ${import_chalk6.default.bold(teamName)}`);
804
+ } else {
805
+ const { default: inquirer2 } = await import("inquirer");
806
+ const { chosen } = await inquirer2.prompt([{
807
+ type: "list",
808
+ name: "chosen",
809
+ message: "Switch to which team?",
810
+ default: creds.teamId,
811
+ choices: teams.map((t) => ({ name: t.name, value: t.teamId }))
812
+ }]);
813
+ teamId = chosen;
814
+ teamName = teams.find((t) => t.teamId === chosen)?.name;
815
+ }
816
+ saveCredentials({ ...creds, teamId, teamName });
817
+ console.log(import_chalk6.default.green(`
818
+ \u2714 Active team: ${import_chalk6.default.bold(teamName ?? teamId)}`));
819
+ }
820
+
782
821
  // src/index.ts
783
822
  var program = new import_commander.Command();
784
823
  program.name("apiblaze").description("APIblaze dev tunnel CLI").version("0.1.0");
@@ -798,6 +837,14 @@ program.command("create").description("Create a new API proxy").action(async ()
798
837
  process.exit(1);
799
838
  }
800
839
  });
840
+ program.command("team").description("Switch the active team").action(async () => {
841
+ try {
842
+ await runTeam();
843
+ } catch (err) {
844
+ printError(err);
845
+ process.exit(1);
846
+ }
847
+ });
801
848
  program.command("projects").description("List the projects in your team").action(async () => {
802
849
  try {
803
850
  await runProjects();
@@ -816,13 +863,13 @@ program.command("dev").description("Start a dev tunnel for your localhost projec
816
863
  });
817
864
  function printError(err) {
818
865
  if (err instanceof ApiError) {
819
- console.error(import_chalk6.default.red(`
866
+ console.error(import_chalk7.default.red(`
820
867
  API error (${err.status}): ${err.message}`));
821
868
  } else if (err instanceof Error) {
822
- console.error(import_chalk6.default.red(`
869
+ console.error(import_chalk7.default.red(`
823
870
  Error: ${err.message}`));
824
871
  } else {
825
- console.error(import_chalk6.default.red("\nUnknown error"));
872
+ console.error(import_chalk7.default.red("\nUnknown error"));
826
873
  }
827
874
  }
828
875
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Dev tunnel CLI for APIblaze — route localhost projects through Cloudflare tunnels",
5
5
  "keywords": [
6
6
  "apiblaze",