commet 1.0.0 → 1.1.0

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 (3) hide show
  1. package/README.md +11 -10
  2. package/dist/index.js +457 -274
  3. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -24,13 +24,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/index.ts
27
- var import_chalk11 = __toESM(require("chalk"));
28
- var import_commander10 = require("commander");
27
+ var import_chalk12 = __toESM(require("chalk"));
28
+ var import_commander11 = require("commander");
29
29
 
30
30
  // package.json
31
31
  var package_default = {
32
32
  name: "commet",
33
- version: "1.0.0",
33
+ version: "1.1.0",
34
34
  description: "Commet CLI - Manage your billing platform from the command line",
35
35
  bin: {
36
36
  commet: "./bin/commet"
@@ -61,7 +61,8 @@ var package_default = {
61
61
  commander: "14.0.2",
62
62
  "jsonc-parser": "3.3.1",
63
63
  open: "11.0.0",
64
- ora: "9.0.0"
64
+ ora: "9.0.0",
65
+ tar: "^7.5.13"
65
66
  },
66
67
  devDependencies: {
67
68
  "@types/node": "24.10.1",
@@ -83,33 +84,229 @@ var package_default = {
83
84
  }
84
85
  };
85
86
 
86
- // src/commands/info.ts
87
- var import_chalk = __toESM(require("chalk"));
88
- var import_commander = require("commander");
89
-
90
- // src/utils/config.ts
87
+ // src/commands/create.ts
88
+ var import_node_child_process = require("child_process");
91
89
  var fs = __toESM(require("fs"));
92
90
  var os = __toESM(require("os"));
93
91
  var path = __toESM(require("path"));
92
+ var import_prompts = require("@inquirer/prompts");
93
+ var import_chalk2 = __toESM(require("chalk"));
94
+ var import_commander = require("commander");
95
+ var import_ora = __toESM(require("ora"));
96
+ var import_tar = require("tar");
97
+
98
+ // src/utils/prompt-theme.ts
99
+ var import_chalk = __toESM(require("chalk"));
100
+ var commetColor = import_chalk.default.hex("#5BC0B0");
101
+ var promptTheme = {
102
+ prefix: commetColor("\u276F"),
103
+ style: {
104
+ answer: commetColor,
105
+ message: import_chalk.default.bold,
106
+ error: import_chalk.default.red,
107
+ help: import_chalk.default.dim,
108
+ highlight: commetColor.bold,
109
+ // Selected option in mint
110
+ description: import_chalk.default.dim,
111
+ defaultAnswer: import_chalk.default.dim
112
+ }
113
+ };
114
+
115
+ // src/commands/create.ts
116
+ var GITHUB_REPO = "commet-labs/commet";
117
+ var TEMPLATES = [
118
+ {
119
+ name: "fixed",
120
+ dir: "fixed-saas",
121
+ description: "Fixed subscriptions (monthly/yearly plans)"
122
+ },
123
+ {
124
+ name: "seats",
125
+ dir: "team-saas",
126
+ description: "Seat-based billing (per team member)"
127
+ },
128
+ {
129
+ name: "credits",
130
+ dir: "credits-saas",
131
+ description: "Credit-based billing (prepaid usage blocks)"
132
+ },
133
+ {
134
+ name: "usage-based",
135
+ dir: "usage-based-saas",
136
+ description: "Usage-based billing (metered, pay for what you use)"
137
+ }
138
+ ];
139
+ function detectPackageManager() {
140
+ const agent = process.env.npm_config_user_agent;
141
+ if (!agent) return "npm";
142
+ if (agent.startsWith("pnpm")) return "pnpm";
143
+ if (agent.startsWith("yarn")) return "yarn";
144
+ if (agent.startsWith("bun")) return "bun";
145
+ return "npm";
146
+ }
147
+ async function downloadTemplate(templateDir, dest, ref) {
148
+ const url = `https://codeload.github.com/${GITHUB_REPO}/tar.gz/${ref}`;
149
+ const response = await fetch(url);
150
+ if (!response.ok) {
151
+ throw new Error(`Failed to download (HTTP ${response.status})`);
152
+ }
153
+ const tempFile = path.join(os.tmpdir(), `commet-${Date.now()}.tar.gz`);
154
+ try {
155
+ const buffer = Buffer.from(await response.arrayBuffer());
156
+ fs.writeFileSync(tempFile, buffer);
157
+ fs.mkdirSync(dest, { recursive: true });
158
+ await (0, import_tar.extract)({
159
+ file: tempFile,
160
+ cwd: dest,
161
+ strip: 3,
162
+ filter: (entryPath) => {
163
+ const parts = entryPath.split("/");
164
+ return parts[1] === "examples" && parts[2] === templateDir;
165
+ }
166
+ });
167
+ } finally {
168
+ if (fs.existsSync(tempFile)) {
169
+ fs.unlinkSync(tempFile);
170
+ }
171
+ }
172
+ const files = fs.readdirSync(dest);
173
+ if (files.length === 0) {
174
+ throw new Error(`Template "${templateDir}" not found in repository`);
175
+ }
176
+ }
177
+ function updatePackageJson(dest, projectName) {
178
+ const pkgPath = path.join(dest, "package.json");
179
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
180
+ pkg.name = projectName;
181
+ pkg.version = "0.0.1";
182
+ pkg.private = true;
183
+ fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
184
+ `);
185
+ }
186
+ function copyEnvExample(dest) {
187
+ const examplePath = path.join(dest, ".env.example");
188
+ const envPath = path.join(dest, ".env");
189
+ if (fs.existsSync(examplePath)) {
190
+ fs.copyFileSync(examplePath, envPath);
191
+ }
192
+ }
193
+ var createCommand = new import_commander.Command("create").description("Create a new Commet app from a template").argument("[name]", "Project name").option(
194
+ "-t, --template <template>",
195
+ "Template to use (fixed, seats, credits, usage-based)"
196
+ ).option("--ref <ref>", "Git ref to fetch templates from", "main").option("--list", "List available templates").action(async (argName, opts) => {
197
+ if (opts.list) {
198
+ console.log(import_chalk2.default.bold("\nAvailable templates:\n"));
199
+ for (const t of TEMPLATES) {
200
+ console.log(
201
+ ` ${commetColor(t.name.padEnd(14))}${import_chalk2.default.dim(t.description)}`
202
+ );
203
+ }
204
+ console.log();
205
+ return;
206
+ }
207
+ let projectName = argName;
208
+ try {
209
+ if (!projectName) {
210
+ projectName = await (0, import_prompts.input)({
211
+ message: "Project name:",
212
+ theme: promptTheme
213
+ });
214
+ }
215
+ } catch {
216
+ console.log(import_chalk2.default.yellow("\n\u26A0 Cancelled"));
217
+ return;
218
+ }
219
+ const dest = path.resolve(projectName);
220
+ if (fs.existsSync(dest)) {
221
+ console.log(import_chalk2.default.red(`\u2717 Directory "${projectName}" already exists`));
222
+ return;
223
+ }
224
+ let template = TEMPLATES.find((t) => t.name === opts.template);
225
+ if (opts.template && !template) {
226
+ console.log(import_chalk2.default.red(`\u2717 Unknown template "${opts.template}"`));
227
+ console.log(
228
+ import_chalk2.default.dim("Run `commet create --list` to see available templates")
229
+ );
230
+ return;
231
+ }
232
+ try {
233
+ if (!template) {
234
+ const selected = await (0, import_prompts.select)({
235
+ message: "Billing model:",
236
+ choices: TEMPLATES.map((t) => ({
237
+ name: `${t.name.padEnd(14)} ${import_chalk2.default.dim(t.description)}`,
238
+ value: t.name
239
+ })),
240
+ theme: promptTheme
241
+ });
242
+ template = TEMPLATES.find((t) => t.name === selected);
243
+ }
244
+ } catch {
245
+ console.log(import_chalk2.default.yellow("\n\u26A0 Cancelled"));
246
+ return;
247
+ }
248
+ const spinner = (0, import_ora.default)("Downloading template...").start();
249
+ try {
250
+ await downloadTemplate(template.dir, dest, opts.ref);
251
+ spinner.succeed("Template downloaded");
252
+ } catch (error) {
253
+ spinner.fail("Failed to download template");
254
+ if (error instanceof Error) {
255
+ console.error(import_chalk2.default.red(error.message));
256
+ }
257
+ if (fs.existsSync(dest)) {
258
+ fs.rmSync(dest, { recursive: true, force: true });
259
+ }
260
+ return;
261
+ }
262
+ updatePackageJson(dest, projectName);
263
+ copyEnvExample(dest);
264
+ const pm = detectPackageManager();
265
+ const installSpinner = (0, import_ora.default)(`Installing dependencies with ${pm}...`).start();
266
+ try {
267
+ (0, import_node_child_process.execSync)(`${pm} install`, { cwd: dest, stdio: "ignore" });
268
+ installSpinner.succeed("Dependencies installed");
269
+ } catch {
270
+ installSpinner.warn("Could not install dependencies");
271
+ console.log(import_chalk2.default.dim(` Run \`${pm} install\` manually`));
272
+ }
273
+ console.log(import_chalk2.default.green(`
274
+ \u2713 Created ${projectName}`));
275
+ console.log(import_chalk2.default.dim(` Template: ${template.name}`));
276
+ console.log();
277
+ console.log(` ${import_chalk2.default.cyan("cd")} ${projectName}`);
278
+ console.log(` ${import_chalk2.default.dim("Update .env with your keys")}`);
279
+ console.log(` ${import_chalk2.default.cyan(`${pm} dev`)}`);
280
+ console.log();
281
+ });
282
+
283
+ // src/commands/info.ts
284
+ var import_chalk3 = __toESM(require("chalk"));
285
+ var import_commander2 = require("commander");
286
+
287
+ // src/utils/config.ts
288
+ var fs2 = __toESM(require("fs"));
289
+ var os2 = __toESM(require("os"));
290
+ var path2 = __toESM(require("path"));
94
291
  function getAuthPath() {
95
- return path.join(os.homedir(), ".commet", "auth.json");
292
+ return path2.join(os2.homedir(), ".commet", "auth.json");
96
293
  }
