feat: cross platform version lol

This commit is contained in:
Yuzu 2022-07-11 04:25:23 -05:00
parent 16399562f7
commit 3781f63e6d
6 changed files with 80 additions and 7 deletions

8
.gitignore vendored
View File

@ -1,3 +1,9 @@
# editors
.vim/ .vim/
.vscode/
# build
npm/
# etc
.env .env
.vscode

69
build.ts Normal file
View File

@ -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');

View File

@ -1,2 +0,0 @@
export * from "../mod.ts";
export * from "../../discordeno/mod.ts";

View File

@ -25,7 +25,7 @@ export async function runMethod<T = any>(
const errorStack = new Error("Location:"); const errorStack = new Error("Location:");
// @ts-ignore Breaks deno deploy. Luca said add ts-ignore until it's fixed // @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 // 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] === "/") { if (!baseEndpoints.BASE_URL.startsWith(BASE_URL) && route[0] === "/") {

1
tests/deps.ts Normal file
View File

@ -0,0 +1 @@
export * from "../mod.ts";

View File

@ -7,8 +7,7 @@ if (!token) {
throw new Error("Please provide a token"); throw new Error("Please provide a token");
} }
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages | const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
GatewayIntents.GuildMembers | GatewayIntents.GuildBans;
const session = new Session({ token, intents }); const session = new Session({ token, intents });
session.on("ready", (payload) => { session.on("ready", (payload) => {
@ -18,7 +17,7 @@ session.on("ready", (payload) => {
const PREFIX = ">"; const PREFIX = ">";
session.on("messageCreate", (message) => { session.on("messageCreate", (message) => {
if (message.author.bot) { if (message.author.bot || message.content.startsWith(PREFIX)) {
return; return;
} }