commet 0.4.1 → 0.4.2

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 +162 -153
  2. package/package.json +2 -3
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/index.ts
27
- var import_chalk10 = __toESM(require("chalk"));
27
+ var import_chalk11 = __toESM(require("chalk"));
28
28
  var import_commander10 = require("commander");
29
29
 
30
30
  // src/commands/info.ts
@@ -124,9 +124,9 @@ var infoCommand = new import_commander.Command("info").description("Display info
124
124
  });
125
125
 
126
126
  // src/commands/link.ts
127
- var import_chalk2 = __toESM(require("chalk"));
127
+ var import_prompts = require("@inquirer/prompts");
128
+ var import_chalk3 = __toESM(require("chalk"));
128
129
  var import_commander2 = require("commander");
129
- var import_inquirer = __toESM(require("inquirer"));
130
130
  var import_ora = __toESM(require("ora"));
131
131
 
132
132
  // src/utils/api.ts
@@ -165,21 +165,38 @@ async function apiRequest(endpoint, options = {}) {
165
165
  }
166
166
  }
167
167
 
168
+ // src/utils/prompt-theme.ts
169
+ var import_chalk2 = __toESM(require("chalk"));
170
+ var commetColor = import_chalk2.default.hex("#5BC0B0");
171
+ var promptTheme = {
172
+ prefix: commetColor("\u276F"),
173
+ style: {
174
+ answer: commetColor,
175
+ message: import_chalk2.default.bold,
176
+ error: import_chalk2.default.red,
177
+ help: import_chalk2.default.dim,
178
+ highlight: commetColor.bold,
179
+ // Selected option in mint
180
+ description: import_chalk2.default.dim,
181
+ defaultAnswer: import_chalk2.default.dim
182
+ }
183
+ };
184
+
168
185
  // src/commands/link.ts
