@wraps.dev/cli 2.12.2 → 2.12.3

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/cli.js CHANGED
@@ -46,10 +46,6 @@ function isCI() {
46
46
  // Azure Pipelines
47
47
  "CODEBUILD_BUILD_ID",
48
48
  // AWS CodeBuild
49
- "NETLIFY",
50
- // Netlify
51
- "VERCEL",
52
- // Vercel
53
49
  "HEROKU_TEST_RUN_ID",
54
50
  // Heroku CI
55
51
  "BUDDY",
@@ -399,7 +395,9 @@ async function readAuthConfig() {
399
395
  async function saveAuthConfig(config2) {
400
396
  await ensureWrapsDir();
401
397
  const path3 = getConfigPath();
402
- await writeFile2(path3, JSON.stringify(config2, null, 2), "utf-8");
398
+ const existing = await readAuthConfig();
399
+ const merged = existing ? { ...existing, ...config2 } : config2;
400
+ await writeFile2(path3, JSON.stringify(merged, null, 2), "utf-8");
403
401
  await chmod(path3, 384);
404
402
  }
405
403
  async function clearAuthConfig() {
@@ -418,7 +416,13 @@ async function resolveTokenAsync(flags2) {
418
416
  return sync;
419
417
  }
420
418
  const config2 = await readAuthConfig();
421
- return config2?.auth?.token || null;
419
+ if (!config2?.auth?.token) {
420
+ return null;
421
+ }
422
+ if (config2.auth.expiresAt && new Date(config2.auth.expiresAt) <= /* @__PURE__ */ new Date()) {
423
+ return null;
424
+ }
425
+ return config2.auth.token;
422
426
  }
423
427
  var CONFIG_FILE;
424
428
  var init_config = __esm({
@@ -674,24 +678,34 @@ var init_client = __esm({
674
678
  await this.flush();
675
679
  }
676
680
  /**
677
- * Enable telemetry
678
- * Note: Won't override environment variable opt-outs (DO_NOT_TRACK, CI, etc.)
681
+ * Enable telemetry.
682
+ * Returns null if enabled, or a string describing why an env override prevented it.
679
683
  */
680
684
  enable() {
681
685
  this.config.setEnabled(true);
682
- if (process.env.DO_NOT_TRACK === "1" || process.env.DO_NOT_TRACK === "true") {
686
+ const override = this.getEnvOverride();
687
+ if (override) {
683
688
  this.enabled = false;
684
- return;
689
+ return override;
690
+ }
691
+ this.enabled = true;
692
+ return null;
693
+ }
694
+ /**
695
+ * Check if an environment variable is overriding the config.
696
+ * Returns a human-readable reason, or null if no override.
697
+ */
698
+ getEnvOverride() {
699
+ if (process.env.DO_NOT_TRACK === "1" || process.env.DO_NOT_TRACK === "true") {
700
+ return "DO_NOT_TRACK environment variable is set";
685
701
  }
686
702
  if (process.env.WRAPS_TELEMETRY_DISABLED === "1") {
687
- this.enabled = false;
688
- return;
703
+ return "WRAPS_TELEMETRY_DISABLED environment variable is set";
689
704
  }
690
705
  if (isCI()) {
691
- this.enabled = false;
692
- return;
706
+ return "CI environment detected";
693
707
  }
694
- this.enabled = true;
708
+ return null;
695
709
  }
696
710
  /**
697
711
  * Disable telemetry
@@ -8552,7 +8566,7 @@ async function login(options) {
8552
8566
  });
8553
8567
  trackError("DEVICE_AUTH_FAILED", "auth:login", { step: "request_code" });
8554
8568
  clack.log.error("Failed to start device authorization.");
8555
- process.exit(1);
8569
+ throw new Error("Failed to start device authorization.");
8556
8570
  }
8557
8571
  const {
8558
8572
  device_code,
@@ -8603,6 +8617,10 @@ async function login(options) {
8603
8617
  clack.log.info(`Organization: ${pc2.cyan(organizations[0].name)}`);
8604
8618
  } else if (organizations.length > 1) {
8605
8619
  clack.log.info(`${organizations.length} organizations available`);
8620
+ } else {
8621
+ clack.log.info(
8622
+ `No organizations found. Create one at ${pc2.underline(`${baseURL}/onboarding`)} and run ${pc2.cyan("wraps auth login")} again.`
8623
+ );
8606
8624
  }
8607
8625
  if (options.json) {
8608
8626
  console.log(
@@ -8616,7 +8634,8 @@ async function login(options) {
8616
8634
  return;
8617
8635
  }
8618
8636
  if (tokenError) {
8619
- const errorCode = tokenError.error || tokenError.code;
8637
+ const err = tokenError;
8638
+ const errorCode = err.error || err.code;
8620
8639
  if (errorCode === "authorization_pending") {
8621
8640
  continue;
8622
8641
  }
@@ -8633,7 +8652,7 @@ async function login(options) {
8633
8652
  trackError("ACCESS_DENIED", "auth:login", { step: "poll_token" });
8634
8653
  spinner9.stop("Denied.");
8635
8654
  clack.log.error("Authorization was denied.");
8636
- process.exit(1);
8655
+ throw new Error("Authorization was denied.");
8637
8656
  }
8638
8657
  if (errorCode === "expired_token") {
8639
8658
  break;
@@ -8648,7 +8667,7 @@ async function login(options) {
8648
8667
  trackError("DEVICE_CODE_EXPIRED", "auth:login", { step: "poll_token" });
8649
8668
  spinner9.stop("Expired.");
8650
8669
  clack.log.error("Device code expired. Run `wraps auth login` to try again.");
8651
- process.exit(1);
8670
+ throw new Error("Device code expired.");
8652
8671
  }
8653
8672
 
8654
8673
  // src/commands/auth/logout.ts
@@ -33088,12 +33107,21 @@ import * as clack47 from "@clack/prompts";
33088
33107
  import pc50 from "picocolors";
33089
33108
  async function telemetryEnable() {
33090
33109
  const client = getTelemetryClient();
33091
- client.enable();
33092
- clack47.log.success(pc50.green("Telemetry enabled"));
33093
- console.log(` Config: ${pc50.dim(client.getConfigPath())}`);
33094
- console.log(`
33110
+ const override = client.enable();
33111
+ if (override) {
33112
+ clack47.log.warn(
33113
+ "Telemetry enabled in config, but overridden by environment"
33114
+ );
33115
+ console.log(` Reason: ${pc50.yellow(override)}`);
33116
+ console.log(` Config: ${pc50.dim(client.getConfigPath())}`);
33117
+ console.log();
33118
+ } else {
33119
+ clack47.log.success(pc50.green("Telemetry enabled"));
33120
+ console.log(` Config: ${pc50.dim(client.getConfigPath())}`);
33121
+ console.log(`
33095
33122
  ${pc50.dim("Thank you for helping improve Wraps!")}
33096
33123
  `);
33124
+ }
33097
33125
  }
33098
33126
  async function telemetryDisable() {
33099
33127
  const client = getTelemetryClient();
@@ -33109,9 +33137,13 @@ async function telemetryDisable() {
33109
33137
  async function telemetryStatus() {
33110
33138
  const client = getTelemetryClient();
33111
33139
  clack47.intro(pc50.bold("Telemetry Status"));
33140
+ const override = client.getEnvOverride();
33112
33141
  const status2 = client.isEnabled() ? pc50.green("Enabled") : pc50.red("Disabled");
33113
33142
  console.log();
33114
33143
  console.log(` ${pc50.bold("Status:")} ${status2}`);
33144
+ if (!client.isEnabled() && override) {
33145
+ console.log(` ${pc50.bold("Reason:")} ${pc50.yellow(override)}`);
33146
+ }
33115
33147
  console.log(` ${pc50.bold("Config file:")} ${pc50.dim(client.getConfigPath())}`);
33116
33148
  if (client.isEnabled()) {
33117
33149
  console.log();
@@ -34268,12 +34300,6 @@ Available commands: ${pc51.cyan("login")}, ${pc51.cyan("status")}, ${pc51.cyan("
34268
34300
  );
34269
34301
  throw new Error(`Unknown auth command: ${subCommand || "(none)"}`);
34270
34302
  }
34271
- const authDuration = Date.now() - startTime;
34272
- const authCommandName = `auth:${subCommand}`;
34273
- trackCommand(authCommandName, {
34274
- success: true,
34275
- duration_ms: authDuration
34276
- });
34277
34303
  return;
34278
34304
  }
34279
34305
  if (primaryCommand === "aws" && subCommand) {