Added scripts

This commit is contained in:
Toastie 2024-09-12 18:16:05 +12:00
parent f6f14c493c
commit 5dbb551e15
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
3 changed files with 69 additions and 0 deletions

15
scripts/run-tsd.mjs Normal file
View file

@ -0,0 +1,15 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
// @ts-nocheck
import tsd from 'tsd';
import formatter from 'tsd/dist/lib/formatter.js';
const diagnostics = await tsd.default({
cwd: process.cwd(),
typingsFile: './v9.d.ts',
});
if (diagnostics.length > 0) {
console.error(formatter.default(diagnostics));
process.exit(1);
}

11
scripts/tsconfig.json Normal file
View file

@ -0,0 +1,11 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"checkJs": true
},
"include": ["./**/*"]
}

43
scripts/versions.mjs Normal file
View file

@ -0,0 +1,43 @@
import { exec } from 'node:child_process';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { promisify } from 'node:util';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const rootDir = join(__dirname, '..');
const execAsync = promisify(exec);
/**
* @param {string} path
* @param {string} version
*/
const fileToESMWrapperCall = (path, version) =>
execAsync(`npx gen-esm-wrapper "${join(rootDir, path, `${version}.js`)}" "${join(rootDir, path, `${version}.mjs`)}"`);
await Promise.allSettled(
[
'v9',
// Voice
'v4',
]
.map((version) => [
fileToESMWrapperCall('gateway', version),
fileToESMWrapperCall(`payloads/${version}`, 'index'),
fileToESMWrapperCall(`rest/${version}`, 'index'),
// Voice
fileToESMWrapperCall('voice', version),
// RPC
fileToESMWrapperCall('rpc', version),
// Utils
fileToESMWrapperCall('utils', version),
// Shortcuts
fileToESMWrapperCall('', version),
])
.flat(),
);