@wraps.dev/cli 2.22.0 → 2.22.1

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.
Binary file
package/dist/cli.js CHANGED
@@ -24129,6 +24129,11 @@ function truncate(str, len) {
24129
24129
  if (!str) return pc30.dim("\u2014");
24130
24130
  return str.length > len ? `${str.slice(0, len - 1)}\u2026` : str;
24131
24131
  }
24132
+ var ANSI_PATTERN = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
24133
+ function padVisible(str, len) {
24134
+ const visibleLength = str.replace(ANSI_PATTERN, "").length;
24135
+ return visibleLength >= len ? str : str + " ".repeat(len - visibleLength);
24136
+ }
24132
24137
  async function emailLogsList(options) {
24133
24138
  const token = await resolveTokenAsync({ token: options.token });
24134
24139
  if (!token) {
@@ -24177,9 +24182,9 @@ async function emailLogsList(options) {
24177
24182
  const header = pc30.bold("Time".padEnd(COL.time)) + " " + pc30.bold("Status".padEnd(COL.status)) + " " + pc30.bold("To".padEnd(COL.to)) + " " + pc30.bold("Subject".padEnd(COL.subject)) + " " + pc30.bold("Message ID");
24178
24183
  const rows = data.logs.map((log59) => {
24179
24184
  const time = relativeTime(log59.createdAt).padEnd(COL.time);
24180
- const status2 = colorStatus(log59.status.padEnd(COL.status));
24181
- const to = truncate(log59.recipient, COL.to).padEnd(COL.to);
24182
- const subject = truncate(log59.subject, COL.subject).padEnd(COL.subject);
24185
+ const status2 = padVisible(colorStatus(log59.status), COL.status);
24186
+ const to = padVisible(truncate(log59.recipient, COL.to), COL.to);
24187
+ const subject = padVisible(truncate(log59.subject, COL.subject), COL.subject);
24183
24188
  const msgId = truncate(log59.messageId, COL.msgId);
24184
24189
  return `${time} ${status2} ${to} ${subject} ${msgId}`;
24185
24190
  });
@@ -32447,8 +32452,7 @@ async function resolveOrganization() {
32447
32452
  return orgs.find((o) => o.id === selected) || null;
32448
32453
  }
32449
32454
  async function registerConnection(params) {
32450
- const baseURL = getApiBaseUrl();
32451
- const response = await fetch(`${baseURL}/v1/connections`, {
32455
+ const response = await fetch(`${params.baseURL}/v1/connections`, {
32452
32456
  method: "POST",
32453
32457
  headers: {
32454
32458
  "Content-Type": "application/json",
@@ -32472,8 +32476,13 @@ async function registerConnection(params) {
32472
32476
  }
32473
32477
  async function authenticatedConnect(token, options) {
32474
32478
  const startTime = Date.now();
32479
+ const selfhosted = options.selfhosted === true;
32475
32480
  if (!isJsonMode()) {
32476
- intro36(pc44.bold("Connect to Wraps Platform"));
32481
+ intro36(
32482
+ pc44.bold(
32483
+ selfhosted ? "Connect to Self-Hosted Wraps" : "Connect to Wraps Platform"
32484
+ )
32485
+ );
32477
32486
  }
32478
32487
  const progress = new DeploymentProgress();
32479
32488
  try {
@@ -32481,12 +32490,27 @@ async function authenticatedConnect(token, options) {
32481
32490
  options,
32482
32491
  progress
32483
32492
  );
32493
+ const selfhostService = metadata.services.selfhost;
32494
+ if (selfhosted && !selfhostService?.apiUrl) {
32495
+ progress.stop();
32496
+ log38.error(
32497
+ `No reachable self-hosted deployment found for account ${pc44.cyan(identity.accountId)} in region ${pc44.cyan(region)}`
32498
+ );
32499
+ console.log(
32500
+ `
32501
+ Run ${pc44.cyan("wraps selfhost deploy")} to finish deploying the self-hosted control plane first.
32502
+ `
32503
+ );
32504
+ process.exit(1);
32505
+ }
32506
+ const apiBaseUrl = selfhosted && selfhostService ? selfhostService.apiUrl : getApiBaseUrl();
32507
+ const dashboardUrl = selfhosted && selfhostService ? selfhostService.config.appUrl : getAppBaseUrl();
32484
32508
  const hasEmail = !!metadata.services.email?.config;
32485
32509
  const org = await resolveOrganization();
32486
32510
  if (!org) {
32487
32511
  progress.stop();
32488
32512
  log38.error(
32489
- "No organizations found. Sign in at https://app.wraps.dev to create one."
32513
+ `No organizations found. Sign in at ${dashboardUrl} to create one.`
32490
32514
  );
32491
32515
  process.exit(1);
32492
32516
  }
@@ -32499,7 +32523,7 @@ async function authenticatedConnect(token, options) {
32499
32523
  if (!isJsonMode()) {
32500
32524
  progress.stop();
32501
32525
  log38.warn(
32502
- "Event tracking must be enabled to connect to the Wraps Platform."
32526
+ selfhosted ? "Event tracking must be enabled to connect to your self-hosted instance." : "Event tracking must be enabled to connect to the Wraps Platform."
32503
32527
  );
32504
32528
  }
32505
32529
  const enableTracking = options.yes || await confirm19({
@@ -32537,8 +32561,9 @@ async function authenticatedConnect(token, options) {
32537
32561
  features.sms = metadata.services.sms.config;
32538
32562
  }
32539
32563
  const result = await progress.execute(
32540
- "Registering connection with Wraps Platform",
32564
+ selfhosted ? "Registering connection with your self-hosted instance" : "Registering connection with Wraps Platform",
32541
32565
  async () => registerConnection({
32566
+ baseURL: apiBaseUrl,
32542
32567
  token,
32543
32568
  orgId: org.id,
32544
32569
  accountId: identity.accountId,
@@ -32595,17 +32620,22 @@ You can try the manual flow: ${pc44.cyan("wraps auth logout")} then ${pc44.cyan(
32595
32620
  region,
32596
32621
  organizationId: org.id,
32597
32622
  connectionId: result.connectionId,
32598
- webhookConnected: true
32623
+ webhookConnected: true,
32624
+ selfhosted
32599
32625
  });
32600
32626
  } else {
32601
- outro24(pc44.green("Platform connection complete!"));
32627
+ outro24(
32628
+ pc44.green(
32629
+ selfhosted ? "Self-hosted connection complete!" : "Platform connection complete!"
32630
+ )
32631
+ );
32602
32632
  console.log();
32603
32633
  console.log(
32604
32634
  pc44.dim(
32605
32635
  "Events from your AWS infrastructure will stream to the dashboard."
32606
32636
  )
32607
32637
  );
32608
- console.log(` Dashboard: ${pc44.cyan("https://app.wraps.dev")}`);
32638
+ console.log(` Dashboard: ${pc44.cyan(dashboardUrl)}`);
32609
32639
  console.log();
32610
32640
  }
32611
32641
  const duration = Date.now() - startTime;
@@ -32635,6 +32665,22 @@ async function connect3(options) {
32635
32665
  await authenticatedConnect(token, options);
32636
32666
  return;
32637
32667
  }
32668
+ if (options.selfhosted) {
32669
+ if (isJsonMode()) {
32670
+ jsonError("platform.connect", {
32671
+ code: "NOT_AUTHENTICATED",
32672
+ message: "Not signed in to the self-hosted instance.",
32673
+ suggestion: "Run `wraps selfhost login` first."
32674
+ });
32675
+ } else {
32676
+ intro36(pc44.bold("Connect to Self-Hosted Wraps"));
32677
+ log38.error("You need to sign in to your self-hosted instance first.");
32678
+ console.log(`
32679
+ Run ${pc44.cyan("wraps selfhost login")} first.
32680
+ `);
32681
+ }
32682
+ process.exit(1);
32683
+ }
32638
32684
  const startTime = Date.now();
32639
32685
  intro36(pc44.bold("Connect to Wraps Platform"));
32640
32686
  const progress = new DeploymentProgress();
@@ -43175,7 +43221,8 @@ Run ${pc67.cyan("wraps --help")} for available commands.
43175
43221
  region: flags.region,
43176
43222
  force: flags.force,
43177
43223
  yes: flags.yes,
43178
- json: flags.json
43224
+ json: flags.json,
43225
+ selfhosted: true
43179
43226
  });
43180
43227
  break;
43181
43228
  default: