From 3781f63e6d61549939abe81a18d9f37c2b51bdc2 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Mon, 11 Jul 2022 04:25:23 -0500 Subject: [PATCH] feat: cross platform version lol --- .gitignore | 8 ++- build.ts | 69 ++++++++++++++++++++++++ packages/biscuit/tests/deps.ts | 2 - packages/discordeno/rest/runMethod.ts | 2 +- tests/deps.ts | 1 + {packages/biscuit/tests => tests}/mod.ts | 5 +- 6 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 build.ts delete mode 100644 packages/biscuit/tests/deps.ts create mode 100644 tests/deps.ts rename {packages/biscuit/tests => tests}/mod.ts (85%) diff --git a/.gitignore b/.gitignore index eff82d6..e32be07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +# editors .vim/ +.vscode/ + +# build +npm/ + +# etc .env -.vscode diff --git a/build.ts b/build.ts new file mode 100644 index 0000000..2ca1688 --- /dev/null +++ b/build.ts @@ -0,0 +1,69 @@ +import { build } from 'https://deno.land/x/dnt@0.23.0/mod.ts'; + +await Deno.remove('npm', { recursive: true }).catch((_) => {}); + +await build({ + shims: { + deno: true, + timers: true, + custom: [ + { + package: { + name: 'ws', + version: '^8.4.0', + }, + globalNames: [ + { + name: 'WebSocket', + exportName: 'default', + }, + ], + }, + ], + }, + package: { + author: 'Yuzuru', + name: '@oasisjs/biscuit', + version: Deno.args[0], + description: 'the Biscuit library', + license: 'Apache License 2.0', + repository: { + type: 'git', + url: 'git+https://github.com/yuzudev/oasis.git', + }, + bugs: { + url: 'https://github.com/yuzudev/oasis/issues', + }, + typesVersions: { + '*': { + '*': ['./types/mod.d.ts'], + 'biscuit': ['./types/packages/biscuit/mod.d.ts'], + 'discordeno': ['./types/packages/discordeno/mod.d.ts'], + 'cache': ['./types/packages/cache/mod.d.ts'], + }, + }, + }, + entryPoints: [ + './mod.ts', + { + name: './biscuit', + path: 'packages/biscuit/mod.ts', + }, + { + name: './discordeno', + path: 'packages/discordeno/mod.ts', + }, + { + name: './cache', + path: 'packages/cache/mod.ts', + }, + ], + outDir: './npm', + declaration: true, + typeCheck: false, + test: false, +}); + +// post build steps +Deno.copyFileSync('LICENSE', 'npm/LICENSE'); +Deno.copyFileSync('README.md', 'npm/README.md'); diff --git a/packages/biscuit/tests/deps.ts b/packages/biscuit/tests/deps.ts deleted file mode 100644 index d927393..0000000 --- a/packages/biscuit/tests/deps.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "../mod.ts"; -export * from "../../discordeno/mod.ts"; diff --git a/packages/discordeno/rest/runMethod.ts b/packages/discordeno/rest/runMethod.ts index f036715..fcd3332 100644 --- a/packages/discordeno/rest/runMethod.ts +++ b/packages/discordeno/rest/runMethod.ts @@ -25,7 +25,7 @@ export async function runMethod( const errorStack = new Error("Location:"); // @ts-ignore Breaks deno deploy. Luca said add ts-ignore until it's fixed - Error.captureStackTrace(errorStack); + Error.captureStackTrace?.(errorStack); // For proxies we don't need to do any of the legwork so we just forward the request if (!baseEndpoints.BASE_URL.startsWith(BASE_URL) && route[0] === "/") { diff --git a/tests/deps.ts b/tests/deps.ts new file mode 100644 index 0000000..4dda9d8 --- /dev/null +++ b/tests/deps.ts @@ -0,0 +1 @@ +export * from "../mod.ts"; diff --git a/packages/biscuit/tests/mod.ts b/tests/mod.ts similarity index 85% rename from packages/biscuit/tests/mod.ts rename to tests/mod.ts index 1cef8bc..8b8e845 100644 --- a/packages/biscuit/tests/mod.ts +++ b/tests/mod.ts @@ -7,8 +7,7 @@ if (!token) { throw new Error("Please provide a token"); } -const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages | - GatewayIntents.GuildMembers | GatewayIntents.GuildBans; +const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages; const session = new Session({ token, intents }); session.on("ready", (payload) => { @@ -18,7 +17,7 @@ session.on("ready", (payload) => { const PREFIX = ">"; session.on("messageCreate", (message) => { - if (message.author.bot) { + if (message.author.bot || message.content.startsWith(PREFIX)) { return; }