calabasas 0.2.2 → 0.2.4

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 +39 -29
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -49683,8 +49683,10 @@ var init_build3 = __esm(async () => {
49683
49683
  });
49684
49684
 
49685
49685
  // src/components/StatusBadge.tsx
49686
- function StatusBadge({ status }) {
49686
+ function StatusBadge({ status, width = 0 }) {
49687
49687
  const config = STATUS_CONFIG[status];
49688
+ const label = `${config.dot} ${status}`;
49689
+ const padded = width > 0 ? label.padEnd(width) : label;
49688
49690
  return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
49689
49691
  children: [
49690
49692
  /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
@@ -49692,11 +49694,8 @@ function StatusBadge({ status }) {
49692
49694
  children: config.dot
49693
49695
  }, undefined, false, undefined, this),
49694
49696
  /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
49695
- children: [
49696
- " ",
49697
- status
49698
- ]
49699
- }, undefined, true, undefined, this)
49697
+ children: padded.slice(1)
49698
+ }, undefined, false, undefined, this)
49700
49699
  ]
49701
49700
  }, undefined, true, undefined, this);
49702
49701
  }
@@ -49772,6 +49771,12 @@ function BotList({
49772
49771
  }, undefined, false, undefined, this)
49773
49772
  }, undefined, false, undefined, this);
49774
49773
  }
49774
+ const COL = { name: 30, status: 16, appId: 22, url: 34 };
49775
+ function truncate(str, max) {
49776
+ if (str.length <= max)
49777
+ return str.padEnd(max);
49778
+ return str.slice(0, max - 1) + "…";
49779
+ }
49775
49780
  return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
49776
49781
  flexDirection: "column",
49777
49782
  children: [
@@ -49780,10 +49785,11 @@ function BotList({
49780
49785
  children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
49781
49786
  bold: true,
49782
49787
  children: [
49783
- " Name".padEnd(22),
49784
- "Status".padEnd(16),
49785
- "Discord App ID".padEnd(22),
49786
- "Convex URL".padEnd(36),
49788
+ " ",
49789
+ "Name".padEnd(COL.name),
49790
+ "Status".padEnd(COL.status),
49791
+ "Discord App ID".padEnd(COL.appId),
49792
+ "Convex URL".padEnd(COL.url),
49787
49793
  "Last Connected"
49788
49794
  ]
49789
49795
  }, undefined, true, undefined, this)
@@ -49801,21 +49807,19 @@ function BotList({
49801
49807
  }, undefined, false, undefined, this),
49802
49808
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
49803
49809
  bold: isSelected,
49804
- children: bot.name.padEnd(20)
49810
+ children: truncate(bot.name, COL.name)
49805
49811
  }, undefined, false, undefined, this),
49806
49812
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(StatusBadge, {
49807
- status: bot.status
49808
- }, undefined, false, undefined, this),
49809
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
49810
- children: "".padEnd(Math.max(0, 16 - bot.status.length - 2))
49813
+ status: bot.status,
49814
+ width: COL.status
49811
49815
  }, undefined, false, undefined, this),
49812
49816
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
49813
49817
  dimColor: true,
49814
- children: bot.discordAppId.padEnd(22)
49818
+ children: bot.discordAppId.padEnd(COL.appId)
49815
49819
  }, undefined, false, undefined, this),
49816
49820
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
49817
49821
  dimColor: true,
49818
- children: bot.convexUrl.replace("https://", "").padEnd(36)
49822
+ children: truncate(bot.convexUrl.replace("https://", ""), COL.url)
49819
49823
  }, undefined, false, undefined, this),
49820
49824
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
49821
49825
  dimColor: true,
@@ -52352,7 +52356,7 @@ async function botList(options) {
52352
52356
  console.log("Not logged in. Run `calabasas login` first.");
52353
52357
  return;
52354
52358
  }
52355
- if (options.watch) {
52359
+ if (!options.once && process.stdin.isTTY) {
52356
52360
  const React14 = await Promise.resolve().then(() => __toESM(require_react(), 1));
52357
52361
  const { render: render2 } = await init_build2().then(() => exports_build);
52358
52362
  const { createConvexClient: createConvexClient2, ConvexProvider: ConvexProvider3 } = await Promise.resolve().then(() => (init_convex(), exports_convex));
@@ -52666,19 +52670,13 @@ function formatTimestamp(ts) {
52666
52670
  function LogViewer({
52667
52671
  apiKey,
52668
52672
  botId,
52669
- limit = 50,
52670
- onQuit
52673
+ limit = 50
52671
52674
  }) {
52672
52675
  const logs = useQuery(cliApi.recentLogs, {
52673
52676
  apiKey,
52674
52677
  botId,
52675
52678
  limit
52676
52679
  });
52677
- use_input_default((input) => {
52678
- if (input === "q" && onQuit) {
52679
- onQuit();
52680
- }
52681
- });
52682
52680
  if (logs === undefined) {
52683
52681
  return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
52684
52682
  children: [
@@ -52854,6 +52852,19 @@ async function fetchBotList(apiKey, env3) {
52854
52852
  const { bots } = await response.json();
52855
52853
  return bots;
52856
52854
  }
52855
+ function LogsApp({ apiKey, botId, limit }) {
52856
+ const { exit } = use_app_default();
52857
+ use_input_default((input) => {
52858
+ if (input === "q") {
52859
+ exit();
52860
+ }
52861
+ });
52862
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(LogViewer, {
52863
+ apiKey,
52864
+ botId,
52865
+ limit
52866
+ }, undefined, false, undefined, this);
52867
+ }
52857
52868
  async function logs(botId, options) {
52858
52869
  if (options.dev && options.prod) {
52859
52870
  console.error("Error: Cannot use both --dev and --prod flags.");
@@ -52898,11 +52909,10 @@ async function logs(botId, options) {
52898
52909
  const client = createConvexClient(convexUrl);
52899
52910
  const { waitUntilExit } = render_default(/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ConvexProvider2, {
52900
52911
  client,
52901
- children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(LogViewer, {
52912
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(LogsApp, {
52902
52913
  apiKey,
52903
52914
  botId,
52904
- limit,
52905
- onQuit: () => process.exit(0)
52915
+ limit
52906
52916
  }, undefined, false, undefined, this)
52907
52917
  }, undefined, false, undefined, this));
52908
52918
  await waitUntilExit();
@@ -52923,7 +52933,7 @@ program2.command("status").alias("dashboard").description("Real-time dashboard s
52923
52933
  program2.command("logs [botId]").description("Live event log viewer for a bot").option("-n, --limit <number>", "Number of log entries to show", "50").option("--dev", "Use development environment").option("--prod", "Use production environment").action(logs);
52924
52934
  var bot = program2.command("bot").description("Manage Discord bots");
52925
52935
  bot.command("add").description("Add a new Discord bot").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botAdd);
52926
- bot.command("list").alias("ls").description("List your Discord bots").option("-w, --watch", "Watch mode with live updates").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botList);
52936
+ bot.command("list").alias("ls").description("List your Discord bots (real-time by default)").option("--once", "One-shot output instead of real-time view").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botList);
52927
52937
  bot.command("remove <botId>").alias("rm").description("Remove a Discord bot").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botRemove);
52928
52938
  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);
52929
52939
  program2.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calabasas",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "CLI for Calabasas - Discord Gateway as a Service for Convex",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,6 +38,7 @@
38
38
  "react": "^18",
39
39
  "react-devtools-core": "^6",
40
40
  "ws": "^8",
41
+ "@types/ws": "^8",
41
42
  "typescript": "^5"
42
43
  },
43
44
  "files": [