apiblaze 0.19.2 → 0.19.4

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 +42 -17
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -933,7 +933,7 @@ var import_commander = require("commander");
933
933
  var import_chalk44 = __toESM(require("chalk"));
934
934
 
935
935
  // package.json
936
- var version = "0.19.2";
936
+ var version = "0.19.4";
937
937
 
938
938
  // src/index.ts
939
939
  init_types();
@@ -1020,9 +1020,11 @@ async function runLogin() {
1020
1020
  let teamName;
1021
1021
  const linked = await resolveLinkedTeam({
1022
1022
  preferredId: defaultTeamId ?? void 0,
1023
- interactive: !!process.stdin.isTTY,
1024
- // >1 team ASK (JWT default is just the cursor). One team link silently.
1025
- promptWhenMultiple: true
1023
+ interactive: !!process.stdin.isTTY
1024
+ // Accept the account's default team silently login stays a single smooth
1025
+ // step. Switching teams is a separate, deliberate act (`apiblaze team`), not
1026
+ // a prompt forced on every login. We still prompt only when the default team
1027
+ // is gone (deleted) and there's a real choice to relink to.
1026
1028
  });
1027
1029
  if (linked) {
1028
1030
  teamId = linked.teamId;
@@ -1668,7 +1670,22 @@ async function runDev(options) {
1668
1670
  }
1669
1671
  }
1670
1672
  let selectedTargets;
1671
- if (targets.length === 0) {
1673
+ if (options.project) {
1674
+ const want = options.project.toLowerCase();
1675
+ const match = targets.find(
1676
+ (t) => t.projectId?.toLowerCase() === want || t.projectName?.toLowerCase() === want
1677
+ );
1678
+ if (!match) {
1679
+ console.error(import_chalk4.default.red(`No localhost project named "${options.project}" found.`));
1680
+ if (targets.length) {
1681
+ console.error(import_chalk4.default.dim(" Projects pointing at this machine: " + targets.map((t) => t.projectName).join(", ")));
1682
+ } else {
1683
+ console.error(import_chalk4.default.dim(" No projects point at localhost yet \u2014 create one with `apiblaze create --target http://localhost:<port>`."));
1684
+ }
1685
+ process.exit(1);
1686
+ }
1687
+ selectedTargets = [match];
1688
+ } else if (targets.length === 0) {
1672
1689
  const created = await offerAutoCreate(teamId, options.port);
1673
1690
  if (!created) {
1674
1691
  console.log("Set a project's upstream target to localhost or a private IP, then try again.");
@@ -1676,17 +1693,25 @@ async function runDev(options) {
1676
1693
  }
1677
1694
  selectedTargets = [created];
1678
1695
  } else if (targets.length === 1) {
1679
- const { confirmed } = await import_inquirer.default.prompt([{
1680
- type: "confirm",
1681
- name: "confirmed",
1682
- message: `Found 1 project with an internal target \u2014 tunnel "${import_chalk4.default.bold(targets[0].projectName)}" (${targets[0].tenantName})?`,
1683
- default: true
1684
- }]);
1685
- if (!confirmed) {
1686
- console.log("Aborted.");
1687
- process.exit(0);
1696
+ if (options.yes || !process.stdin.isTTY) {
1697
+ selectedTargets = targets;
1698
+ } else {
1699
+ const { confirmed } = await import_inquirer.default.prompt([{
1700
+ type: "confirm",
1701
+ name: "confirmed",
1702
+ message: `Found 1 project with an internal target \u2014 tunnel "${import_chalk4.default.bold(targets[0].projectName)}" (${targets[0].tenantName})?`,
1703
+ default: true
1704
+ }]);
1705
+ if (!confirmed) {
1706
+ console.log("Aborted.");
1707
+ process.exit(0);
1708
+ }
1709
+ selectedTargets = targets;
1688
1710
  }
1689
- selectedTargets = targets;
1711
+ } else if (!process.stdin.isTTY) {
1712
+ console.error(import_chalk4.default.red(`Found ${targets.length} projects pointing at localhost \u2014 pass --project <name> to choose one non-interactively.`));
1713
+ console.error(import_chalk4.default.dim(" " + targets.map((t) => t.projectName).join(", ")));
1714
+ process.exit(1);
1690
1715
  } else {
1691
1716
  const ALL = "__all__";
1692
1717
  const { chosen } = await import_inquirer.default.prompt([{
@@ -7354,14 +7379,14 @@ withSetupOptions(sidecar.command("setup").description("Wire a Next.js app to rou
7354
7379
  sidecar.command("approve").description("Route an origin through APIblaze (creates its proxy)").argument("<origin>", "Origin, e.g. api.stripe.com").option("--team <id|name>", "Team (defaults to active team)").option("--json", "Machine-readable output").action(action((origin, opts) => runOriginsApprove(origin, opts)));
7355
7380
  sidecar.command("deny").description("Dismiss a candidate origin so it stops being suggested").argument("<origin>", "Origin, e.g. sentry.io").option("--team <id|name>", "Team (defaults to active team)").action(action((origin, opts) => runOriginsDeny(origin, opts)));
7356
7381
  sidecar.command("remove").description("Un-route an approved origin (deletes its proxy; the app goes direct again)").argument("<origin>", "Origin, e.g. api.stripe.com").option("--team <id|name>", "Team (defaults to active team)").action(action((origin, opts) => runOriginsRemove(origin, opts)));
7357
- program.command("dev").description("Put your localhost behind a public URL (dev tunnel)").argument("[port]", "Local port to tunnel (positional; overrides --port)").option("-p, --port <number>", "Local port to tunnel", "3000").option("-o, --capture-file <path>", "Stream full request/response traffic to a file (JSON lines)").action(async (port, opts) => {
7382
+ program.command("dev").description("Put your localhost behind a public URL (dev tunnel)").argument("[port]", "Local port to tunnel (positional; overrides --port)").option("-p, --port <number>", "Local port to tunnel", "3000").option("--project <nameOrId>", "Tunnel this specific project (skips the picker \u2014 for scripts)").option("-y, --yes", "Skip confirmation prompts (non-interactive)").option("-o, --capture-file <path>", "Stream full request/response traffic to a file (JSON lines)").action(async (port, opts) => {
7358
7383
  try {
7359
7384
  const resolved = parseInt(port ?? opts.port, 10);
7360
7385
  if (Number.isNaN(resolved)) {
7361
7386
  console.error(import_chalk44.default.red(`Invalid port: ${port ?? opts.port}`));
7362
7387
  process.exit(1);
7363
7388
  }
7364
- await runDev({ port: resolved, captureFile: opts.captureFile });
7389
+ await runDev({ port: resolved, project: opts.project, yes: opts.yes, captureFile: opts.captureFile });
7365
7390
  } catch (err) {
7366
7391
  await printError(err);
7367
7392
  process.exit(1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.19.2",
4
- "description": "APIblaze CLI \u2014 Chat with your APIs, Manage your API keys, users and groups with the APIblaze serverless proxy",
3
+ "version": "0.19.4",
4
+ "description": "APIblaze CLI Chat with your APIs, Manage your API keys, users and groups with the APIblaze serverless proxy",
5
5
  "keywords": [
6
6
  "apiblaze",
7
7
  "dev-tunnel",