calabasas 0.23.1 → 0.24.1
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 +44 -50
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2085,59 +2085,53 @@ Run \`calabasas logout\` to clear credentials.`, "Already logged in");
|
|
|
2085
2085
|
}
|
|
2086
2086
|
const s = p.spinner();
|
|
2087
2087
|
s.start("Opening browser for authentication...");
|
|
2088
|
+
const webOrigin = new URL(getWebUrl()).origin;
|
|
2089
|
+
function corsHeaders() {
|
|
2090
|
+
return {
|
|
2091
|
+
"Access-Control-Allow-Origin": webOrigin,
|
|
2092
|
+
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
|
2093
|
+
"Access-Control-Allow-Headers": "Content-Type"
|
|
2094
|
+
};
|
|
2095
|
+
}
|
|
2088
2096
|
const server = http.createServer((req, res) => {
|
|
2089
2097
|
const url = new URL(req.url || "", `http://localhost:${CALLBACK_PORT}`);
|
|
2090
|
-
if (
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
</div>
|
|
2112
|
-
</body>
|
|
2113
|
-
</html>
|
|
2114
|
-
`);
|
|
2115
|
-
s.stop("Authenticated!");
|
|
2116
|
-
p.note(`calabasas bot add - Add a Discord bot
|
|
2098
|
+
if (req.method === "OPTIONS") {
|
|
2099
|
+
res.writeHead(204, { ...corsHeaders(), "Access-Control-Max-Age": "600" });
|
|
2100
|
+
res.end();
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
if (url.pathname === "/callback" && req.method === "POST") {
|
|
2104
|
+
const chunks = [];
|
|
2105
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
2106
|
+
req.on("end", () => {
|
|
2107
|
+
let apiKey;
|
|
2108
|
+
try {
|
|
2109
|
+
const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
2110
|
+
if (typeof parsed.key === "string")
|
|
2111
|
+
apiKey = parsed.key;
|
|
2112
|
+
} catch {}
|
|
2113
|
+
if (apiKey) {
|
|
2114
|
+
saveConfig({ apiKey });
|
|
2115
|
+
res.writeHead(204, corsHeaders());
|
|
2116
|
+
res.end();
|
|
2117
|
+
s.stop("Authenticated!");
|
|
2118
|
+
p.note(`calabasas bot add - Add a Discord bot
|
|
2117
2119
|
calabasas bot list - List your bots
|
|
2118
2120
|
calabasas generate - Generate event handlers`, "Available commands");
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
<body>
|
|
2131
|
-
<h1>Authentication failed</h1>
|
|
2132
|
-
<p>No API key received.</p>
|
|
2133
|
-
</body>
|
|
2134
|
-
</html>
|
|
2135
|
-
`);
|
|
2136
|
-
}
|
|
2137
|
-
} else {
|
|
2138
|
-
res.writeHead(404);
|
|
2139
|
-
res.end("Not found");
|
|
2121
|
+
p.outro("Logged in successfully!");
|
|
2122
|
+
setTimeout(() => {
|
|
2123
|
+
server.close();
|
|
2124
|
+
process.exit(0);
|
|
2125
|
+
}, 500);
|
|
2126
|
+
} else {
|
|
2127
|
+
res.writeHead(400, { ...corsHeaders(), "Content-Type": "application/json" });
|
|
2128
|
+
res.end(JSON.stringify({ error: "Missing or invalid key" }));
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
return;
|
|
2140
2132
|
}
|
|
2133
|
+
res.writeHead(404);
|
|
2134
|
+
res.end("Not found");
|
|
2141
2135
|
});
|
|
2142
2136
|
server.listen(CALLBACK_PORT, async () => {
|
|
2143
2137
|
const authUrl = `${getWebUrl()}/auth/cli?callback=http://localhost:${CALLBACK_PORT}/callback`;
|
|
@@ -2621,11 +2615,11 @@ async function generate(options) {
|
|
|
2621
2615
|
if (text.includes("roles") && text.includes("true"))
|
|
2622
2616
|
syncExports.push("syncRole", "syncRoleBatch");
|
|
2623
2617
|
if (text.includes("members") && text.includes("true"))
|
|
2624
|
-
syncExports.push("syncMember", "syncMemberBatch", "deleteMemberBatch");
|
|
2618
|
+
syncExports.push("syncMember", "syncMemberBatch", "deleteMemberBatch", "bootstrapMemberCache");
|
|
2625
2619
|
if (text.includes("presence") && text.includes("true"))
|
|
2626
2620
|
syncExports.push("syncPresence", "syncPresenceBatch");
|
|
2627
2621
|
if (syncExports.length === 0) {
|
|
2628
|
-
syncExports.push("syncGuild", "syncChannel", "syncChannelBatch", "syncRole", "syncRoleBatch", "syncMember", "syncMemberBatch", "deleteMemberBatch", "syncPresence", "syncPresenceBatch");
|
|
2622
|
+
syncExports.push("syncGuild", "syncChannel", "syncChannelBatch", "syncRole", "syncRoleBatch", "syncMember", "syncMemberBatch", "deleteMemberBatch", "bootstrapMemberCache", "syncPresence", "syncPresenceBatch");
|
|
2629
2623
|
}
|
|
2630
2624
|
syncExports.push("updateSyncState");
|
|
2631
2625
|
steps.push(`${stepNum}. Re-export sync mutations in convex/discord.ts:
|