diff --git a/scripts/run-tsd.mjs b/scripts/run-tsd.mjs new file mode 100644 index 0000000..082d7d9 --- /dev/null +++ b/scripts/run-tsd.mjs @@ -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); +} \ No newline at end of file diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 0000000..ce17b26 --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true, + "checkJs": true + }, + "include": ["./**/*"] +} \ No newline at end of file diff --git a/scripts/versions.mjs b/scripts/versions.mjs new file mode 100644 index 0000000..efa5f2b --- /dev/null +++ b/scripts/versions.mjs @@ -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(), +); \ No newline at end of file