calabasas 0.1.4 → 0.1.6
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.
- package/dist/index.js +32 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2624,7 +2624,8 @@ import * as path from "path";
|
|
|
2624
2624
|
import * as os from "os";
|
|
2625
2625
|
var CONFIG_DIR = path.join(os.homedir(), ".calabasas");
|
|
2626
2626
|
var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
2627
|
-
var
|
|
2627
|
+
var PROD_API_URL = "https://savory-llama-364.convex.site";
|
|
2628
|
+
var DEV_API_URL = "https://notable-monitor-41.convex.site";
|
|
2628
2629
|
function getConfig() {
|
|
2629
2630
|
try {
|
|
2630
2631
|
if (!fs.existsSync(CONFIG_FILE)) {
|
|
@@ -2655,7 +2656,14 @@ function isAuthenticated() {
|
|
|
2655
2656
|
}
|
|
2656
2657
|
function getApiUrl() {
|
|
2657
2658
|
const config = getConfig();
|
|
2658
|
-
return config.apiUrl ||
|
|
2659
|
+
return config.apiUrl || PROD_API_URL;
|
|
2660
|
+
}
|
|
2661
|
+
function getApiUrlForEnv(env) {
|
|
2662
|
+
if (env === "dev")
|
|
2663
|
+
return DEV_API_URL;
|
|
2664
|
+
if (env === "prod")
|
|
2665
|
+
return PROD_API_URL;
|
|
2666
|
+
return getApiUrl();
|
|
2659
2667
|
}
|
|
2660
2668
|
|
|
2661
2669
|
// src/commands/login.ts
|
|
@@ -2682,6 +2690,7 @@ async function login() {
|
|
|
2682
2690
|
<!DOCTYPE html>
|
|
2683
2691
|
<html>
|
|
2684
2692
|
<head>
|
|
2693
|
+
<meta charset="utf-8">
|
|
2685
2694
|
<title>Calabasas CLI</title>
|
|
2686
2695
|
<style>
|
|
2687
2696
|
body { font-family: system-ui; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: #0a0a0a; color: white; }
|
|
@@ -2712,7 +2721,7 @@ async function login() {
|
|
|
2712
2721
|
res.end(`
|
|
2713
2722
|
<!DOCTYPE html>
|
|
2714
2723
|
<html>
|
|
2715
|
-
<head><title>Error</title></head>
|
|
2724
|
+
<head><meta charset="utf-8"><title>Error</title></head>
|
|
2716
2725
|
<body>
|
|
2717
2726
|
<h1>Authentication failed</h1>
|
|
2718
2727
|
<p>No API key received.</p>
|
|
@@ -2726,7 +2735,7 @@ async function login() {
|
|
|
2726
2735
|
}
|
|
2727
2736
|
});
|
|
2728
2737
|
server.listen(CALLBACK_PORT, async () => {
|
|
2729
|
-
const authUrl = `
|
|
2738
|
+
const authUrl = `https://calabasas-web.vercel.app/auth/cli?callback=http://localhost:${CALLBACK_PORT}/callback`;
|
|
2730
2739
|
console.log("If the browser doesn't open automatically, visit:");
|
|
2731
2740
|
console.log(` ${authUrl}
|
|
2732
2741
|
`);
|
|
@@ -2835,8 +2844,8 @@ function parseConfigFile(configPath) {
|
|
|
2835
2844
|
}
|
|
2836
2845
|
return { sync, events };
|
|
2837
2846
|
}
|
|
2838
|
-
async function selectBot(apiKey) {
|
|
2839
|
-
const response = await fetch(`${
|
|
2847
|
+
async function selectBot(apiKey, apiUrl) {
|
|
2848
|
+
const response = await fetch(`${apiUrl}/api/cli/bots`, {
|
|
2840
2849
|
method: "GET",
|
|
2841
2850
|
headers: {
|
|
2842
2851
|
"Content-Type": "application/json",
|
|
@@ -2878,6 +2887,12 @@ async function selectBot(apiKey) {
|
|
|
2878
2887
|
});
|
|
2879
2888
|
}
|
|
2880
2889
|
async function push(options) {
|
|
2890
|
+
if (options.dev && options.prod) {
|
|
2891
|
+
console.error("Error: Cannot use both --dev and --prod flags.");
|
|
2892
|
+
process.exit(1);
|
|
2893
|
+
}
|
|
2894
|
+
const env = options.dev ? "dev" : options.prod ? "prod" : undefined;
|
|
2895
|
+
const apiUrl = getApiUrlForEnv(env);
|
|
2881
2896
|
const configPath = path4.resolve(process.cwd(), options.config);
|
|
2882
2897
|
if (!fs8.existsSync(configPath)) {
|
|
2883
2898
|
console.error(`Error: Config file not found: ${configPath}`);
|
|
@@ -2893,15 +2908,16 @@ async function push(options) {
|
|
|
2893
2908
|
const apiKey = config.apiKey;
|
|
2894
2909
|
let botId = options.bot;
|
|
2895
2910
|
if (!botId) {
|
|
2896
|
-
botId = await selectBot(apiKey) ?? undefined;
|
|
2911
|
+
botId = await selectBot(apiKey, apiUrl) ?? undefined;
|
|
2897
2912
|
if (!botId) {
|
|
2898
2913
|
process.exit(1);
|
|
2899
2914
|
}
|
|
2900
2915
|
}
|
|
2901
|
-
|
|
2916
|
+
const envLabel = env ?? "prod";
|
|
2917
|
+
console.log(`Pushing config from ${options.config} to ${envLabel}...`);
|
|
2902
2918
|
const calabasasConfig = parseConfigFile(configPath);
|
|
2903
2919
|
const eventConfigs = Object.keys(calabasasConfig.events ?? {}).map((eventType) => ({ eventType }));
|
|
2904
|
-
const response = await fetch(`${
|
|
2920
|
+
const response = await fetch(`${apiUrl}/api/cli/sync-config`, {
|
|
2905
2921
|
method: "POST",
|
|
2906
2922
|
headers: {
|
|
2907
2923
|
"Content-Type": "application/json",
|
|
@@ -4262,6 +4278,7 @@ type ChannelSelectProps = {
|
|
|
4262
4278
|
onValueChange?: (channelDiscordId: string) => void;
|
|
4263
4279
|
placeholder?: string;
|
|
4264
4280
|
className?: string;
|
|
4281
|
+
channelTypes?: number[];
|
|
4265
4282
|
};
|
|
4266
4283
|
|
|
4267
4284
|
export function ChannelSelect({
|
|
@@ -4270,9 +4287,13 @@ export function ChannelSelect({
|
|
|
4270
4287
|
onValueChange,
|
|
4271
4288
|
placeholder = "Select channel...",
|
|
4272
4289
|
className,
|
|
4290
|
+
channelTypes,
|
|
4273
4291
|
}: ChannelSelectProps) {
|
|
4274
4292
|
const [open, setOpen] = useState(false);
|
|
4275
|
-
const
|
|
4293
|
+
const allChannels = useQuery(api.calabasas.queries.listChannels, { guildDiscordId });
|
|
4294
|
+
const channels = channelTypes
|
|
4295
|
+
? allChannels?.filter((c) => channelTypes.includes(c.type))
|
|
4296
|
+
: allChannels;
|
|
4276
4297
|
|
|
4277
4298
|
const selected = channels?.find((c) => c.discordId === value);
|
|
4278
4299
|
|
|
@@ -5332,7 +5353,7 @@ program2.name("calabasas").description("CLI for Calabasas - Discord Gateway as a
|
|
|
5332
5353
|
program2.command("login").description("Authenticate with Calabasas using your API key").action(login);
|
|
5333
5354
|
program2.command("logout").description("Clear stored credentials").action(logout);
|
|
5334
5355
|
program2.command("init").description("Initialize Calabasas config in your Convex project").action(init);
|
|
5335
|
-
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)").action(push);
|
|
5356
|
+
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);
|
|
5336
5357
|
program2.command("generate").description("Generate discord.generated.ts with type-safe handlers").option("-o, --output <path>", "Output path", "convex/discord.generated.ts").action(generate);
|
|
5337
5358
|
program2.command("skill").description("Generate Calabasas documentation for AI assistants").action(skill);
|
|
5338
5359
|
program2.command("add [components...]").description("Add Discord UI components to your project").action(add);
|