97
294
  function getProjectConfigPath() {
98
- return path.join(process.cwd(), ".commet", "config.json");
295
+ return path2.join(process.cwd(), ".commet", "config.json");
99
296
  }
100
297
  function getProjectConfigDir() {
101
- return path.join(process.cwd(), ".commet");
298
+ return path2.join(process.cwd(), ".commet");
102
299
  }
103
300
  function authExists() {
104
- return fs.existsSync(getAuthPath());
301
+ return fs2.existsSync(getAuthPath());
105
302
  }
106
303
  function loadAuth() {
107
304
  try {
108
305
  const authPath = getAuthPath();
109
- if (!fs.existsSync(authPath)) {
306
+ if (!fs2.existsSync(authPath)) {
110
307
  return null;
111
308
  }
112
- const data = fs.readFileSync(authPath, "utf8");
309
+ const data = fs2.readFileSync(authPath, "utf8");
113
310
  return JSON.parse(data);
114
311
  } catch {
115
312
  return null;
@@ -117,25 +314,25 @@ function loadAuth() {
117
314
  }
118
315
  function saveAuth(data) {
119
316
  const authPath = getAuthPath();
120
- fs.mkdirSync(path.dirname(authPath), { recursive: true });
121
- fs.writeFileSync(authPath, JSON.stringify(data, null, 2), "utf8");
317
+ fs2.mkdirSync(path2.dirname(authPath), { recursive: true });
318
+ fs2.writeFileSync(authPath, JSON.stringify(data, null, 2), "utf8");
122
319
  }
123
320
  function clearAuth() {
124
321
  const authPath = getAuthPath();
125
- if (fs.existsSync(authPath)) {
126
- fs.unlinkSync(authPath);
322
+ if (fs2.existsSync(authPath)) {
323
+ fs2.unlinkSync(authPath);
127
324
  }
128
325
  }
129
326
  function projectConfigExists() {
130
- return fs.existsSync(getProjectConfigPath());
327
+ return fs2.existsSync(getProjectConfigPath());
131
328
  }
132
329
  function loadProjectConfig() {
133
330
  try {
134
331
  const configPath = getProjectConfigPath();
135
- if (!fs.existsSync(configPath)) {
332
+ if (!fs2.existsSync(configPath)) {
136
333
  return null;
137
334
  }
138
- const data = fs.readFileSync(configPath, "utf8");
335
+ const data = fs2.readFileSync(configPath, "utf8");
139
336
  return JSON.parse(data);
140
337
  } catch {
141
338
  return null;
@@ -144,51 +341,51 @@ function loadProjectConfig() {
144
341
  function saveProjectConfig(data) {
145
342
  const configDir = getProjectConfigDir();
146
343
  const configPath = getProjectConfigPath();
147
- fs.mkdirSync(configDir, { recursive: true });
148
- fs.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf8");
344
+ fs2.mkdirSync(configDir, { recursive: true });
345
+ fs2.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf8");
149
346
  }
150
347
  function clearProjectConfig() {
151
348
  const configDir = getProjectConfigDir();
152
- if (fs.existsSync(configDir)) {
153
- fs.rmSync(configDir, { recursive: true, force: true });
349
+ if (fs2.existsSync(configDir)) {
350
+ fs2.rmSync(configDir, { recursive: true, force: true });
154
351
  }
155
352
  }
156
353
 
157
354
  // src/commands/info.ts
158
- var infoCommand = new import_commander.Command("info").description("Display information about the current project").action(async () => {
159
- console.log(import_chalk.default.bold("\n\u{1F4E6} Project Information\n"));
355
+ var infoCommand = new import_commander2.Command("info").description("Display information about the current project").action(async () => {
356
+ console.log(import_chalk3.default.bold("\n\u{1F4E6} Project Information\n"));
160
357
  if (!authExists()) {
161
- console.log(import_chalk.default.yellow("Authentication: Not logged in"));
162
- console.log(import_chalk.default.dim("Run `commet login` to authenticate\n"));
358
+ console.log(import_chalk3.default.yellow("Authentication: Not logged in"));
359
+ console.log(import_chalk3.default.dim("Run `commet login` to authenticate\n"));
163
360
  return;
164
361
  }
165
- console.log(import_chalk.default.green("Authentication: Logged in \u2713"));
362
+ console.log(import_chalk3.default.green("Authentication: Logged in \u2713"));
166
363
  if (!projectConfigExists()) {
167
- console.log(import_chalk.default.yellow("\nProject: Not linked"));
364
+ console.log(import_chalk3.default.yellow("\nProject: Not linked"));
168
365
  console.log(
169
- import_chalk.default.dim("Run `commet link` to connect to an organization\n")
366
+ import_chalk3.default.dim("Run `commet link` to connect to an organization\n")
170
367
  );
171
368
  return;
172
369
  }
173
370
  const projectConfig = loadProjectConfig();
174
371
  if (!projectConfig) {
175
- console.log(import_chalk.default.red("\nProject: Invalid configuration"));
372
+ console.log(import_chalk3.default.red("\nProject: Invalid configuration"));
176
373
  return;
177
374
  }
178
- console.log(import_chalk.default.green("\nProject: Linked \u2713"));
179
- console.log(import_chalk.default.dim(" Organization:"), projectConfig.orgName);
180
- console.log(import_chalk.default.dim(" Organization ID:"), projectConfig.orgId);
181
- console.log(import_chalk.default.dim(" Environment:"), projectConfig.environment);
375
+ console.log(import_chalk3.default.green("\nProject: Linked \u2713"));
376
+ console.log(import_chalk3.default.dim(" Organization:"), projectConfig.orgName);
377
+ console.log(import_chalk3.default.dim(" Organization ID:"), projectConfig.orgId);
378
+ console.log(import_chalk3.default.dim(" Environment:"), projectConfig.environment);
182
379
  console.log(
183
- import_chalk.default.dim("\nRun `commet pull` to generate type definitions\n")
380
+ import_chalk3.default.dim("\nRun `commet pull` to generate type definitions\n")
184
381
  );
185
382
  });
186
383
 
187
384
  // src/commands/link.ts
188
- var import_prompts = require("@inquirer/prompts");
189
- var import_chalk3 = __toESM(require("chalk"));
190
- var import_commander2 = require("commander");
191
- var import_ora = __toESM(require("ora"));
385
+ var import_prompts2 = require("@inquirer/prompts");
386
+ var import_chalk4 = __toESM(require("chalk"));
387
+ var import_commander3 = require("commander");
388
+ var import_ora2 = __toESM(require("ora"));
192
389
 
193
390
  // src/utils/api.ts
194
391
  function getBaseURL(environment) {
@@ -227,15 +424,15 @@ async function apiRequest(endpoint, options = {}) {
227
424
  }
228
425
 
229
426
  // src/utils/gitignore-updater.ts
230
- var fs2 = __toESM(require("fs"));
231
- var path2 = __toESM(require("path"));
427
+ var fs3 = __toESM(require("fs"));
428
+ var path3 = __toESM(require("path"));
232
429
  function updateGitignore(entry) {
233
430
  const cwd = process.cwd();
234
- const gitignorePath = path2.join(cwd, ".gitignore");
431
+ const gitignorePath = path3.join(cwd, ".gitignore");
235
432
  try {
236
433
  let content = "";
237
- if (fs2.existsSync(gitignorePath)) {
238
- content = fs2.readFileSync(gitignorePath, "utf8");
434
+ if (fs3.existsSync(gitignorePath)) {
435
+ content = fs3.readFileSync(gitignorePath, "utf8");
239
436
  const lines = content.split("\n");
240
437
  for (const line of lines) {
241
438
  const trimmed = line.trim();
@@ -249,7 +446,7 @@ function updateGitignore(entry) {
249
446
  }
250
447
  content += `${entry}
251
448
  `;
252
- fs2.writeFileSync(gitignorePath, content, "utf8");
449
+ fs3.writeFileSync(gitignorePath, content, "utf8");
253
450
  return { success: true };
254
451
  } catch (error) {
255
452
  return {
@@ -259,48 +456,31 @@ function updateGitignore(entry) {
259
456
  }
260
457
  }
261
458
 
262
- // src/utils/prompt-theme.ts
263
- var import_chalk2 = __toESM(require("chalk"));
264
- var commetColor = import_chalk2.default.hex("#5BC0B0");
265
- var promptTheme = {
266
- prefix: commetColor("\u276F"),
267
- style: {
268
- answer: commetColor,
269
- message: import_chalk2.default.bold,
270
- error: import_chalk2.default.red,
271
- help: import_chalk2.default.dim,
272
- highlight: commetColor.bold,
273
- // Selected option in mint
274
- description: import_chalk2.default.dim,
275
- defaultAnswer: import_chalk2.default.dim
276
- }
277
- };
278
-
279
459
  // src/commands/link.ts
280
- var linkCommand = new import_commander2.Command("link").description("Link this project to a Commet organization").action(async () => {
460
+ var linkCommand = new import_commander3.Command("link").description("Link this project to a Commet organization").action(async () => {
281
461
  if (!authExists()) {
282
- console.log(import_chalk3.default.red("\u2717 Not authenticated"));
283
- console.log(import_chalk3.default.dim("Run `commet login` first"));
462
+ console.log(import_chalk4.default.red("\u2717 Not authenticated"));
463
+ console.log(import_chalk4.default.dim("Run `commet login` first"));
284
464
  return;
285
465
  }
286
466
  if (projectConfigExists()) {
287
467
  const config = loadProjectConfig();
288
- console.log(import_chalk3.default.yellow("\u26A0 This project is already linked"));
468
+ console.log(import_chalk4.default.yellow("\u26A0 This project is already linked"));
289
469
  console.log(
290
- import_chalk3.default.dim(`Organization: ${config?.orgName} (${config?.environment})`)
470
+ import_chalk4.default.dim(`Organization: ${config?.orgName} (${config?.environment})`)
291
471
  );
292
472
  console.log(
293
- import_chalk3.default.dim(
473
+ import_chalk4.default.dim(
294
474
  "\nRun `commet unlink` first if you want to change the organization"
295
475
  )
296
476
  );
297
477
  return;
298
478
  }
299
- const spinner = (0, import_ora.default)("Fetching organizations...").start();
479
+ const spinner = (0, import_ora2.default)("Fetching organizations...").start();
300
480
  const auth = loadAuth();
301
481
  if (!auth) {
302
482
  spinner.fail("Authentication error");
303
- console.log(import_chalk3.default.red("\u2717 Could not load authentication"));
483
+ console.log(import_chalk4.default.red("\u2717 Could not load authentication"));
304
484
  return;
305
485
  }
306
486
  const baseURL = getBaseURL(auth.environment);
@@ -309,36 +489,36 @@ var linkCommand = new import_commander2.Command("link").description("Link this p
309
489
  );
310
490
  if (result.error || !result.data) {
311
491
  spinner.fail("Failed to fetch organizations");
312
- console.error(import_chalk3.default.red("Error:"), result.error);
492
+ console.error(import_chalk4.default.red("Error:"), result.error);
313
493
  return;
314
494
  }
315
495
  const { organizations } = result.data;
316
496
  if (organizations.length === 0) {
317
497
  spinner.stop();
318
- console.log(import_chalk3.default.yellow("\u26A0 No organizations found"));
498
+ console.log(import_chalk4.default.yellow("\u26A0 No organizations found"));
319
499
  console.log(
320
- import_chalk3.default.dim("Create an organization at https://commet.co first")
500
+ import_chalk4.default.dim("Create an organization at https://commet.co first")
321
501
  );
322
502
  return;
323
503
  }
324
504
  spinner.stop();
325
505
  let orgId;
326
506
  try {
327
- orgId = await (0, import_prompts.select)({
507
+ orgId = await (0, import_prompts2.select)({
328
508
  message: "Select organization:",
329
509
  choices: organizations.map((org) => ({
330
- name: `${org.name} ${import_chalk3.default.dim(`(${org.slug})`)}`,
510
+ name: `${org.name} ${import_chalk4.default.dim(`(${org.slug})`)}`,
331
511
  value: org.id
332
512
  })),
333
513
  theme: promptTheme
334
514
  });
335
515
  } catch (error) {
336
- console.log(import_chalk3.default.yellow("\n\u26A0 Link cancelled"));
516
+ console.log(import_chalk4.default.yellow("\n\u26A0 Link cancelled"));
337
517
  return;
338
518
  }
339
519
  const selectedOrg = organizations.find((org) => org.id === orgId);
340
520
  if (!selectedOrg) {
341
- console.log(import_chalk3.default.red("\u2717 Organization not found"));
521
+ console.log(import_chalk4.default.red("\u2717 Organization not found"));
342
522
  return;
343
523
  }
344
524
  saveProjectConfig({
@@ -347,97 +527,119 @@ var linkCommand = new import_commander2.Command("link").description("Link this p
347
527
  environment: auth.environment
348
528
  });
349
529
  const gitignoreResult = updateGitignore(".commet/");
350
- console.log(import_chalk3.default.green("\n\u2713 Project linked successfully"));
351
- console.log(import_chalk3.default.dim(`Organization: ${selectedOrg.name}`));
352
- console.log(import_chalk3.default.dim(`Environment: ${auth.environment}`));
530
+ console.log(import_chalk4.default.green("\n\u2713 Project linked successfully"));
531
+ console.log(import_chalk4.default.dim(`Organization: ${selectedOrg.name}`));
532
+ console.log(import_chalk4.default.dim(`Environment: ${auth.environment}`));
353
533
  if (gitignoreResult.success) {
354
- console.log(import_chalk3.default.green("\u2713 Updated .gitignore"));
534
+ console.log(import_chalk4.default.green("\u2713 Updated .gitignore"));
355
535
  } else {
356
- console.log(import_chalk3.default.yellow("\u26A0 No .gitignore found"));
357
- console.log(import_chalk3.default.dim("Add .commet/ to your .gitignore file"));
536
+ console.log(import_chalk4.default.yellow("\u26A0 No .gitignore found"));
537
+ console.log(import_chalk4.default.dim("Add .commet/ to your .gitignore file"));
358
538
  }
359
- console.log(import_chalk3.default.dim("\nRun 'commet pull' to generate TypeScript types"));
539
+ console.log(import_chalk4.default.dim("\nRun 'commet pull' to generate TypeScript types"));
360
540
  });
361
541
 
362
542
  // src/commands/list.ts
363
- var import_chalk4 = __toESM(require("chalk"));
364
- var import_commander3 = require("commander");
365
- var import_ora2 = __toESM(require("ora"));
366
- 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) => {
367
- if (type !== "events" && type !== "seats") {
368
- console.log(import_chalk4.default.red('\u2717 Invalid type. Use "events" or "seats"'));
369
- console.log(import_chalk4.default.dim("\nExamples:"));
370
- console.log(import_chalk4.default.dim(" commet list events"));
371
- console.log(import_chalk4.default.dim(" commet list seats"));
543
+ var import_chalk5 = __toESM(require("chalk"));
544
+ var import_commander4 = require("commander");
545
+ var import_ora3 = __toESM(require("ora"));
546
+ var validTypes = ["features", "seats", "plans"];
547
+ var listCommand = new import_commander4.Command("list").description("List features, seat types, or plans").argument("<type>", "Type to list (features, seats, or plans)").action(async (type) => {
548
+ if (!validTypes.includes(type)) {
549
+ console.log(
550
+ import_chalk5.default.red('\u2717 Invalid type. Use "features", "seats", or "plans"')
551
+ );
552
+ console.log(import_chalk5.default.dim("\nExamples:"));
553
+ console.log(import_chalk5.default.dim(" commet list features"));
554
+ console.log(import_chalk5.default.dim(" commet list seats"));
555
+ console.log(import_chalk5.default.dim(" commet list plans"));
372
556
  return;
373
557
  }
374
558
  if (!authExists()) {
375
- console.log(import_chalk4.default.red("\u2717 Not authenticated"));
376
- console.log(import_chalk4.default.dim("Run `commet login` first"));
559
+ console.log(import_chalk5.default.red("\u2717 Not authenticated"));
560
+ console.log(import_chalk5.default.dim("Run `commet login` first"));
377
561
  return;
378
562
  }
379
563
  if (!projectConfigExists()) {
380
- console.log(import_chalk4.default.red("\u2717 Project not linked"));
564
+ console.log(import_chalk5.default.red("\u2717 Project not linked"));
381
565
  console.log(
382
- import_chalk4.default.dim("Run `commet link` first to connect to an organization")
566
+ import_chalk5.default.dim("Run `commet link` first to connect to an organization")
383
567
  );
384
568
  return;
385
569
  }
386
570
  const projectConfig = loadProjectConfig();
387
571
  if (!projectConfig) {
388
- console.log(import_chalk4.default.red("\u2717 Invalid project configuration"));
572
+ console.log(import_chalk5.default.red("\u2717 Invalid project configuration"));
389
573
  return;
390
574
  }
391
- const spinner = (0, import_ora2.default)(`Fetching ${type}...`).start();
575
+ const spinner = (0, import_ora3.default)(`Fetching ${type}...`).start();
392
576
  const baseURL = getBaseURL(projectConfig.environment);
393
577
  const result = await apiRequest(
394
578
  `${baseURL}/api/cli/types?orgId=${projectConfig.orgId}`
395
579
  );
396
580
  if (result.error || !result.data) {
397
581
  spinner.fail(`Failed to fetch ${type}`);
398
- console.error(import_chalk4.default.red("Error:"), result.error);
582
+ console.error(import_chalk5.default.red("Error:"), result.error);
399
583
  return;
400
584
  }
401
585
  spinner.stop();
402
- if (type === "events") {
403
- const { eventTypes } = result.data;
404
- if (eventTypes.length === 0) {
405
- console.log(import_chalk4.default.yellow("\u26A0 No event types found"));
586
+ if (type === "features") {
587
+ const { features } = result.data;
588
+ if (features.length === 0) {
589
+ console.log(import_chalk5.default.yellow("\u26A0 No features found"));
406
590
  console.log(
407
- import_chalk4.default.dim("Create event types in your Commet dashboard first")
591
+ import_chalk5.default.dim("Create features in your Commet dashboard first")
408
592
  );
409
593
  return;
410
594
  }
411
- console.log(import_chalk4.default.bold(`
412
- \u{1F4CA} Event Types (${eventTypes.length})
595
+ console.log(import_chalk5.default.bold(`
596
+ \u{1F4CA} Features (${features.length})
413
597
  `));
414
- for (const eventType of eventTypes) {
415
- console.log(import_chalk4.default.green(`\u2022 ${eventType.code}`));
416
- console.log(import_chalk4.default.dim(` ${eventType.name}`));
417
- if (eventType.description) {
418
- console.log(import_chalk4.default.dim(` ${eventType.description}`));
598
+ for (const feature of features) {
599
+ console.log(import_chalk5.default.green(`\u2022 ${feature.code} (${feature.type})`));
600
+ console.log(import_chalk5.default.dim(` ${feature.name}`));
601
+ if (feature.description) {
602
+ console.log(import_chalk5.default.dim(` ${feature.description}`));
419
603
  }
420
604
  console.log("");
421
605
  }
422
- } else {
606
+ } else if (type === "seats") {
423
607
  const { seatTypes } = result.data;
424
608
  if (seatTypes.length === 0) {
425
- console.log(import_chalk4.default.yellow("\u26A0 No seat types found"));
609
+ console.log(import_chalk5.default.yellow("\u26A0 No seat types found"));
426
610
  console.log(
427
- import_chalk4.default.dim("Create seat types in your Commet dashboard first")
611
+ import_chalk5.default.dim("Create seat types in your Commet dashboard first")
428
612
  );
429
613
  return;
430
614
  }
431
- console.log(import_chalk4.default.bold(`
615
+ console.log(import_chalk5.default.bold(`
432
616
  \u{1F4BA} Seat Types (${seatTypes.length})
433
617
  `));
434
618
  for (const seatType of seatTypes) {
435
619
  console.log(
436
- import_chalk4.default.green(`\u2022 ${seatType.code}${seatType.isFree ? " (Free)" : ""}`)
620
+ import_chalk5.default.green(`\u2022 ${seatType.code}${seatType.isFree ? " (Free)" : ""}`)
437
621
  );
438
- console.log(import_chalk4.default.dim(` ${seatType.name}`));
622
+ console.log(import_chalk5.default.dim(` ${seatType.name}`));
439
623
  if (seatType.description) {
440
- console.log(import_chalk4.default.dim(` ${seatType.description}`));
624
+ console.log(import_chalk5.default.dim(` ${seatType.description}`));
625
+ }
626
+ console.log("");
627
+ }
628
+ } else {
629
+ const { plans } = result.data;
630
+ if (plans.length === 0) {
631
+ console.log(import_chalk5.default.yellow("\u26A0 No plans found"));
632
+ console.log(import_chalk5.default.dim("Create plans in your Commet dashboard first"));
633
+ return;
634
+ }
635
+ console.log(import_chalk5.default.bold(`
636
+ \u{1F4CB} Plans (${plans.length})
637
+ `));
638
+ for (const plan of plans) {
639
+ console.log(import_chalk5.default.green(`\u2022 ${plan.code}`));
640
+ console.log(import_chalk5.default.dim(` ${plan.name}`));
641
+ if (plan.description) {
642
+ console.log(import_chalk5.default.dim(` ${plan.description}`));
441
643
  }
442
644
  console.log("");
443
645
  }
@@ -445,17 +647,17 @@ var listCommand = new import_commander3.Command("list").description("List event
445
647
  });
446
648
 
447
649
  // src/commands/login.ts
448
- var import_prompts2 = require("@inquirer/prompts");
449
- var import_chalk5 = __toESM(require("chalk"));
450
- var import_commander4 = require("commander");
650
+ var import_prompts3 = require("@inquirer/prompts");
651
+ var import_chalk6 = __toESM(require("chalk"));
652
+ var import_commander5 = require("commander");
451
653
  var import_open = __toESM(require("open"));
452
- var import_ora3 = __toESM(require("ora"));
453
- var loginCommand = new import_commander4.Command("login").description("Authenticate with Commet").action(async () => {
654
+ var import_ora4 = __toESM(require("ora"));
655
+ var loginCommand = new import_commander5.Command("login").description("Authenticate with Commet").action(async () => {
454
656
  if (authExists()) {
455
657
  const auth = loadAuth();
456
- console.log(import_chalk5.default.yellow("\u26A0 You are already logged in."));
658
+ console.log(import_chalk6.default.yellow("\u26A0 You are already logged in."));
457
659
  console.log(
458
- import_chalk5.default.dim(
660
+ import_chalk6.default.dim(
459
661
  "Run `commet logout` first if you want to login with a different account."
460
662
  )
461
663
  );
@@ -463,11 +665,11 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
463
665
  }
464
666
  let environment;
465
667
  try {
466
- environment = await (0, import_prompts2.select)({
668
+ environment = await (0, import_prompts3.select)({
467
669
  message: "Select environment to login:",
468
670
  choices: [
469
671
  {
470
- name: `Sandbox ${import_chalk5.default.dim("(Development)")}`,
672
+ name: `Sandbox ${import_chalk6.default.dim("(Development)")}`,
471
673
  value: "sandbox"
472
674
  },
473
675
  {
@@ -479,10 +681,10 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
479
681
  theme: promptTheme
480
682
  });
481
683
  } catch (error) {
482
- console.log(import_chalk5.default.yellow("\n\u26A0 Login cancelled"));
684
+ console.log(import_chalk6.default.yellow("\n\u26A0 Login cancelled"));
483
685
  return;
484
686
  }
485
- const spinner = (0, import_ora3.default)("Initiating login flow...").start();
687
+ const spinner = (0, import_ora4.default)("Initiating login flow...").start();
486
688
  const baseURL = getBaseURL(environment);
487
689
  try {
488
690
  const deviceResponse = await fetch(`${baseURL}/api/auth/device/code`, {
@@ -495,7 +697,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
495
697
  });
496
698
  if (!deviceResponse.ok) {
497
699
  spinner.fail("Failed to initiate login");
498
- console.error(import_chalk5.default.red("Error:"), await deviceResponse.text());
700
+ console.error(import_chalk6.default.red("Error:"), await deviceResponse.text());
499
701
  return;
500
702
  }
501
703
  const deviceData = await deviceResponse.json();
@@ -506,25 +708,25 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
506
708
  interval = 5
507
709
  } = deviceData;
508
710
  spinner.stop();
509
- console.log(import_chalk5.default.bold("\n\u{1F510} Commet CLI Login\n"));
711
+ console.log(import_chalk6.default.bold("\n\u{1F510} Commet CLI Login\n"));
510
712
  console.log("Visit the following URL in your browser:");
511
- console.log(import_chalk5.default.cyan.underline(verification_uri_complete));
713
+ console.log(import_chalk6.default.cyan.underline(verification_uri_complete));
512
714
  console.log("\nOr enter this code manually:");
513
- console.log(import_chalk5.default.bold.green(` ${user_code}`));
514
- console.log(import_chalk5.default.dim("\nOpening browser...\n"));
715
+ console.log(import_chalk6.default.bold.green(` ${user_code}`));
716
+ console.log(import_chalk6.default.dim("\nOpening browser...\n"));
515
717
  try {
516
718
  await (0, import_open.default)(verification_uri_complete);
517
719
  } catch {
518
- console.log(import_chalk5.default.yellow("\u26A0 Could not open browser automatically."));
720
+ console.log(import_chalk6.default.yellow("\u26A0 Could not open browser automatically."));
519
721
  }
520
- const pollSpinner = (0, import_ora3.default)("Waiting for authorization...").start();
722
+ const pollSpinner = (0, import_ora4.default)("Waiting for authorization...").start();
521
723
  let pollingInterval = interval;
522
724
  let attempts = 0;
523
725
  const maxAttempts = 180 / pollingInterval;
524
726
  const poll = async () => {
525
727
  if (attempts >= maxAttempts) {
526
728
  pollSpinner.fail("Login timed out");
527
- console.log(import_chalk5.default.red("Authorization timed out. Please try again."));
729
+ console.log(import_chalk6.default.red("Authorization timed out. Please try again."));
528
730
  return;
529
731
  }
530
732
  attempts++;
@@ -555,9 +757,9 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
555
757
  }
556
758
  saveAuth(authConfig);
557
759
  pollSpinner.succeed("Successfully logged in!");
558
- console.log(import_chalk5.default.green("\n\u2713 Authentication complete"));
760
+ console.log(import_chalk6.default.green("\n\u2713 Authentication complete"));
559
761
  console.log(
560
- import_chalk5.default.dim(
762
+ import_chalk6.default.dim(
561
763
  "\nNext steps:\n 1. Run `commet link` to connect a project\n 2. Run `commet pull` to generate types\n"
562
764
  )
563
765
  );
@@ -570,12 +772,12 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
570
772
  setTimeout(() => poll(), pollingInterval * 1e3);
571
773
  } else if (tokenData.error === "access_denied") {
572
774
  pollSpinner.fail("Authorization denied");
573
- console.log(import_chalk5.default.red("\n\u2717 You denied the authorization request."));
775
+ console.log(import_chalk6.default.red("\n\u2717 You denied the authorization request."));
574
776
  return;
575
777
  } else if (tokenData.error === "expired_token") {
576
778
  pollSpinner.fail("Code expired");
577
779
  console.log(
578
- import_chalk5.default.red(
780
+ import_chalk6.default.red(
579
781
  "\n\u2717 The authorization code expired. Please try again."
580
782
  )
581
783
  );
@@ -583,7 +785,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
583
785
  } else {
584
786
  pollSpinner.fail("Authorization failed");
585
787
  console.log(
586
- import_chalk5.default.red("\n\u2717 Error:"),
788
+ import_chalk6.default.red("\n\u2717 Error:"),
587
789
  tokenData.error || "Unknown error"
588
790
  );
589
791
  return;
@@ -591,7 +793,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
591
793
  } catch (error) {
592
794
  pollSpinner.fail("Network error");
593
795
  console.error(
594
- import_chalk5.default.red("Error:"),
796
+ import_chalk6.default.red("Error:"),
595
797
  error instanceof Error ? error.message : "Unknown error"
596
798
  );
597
799
  }
@@ -600,42 +802,42 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
600
802
  } catch (error) {
601
803
  spinner.fail("Login failed");
602
804
  console.error(
603
- import_chalk5.default.red("Error:"),
805
+ import_chalk6.default.red("Error:"),
604
806
  error instanceof Error ? error.message : "Unknown error"
605
807
  );
606
808
  }
607
809
  });
608
810
 
609
811
  // src/commands/logout.ts
610
- var import_chalk6 = __toESM(require("chalk"));
611
- var import_commander5 = require("commander");
612
- var logoutCommand = new import_commander5.Command("logout").description("Log out of Commet").action(async () => {
812
+ var import_chalk7 = __toESM(require("chalk"));
813
+ var import_commander6 = require("commander");
814
+ var logoutCommand = new import_commander6.Command("logout").description("Log out of Commet").action(async () => {
613
815
  if (!authExists()) {
614
- console.log(import_chalk6.default.yellow("\u26A0 You are not logged in."));
816
+ console.log(import_chalk7.default.yellow("\u26A0 You are not logged in."));
615
817
  return;
616
818
  }
617
819
  clearAuth();
618
- console.log(import_chalk6.default.green("\u2713 Successfully logged out"));
820
+ console.log(import_chalk7.default.green("\u2713 Successfully logged out"));
619
821
  });
620
822
 
621
823
  // src/commands/pull.ts
622
- var fs5 = __toESM(require("fs"));
623
- var path5 = __toESM(require("path"));
624
- var import_chalk7 = __toESM(require("chalk"));
625
- var import_commander6 = require("commander");
626
- var import_ora4 = __toESM(require("ora"));
824
+ var fs6 = __toESM(require("fs"));
825
+ var path6 = __toESM(require("path"));
826
+ var import_chalk8 = __toESM(require("chalk"));
827
+ var import_commander7 = require("commander");
828
+ var import_ora5 = __toESM(require("ora"));
627
829
 
628
830
  // src/utils/environment-validator.ts
629
- var fs3 = __toESM(require("fs"));
630
- var path3 = __toESM(require("path"));
831
+ var fs4 = __toESM(require("fs"));
832
+ var path4 = __toESM(require("path"));
631
833
  function validateTypeScriptProject() {
632
834
  const cwd = process.cwd();
633
- const tsconfigPath = path3.join(cwd, "tsconfig.json");
634
- if (!fs3.existsSync(tsconfigPath)) {
835
+ const tsconfigPath = path4.join(cwd, "tsconfig.json");
836
+ if (!fs4.existsSync(tsconfigPath)) {
635
837
  return false;
636
838
  }
637
839
  try {
638
- const content = fs3.readFileSync(tsconfigPath, "utf8");
840
+ const content = fs4.readFileSync(tsconfigPath, "utf8");
639
841
  JSON.parse(content);
640
842
  return true;
641
843
  } catch (error) {
@@ -644,14 +846,10 @@ function validateTypeScriptProject() {
644
846
  }
645
847
 
646
848
  // src/utils/generator.ts
647
- function generateTypes(eventTypes, seatTypes, features, plans) {
648
- const eventTypeUnion = eventTypes.length > 0 ? eventTypes.map((e) => `"${e.code}"`).join(" | ") : "string";
849
+ function generateTypes(seatTypes, features, plans) {
649
850
  const seatTypeUnion = seatTypes.length > 0 ? seatTypes.map((s) => `"${s.code}"`).join(" | ") : "string";
650
851
  const planCodeUnion = plans.length > 0 ? plans.map((p) => `"${p.code}"`).join(" | ") : "string";
651
852
  const featureCodeUnion = features.length > 0 ? features.map((f) => `"${f.code}"`).join(" | ") : "string";
652
- const eventComments = eventTypes.map(
653
- (e) => ` * - "${e.code}": ${e.name}${e.description ? ` - ${e.description}` : ""}`
654
- ).join("\n");
655
853
  const seatComments = seatTypes.map(
656
854
  (s) => ` * - "${s.code}": ${s.name}${s.description ? ` - ${s.description}` : ""} ${s.isFree ? "(Free)" : ""}`
657
855
  ).join("\n");
@@ -665,52 +863,46 @@ function generateTypes(eventTypes, seatTypes, features, plans) {
665
863
  // Do not edit this file manually - run 'commet pull' to update
666
864
 
667
865
  /**
668
- * This augments the Commet SDK to automatically use your organization's
669
- * specific event types, seat types, plans, and features without requiring generic type parameters.
670
- *
671
- * Event types available in your organization:
672
- ${eventComments || " * (none)"}
673
- *
866
+ * This augments the Commet SDK with your organization's
867
+ * feature codes, seat types, and plan codes for autocomplete.
868
+ *
869
+ * Features available in your organization:
870
+ ${featureComments || " * (none)"}
871
+ *
674
872
  * Seat types available in your organization:
675
873
  ${seatComments || " * (none)"}
676
- *
874
+ *
677
875
  * Plans available in your organization:
678
876
  ${planComments || " * (none)"}
679
- *
680
- * Features available in your organization:
681
- ${featureComments || " * (none)"}
682
- *
683
- */
877
+ *
878
+ */
684
879
  declare module '@commet/node' {
685
880
  interface CommetGeneratedTypes {
686
- eventType: ${eventTypeUnion};
687
881
  seatType: ${seatTypeUnion};
688
882
  planCode: ${planCodeUnion};
689
883
  featureCode: ${featureCodeUnion};
690
884
  }
691
885
  }
692
886
 
693
- // This export is required for TypeScript to treat this file as a module
694
- // and apply the module augmentation above
695
887
  export {};
696
888
  `;
697
889
  }
698
890
 
699
891
  // src/utils/tsconfig-updater.ts
700
- var fs4 = __toESM(require("fs"));
701
- var path4 = __toESM(require("path"));
892
+ var fs5 = __toESM(require("fs"));
893
+ var path5 = __toESM(require("path"));
702
894
  var import_jsonc_parser = require("jsonc-parser");
703
895
  function updateTsConfig(entry) {
704
896
  const cwd = process.cwd();
705
- const tsconfigPath = path4.join(cwd, "tsconfig.json");
897
+ const tsconfigPath = path5.join(cwd, "tsconfig.json");
706
898
  try {
707
- if (!fs4.existsSync(tsconfigPath)) {
899
+ if (!fs5.existsSync(tsconfigPath)) {
708
900
  return {
709
901
  success: false,
710
902
  error: "tsconfig.json not found"
711
903
  };
712
904
  }
713
- const content = fs4.readFileSync(tsconfigPath, "utf8");
905
+ const content = fs5.readFileSync(tsconfigPath, "utf8");
714
906
  const config = (0, import_jsonc_parser.parse)(content);
715
907
  if (config.include && Array.isArray(config.include)) {
716
908
  if (config.include.includes(entry)) {
@@ -726,7 +918,7 @@ function updateTsConfig(entry) {
726
918
  }
727
919
  });
728
920
  const updatedContent = (0, import_jsonc_parser.applyEdits)(content, edits);
729
- fs4.writeFileSync(tsconfigPath, updatedContent, "utf8");
921
+ fs5.writeFileSync(tsconfigPath, updatedContent, "utf8");
730
922
  return { success: true };
731
923
  } catch (error) {
732
924
  return {
@@ -737,130 +929,120 @@ function updateTsConfig(entry) {
737
929
  }
738
930
 
739
931
  // src/commands/pull.ts
740
- var pullCommand = new import_commander6.Command("pull").description("Pull type definitions from Commet").action(async () => {
932
+ var pullCommand = new import_commander7.Command("pull").description("Pull type definitions from Commet").action(async () => {
741
933
  if (!authExists()) {
742
- console.log(import_chalk7.default.red("\u2717 Not authenticated"));
743
- console.log(import_chalk7.default.dim("Run `commet login` first"));
934
+ console.log(import_chalk8.default.red("\u2717 Not authenticated"));
935
+ console.log(import_chalk8.default.dim("Run `commet login` first"));
744
936
  return;
745
937
  }
746
938
  const hasTsConfig = validateTypeScriptProject();
747
939
  if (!projectConfigExists()) {
748
- console.log(import_chalk7.default.red("\u2717 Project not linked"));
940
+ console.log(import_chalk8.default.red("\u2717 Project not linked"));
749
941
  console.log(
750
- import_chalk7.default.dim("Run `commet link` first to connect to an organization")
942
+ import_chalk8.default.dim("Run `commet link` first to connect to an organization")
751
943
  );
752
944
  return;
753
945
  }
754
946
  const projectConfig = loadProjectConfig();
755
947
  if (!projectConfig) {
756
- console.log(import_chalk7.default.red("\u2717 Invalid project configuration"));
948
+ console.log(import_chalk8.default.red("\u2717 Invalid project configuration"));
757
949
  return;
758
950
  }
759
- const spinner = (0, import_ora4.default)("Fetching type definitions...").start();
951
+ const spinner = (0, import_ora5.default)("Fetching type definitions...").start();
760
952
  const baseURL = getBaseURL(projectConfig.environment);
761
953
  const result = await apiRequest(
762
954
  `${baseURL}/api/cli/types?orgId=${projectConfig.orgId}`
763
955
  );
764
956
  if (result.error || !result.data) {
765
957
  spinner.fail("Failed to fetch types");
766
- console.error(import_chalk7.default.red("Error:"), result.error);
958
+ console.error(import_chalk8.default.red("Error:"), result.error);
767
959
  return;
768
960
  }
769
- const { eventTypes, seatTypes, features, plans } = result.data;
770
- const typeDefinitions = generateTypes(
771
- eventTypes,
772
- seatTypes,
773
- features,
774
- plans
775
- );
776
- const commetDir = path5.resolve(process.cwd(), ".commet");
777
- const outputPath = path5.join(commetDir, "types.d.ts");
778
- fs5.mkdirSync(commetDir, { recursive: true });
779
- fs5.writeFileSync(outputPath, typeDefinitions, "utf8");
961
+ const { seatTypes, features, plans } = result.data;
962
+ const typeDefinitions = generateTypes(seatTypes, features, plans);
963
+ const commetDir = path6.resolve(process.cwd(), ".commet");
964
+ const outputPath = path6.join(commetDir, "types.d.ts");
965
+ fs6.mkdirSync(commetDir, { recursive: true });
966
+ fs6.writeFileSync(outputPath, typeDefinitions, "utf8");
780
967
  spinner.succeed("Type definitions generated!");
781
968
  if (hasTsConfig) {
782
969
  const tsconfigResult = updateTsConfig(".commet/types.d.ts");
783
970
  if (tsconfigResult.success) {
784
- console.log(import_chalk7.default.green("\u2713 Updated tsconfig.json"));
971
+ console.log(import_chalk8.default.green("\u2713 Updated tsconfig.json"));
785
972
  } else {
786
- console.log(import_chalk7.default.yellow("\u26A0 Could not update tsconfig.json"));
973
+ console.log(import_chalk8.default.yellow("\u26A0 Could not update tsconfig.json"));
787
974
  console.log(
788
- import_chalk7.default.dim(
975
+ import_chalk8.default.dim(
789
976
  'Add ".commet/types.d.ts" to your tsconfig.json include array'
790
977
  )
791
978
  );
792
979
  }
793
980
  } else {
794
- console.log(import_chalk7.default.yellow("\u26A0 No tsconfig.json found"));
981
+ console.log(import_chalk8.default.yellow("\u26A0 No tsconfig.json found"));
795
982
  console.log(
796
- import_chalk7.default.dim(
983
+ import_chalk8.default.dim(
797
984
  'Add ".commet/types.d.ts" to your tsconfig.json to enable types'
798
985
  )
799
986
  );
800
987
  }
801
988
  const gitignoreResult = updateGitignore(".commet/");
802
989
  if (gitignoreResult.success) {
803
- console.log(import_chalk7.default.green("\u2713 Updated .gitignore"));
990
+ console.log(import_chalk8.default.green("\u2713 Updated .gitignore"));
804
991
  } else {
805
- console.log(import_chalk7.default.yellow("\u26A0 No .gitignore found"));
806
- console.log(import_chalk7.default.dim("Add .commet/ to your .gitignore file"));
992
+ console.log(import_chalk8.default.yellow("\u26A0 No .gitignore found"));
993
+ console.log(import_chalk8.default.dim("Add .commet/ to your .gitignore file"));
807
994
  }
808
- console.log(import_chalk7.default.green("\nSuccess!"));
809
- console.log(import_chalk7.default.dim("\nGenerated types:"));
995
+ console.log(import_chalk8.default.green("\nSuccess!"));
996
+ console.log(import_chalk8.default.dim("\nGenerated types:"));
810
997
  console.log(
811
- import_chalk7.default.dim(
812
- ` Event types: ${eventTypes.length > 0 ? eventTypes.map((e) => e.code).join(", ") : "none"}`
998
+ import_chalk8.default.dim(
999
+ ` Features: ${features.length > 0 ? features.map((f) => f.code).join(", ") : "none"}`
813
1000
  )
814
1001
  );
815
1002
  console.log(
816
- import_chalk7.default.dim(
1003
+ import_chalk8.default.dim(
817
1004
  ` Seat types: ${seatTypes.length > 0 ? seatTypes.map((s) => s.code).join(", ") : "none"}`
818
1005
  )
819
1006
  );
820
1007
  console.log(
821
- import_chalk7.default.dim(
1008
+ import_chalk8.default.dim(
822
1009
  ` Plans: ${plans.length > 0 ? plans.map((p) => p.code).join(", ") : "none"}`
823
1010
  )
824
1011
  );
825
- console.log(
826
- import_chalk7.default.dim(
827
- ` Features: ${features.length > 0 ? features.map((f) => f.code).join(", ") : "none"}`
828
- )
829
- );
830
- console.log(import_chalk7.default.dim(`
1012
+ console.log(import_chalk8.default.dim(`
831
1013
  Output: ${outputPath}`));
832
- if (eventTypes.length === 0 && seatTypes.length === 0 && plans.length === 0 && features.length === 0) {
1014
+ if (seatTypes.length === 0 && plans.length === 0 && features.length === 0) {
833
1015
  console.log(
834
- import_chalk7.default.yellow(
835
- "\n\u26A0 No types found. Create event types, seat types, plans, and features in your Commet dashboard."
1016
+ import_chalk8.default.yellow(
1017
+ "\n\u26A0 No types found. Create features, seat types, and plans in your Commet dashboard."
836
1018
  )
837
1019
  );
838
1020
  }
839
1021
  });
840
1022
 
841
1023
  // src/commands/switch.ts
842
- var import_prompts3 = require("@inquirer/prompts");
843
- var import_chalk8 = __toESM(require("chalk"));
844
- var import_commander7 = require("commander");
845
- var import_ora5 = __toESM(require("ora"));
846
- var switchCommand = new import_commander7.Command("switch").description("Switch to a different organization").action(async () => {
1024
+ var import_prompts4 = require("@inquirer/prompts");
1025
+ var import_chalk9 = __toESM(require("chalk"));
1026
+ var import_commander8 = require("commander");
1027
+ var import_ora6 = __toESM(require("ora"));
1028
+ var switchCommand = new import_commander8.Command("switch").description("Switch to a different organization").action(async () => {
847
1029
  if (!authExists()) {
848
- console.log(import_chalk8.default.red("\u2717 Not authenticated"));
849
- console.log(import_chalk8.default.dim("Run `commet login` first"));
1030
+ console.log(import_chalk9.default.red("\u2717 Not authenticated"));
1031
+ console.log(import_chalk9.default.dim("Run `commet login` first"));
850
1032
  return;
851
1033
  }
852
1034
  if (!projectConfigExists()) {
853
- console.log(import_chalk8.default.yellow("\u26A0 Project not linked"));
1035
+ console.log(import_chalk9.default.yellow("\u26A0 Project not linked"));
854
1036
  console.log(
855
- import_chalk8.default.dim("Run `commet link` first to connect to an organization")
1037
+ import_chalk9.default.dim("Run `commet link` first to connect to an organization")
856
1038
  );
857
1039
  return;
858
1040
  }
859
- const spinner = (0, import_ora5.default)("Fetching organizations...").start();
1041
+ const spinner = (0, import_ora6.default)("Fetching organizations...").start();
860
1042
  const auth = loadAuth();
861
1043
  if (!auth) {
862
1044
  spinner.fail("Authentication error");
863
- console.log(import_chalk8.default.red("\u2717 Could not load authentication"));
1045
+ console.log(import_chalk9.default.red("\u2717 Could not load authentication"));
864
1046
  return;
865
1047
  }
866
1048
  const baseURL = getBaseURL(auth.environment);
@@ -869,33 +1051,33 @@ var switchCommand = new import_commander7.Command("switch").description("Switch
869
1051
  );
870
1052
  if (result.error || !result.data) {
871
1053
  spinner.fail("Failed to fetch organizations");
872
- console.error(import_chalk8.default.red("Error:"), result.error);
1054
+ console.error(import_chalk9.default.red("Error:"), result.error);
873
1055
  return;
874
1056
  }
875
1057
  const { organizations } = result.data;
876
1058
  if (organizations.length === 0) {
877
1059
  spinner.stop();
878
- console.log(import_chalk8.default.yellow("\u26A0 No organizations found"));
1060
+ console.log(import_chalk9.default.yellow("\u26A0 No organizations found"));
879
1061
  return;
880
1062
  }
881
1063
  spinner.stop();
882
1064
  let orgId;
883
1065
  try {
884
- orgId = await (0, import_prompts3.select)({
1066
+ orgId = await (0, import_prompts4.select)({
885
1067
  message: "Select organization:",
886
1068
  choices: organizations.map((org) => ({
887
- name: `${org.name} ${import_chalk8.default.dim(`(${org.slug})`)}`,
1069
+ name: `${org.name} ${import_chalk9.default.dim(`(${org.slug})`)}`,
888
1070
  value: org.id
889
1071
  })),
890
1072
  theme: promptTheme
891
1073
  });
892
1074
  } catch (error) {
893
- console.log(import_chalk8.default.yellow("\n\u26A0 Switch cancelled"));
1075
+ console.log(import_chalk9.default.yellow("\n\u26A0 Switch cancelled"));
894
1076
  return;
895
1077
  }
896
1078
  const selectedOrg = organizations.find((org) => org.id === orgId);
897
1079
  if (!selectedOrg) {
898
- console.log(import_chalk8.default.red("\u2717 Organization not found"));
1080
+ console.log(import_chalk9.default.red("\u2717 Organization not found"));
899
1081
  return;
900
1082
  }
901
1083
  saveProjectConfig({
@@ -903,54 +1085,54 @@ var switchCommand = new import_commander7.Command("switch").description("Switch
903
1085
  orgName: selectedOrg.name,
904
1086
  environment: auth.environment
905
1087
  });
906
- console.log(import_chalk8.default.green("\n\u2713 Switched organization successfully!"));
907
- console.log(import_chalk8.default.dim("\nNew configuration:"));
908
- console.log(import_chalk8.default.dim(` Organization: ${selectedOrg.name}`));
909
- console.log(import_chalk8.default.dim(` Environment: ${auth.environment}`));
1088
+ console.log(import_chalk9.default.green("\n\u2713 Switched organization successfully!"));
1089
+ console.log(import_chalk9.default.dim("\nNew configuration:"));
1090
+ console.log(import_chalk9.default.dim(` Organization: ${selectedOrg.name}`));
1091
+ console.log(import_chalk9.default.dim(` Environment: ${auth.environment}`));
910
1092
  console.log(
911
- import_chalk8.default.dim(
1093
+ import_chalk9.default.dim(
912
1094
  "\nRun `commet pull` to update TypeScript types for this organization"
913
1095
  )
914
1096
  );
915
1097
  });
916
1098
 
917
1099
  // src/commands/unlink.ts
918
- var import_chalk9 = __toESM(require("chalk"));
919
- var import_commander8 = require("commander");
920
- var unlinkCommand = new import_commander8.Command("unlink").description("Unlink this project from Commet").action(async () => {
1100
+ var import_chalk10 = __toESM(require("chalk"));
1101
+ var import_commander9 = require("commander");
1102
+ var unlinkCommand = new import_commander9.Command("unlink").description("Unlink this project from Commet").action(async () => {
921
1103
  if (!projectConfigExists()) {
922
1104
  console.log(
923
- import_chalk9.default.yellow("\u26A0 This project is not linked to any organization")
1105
+ import_chalk10.default.yellow("\u26A0 This project is not linked to any organization")
924
1106
  );
925
1107
  return;
926
1108
  }
927
1109
  clearProjectConfig();
928
- console.log(import_chalk9.default.green("\u2713 Project unlinked successfully"));
929
- console.log(import_chalk9.default.dim("\u2713 Removed .commet/ directory"));
1110
+ console.log(import_chalk10.default.green("\u2713 Project unlinked successfully"));
1111
+ console.log(import_chalk10.default.dim("\u2713 Removed .commet/ directory"));
930
1112
  console.log(
931
- import_chalk9.default.dim("\nRun `commet link` to connect to a different organization")
1113
+ import_chalk10.default.dim("\nRun `commet link` to connect to a different organization")
932
1114
  );
933
1115
  });
934
1116
 
935
1117
  // src/commands/whoami.ts
936
- var import_chalk10 = __toESM(require("chalk"));
937
- var import_commander9 = require("commander");
938
- var whoamiCommand = new import_commander9.Command("whoami").description("Display current authentication and project status").action(async () => {
1118
+ var import_chalk11 = __toESM(require("chalk"));
1119
+ var import_commander10 = require("commander");
1120
+ var whoamiCommand = new import_commander10.Command("whoami").description("Display current authentication and project status").action(async () => {
939
1121
  if (!authExists()) {
940
- console.log(import_chalk10.default.yellow("\u26A0 Not logged in"));
941
- console.log(import_chalk10.default.dim("Run `commet login` to authenticate"));
1122
+ console.log(import_chalk11.default.yellow("\u26A0 Not logged in"));
1123
+ console.log(import_chalk11.default.dim("Run `commet login` to authenticate"));
942
1124
  return;
943
1125
  }
944
- console.log(import_chalk10.default.green("\u2713 Logged in"));
1126
+ console.log(import_chalk11.default.green("\u2713 Logged in"));
945
1127
  const projectConfig = loadProjectConfig();
946
1128
  if (projectConfig) {
947
- console.log(import_chalk10.default.bold("\nProject:"));
948
- console.log(import_chalk10.default.dim("Organization:"), projectConfig.orgName);
949
- console.log(import_chalk10.default.dim("Environment:"), projectConfig.environment);
1129
+ console.log(import_chalk11.default.bold("\nProject:"));
1130
+ console.log(import_chalk11.default.dim("Organization:"), projectConfig.orgName);
1131
+ console.log(import_chalk11.default.dim("Environment:"), projectConfig.environment);
950
1132
  } else {
951
- console.log(import_chalk10.default.yellow("\n\u26A0 No project linked"));
1133
+ console.log(import_chalk11.default.yellow("\n\u26A0 No project linked"));
952
1134
  console.log(
953
- import_chalk10.default.dim(
1135
+ import_chalk11.default.dim(
954
1136
  "Run `commet link` to connect this directory to an organization"
955
1137
  )
956
1138
  );
@@ -958,10 +1140,11 @@ var whoamiCommand = new import_commander9.Command("whoami").description("Display
958
1140
  });
959
1141
 
960
1142
  // src/index.ts
961
- var program = new import_commander10.Command();
1143
+ var program = new import_commander11.Command();
962
1144
  program.name("commet").description(
963
1145
  "Commet CLI - Manage your billing platform from the command line"
964
1146
  ).version(package_default.version);
1147
+ program.addCommand(createCommand);
965
1148
  program.addCommand(loginCommand);
966
1149
  program.addCommand(logoutCommand);
967
1150
  program.addCommand(whoamiCommand);
@@ -979,7 +1162,7 @@ try {
979
1162
  if (error.message.includes("outputHelp")) {
980
1163
  process.exit(0);
981
1164
  }
982
- console.error(import_chalk11.default.red("Error:"), error.message);
1165
+ console.error(import_chalk12.default.red("Error:"), error.message);
983
1166
  }
984
1167
  process.exit(1);
985
1168
  }