calabasas 0.1.7 → 0.1.8

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 +48 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2626,6 +2626,8 @@ var CONFIG_DIR = path.join(os.homedir(), ".calabasas");
2626
2626
  var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
2627
2627
  var PROD_API_URL = "https://savory-llama-364.convex.site";
2628
2628
  var DEV_API_URL = "https://notable-monitor-41.convex.site";
2629
+ var PROD_WEB_URL = "https://calabasas-web.vercel.app";
2630
+ var DEV_WEB_URL = "http://localhost:3000";
2629
2631
  function getConfig() {
2630
2632
  try {
2631
2633
  if (!fs.existsSync(CONFIG_FILE)) {
@@ -2665,10 +2667,20 @@ function getApiUrlForEnv(env) {
2665
2667
  return PROD_API_URL;
2666
2668
  return getApiUrl();
2667
2669
  }
2670
+ function getWebUrlForEnv(env) {
2671
+ if (env === "dev")
2672
+ return DEV_WEB_URL;
2673
+ return PROD_WEB_URL;
2674
+ }
2668
2675
 
2669
2676
  // src/commands/login.ts
2670
2677
  var CALLBACK_PORT = 9876;
2671
- async function login() {
2678
+ async function login(options) {
2679
+ if (options.dev && options.prod) {
2680
+ console.error("Error: Cannot use both --dev and --prod flags.");
2681
+ process.exit(1);
2682
+ }
2683
+ const env = options.dev ? "dev" : options.prod ? "prod" : undefined;
2672
2684
  const existing = getConfig();
2673
2685
  if (existing.apiKey) {
2674
2686
  console.log("You are already logged in.");
@@ -2735,7 +2747,7 @@ async function login() {
2735
2747
  }
2736
2748
  });
2737
2749
  server.listen(CALLBACK_PORT, async () => {
2738
- const authUrl = `https://calabasas-web.vercel.app/auth/cli?callback=http://localhost:${CALLBACK_PORT}/callback`;
2750
+ const authUrl = `${getWebUrlForEnv(env)}/auth/cli?callback=http://localhost:${CALLBACK_PORT}/callback`;
2739
2751
  console.log("If the browser doesn't open automatically, visit:");
2740
2752
  console.log(` ${authUrl}
2741
2753
  `);
@@ -5286,9 +5298,9 @@ Selected intents value: ${total}`);
5286
5298
  process.stdin.on("data", onKeypress);
5287
5299
  });
5288
5300
  }
5289
- async function apiRequest(method, path8, body) {
5301
+ async function apiRequest(method, path8, body, env) {
5290
5302
  const config = getConfig();
5291
- const url = `${getApiUrl()}${path8}`;
5303
+ const url = `${getApiUrlForEnv(env)}${path8}`;
5292
5304
  const response = await fetch(url, {
5293
5305
  method,
5294
5306
  headers: {
@@ -5300,7 +5312,12 @@ async function apiRequest(method, path8, body) {
5300
5312
  const data = await response.json();
5301
5313
  return { ok: response.ok, data, status: response.status };
5302
5314
  }
5303
- async function botAdd() {
5315
+ async function botAdd(options) {
5316
+ if (options.dev && options.prod) {
5317
+ console.error("Error: Cannot use both --dev and --prod flags.");
5318
+ process.exit(1);
5319
+ }
5320
+ const env = options.dev ? "dev" : options.prod ? "prod" : undefined;
5304
5321
  if (!isAuthenticated()) {
5305
5322
  console.log("Not logged in. Run `calabasas login` first.");
5306
5323
  return;
@@ -5339,7 +5356,7 @@ async function botAdd() {
5339
5356
  intents,
5340
5357
  convexUrl: convexUrl.trim(),
5341
5358
  sharedSecret
5342
- });
5359
+ }, env);
5343
5360
  if (!ok) {
5344
5361
  console.log(`
5345
5362
  Failed to create bot: ${data.error || `HTTP ${status}`}`);
@@ -5356,12 +5373,17 @@ Failed to create bot: ${data.error || `HTTP ${status}`}`);
5356
5373
  console.log("2. Create your handler in convex/discord.ts");
5357
5374
  console.log("3. Add CALABASAS_SECRET to your Convex environment variables");
5358
5375
  }
5359
- async function botList() {
5376
+ async function botList(options) {
5377
+ if (options.dev && options.prod) {
5378
+ console.error("Error: Cannot use both --dev and --prod flags.");
5379
+ process.exit(1);
5380
+ }
5381
+ const env = options.dev ? "dev" : options.prod ? "prod" : undefined;
5360
5382
  if (!isAuthenticated()) {
5361
5383
  console.log("Not logged in. Run `calabasas login` first.");
5362
5384
  return;
5363
5385
  }
5364
- const { ok, data, status } = await apiRequest("GET", "/api/cli/bots");
5386
+ const { ok, data, status } = await apiRequest("GET", "/api/cli/bots", undefined, env);
5365
5387
  if (!ok) {
5366
5388
  console.log(`Failed to list bots: ${data.error || `HTTP ${status}`}`);
5367
5389
  return;
@@ -5383,7 +5405,12 @@ async function botList() {
5383
5405
  console.log("");
5384
5406
  }
5385
5407
  }
5386
- async function botRemove(botId) {
5408
+ async function botRemove(botId, options) {
5409
+ if (options.dev && options.prod) {
5410
+ console.error("Error: Cannot use both --dev and --prod flags.");
5411
+ process.exit(1);
5412
+ }
5413
+ const env = options.dev ? "dev" : options.prod ? "prod" : undefined;
5387
5414
  if (!isAuthenticated()) {
5388
5415
  console.log("Not logged in. Run `calabasas login` first.");
5389
5416
  return;
@@ -5393,7 +5420,7 @@ async function botRemove(botId) {
5393
5420
  console.log("Cancelled.");
5394
5421
  return;
5395
5422
  }
5396
- const { ok, data, status } = await apiRequest("DELETE", `/api/cli/bots?id=${botId}`);
5423
+ const { ok, data, status } = await apiRequest("DELETE", `/api/cli/bots?id=${botId}`, undefined, env);
5397
5424
  if (!ok) {
5398
5425
  console.log(`Failed to remove bot: ${data.error || `HTTP ${status}`}`);
5399
5426
  return;
@@ -5401,6 +5428,11 @@ async function botRemove(botId) {
5401
5428
  console.log("✅ Bot removed successfully!");
5402
5429
  }
5403
5430
  async function botEdit(botId, options) {
5431
+ if (options.dev && options.prod) {
5432
+ console.error("Error: Cannot use both --dev and --prod flags.");
5433
+ process.exit(1);
5434
+ }
5435
+ const env = options.dev ? "dev" : options.prod ? "prod" : undefined;
5404
5436
  if (!isAuthenticated()) {
5405
5437
  console.log("Not logged in. Run `calabasas login` first.");
5406
5438
  return;
@@ -5430,7 +5462,7 @@ async function botEdit(botId, options) {
5430
5462
  return;
5431
5463
  }
5432
5464
  console.log("Updating bot...");
5433
- const { ok, data, status } = await apiRequest("PATCH", "/api/cli/bots", updates);
5465
+ const { ok, data, status } = await apiRequest("PATCH", "/api/cli/bots", updates, env);
5434
5466
  if (!ok) {
5435
5467
  console.log(`Failed to update bot: ${data.error || `HTTP ${status}`}`);
5436
5468
  return;
@@ -5443,7 +5475,7 @@ async function botEdit(botId, options) {
5443
5475
  // src/index.ts
5444
5476
  var program2 = new Command;
5445
5477
  program2.name("calabasas").description("CLI for Calabasas - Discord Gateway as a Service for Convex").version("0.0.1");
5446
- program2.command("login").description("Authenticate with Calabasas using your API key").action(login);
5478
+ program2.command("login").description("Authenticate with Calabasas using your API key").option("--dev", "Use development environment").option("--prod", "Use production environment").action(login);
5447
5479
  program2.command("logout").description("Clear stored credentials").action(logout);
5448
5480
  program2.command("init").description("Initialize Calabasas config in your Convex project").action(init);
5449
5481
  program2.command("push").description("Push your calabasas.config.ts to Calabasas").option("-c, --config <path>", "Path to config file", "convex/calabasas.config.ts").option("-b, --bot <botId>", "Bot ID to configure (prompts if not specified)").option("--dev", "Push to development environment").option("--prod", "Push to production environment").action(push);
@@ -5451,8 +5483,8 @@ program2.command("generate").description("Generate discord.generated.ts with typ
5451
5483
  program2.command("skill").description("Generate Calabasas documentation for AI assistants").action(skill);
5452
5484
  program2.command("add [components...]").description("Add Discord UI components to your project").action(add);
5453
5485
  var bot = program2.command("bot").description("Manage Discord bots");
5454
- bot.command("add").description("Add a new Discord bot").action(botAdd);
5455
- bot.command("list").alias("ls").description("List your Discord bots").action(botList);
5456
- bot.command("remove <botId>").alias("rm").description("Remove a Discord bot").action(botRemove);
5457
- bot.command("edit <botId>").description("Edit a Discord bot").option("-n, --name <name>", "New bot name").option("-u, --url <url>", "New Convex URL").option("-t, --token <token>", "New bot token").option("-i, --intents <intents>", "New intents value").action(botEdit);
5486
+ bot.command("add").description("Add a new Discord bot").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botAdd);
5487
+ bot.command("list").alias("ls").description("List your Discord bots").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botList);
5488
+ bot.command("remove <botId>").alias("rm").description("Remove a Discord bot").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botRemove);
5489
+ bot.command("edit <botId>").description("Edit a Discord bot").option("-n, --name <name>", "New bot name").option("-u, --url <url>", "New Convex URL").option("-t, --token <token>", "New bot token").option("-i, --intents <intents>", "New intents value").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botEdit);
5458
5490
  program2.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calabasas",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "CLI for Calabasas - Discord Gateway as a Service for Convex",
5
5
  "type": "module",
6
6
  "bin": {