169
186
  var linkCommand = new import_commander2.Command("link").description("Link this project to a Commet organization").action(async () => {
170
187
  if (!authExists()) {
171
- console.log(import_chalk2.default.red("\u2717 Not authenticated"));
172
- console.log(import_chalk2.default.dim("Run `commet login` first"));
188
+ console.log(import_chalk3.default.red("\u2717 Not authenticated"));
189
+ console.log(import_chalk3.default.dim("Run `commet login` first"));
173
190
  return;
174
191
  }
175
192
  if (projectConfigExists()) {
176
193
  const config = loadProjectConfig();
177
- console.log(import_chalk2.default.yellow("\u26A0 This project is already linked"));
194
+ console.log(import_chalk3.default.yellow("\u26A0 This project is already linked"));
178
195
  console.log(
179
- import_chalk2.default.dim(`Organization: ${config?.orgName} (${config?.environment})`)
196
+ import_chalk3.default.dim(`Organization: ${config?.orgName} (${config?.environment})`)
180
197
  );
181
198
  console.log(
182
- import_chalk2.default.dim(
199
+ import_chalk3.default.dim(
183
200
  "\nRun `commet unlink` first if you want to change the organization"
184
201
  )
185
202
  );
@@ -189,7 +206,7 @@ var linkCommand = new import_commander2.Command("link").description("Link this p
189
206
  const auth = loadAuth();
190
207
  if (!auth) {
191
208
  spinner.fail("Authentication error");
192
- console.log(import_chalk2.default.red("\u2717 Could not load authentication"));
209
+ console.log(import_chalk3.default.red("\u2717 Could not load authentication"));
193
210
  return;
194
211
  }
195
212
  const baseURL = getBaseURL(auth.environment);
@@ -198,88 +215,81 @@ var linkCommand = new import_commander2.Command("link").description("Link this p
198
215
  );
199
216
  if (result.error || !result.data) {
200
217
  spinner.fail("Failed to fetch organizations");
201
- console.error(import_chalk2.default.red("Error:"), result.error);
218
+ console.error(import_chalk3.default.red("Error:"), result.error);
202
219
  return;
203
220
  }
204
221
  const { organizations } = result.data;
205
222
  if (organizations.length === 0) {
206
223
  spinner.stop();
207
- console.log(import_chalk2.default.yellow("\u26A0 No organizations found"));
224
+ console.log(import_chalk3.default.yellow("\u26A0 No organizations found"));
208
225
  console.log(
209
- import_chalk2.default.dim("Create an organization at https://billing.commet.co first")
226
+ import_chalk3.default.dim("Create an organization at https://billing.commet.co first")
210
227
  );
211
228
  return;
212
229
  }
213
230
  spinner.stop();
214
- const answers = await import_inquirer.default.prompt([
215
- {
216
- type: "list",
217
- name: "orgId",
231
+ let orgId;
232
+ try {
233
+ orgId = await (0, import_prompts.select)({
218
234
  message: "Select organization:",
219
235
  choices: organizations.map((org) => ({
220
- name: `${org.name} (${org.slug})`,
236
+ name: `${org.name} ${import_chalk3.default.dim(`(${org.slug})`)}`,
221
237
  value: org.id
222
- }))
223
- },
224
- {
225
- type: "list",
226
- name: "environment",
227
- message: "Select environment:",
228
- choices: [
229
- { name: "Sandbox (Development)", value: "sandbox" },
230
- { name: "Production", value: "production" }
231
- ],
232
- default: "sandbox"
233
- }
234
- ]);
235
- const selectedOrg = organizations.find((org) => org.id === answers.orgId);
238
+ })),
239
+ theme: promptTheme
240
+ });
241
+ } catch (error) {
242
+ console.log(import_chalk3.default.yellow("\n\u26A0 Link cancelled"));
243
+ return;
244
+ }
245
+ const selectedOrg = organizations.find((org) => org.id === orgId);
236
246
  if (!selectedOrg) {
237
- console.log(import_chalk2.default.red("\u2717 Organization not found"));
247
+ console.log(import_chalk3.default.red("\u2717 Organization not found"));
238
248
  return;
239
249
  }
240
250
  saveProjectConfig({
241
251
  orgId: selectedOrg.id,
242
252
  orgName: selectedOrg.name,
243
- environment: answers.environment
253
+ environment: auth.environment
244
254
  });
245
- console.log(import_chalk2.default.green("\n\u2713 Project linked successfully!"));
246
- console.log(import_chalk2.default.dim("\nProject configuration:"));
247
- console.log(import_chalk2.default.dim(` Organization: ${selectedOrg.name}`));
248
- console.log(import_chalk2.default.dim(` Environment: ${answers.environment}`));
255
+ console.log(import_chalk3.default.green("\n\u2713 Project linked successfully!"));
256
+ console.log(import_chalk3.default.dim("\nProject configuration:"));
257
+ console.log(import_chalk3.default.dim(` Organization: ${selectedOrg.name}`));
258
+ console.log(import_chalk3.default.dim(` Environment: ${auth.environment}`));
249
259
  console.log(
250
- import_chalk2.default.dim(
260
+ import_chalk3.default.dim(
251
261
  "\nNext step:\n Run `commet pull` to generate TypeScript types"
252
262
  )
253
263
  );
254
264
  });
255
265
 
256
266
  // src/commands/list.ts
257
- var import_chalk3 = __toESM(require("chalk"));
267
+ var import_chalk4 = __toESM(require("chalk"));
258
268
  var import_commander3 = require("commander");
259
269
  var import_ora2 = __toESM(require("ora"));
260
270
  var listCommand = new import_commander3.Command("list").description("List event types or seat types").argument("<type>", "Type to list (events or seats)").action(async (type) => {
261
271
  if (type !== "events" && type !== "seats") {
262
- console.log(import_chalk3.default.red('\u2717 Invalid type. Use "events" or "seats"'));
263
- console.log(import_chalk3.default.dim("\nExamples:"));
264
- console.log(import_chalk3.default.dim(" commet list events"));
265
- console.log(import_chalk3.default.dim(" commet list seats"));
272
+ console.log(import_chalk4.default.red('\u2717 Invalid type. Use "events" or "seats"'));
273
+ console.log(import_chalk4.default.dim("\nExamples:"));
274
+ console.log(import_chalk4.default.dim(" commet list events"));
275
+ console.log(import_chalk4.default.dim(" commet list seats"));
266
276
  return;
267
277
  }
268
278
  if (!authExists()) {
269
- console.log(import_chalk3.default.red("\u2717 Not authenticated"));
270
- console.log(import_chalk3.default.dim("Run `commet login` first"));
279
+ console.log(import_chalk4.default.red("\u2717 Not authenticated"));
280
+ console.log(import_chalk4.default.dim("Run `commet login` first"));
271
281
  return;
272
282
  }
273
283
  if (!projectConfigExists()) {
274
- console.log(import_chalk3.default.red("\u2717 Project not linked"));
284
+ console.log(import_chalk4.default.red("\u2717 Project not linked"));
275
285
  console.log(
276
- import_chalk3.default.dim("Run `commet link` first to connect to an organization")
286
+ import_chalk4.default.dim("Run `commet link` first to connect to an organization")
277
287
  );
278
288
  return;
279
289
  }
280
290
  const projectConfig = loadProjectConfig();
281
291
  if (!projectConfig) {
282
- console.log(import_chalk3.default.red("\u2717 Invalid project configuration"));
292
+ console.log(import_chalk4.default.red("\u2717 Invalid project configuration"));
283
293
  return;
284
294
  }
285
295
  const spinner = (0, import_ora2.default)(`Fetching ${type}...`).start();
@@ -289,49 +299,49 @@ var listCommand = new import_commander3.Command("list").description("List event
289
299
  );
290
300
  if (result.error || !result.data) {
291
301
  spinner.fail(`Failed to fetch ${type}`);
292
- console.error(import_chalk3.default.red("Error:"), result.error);
302
+ console.error(import_chalk4.default.red("Error:"), result.error);
293
303
  return;
294
304
  }
295
305
  spinner.stop();
296
306
  if (type === "events") {
297
307
  const { eventTypes } = result.data;
298
308
  if (eventTypes.length === 0) {
299
- console.log(import_chalk3.default.yellow("\u26A0 No event types found"));
309
+ console.log(import_chalk4.default.yellow("\u26A0 No event types found"));
300
310
  console.log(
301
- import_chalk3.default.dim("Create event types in your Commet dashboard first")
311
+ import_chalk4.default.dim("Create event types in your Commet dashboard first")
302
312
  );
303
313
  return;
304
314
  }
305
- console.log(import_chalk3.default.bold(`
315
+ console.log(import_chalk4.default.bold(`
306
316
  \u{1F4CA} Event Types (${eventTypes.length})
307
317
  `));
308
318
  for (const eventType of eventTypes) {
309
- console.log(import_chalk3.default.green(`\u2022 ${eventType.code}`));
310
- console.log(import_chalk3.default.dim(` ${eventType.name}`));
319
+ console.log(import_chalk4.default.green(`\u2022 ${eventType.code}`));
320
+ console.log(import_chalk4.default.dim(` ${eventType.name}`));
311
321
  if (eventType.description) {
312
- console.log(import_chalk3.default.dim(` ${eventType.description}`));
322
+ console.log(import_chalk4.default.dim(` ${eventType.description}`));
313
323
  }
314
324
  console.log("");
315
325
  }
316
326
  } else {
317
327
  const { seatTypes } = result.data;
318
328
  if (seatTypes.length === 0) {
319
- console.log(import_chalk3.default.yellow("\u26A0 No seat types found"));
329
+ console.log(import_chalk4.default.yellow("\u26A0 No seat types found"));
320
330
  console.log(
321
- import_chalk3.default.dim("Create seat types in your Commet dashboard first")
331
+ import_chalk4.default.dim("Create seat types in your Commet dashboard first")
322
332
  );
323
333
  return;
324
334
  }
325
- console.log(import_chalk3.default.bold(`
335
+ console.log(import_chalk4.default.bold(`
326
336
  \u{1F4BA} Seat Types (${seatTypes.length})
327
337
  `));
328
338
  for (const seatType of seatTypes) {
329
339
  console.log(
330
- import_chalk3.default.green(`\u2022 ${seatType.code}${seatType.isFree ? " (Free)" : ""}`)
340
+ import_chalk4.default.green(`\u2022 ${seatType.code}${seatType.isFree ? " (Free)" : ""}`)
331
341
  );
332
- console.log(import_chalk3.default.dim(` ${seatType.name}`));
342
+ console.log(import_chalk4.default.dim(` ${seatType.name}`));
333
343
  if (seatType.description) {
334
- console.log(import_chalk3.default.dim(` ${seatType.description}`));
344
+ console.log(import_chalk4.default.dim(` ${seatType.description}`));
335
345
  }
336
346
  console.log("");
337
347
  }
@@ -339,37 +349,43 @@ var listCommand = new import_commander3.Command("list").description("List event
339
349
  });
340
350
 
341
351
  // src/commands/login.ts
342
- var import_chalk4 = __toESM(require("chalk"));
352
+ var import_prompts2 = require("@inquirer/prompts");
353
+ var import_chalk5 = __toESM(require("chalk"));
343
354
  var import_commander4 = require("commander");
344
- var import_inquirer2 = __toESM(require("inquirer"));
345
355
  var import_open = __toESM(require("open"));
346
356
  var import_ora3 = __toESM(require("ora"));
347
357
  var loginCommand = new import_commander4.Command("login").description("Authenticate with Commet").action(async () => {
348
358
  if (authExists()) {
349
359
  const auth = loadAuth();
350
- console.log(import_chalk4.default.yellow("\u26A0 You are already logged in."));
360
+ console.log(import_chalk5.default.yellow("\u26A0 You are already logged in."));
351
361
  console.log(
352
- import_chalk4.default.dim(
362
+ import_chalk5.default.dim(
353
363
  "Run `commet logout` first if you want to login with a different account."
354
364
  )
355
365
  );
356
366
  return;
357
367
  }
358
- const { environment } = await import_inquirer2.default.prompt([
359
- {
360
- type: "list",
361
- name: "environment",
368
+ let environment;
369
+ try {
370
+ environment = await (0, import_prompts2.select)({
362
371
  message: "Select environment to login:",
363
372
  choices: [
364
373
  {
365
- name: "Sandbox (Development) - sandbox.commet.co",
374
+ name: `Sandbox ${import_chalk5.default.dim("(Development)")}`,
366
375
  value: "sandbox"
367
376
  },
368
- { name: "Production - billing.commet.co", value: "production" }
377
+ {
378
+ name: "Production",
379
+ value: "production"
380
+ }
369
381
  ],
370
- default: "sandbox"
371
- }
372
- ]);
382
+ default: "sandbox",
383
+ theme: promptTheme
384
+ });
385
+ } catch (error) {
386
+ console.log(import_chalk5.default.yellow("\n\u26A0 Login cancelled"));
387
+ return;
388
+ }
373
389
  const spinner = (0, import_ora3.default)("Initiating login flow...").start();
374
390
  const baseURL = getBaseURL(environment);
375
391
  try {
@@ -383,7 +399,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
383
399
  });
384
400
  if (!deviceResponse.ok) {
385
401
  spinner.fail("Failed to initiate login");
386
- console.error(import_chalk4.default.red("Error:"), await deviceResponse.text());
402
+ console.error(import_chalk5.default.red("Error:"), await deviceResponse.text());
387
403
  return;
388
404
  }
389
405
  const deviceData = await deviceResponse.json();
@@ -394,16 +410,16 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
394
410
  interval = 5
395
411
  } = deviceData;
396
412
  spinner.stop();
397
- console.log(import_chalk4.default.bold("\n\u{1F510} Commet CLI Login\n"));
413
+ console.log(import_chalk5.default.bold("\n\u{1F510} Commet CLI Login\n"));
398
414
  console.log("Visit the following URL in your browser:");
399
- console.log(import_chalk4.default.cyan.underline(verification_uri_complete));
415
+ console.log(import_chalk5.default.cyan.underline(verification_uri_complete));
400
416
  console.log("\nOr enter this code manually:");
401
- console.log(import_chalk4.default.bold.green(` ${user_code}`));
402
- console.log(import_chalk4.default.dim("\nOpening browser...\n"));
417
+ console.log(import_chalk5.default.bold.green(` ${user_code}`));
418
+ console.log(import_chalk5.default.dim("\nOpening browser...\n"));
403
419
  try {
404
420
  await (0, import_open.default)(verification_uri_complete);
405
421
  } catch {
406
- console.log(import_chalk4.default.yellow("\u26A0 Could not open browser automatically."));
422
+ console.log(import_chalk5.default.yellow("\u26A0 Could not open browser automatically."));
407
423
  }
408
424
  const pollSpinner = (0, import_ora3.default)("Waiting for authorization...").start();
409
425
  let pollingInterval = interval;
@@ -412,7 +428,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
412
428
  const poll = async () => {
413
429
  if (attempts >= maxAttempts) {
414
430
  pollSpinner.fail("Login timed out");
415
- console.log(import_chalk4.default.red("Authorization timed out. Please try again."));
431
+ console.log(import_chalk5.default.red("Authorization timed out. Please try again."));
416
432
  return;
417
433
  }
418
434
  attempts++;
@@ -443,9 +459,9 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
443
459
  }
444
460
  saveAuth(authConfig);
445
461
  pollSpinner.succeed("Successfully logged in!");
446
- console.log(import_chalk4.default.green("\n\u2713 Authentication complete"));
462
+ console.log(import_chalk5.default.green("\n\u2713 Authentication complete"));
447
463
  console.log(
448
- import_chalk4.default.dim(
464
+ import_chalk5.default.dim(
449
465
  "\nNext steps:\n 1. Run `commet link` to connect a project\n 2. Run `commet pull` to generate types\n"
450
466
  )
451
467
  );
@@ -458,12 +474,12 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
458
474
  setTimeout(() => poll(), pollingInterval * 1e3);
459
475
  } else if (tokenData.error === "access_denied") {
460
476
  pollSpinner.fail("Authorization denied");
461
- console.log(import_chalk4.default.red("\n\u2717 You denied the authorization request."));
477
+ console.log(import_chalk5.default.red("\n\u2717 You denied the authorization request."));
462
478
  return;
463
479
  } else if (tokenData.error === "expired_token") {
464
480
  pollSpinner.fail("Code expired");
465
481
  console.log(
466
- import_chalk4.default.red(
482
+ import_chalk5.default.red(
467
483
  "\n\u2717 The authorization code expired. Please try again."
468
484
  )
469
485
  );
@@ -471,7 +487,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
471
487
  } else {
472
488
  pollSpinner.fail("Authorization failed");
473
489
  console.log(
474
- import_chalk4.default.red("\n\u2717 Error:"),
490
+ import_chalk5.default.red("\n\u2717 Error:"),
475
491
  tokenData.error || "Unknown error"
476
492
  );
477
493
  return;
@@ -479,7 +495,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
479
495
  } catch (error) {
480
496
  pollSpinner.fail("Network error");
481
497
  console.error(
482
- import_chalk4.default.red("Error:"),
498
+ import_chalk5.default.red("Error:"),
483
499
  error instanceof Error ? error.message : "Unknown error"
484
500
  );
485
501
  }
@@ -488,28 +504,28 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
488
504
  } catch (error) {
489
505
  spinner.fail("Login failed");
490
506
  console.error(
491
- import_chalk4.default.red("Error:"),
507
+ import_chalk5.default.red("Error:"),
492
508
  error instanceof Error ? error.message : "Unknown error"
493
509
  );
494
510
  }
495
511
  });
496
512
 
497
513
  // src/commands/logout.ts
498
- var import_chalk5 = __toESM(require("chalk"));
514
+ var import_chalk6 = __toESM(require("chalk"));
499
515
  var import_commander5 = require("commander");
500
516
  var logoutCommand = new import_commander5.Command("logout").description("Log out of Commet").action(async () => {
501
517
  if (!authExists()) {
502
- console.log(import_chalk5.default.yellow("\u26A0 You are not logged in."));
518
+ console.log(import_chalk6.default.yellow("\u26A0 You are not logged in."));
503
519
  return;
504
520
  }
505
521
  clearAuth();
506
- console.log(import_chalk5.default.green("\u2713 Successfully logged out"));
522
+ console.log(import_chalk6.default.green("\u2713 Successfully logged out"));
507
523
  });
508
524
 
509
525
  // src/commands/pull.ts
510
526
  var fs2 = __toESM(require("fs"));
511
527
  var path2 = __toESM(require("path"));
512
- var import_chalk6 = __toESM(require("chalk"));
528
+ var import_chalk7 = __toESM(require("chalk"));
513
529
  var import_commander6 = require("commander");
514
530
  var import_ora4 = __toESM(require("ora"));
515
531
 
@@ -567,20 +583,20 @@ export type CommetSeatType = ${seatTypeUnion};
567
583
  // src/commands/pull.ts
568
584
  var pullCommand = new import_commander6.Command("pull").description("Pull type definitions from Commet").option("-o, --output <file>", "Output file path", ".commet.d.ts").action(async (options) => {
569
585
  if (!authExists()) {
570
- console.log(import_chalk6.default.red("\u2717 Not authenticated"));
571
- console.log(import_chalk6.default.dim("Run `commet login` first"));
586
+ console.log(import_chalk7.default.red("\u2717 Not authenticated"));
587
+ console.log(import_chalk7.default.dim("Run `commet login` first"));
572
588
  return;
573
589
  }
574
590
  if (!projectConfigExists()) {
575
- console.log(import_chalk6.default.red("\u2717 Project not linked"));
591
+ console.log(import_chalk7.default.red("\u2717 Project not linked"));
576
592
  console.log(
577
- import_chalk6.default.dim("Run `commet link` first to connect to an organization")
593
+ import_chalk7.default.dim("Run `commet link` first to connect to an organization")
578
594
  );
579
595
  return;
580
596
  }
581
597
  const projectConfig = loadProjectConfig();
582
598
  if (!projectConfig) {
583
- console.log(import_chalk6.default.red("\u2717 Invalid project configuration"));
599
+ console.log(import_chalk7.default.red("\u2717 Invalid project configuration"));
584
600
  return;
585
601
  }
586
602
  const spinner = (0, import_ora4.default)("Fetching type definitions...").start();
@@ -590,7 +606,7 @@ var pullCommand = new import_commander6.Command("pull").description("Pull type d
590
606
  );
591
607
  if (result.error || !result.data) {
592
608
  spinner.fail("Failed to fetch types");
593
- console.error(import_chalk6.default.red("Error:"), result.error);
609
+ console.error(import_chalk7.default.red("Error:"), result.error);
594
610
  return;
595
611
  }
596
612
  const { eventTypes, seatTypes } = result.data;
@@ -598,23 +614,23 @@ var pullCommand = new import_commander6.Command("pull").description("Pull type d
598
614
  const outputPath = path2.resolve(process.cwd(), options.output);
599
615
  fs2.writeFileSync(outputPath, typeDefinitions, "utf8");
600
616
  spinner.succeed("Type definitions generated!");
601
- console.log(import_chalk6.default.green("\n\u2713 Success"));
602
- console.log(import_chalk6.default.dim("\nGenerated types:"));
617
+ console.log(import_chalk7.default.green("\n\u2713 Success"));
618
+ console.log(import_chalk7.default.dim("\nGenerated types:"));
603
619
  console.log(
604
- import_chalk6.default.dim(
620
+ import_chalk7.default.dim(
605
621
  ` Event types: ${eventTypes.length > 0 ? eventTypes.map((e) => e.code).join(", ") : "none"}`
606
622
  )
607
623
  );
608
624
  console.log(
609
- import_chalk6.default.dim(
625
+ import_chalk7.default.dim(
610
626
  ` Seat types: ${seatTypes.length > 0 ? seatTypes.map((s) => s.code).join(", ") : "none"}`
611
627
  )
612
628
  );
613
- console.log(import_chalk6.default.dim(`
629
+ console.log(import_chalk7.default.dim(`
614
630
  Output file: ${outputPath}`));
615
631
  if (eventTypes.length === 0 && seatTypes.length === 0) {
616
632
  console.log(
617
- import_chalk6.default.yellow(
633
+ import_chalk7.default.yellow(
618
634
  "\n\u26A0 No types found. Create event types and seat types in your Commet dashboard."
619
635
  )
620
636
  );
@@ -622,20 +638,20 @@ Output file: ${outputPath}`));
622
638
  });
623
639
 
624
640
  // src/commands/switch.ts
625
- var import_chalk7 = __toESM(require("chalk"));
641
+ var import_prompts3 = require("@inquirer/prompts");
642
+ var import_chalk8 = __toESM(require("chalk"));
626
643
  var import_commander7 = require("commander");
627
- var import_inquirer3 = __toESM(require("inquirer"));
628
644
  var import_ora5 = __toESM(require("ora"));
629
645
  var switchCommand = new import_commander7.Command("switch").description("Switch to a different organization").action(async () => {
630
646
  if (!authExists()) {
631
- console.log(import_chalk7.default.red("\u2717 Not authenticated"));
632
- console.log(import_chalk7.default.dim("Run `commet login` first"));
647
+ console.log(import_chalk8.default.red("\u2717 Not authenticated"));
648
+ console.log(import_chalk8.default.dim("Run `commet login` first"));
633
649
  return;
634
650
  }
635
651
  if (!projectConfigExists()) {
636
- console.log(import_chalk7.default.yellow("\u26A0 Project not linked"));
652
+ console.log(import_chalk8.default.yellow("\u26A0 Project not linked"));
637
653
  console.log(
638
- import_chalk7.default.dim("Run `commet link` first to connect to an organization")
654
+ import_chalk8.default.dim("Run `commet link` first to connect to an organization")
639
655
  );
640
656
  return;
641
657
  }
@@ -643,7 +659,7 @@ var switchCommand = new import_commander7.Command("switch").description("Switch
643
659
  const auth = loadAuth();
644
660
  if (!auth) {
645
661
  spinner.fail("Authentication error");
646
- console.log(import_chalk7.default.red("\u2717 Could not load authentication"));
662
+ console.log(import_chalk8.default.red("\u2717 Could not load authentication"));
647
663
  return;
648
664
  }
649
665
  const baseURL = getBaseURL(auth.environment);
@@ -652,92 +668,85 @@ var switchCommand = new import_commander7.Command("switch").description("Switch
652
668
  );
653
669
  if (result.error || !result.data) {
654
670
  spinner.fail("Failed to fetch organizations");
655
- console.error(import_chalk7.default.red("Error:"), result.error);
671
+ console.error(import_chalk8.default.red("Error:"), result.error);
656
672
  return;
657
673
  }
658
674
  const { organizations } = result.data;
659
675
  if (organizations.length === 0) {
660
676
  spinner.stop();
661
- console.log(import_chalk7.default.yellow("\u26A0 No organizations found"));
677
+ console.log(import_chalk8.default.yellow("\u26A0 No organizations found"));
662
678
  return;
663
679
  }
664
680
  spinner.stop();
665
- const answers = await import_inquirer3.default.prompt([
666
- {
667
- type: "list",
668
- name: "orgId",
681
+ let orgId;
682
+ try {
683
+ orgId = await (0, import_prompts3.select)({
669
684
  message: "Select organization:",
670
685
  choices: organizations.map((org) => ({
671
- name: `${org.name} (${org.slug})`,
686
+ name: `${org.name} ${import_chalk8.default.dim(`(${org.slug})`)}`,
672
687
  value: org.id
673
- }))
674
- },
675
- {
676
- type: "list",
677
- name: "environment",
678
- message: "Select environment:",
679
- choices: [
680
- { name: "Sandbox (Development)", value: "sandbox" },
681
- { name: "Production", value: "production" }
682
- ],
683
- default: "sandbox"
684
- }
685
- ]);
686
- const selectedOrg = organizations.find((org) => org.id === answers.orgId);
688
+ })),
689
+ theme: promptTheme
690
+ });
691
+ } catch (error) {
692
+ console.log(import_chalk8.default.yellow("\n\u26A0 Switch cancelled"));
693
+ return;
694
+ }
695
+ const selectedOrg = organizations.find((org) => org.id === orgId);
687
696
  if (!selectedOrg) {
688
- console.log(import_chalk7.default.red("\u2717 Organization not found"));
697
+ console.log(import_chalk8.default.red("\u2717 Organization not found"));
689
698
  return;
690
699
  }
691
700
  saveProjectConfig({
692
701
  orgId: selectedOrg.id,
693
702
  orgName: selectedOrg.name,
694
- environment: answers.environment
703
+ environment: auth.environment
695
704
  });
696
- console.log(import_chalk7.default.green("\n\u2713 Switched organization successfully!"));
697
- console.log(import_chalk7.default.dim("\nNew configuration:"));
698
- console.log(import_chalk7.default.dim(` Organization: ${selectedOrg.name}`));
699
- console.log(import_chalk7.default.dim(` Environment: ${answers.environment}`));
705
+ console.log(import_chalk8.default.green("\n\u2713 Switched organization successfully!"));
706
+ console.log(import_chalk8.default.dim("\nNew configuration:"));
707
+ console.log(import_chalk8.default.dim(` Organization: ${selectedOrg.name}`));
708
+ console.log(import_chalk8.default.dim(` Environment: ${auth.environment}`));
700
709
  console.log(
701
- import_chalk7.default.dim(
710
+ import_chalk8.default.dim(
702
711
  "\nRun `commet pull` to update TypeScript types for this organization"
703
712
  )
704
713
  );
705
714
  });
706
715
 
707
716
  // src/commands/unlink.ts
708
- var import_chalk8 = __toESM(require("chalk"));
717
+ var import_chalk9 = __toESM(require("chalk"));
709
718
  var import_commander8 = require("commander");
710
719
  var unlinkCommand = new import_commander8.Command("unlink").description("Unlink this project from Commet").action(async () => {
711
720
  if (!projectConfigExists()) {
712
721
  console.log(
713
- import_chalk8.default.yellow("\u26A0 This project is not linked to any organization")
722
+ import_chalk9.default.yellow("\u26A0 This project is not linked to any organization")
714
723
  );
715
724
  return;
716
725
  }
717
726
  clearProjectConfig();
718
- console.log(import_chalk8.default.green("\u2713 Project unlinked successfully"));
719
- console.log(import_chalk8.default.dim("Run `commet link` to connect to an organization"));
727
+ console.log(import_chalk9.default.green("\u2713 Project unlinked successfully"));
728
+ console.log(import_chalk9.default.dim("Run `commet link` to connect to an organization"));
720
729
  });
721
730
 
722
731
  // src/commands/whoami.ts
723
- var import_chalk9 = __toESM(require("chalk"));
732
+ var import_chalk10 = __toESM(require("chalk"));
724
733
  var import_commander9 = require("commander");
725
734
  var whoamiCommand = new import_commander9.Command("whoami").description("Display current authentication and project status").action(async () => {
726
735
  if (!authExists()) {
727
- console.log(import_chalk9.default.yellow("\u26A0 Not logged in"));
728
- console.log(import_chalk9.default.dim("Run `commet login` to authenticate"));
736
+ console.log(import_chalk10.default.yellow("\u26A0 Not logged in"));
737
+ console.log(import_chalk10.default.dim("Run `commet login` to authenticate"));
729
738
  return;
730
739
  }
731
- console.log(import_chalk9.default.green("\u2713 Logged in"));
740
+ console.log(import_chalk10.default.green("\u2713 Logged in"));
732
741
  const projectConfig = loadProjectConfig();
733
742
  if (projectConfig) {
734
- console.log(import_chalk9.default.bold("\nProject:"));
735
- console.log(import_chalk9.default.dim("Organization:"), projectConfig.orgName);
736
- console.log(import_chalk9.default.dim("Environment:"), projectConfig.environment);
743
+ console.log(import_chalk10.default.bold("\nProject:"));
744
+ console.log(import_chalk10.default.dim("Organization:"), projectConfig.orgName);
745
+ console.log(import_chalk10.default.dim("Environment:"), projectConfig.environment);
737
746
  } else {
738
- console.log(import_chalk9.default.yellow("\n\u26A0 No project linked"));
747
+ console.log(import_chalk10.default.yellow("\n\u26A0 No project linked"));
739
748
  console.log(
740
- import_chalk9.default.dim(
749
+ import_chalk10.default.dim(
741
750
  "Run `commet link` to connect this directory to an organization"
742
751
  )
743
752
  );
@@ -766,7 +775,7 @@ try {
766
775
  if (error.message.includes("outputHelp")) {
767
776
  process.exit(0);
768
777
  }
769
- console.error(import_chalk10.default.red("Error:"), error.message);
778
+ console.error(import_chalk11.default.red("Error:"), error.message);
770
779
  }
771
780
  process.exit(1);
772
781
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commet",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Commet CLI - Manage your billing platform from the command line",
5
5
  "bin": {
6
6
  "commet": "./bin/commet"
@@ -19,16 +19,15 @@
19
19
  "author": "Commet Team",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
+ "@inquirer/prompts": "^7.8.6",
22
23
  "chalk": "^5.3.0",
23
24
  "commander": "^12.0.0",
24
- "inquirer": "^9.2.0",
25
25
  "open": "^10.0.0",
26
26
  "ora": "^7.0.1",
27
27
  "@commet/node": "0.4.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@biomejs/biome": "^1.9.4",
31
- "@types/inquirer": "^9.0.9",
32
31
  "@types/node": "^20.10.0",
33
32
  "tsup": "^8.0.1",
34
33
  "typescript": "^5.3.3"