@floomhq/skills 0.2.3 → 0.2.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.
package/dist/index.js CHANGED
@@ -2360,8 +2360,8 @@ import { join as join3 } from "node:path";
2360
2360
  import { mkdir as mkdir2, readFile as readFile3, writeFile, chmod } from "node:fs/promises";
2361
2361
  var CONFIG_DIR = join3(homedir2(), ".floom");
2362
2362
  var AUTH_FILE = join3(CONFIG_DIR, "auth.json");
2363
- var DEFAULT_APP_URL = "https://floom.dev";
2364
- var DEFAULT_API_URL = "https://floom-v0.vercel.app/api/v1";
2363
+ var DEFAULT_APP_URL = "https://skills.floom.dev";
2364
+ var DEFAULT_API_URL = "https://skills.floom.dev/api/v1";
2365
2365
  async function ensureDir() {
2366
2366
  await mkdir2(CONFIG_DIR, { recursive: true, mode: 448 });
2367
2367
  }
@@ -2407,7 +2407,7 @@ function getApiBaseUrls(preferred) {
2407
2407
  }
2408
2408
 
2409
2409
  // src/version.ts
2410
- var VERSION = "0.2.3";
2410
+ var VERSION = "0.2.4";
2411
2411
 
2412
2412
  // src/api-client.ts
2413
2413
  var DEFAULT_TIMEOUT_MS = 2e4;
@@ -2431,7 +2431,8 @@ async function fetchWithTimeout(url, init = {}) {
2431
2431
  }
2432
2432
  async function api(path, opts = {}) {
2433
2433
  const auth = await readAuth();
2434
- if (opts.authRequired && !auth) {
2434
+ const token = process.env.FLOOM_API_TOKEN?.trim() || auth?.token;
2435
+ if (opts.authRequired && !token) {
2435
2436
  throw new FloomError("AUTH_REQUIRED", "Not logged in. Run: floom login");
2436
2437
  }
2437
2438
  let lastError = null;
@@ -2448,7 +2449,7 @@ async function api(path, opts = {}) {
2448
2449
  "User-Agent": `floom-cli/${VERSION}`,
2449
2450
  "x-floom-cli-version": VERSION
2450
2451
  };
2451
- if (auth) headers.Authorization = `Bearer ${auth.token}`;
2452
+ if (token) headers.Authorization = `Bearer ${token}`;
2452
2453
  let res;
2453
2454
  try {
2454
2455
  res = await fetchWithTimeout(url.toString(), {
@@ -2594,22 +2595,25 @@ async function logoutCommand() {
2594
2595
  // src/commands/whoami.ts
2595
2596
  async function whoamiCommand() {
2596
2597
  const auth = await readAuth();
2597
- if (!auth) {
2598
+ const envToken = process.env.FLOOM_API_TOKEN?.trim();
2599
+ if (!auth && !envToken) {
2598
2600
  log.info("Not logged in. Run: floom login");
2599
2601
  return;
2600
2602
  }
2603
+ let me;
2601
2604
  try {
2602
- await api("/me", { authRequired: true });
2605
+ me = await api("/me", { authRequired: true });
2603
2606
  } catch (e) {
2604
- log.err(`Stored login is not accepted by the Floom API: ${e.message}`);
2607
+ log.err(`Login is not accepted by the Floom API: ${e.message}`);
2605
2608
  log.info("Run: floom login");
2606
2609
  process.exitCode = 1;
2607
2610
  return;
2608
2611
  }
2609
2612
  log.heading("Logged in as:");
2610
- log.kv("handle", `@${auth.handle}`);
2611
- log.kv("email", auth.email);
2612
- log.kv("api url", auth.apiUrl);
2613
+ log.kv("handle", `@${me.user.handle}`);
2614
+ log.kv("email", me.user.email);
2615
+ log.kv("api url", process.env.FLOOM_API_URL ?? auth?.apiUrl ?? "default");
2616
+ if (envToken) log.kv("auth", "FLOOM_API_TOKEN");
2613
2617
  }
2614
2618
 
2615
2619
  // src/commands/init.ts