apiblaze 0.3.2 → 0.3.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 +28 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ var import_commander = require("commander");
28
28
  var import_chalk15 = __toESM(require("chalk"));
29
29
 
30
30
  // package.json
31
- var version = "0.3.2";
31
+ var version = "0.3.4";
32
32
 
33
33
  // src/types.ts
34
34
  var ApiError = class extends Error {
@@ -757,6 +757,32 @@ function startTunnelClient(opts) {
757
757
  }
758
758
 
759
759
  // src/commands/dev.ts
760
+ async function ensureLoggedIn(interactive) {
761
+ const existing = loadCredentials();
762
+ if (existing && Date.now() < existing.expiresAt) return existing;
763
+ console.log(import_chalk4.default.yellow(existing ? "\nYour APIblaze session has expired." : "\nYou're not logged in to APIblaze."));
764
+ if (!interactive) {
765
+ console.error(import_chalk4.default.red("Run `apiblaze login` first."));
766
+ process.exit(1);
767
+ }
768
+ const { doLogin } = await import_inquirer.default.prompt([{
769
+ type: "confirm",
770
+ name: "doLogin",
771
+ message: "Log in now?",
772
+ default: true
773
+ }]);
774
+ if (!doLogin) {
775
+ console.log(import_chalk4.default.dim("Run `apiblaze login` when you're ready."));
776
+ process.exit(0);
777
+ }
778
+ await runLogin();
779
+ const creds = loadCredentials();
780
+ if (!creds) {
781
+ console.error(import_chalk4.default.red("Login did not complete. Run `apiblaze login` and try again."));
782
+ process.exit(1);
783
+ }
784
+ return creds;
785
+ }
760
786
  async function offerAutoCreate(teamId, port) {
761
787
  if (!process.stdin.isTTY) {
762
788
  console.log(import_chalk4.default.yellow("No projects found with an internal target."));
@@ -828,11 +854,7 @@ async function probeLocalServer(port) {
828
854
  }
829
855
  }
830
856
  async function runDev(options) {
831
- const creds = loadCredentials();
832
- if (!creds) {
833
- console.error(import_chalk4.default.red("Not logged in. Run `apiblaze login` first."));
834
- process.exit(1);
835
- }
857
+ const creds = await ensureLoggedIn(!!process.stdin.isTTY);
836
858
  const linked = await resolveLinkedTeam({ preferredId: creds.teamId, interactive: !!process.stdin.isTTY });
837
859
  if (!linked) {
838
860
  console.error(import_chalk4.default.red("No team available. 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.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Dev tunnel CLI for APIblaze — route localhost projects through your APIblaze endpoints",
5
5
  "keywords": [
6
6
  "apiblaze",