diff --git a/packages/create-discord-bot/src/create-discord-bot.ts b/packages/create-discord-bot/src/create-discord-bot.ts index c6925c84b..8549bc4b3 100644 --- a/packages/create-discord-bot/src/create-discord-bot.ts +++ b/packages/create-discord-bot/src/create-discord-bot.ts @@ -1,11 +1,11 @@ import type { ExecException } from 'node:child_process'; -import { cp, glob, mkdir, stat, readdir, readFile, writeFile } from 'node:fs/promises'; +import { cp, mkdir, stat, readdir, readFile, writeFile } from 'node:fs/promises'; import path from 'node:path'; import process from 'node:process'; import { URL } from 'node:url'; import { styleText } from 'node:util'; import type { PackageManager } from './helpers/packageManager.js'; -import { install, isNodePackageManager } from './helpers/packageManager.js'; +import { install } from './helpers/packageManager.js'; import { GUIDE_URL } from './util/constants.js'; interface Options { @@ -67,39 +67,18 @@ export async function createDiscordBot({ directory, installPackages, typescript, process.chdir(root); - const newVSCodeSettings = await readFile('./.vscode/settings.json', { - encoding: 'utf8', - }).then((str) => { - let newStr = str.replace('[REPLACE_ME]', deno || bun ? 'auto' : packageManager); - if (deno) { - // @ts-expect-error: This is fine - newStr = newStr.replaceAll('"[REPLACE_BOOL]"', true); - } - - return newStr; - }); - await writeFile('./.vscode/settings.json', newVSCodeSettings); - - const globIterator = glob('./src/**/*.ts'); - for await (const file of globIterator) { - const newData = await readFile(file, { encoding: 'utf8' }).then((str) => - str.replaceAll('[REPLACE_IMPORT_EXT]', typescript && !isNodePackageManager(packageManager) ? 'ts' : 'js'), - ); - await writeFile(file, newData); - } + const newVSCodeSettings = await readFile('./.vscode/settings.json', { encoding: 'utf8' }); + await writeFile( + './.vscode/settings.json', + newVSCodeSettings.replace( + /"npm\.packageManager":\s*"[^"]+"/, + `"npm.packageManager": "${deno || bun ? 'auto' : packageManager}"`, + ), + ); if (!deno) { - const newPackageJSON = await readFile('./package.json', { - encoding: 'utf8', - }).then((str) => { - let newStr = str.replace('[REPLACE_ME]', directoryName); - newStr = newStr.replaceAll( - '[REPLACE_IMPORT_EXT]', - typescript && !isNodePackageManager(packageManager) ? 'ts' : 'js', - ); - return newStr; - }); - await writeFile('./package.json', newPackageJSON); + const newPackageJSON = await readFile('./package.json', { encoding: 'utf8' }); + await writeFile('./package.json', newPackageJSON.replace(/"name":\s*"[^"]+"/, `"name": "${directoryName}"`)); } if (installPackages) { diff --git a/packages/create-discord-bot/src/helpers/packageManager.ts b/packages/create-discord-bot/src/helpers/packageManager.ts index 4d02c679a..ff5d98150 100644 --- a/packages/create-discord-bot/src/helpers/packageManager.ts +++ b/packages/create-discord-bot/src/helpers/packageManager.ts @@ -1,12 +1,12 @@ import { execSync } from 'node:child_process'; import process from 'node:process'; import { styleText } from 'node:util'; -import { DEFAULT_PACKAGE_MANAGER, NODE_PACKAGE_MANAGERS } from '../util/constants.js'; +import { DEFAULT_PACKAGE_MANAGER, type PACKAGE_MANAGERS } from '../util/constants.js'; /** * A union of supported package managers. */ -export type PackageManager = 'bun' | 'deno' | 'npm' | 'pnpm' | 'yarn'; +export type PackageManager = (typeof PACKAGE_MANAGERS)[number]; /** * Resolves the package manager from `npm_config_user_agent`. @@ -117,12 +117,3 @@ export function install(packageManager: PackageManager) { env, }); } - -/** - * Whether the provided package manager is a Node package manager. - * - * @param packageManager - The package manager to check - */ -export function isNodePackageManager(packageManager: PackageManager): packageManager is 'npm' | 'pnpm' | 'yarn' { - return NODE_PACKAGE_MANAGERS.includes(packageManager as any); -} diff --git a/packages/create-discord-bot/src/util/constants.ts b/packages/create-discord-bot/src/util/constants.ts index 3193a01c8..828748197 100644 --- a/packages/create-discord-bot/src/util/constants.ts +++ b/packages/create-discord-bot/src/util/constants.ts @@ -13,11 +13,6 @@ export const DEFAULT_PROJECT_NAME = 'my-bot' as const; */ export const PACKAGE_MANAGERS = ['npm', 'pnpm', 'yarn', 'bun', 'deno'] as const; -/** - * The supported Node.js package managers. - */ -export const NODE_PACKAGE_MANAGERS = ['npm', 'pnpm', 'yarn'] as const; - /** * The URL to the guide. */ diff --git a/packages/create-discord-bot/template/Bun/JavaScript/eslint.config.js b/packages/create-discord-bot/template/Bun/JavaScript/eslint.config.js new file mode 100644 index 000000000..5d92eaf15 --- /dev/null +++ b/packages/create-discord-bot/template/Bun/JavaScript/eslint.config.js @@ -0,0 +1,21 @@ +import common from 'eslint-config-neon/common'; +import node from 'eslint-config-neon/node'; +import prettier from 'eslint-config-neon/prettier'; + +const config = [ + { + ignores: [], + }, + ...common, + ...node, + ...prettier, + { + rules: { + 'jsdoc/check-tag-names': 0, + 'jsdoc/no-undefined-types': 0, + 'jsdoc/valid-types': 0, + }, + }, +]; + +export default config; diff --git a/packages/create-discord-bot/template/Bun/JavaScript/package.json b/packages/create-discord-bot/template/Bun/JavaScript/package.json index c01c24d9c..21c88e57e 100644 --- a/packages/create-discord-bot/template/Bun/JavaScript/package.json +++ b/packages/create-discord-bot/template/Bun/JavaScript/package.json @@ -1,14 +1,14 @@ { "$schema": "https://json.schemastore.org/package.json", - "name": "[REPLACE_ME]", + "name": "@discordjs/template-bun-javascript", "version": "0.1.0", "private": true, "type": "module", "scripts": { - "lint": "prettier --check . && eslint --ext .[REPLACE_IMPORT_EXT] --format=pretty src", - "deploy": "bun run src/util/deploy.[REPLACE_IMPORT_EXT]", - "format": "prettier --write . && eslint --ext .[REPLACE_IMPORT_EXT] --fix --format=pretty src", - "start": "bun run src/index.[REPLACE_IMPORT_EXT]" + "lint": "prettier --check . && eslint --ext .js --format=pretty src", + "deploy": "bun run src/util/deploy.js", + "format": "prettier --write . && eslint --ext .js --fix --format=pretty src", + "start": "bun run src/index.js" }, "dependencies": { "@discordjs/core": "^2.4.0", diff --git a/packages/create-discord-bot/template/Bun/JavaScript/src/index.js b/packages/create-discord-bot/template/Bun/JavaScript/src/index.js new file mode 100644 index 000000000..b7bd4c885 --- /dev/null +++ b/packages/create-discord-bot/template/Bun/JavaScript/src/index.js @@ -0,0 +1 @@ +console.log(); diff --git a/packages/create-discord-bot/template/Bun/TypeScript/eslint.config.js b/packages/create-discord-bot/template/Bun/TypeScript/eslint.config.js new file mode 100644 index 000000000..041e3ca10 --- /dev/null +++ b/packages/create-discord-bot/template/Bun/TypeScript/eslint.config.js @@ -0,0 +1,26 @@ +import common from 'eslint-config-neon/common'; +import node from 'eslint-config-neon/node'; +import prettier from 'eslint-config-neon/prettier'; +import typescript from 'eslint-config-neon/typescript'; + +const config = [ + { + ignores: [], + }, + ...common, + ...node, + ...typescript, + ...prettier, + { + languageOptions: { + parserOptions: { + project: ['./tsconfig.eslint.json'], + }, + }, + rules: { + 'import/extensions': 0, + }, + }, +]; + +export default config; diff --git a/packages/create-discord-bot/template/Bun/TypeScript/package.json b/packages/create-discord-bot/template/Bun/TypeScript/package.json index 633df1f5a..c53c3f829 100644 --- a/packages/create-discord-bot/template/Bun/TypeScript/package.json +++ b/packages/create-discord-bot/template/Bun/TypeScript/package.json @@ -1,14 +1,14 @@ { "$schema": "https://json.schemastore.org/package.json", - "name": "[REPLACE_ME]", + "name": "@discordjs/template-bun-typescript", "version": "0.1.0", "private": true, "type": "module", "scripts": { - "lint": "tsc && prettier --check . && eslint --ext .[REPLACE_IMPORT_EXT] --format=pretty src", - "deploy": "bun run src/util/deploy.[REPLACE_IMPORT_EXT]", - "format": "prettier --write . && eslint --ext .[REPLACE_IMPORT_EXT] --fix --format=pretty src", - "start": "bun run src/index.[REPLACE_IMPORT_EXT]" + "lint": "tsc && prettier --check . && eslint --ext .ts --format=pretty src", + "deploy": "bun run src/util/deploy.ts", + "format": "prettier --write . && eslint --ext .ts --fix --format=pretty src", + "start": "bun run src/index.ts" }, "dependencies": { "@discordjs/core": "^2.4.0", diff --git a/packages/create-discord-bot/template/Bun/TypeScript/src/index.ts b/packages/create-discord-bot/template/Bun/TypeScript/src/index.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/packages/create-discord-bot/template/Bun/TypeScript/src/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json b/packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json index 17d3c1864..7e6c323b1 100644 --- a/packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json +++ b/packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json @@ -2,14 +2,14 @@ "$schema": "https://json.schemastore.org/tsconfig.json", "extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict"], "compilerOptions": { + "allowImportingTsExtensions": true, "declaration": false, "declarationMap": false, + "incremental": false, "module": "ESNext", "moduleResolution": "Bundler", - "target": "ESNext", - "outDir": "dist", "noEmit": true, - "allowImportingTsExtensions": true, + "target": "ESNext", "skipLibCheck": true } } diff --git a/packages/create-discord-bot/template/Deno/.vscode/settings.json b/packages/create-discord-bot/template/Deno/.vscode/settings.json index 6457249fe..eb4101864 100644 --- a/packages/create-discord-bot/template/Deno/.vscode/settings.json +++ b/packages/create-discord-bot/template/Deno/.vscode/settings.json @@ -8,5 +8,5 @@ "editor.trimAutoWhitespace": false, "files.insertFinalNewline": true, "files.eol": "\n", - "deno.enable": "[REPLACE_BOOL]" + "deno.enable": true } diff --git a/packages/create-discord-bot/template/Deno/src/util/loaders.ts b/packages/create-discord-bot/template/Deno/src/util/loaders.ts index 9a1d9cbc6..b123e3c24 100644 --- a/packages/create-discord-bot/template/Deno/src/util/loaders.ts +++ b/packages/create-discord-bot/template/Deno/src/util/loaders.ts @@ -1,6 +1,6 @@ import type { PathLike } from 'node:fs'; import { glob, stat } from 'node:fs/promises'; -import { resolve } from 'node:path'; +import { basename, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import type { Command } from '../commands/index.ts'; import { predicate as commandPredicate } from '../commands/index.ts'; @@ -43,7 +43,7 @@ export async function loadStructures( // Loop through all the matching files in the directory for await (const file of glob(pattern)) { // If the file is index.ts, skip the file - if (file.endsWith('/index.ts')) { + if (basename(file) === 'index.ts') { continue; } diff --git a/packages/create-discord-bot/template/JavaScript/.prettierignore b/packages/create-discord-bot/template/JavaScript/.prettierignore new file mode 100644 index 000000000..bd5535a60 --- /dev/null +++ b/packages/create-discord-bot/template/JavaScript/.prettierignore @@ -0,0 +1 @@ +pnpm-lock.yaml diff --git a/packages/create-discord-bot/template/JavaScript/.vscode/extensions.json b/packages/create-discord-bot/template/JavaScript/.vscode/extensions.json index 3d5debb10..e4679713f 100644 --- a/packages/create-discord-bot/template/JavaScript/.vscode/extensions.json +++ b/packages/create-discord-bot/template/JavaScript/.vscode/extensions.json @@ -2,7 +2,6 @@ "recommendations": [ "esbenp.prettier-vscode", "dbaeumer.vscode-eslint", - "tamasfe.even-better-toml", "codezombiech.gitignore", "christian-kohler.npm-intellisense", "christian-kohler.path-intellisense" diff --git a/packages/create-discord-bot/template/JavaScript/.vscode/settings.json b/packages/create-discord-bot/template/JavaScript/.vscode/settings.json index a3ff3551e..30619664d 100644 --- a/packages/create-discord-bot/template/JavaScript/.vscode/settings.json +++ b/packages/create-discord-bot/template/JavaScript/.vscode/settings.json @@ -9,5 +9,5 @@ "editor.trimAutoWhitespace": false, "files.insertFinalNewline": true, "files.eol": "\n", - "npm.packageManager": "[REPLACE_ME]" + "npm.packageManager": "[REPLACE_PACKAGE_MANAGER]" } diff --git a/packages/create-discord-bot/template/JavaScript/package.json b/packages/create-discord-bot/template/JavaScript/package.json index 3af863296..1c60bd8ba 100644 --- a/packages/create-discord-bot/template/JavaScript/package.json +++ b/packages/create-discord-bot/template/JavaScript/package.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/package.json", - "name": "[REPLACE_ME]", + "name": "@discordjs/template-javascript", "version": "0.1.0", "private": true, "type": "module", diff --git a/packages/create-discord-bot/template/JavaScript/src/util/loaders.js b/packages/create-discord-bot/template/JavaScript/src/util/loaders.js index 8bde35f3b..4b37580cb 100644 --- a/packages/create-discord-bot/template/JavaScript/src/util/loaders.js +++ b/packages/create-discord-bot/template/JavaScript/src/util/loaders.js @@ -1,5 +1,5 @@ import { glob, stat } from 'node:fs/promises'; -import { resolve } from 'node:path'; +import { basename, resolve } from 'node:path'; import { fileURLToPath, URL } from 'node:url'; import { predicate as commandPredicate } from '../commands/index.js'; import { predicate as eventPredicate } from '../events/index.js'; @@ -40,7 +40,7 @@ export async function loadStructures(dir, predicate, recursive = true) { // Loop through all the matching files in the directory for await (const file of glob(pattern)) { // If the file is index.js, skip the file - if (file.endsWith('/index.js')) { + if (basename(file) === 'index.js') { continue; } diff --git a/packages/create-discord-bot/template/TypeScript/.prettierignore b/packages/create-discord-bot/template/TypeScript/.prettierignore index 1521c8b76..bd5535a60 100644 --- a/packages/create-discord-bot/template/TypeScript/.prettierignore +++ b/packages/create-discord-bot/template/TypeScript/.prettierignore @@ -1 +1 @@ -dist +pnpm-lock.yaml diff --git a/packages/create-discord-bot/template/TypeScript/.vscode/extensions.json b/packages/create-discord-bot/template/TypeScript/.vscode/extensions.json index 3d5debb10..e4679713f 100644 --- a/packages/create-discord-bot/template/TypeScript/.vscode/extensions.json +++ b/packages/create-discord-bot/template/TypeScript/.vscode/extensions.json @@ -2,7 +2,6 @@ "recommendations": [ "esbenp.prettier-vscode", "dbaeumer.vscode-eslint", - "tamasfe.even-better-toml", "codezombiech.gitignore", "christian-kohler.npm-intellisense", "christian-kohler.path-intellisense" diff --git a/packages/create-discord-bot/template/TypeScript/.vscode/settings.json b/packages/create-discord-bot/template/TypeScript/.vscode/settings.json index ae55b963b..f756167dd 100644 --- a/packages/create-discord-bot/template/TypeScript/.vscode/settings.json +++ b/packages/create-discord-bot/template/TypeScript/.vscode/settings.json @@ -9,5 +9,5 @@ "editor.trimAutoWhitespace": false, "files.insertFinalNewline": true, "files.eol": "\n", - "npm.packageManager": "[REPLACE_ME]" + "npm.packageManager": "[REPLACE_PACKAGE_MANAGER]" } diff --git a/packages/create-discord-bot/template/TypeScript/eslint.config.js b/packages/create-discord-bot/template/TypeScript/eslint.config.js index 777913a13..041e3ca10 100644 --- a/packages/create-discord-bot/template/TypeScript/eslint.config.js +++ b/packages/create-discord-bot/template/TypeScript/eslint.config.js @@ -5,7 +5,7 @@ import typescript from 'eslint-config-neon/typescript'; const config = [ { - ignores: ['**/dist/*'], + ignores: [], }, ...common, ...node, diff --git a/packages/create-discord-bot/template/TypeScript/package.json b/packages/create-discord-bot/template/TypeScript/package.json index a9dcdb5a9..83b26ca47 100644 --- a/packages/create-discord-bot/template/TypeScript/package.json +++ b/packages/create-discord-bot/template/TypeScript/package.json @@ -1,15 +1,15 @@ { "$schema": "https://json.schemastore.org/package.json", - "name": "[REPLACE_ME]", + "name": "@discordjs/template-typescript", "version": "0.1.0", "private": true, "type": "module", "scripts": { "build": "tsc", "lint": "prettier --check . && eslint --ext .ts --format=pretty src", - "deploy": "node --env-file=.env dist/util/deploy.js", + "deploy": "node --env-file=.env src/util/deploy.ts", "format": "prettier --write . && eslint --ext .ts --fix --format=pretty src", - "start": "node --env-file=.env dist/index.js" + "start": "node --env-file=.env src/index.ts" }, "dependencies": { "@discordjs/core": "^2.4.0", diff --git a/packages/create-discord-bot/template/TypeScript/src/commands/index.ts b/packages/create-discord-bot/template/TypeScript/src/commands/index.ts index 0da41a43a..ba63bf6da 100644 --- a/packages/create-discord-bot/template/TypeScript/src/commands/index.ts +++ b/packages/create-discord-bot/template/TypeScript/src/commands/index.ts @@ -1,6 +1,6 @@ import type { RESTPostAPIApplicationCommandsJSONBody, CommandInteraction } from 'discord.js'; import { z } from 'zod'; -import type { StructurePredicate } from '../util/loaders.[REPLACE_IMPORT_EXT]'; +import type { StructurePredicate } from '../util/loaders.ts'; /** * Defines the structure of a command diff --git a/packages/create-discord-bot/template/TypeScript/src/commands/ping.ts b/packages/create-discord-bot/template/TypeScript/src/commands/ping.ts index a72cc3a08..7b30e8273 100644 --- a/packages/create-discord-bot/template/TypeScript/src/commands/ping.ts +++ b/packages/create-discord-bot/template/TypeScript/src/commands/ping.ts @@ -1,4 +1,4 @@ -import type { Command } from './index.[REPLACE_IMPORT_EXT]'; +import type { Command } from './index.ts'; export default { data: { diff --git a/packages/create-discord-bot/template/TypeScript/src/commands/utility/user.ts b/packages/create-discord-bot/template/TypeScript/src/commands/utility/user.ts index 121d4cec7..34bc5315a 100644 --- a/packages/create-discord-bot/template/TypeScript/src/commands/utility/user.ts +++ b/packages/create-discord-bot/template/TypeScript/src/commands/utility/user.ts @@ -1,4 +1,4 @@ -import type { Command } from '../index.[REPLACE_IMPORT_EXT]'; +import type { Command } from '../index.ts'; export default { data: { diff --git a/packages/create-discord-bot/template/TypeScript/src/events/index.ts b/packages/create-discord-bot/template/TypeScript/src/events/index.ts index 516ac1edb..ccbfe5c18 100644 --- a/packages/create-discord-bot/template/TypeScript/src/events/index.ts +++ b/packages/create-discord-bot/template/TypeScript/src/events/index.ts @@ -1,6 +1,6 @@ import type { ClientEvents } from 'discord.js'; import { z } from 'zod'; -import type { StructurePredicate } from '../util/loaders.[REPLACE_IMPORT_EXT]'; +import type { StructurePredicate } from '../util/loaders.ts'; /** * Defines the structure of an event. diff --git a/packages/create-discord-bot/template/TypeScript/src/events/interactionCreate.ts b/packages/create-discord-bot/template/TypeScript/src/events/interactionCreate.ts index 4e0f0a900..fe37d3d67 100644 --- a/packages/create-discord-bot/template/TypeScript/src/events/interactionCreate.ts +++ b/packages/create-discord-bot/template/TypeScript/src/events/interactionCreate.ts @@ -1,7 +1,7 @@ import { URL } from 'node:url'; import { Events } from 'discord.js'; -import { loadCommands } from '../util/loaders.[REPLACE_IMPORT_EXT]'; -import type { Event } from './index.[REPLACE_IMPORT_EXT]'; +import { loadCommands } from '../util/loaders.ts'; +import type { Event } from './index.ts'; const commands = await loadCommands(new URL('../commands/', import.meta.url)); diff --git a/packages/create-discord-bot/template/TypeScript/src/events/ready.ts b/packages/create-discord-bot/template/TypeScript/src/events/ready.ts index c5917b923..5fd6216f9 100644 --- a/packages/create-discord-bot/template/TypeScript/src/events/ready.ts +++ b/packages/create-discord-bot/template/TypeScript/src/events/ready.ts @@ -1,5 +1,5 @@ import { Events } from 'discord.js'; -import type { Event } from './index.[REPLACE_IMPORT_EXT]'; +import type { Event } from './index.ts'; export default { name: Events.ClientReady, diff --git a/packages/create-discord-bot/template/TypeScript/src/index.ts b/packages/create-discord-bot/template/TypeScript/src/index.ts index 5c6001733..ddb980d95 100644 --- a/packages/create-discord-bot/template/TypeScript/src/index.ts +++ b/packages/create-discord-bot/template/TypeScript/src/index.ts @@ -1,7 +1,7 @@ import process from 'node:process'; import { URL } from 'node:url'; import { Client, GatewayIntentBits } from 'discord.js'; -import { loadEvents } from './util/loaders.[REPLACE_IMPORT_EXT]'; +import { loadEvents } from './util/loaders.ts'; // Initialize the client const client = new Client({ intents: [GatewayIntentBits.Guilds] }); diff --git a/packages/create-discord-bot/template/TypeScript/src/util/deploy.ts b/packages/create-discord-bot/template/TypeScript/src/util/deploy.ts index ee2b429c5..a5b7ef25a 100644 --- a/packages/create-discord-bot/template/TypeScript/src/util/deploy.ts +++ b/packages/create-discord-bot/template/TypeScript/src/util/deploy.ts @@ -2,7 +2,7 @@ import process from 'node:process'; import { URL } from 'node:url'; import { API } from '@discordjs/core/http-only'; import { REST } from 'discord.js'; -import { loadCommands } from './loaders.[REPLACE_IMPORT_EXT]'; +import { loadCommands } from './loaders.ts'; const commands = await loadCommands(new URL('../commands/', import.meta.url)); const commandData = [...commands.values()].map((command) => command.data); diff --git a/packages/create-discord-bot/template/TypeScript/src/util/loaders.ts b/packages/create-discord-bot/template/TypeScript/src/util/loaders.ts index 09bad738c..94f8cab10 100644 --- a/packages/create-discord-bot/template/TypeScript/src/util/loaders.ts +++ b/packages/create-discord-bot/template/TypeScript/src/util/loaders.ts @@ -1,11 +1,9 @@ import type { PathLike } from 'node:fs'; import { glob, stat } from 'node:fs/promises'; -import { resolve } from 'node:path'; -import { fileURLToPath } from 'node:url'; -import type { Command } from '../commands/index.[REPLACE_IMPORT_EXT]'; -import { predicate as commandPredicate } from '../commands/index.[REPLACE_IMPORT_EXT]'; -import type { Event } from '../events/index.[REPLACE_IMPORT_EXT]'; -import { predicate as eventPredicate } from '../events/index.[REPLACE_IMPORT_EXT]'; +import { basename, resolve } from 'node:path'; +import { fileURLToPath, URL } from 'node:url'; +import { predicate as commandPredicate, type Command } from '../commands/index.ts'; +import { predicate as eventPredicate, type Event } from '../events/index.ts'; /** * A predicate to check if the structure is valid @@ -36,14 +34,14 @@ export async function loadStructures( // Create an empty array to store the structures const structures: Structure[] = []; - // Create a glob pattern to match the .[REPLACE_IMPORT_EXT] files + // Create a glob pattern to match the .ts files const basePath = dir instanceof URL ? fileURLToPath(dir) : dir.toString(); - const pattern = resolve(basePath, recursive ? '**/*.[REPLACE_IMPORT_EXT]' : '*.[REPLACE_IMPORT_EXT]'); + const pattern = resolve(basePath, recursive ? '**/*.ts' : '*.ts'); // Loop through all the matching files in the directory for await (const file of glob(pattern)) { - // If the file is index.[REPLACE_IMPORT_EXT], skip the file - if (file.endsWith('/index.[REPLACE_IMPORT_EXT]')) { + // If the file is index.ts, skip the file + if (basename(file) === 'index.ts') { continue; } diff --git a/packages/create-discord-bot/template/TypeScript/tsconfig.json b/packages/create-discord-bot/template/TypeScript/tsconfig.json index 01a98906e..c82567277 100644 --- a/packages/create-discord-bot/template/TypeScript/tsconfig.json +++ b/packages/create-discord-bot/template/TypeScript/tsconfig.json @@ -2,12 +2,15 @@ "$schema": "https://json.schemastore.org/tsconfig.json", "extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict"], "compilerOptions": { + "allowImportingTsExtensions": true, + "erasableSyntaxOnly": true, "declaration": false, "declarationMap": false, - "module": "NodeNext", - "moduleResolution": "NodeNext", + "incremental": false, + "module": "ESNext", + "moduleResolution": "Bundler", + "noEmit": true, "target": "ESNext", - "outDir": "dist", "skipLibCheck": true } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4a1b63d0f..2be6f29b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1017,6 +1017,124 @@ importers: specifier: ~5.9.3 version: 5.9.3 + packages/create-discord-bot/template/Bun/JavaScript: + dependencies: + '@discordjs/core': + specifier: ^2.4.0 + version: 2.4.0(bufferutil@4.0.9) + discord.js: + specifier: ^14.25.1 + version: 14.25.1(bufferutil@4.0.9) + devDependencies: + eslint: + specifier: ^9.38.1 + version: 9.39.1(jiti@2.6.1) + eslint-config-neon: + specifier: ^0.2.9 + version: 0.2.9(@typescript-eslint/types@8.48.1)(@typescript-eslint/utils@8.48.1(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + eslint-formatter-pretty: + specifier: ^7.0.0 + version: 7.0.0 + prettier: + specifier: ^3.7.4 + version: 3.7.4 + zod: + specifier: ^4.1.13 + version: 4.1.13 + + packages/create-discord-bot/template/Bun/TypeScript: + dependencies: + '@discordjs/core': + specifier: ^2.4.0 + version: 2.4.0(bufferutil@4.0.9) + discord.js: + specifier: ^14.25.1 + version: 14.25.1(bufferutil@4.0.9) + devDependencies: + '@sapphire/ts-config': + specifier: ^5.0.3 + version: 5.0.3 + '@types/bun': + specifier: ^1.3.3 + version: 1.3.3 + eslint: + specifier: ^9.39.1 + version: 9.39.1(jiti@2.6.1) + eslint-config-neon: + specifier: ^0.2.9 + version: 0.2.9(@typescript-eslint/types@8.48.1)(@typescript-eslint/utils@8.48.1(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + eslint-formatter-pretty: + specifier: ^7.0.0 + version: 7.0.0 + prettier: + specifier: ^3.7.4 + version: 3.7.4 + typescript: + specifier: ~5.9.3 + version: 5.9.3 + zod: + specifier: ^4.1.13 + version: 4.1.13 + + packages/create-discord-bot/template/JavaScript: + dependencies: + '@discordjs/core': + specifier: ^2.4.0 + version: 2.4.0(bufferutil@4.0.9) + discord.js: + specifier: ^14.25.1 + version: 14.25.1(bufferutil@4.0.9) + devDependencies: + eslint: + specifier: ^9.38.1 + version: 9.39.1(jiti@2.6.1) + eslint-config-neon: + specifier: ^0.2.9 + version: 0.2.9(@typescript-eslint/types@8.48.1)(@typescript-eslint/utils@8.48.1(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + eslint-formatter-pretty: + specifier: ^7.0.0 + version: 7.0.0 + prettier: + specifier: ^3.7.4 + version: 3.7.4 + zod: + specifier: ^4.1.13 + version: 4.1.13 + + packages/create-discord-bot/template/TypeScript: + dependencies: + '@discordjs/core': + specifier: ^2.4.0 + version: 2.4.0(bufferutil@4.0.9) + discord.js: + specifier: ^14.25.1 + version: 14.25.1(bufferutil@4.0.9) + devDependencies: + '@sapphire/ts-config': + specifier: ^5.0.3 + version: 5.0.3 + '@types/node': + specifier: ^22.19.1 + version: 22.19.1 + eslint: + specifier: ^9.39.1 + version: 9.39.1(jiti@2.6.1) + eslint-config-neon: + specifier: ^0.2.9 + version: 0.2.9(@typescript-eslint/types@8.48.1)(@typescript-eslint/utils@8.48.1(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + eslint-formatter-pretty: + specifier: ^7.0.0 + version: 7.0.0 + prettier: + specifier: ^3.7.4 + version: 3.7.4 + typescript: + specifier: ~5.9.3 + version: 5.9.3 + zod: + specifier: ^4.1.13 + version: 4.1.13 + packages/discord.js: dependencies: '@discordjs/builders': @@ -2664,6 +2782,26 @@ packages: resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} engines: {node: '>=12'} + '@discordjs/builders@1.13.0': + resolution: {integrity: sha512-COK0uU6ZaJI+LA67H/rp8IbEkYwlZf3mAoBI5wtPh5G5cbEQGNhVpzINg2f/6+q/YipnNIKy6fJDg6kMUKUw4Q==} + engines: {node: '>=16.11.0'} + + '@discordjs/collection@1.5.3': + resolution: {integrity: sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==} + engines: {node: '>=16.11.0'} + + '@discordjs/collection@2.1.1': + resolution: {integrity: sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==} + engines: {node: '>=18'} + + '@discordjs/core@2.4.0': + resolution: {integrity: sha512-+y9kvW94Zc/3IVZVBktSnC2tK45LTonfmhZh+ExUUsBlfgorMY/A+11jAcCbtzz15NtNrtUOJiMA1MGGJkv0/A==} + engines: {node: '>=20'} + + '@discordjs/formatters@0.6.2': + resolution: {integrity: sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==} + engines: {node: '>=16.11.0'} + '@discordjs/node-pre-gyp@0.4.5': resolution: {integrity: sha512-YJOVVZ545x24mHzANfYoy0BJX5PDyeZlpiJjDkUBM/V/Ao7TFX9lcUvCN4nr0tbr5ubeaXxtEBILUrHtTphVeQ==} hasBin: true @@ -2672,6 +2810,22 @@ packages: resolution: {integrity: sha512-NEE76A96FtQ5YuoAVlOlB3ryMPrkXbUCTQICHGKb8ShtjXyubGicjRMouHtP1RpuDdm16cDa+oI3aAMo1zQRUQ==} engines: {node: '>=12.0.0'} + '@discordjs/rest@2.6.0': + resolution: {integrity: sha512-RDYrhmpB7mTvmCKcpj+pc5k7POKszS4E2O9TYc+U+Y4iaCP+r910QdO43qmpOja8LRr1RJ0b3U+CqVsnPqzf4w==} + engines: {node: '>=18'} + + '@discordjs/util@1.2.0': + resolution: {integrity: sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==} + engines: {node: '>=18'} + + '@discordjs/ws@1.2.3': + resolution: {integrity: sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==} + engines: {node: '>=16.11.0'} + + '@discordjs/ws@2.0.4': + resolution: {integrity: sha512-ARXnE+qi+D7Y4trd1bKA9uhiUxQvLbOKcdehDa6NLd7FiqmDvvk8N5RGk6Ho9gdT/Wap09dz/IuLv7hNpUzt6g==} + engines: {node: '>=20'} + '@dotenvx/dotenvx@1.31.0': resolution: {integrity: sha512-GeDxvtjiRuoyWVU9nQneId879zIyNdL05bS7RKiqMkfBSKpHMWHLoRyRqjYWLaXmX/llKO1hTlqHDmatkQAjPA==} hasBin: true @@ -5486,10 +5640,22 @@ packages: resolution: {integrity: sha512-693yWouX+hR9uJm1Jgq0uSSjbSD3UrblMaxiuGbHPjSwzLCSZTcm0h3kvdVhq3o/yl4+oeAWW3hiaJ0TELuRJQ==} engines: {node: '>=v14.0.0', npm: '>=7.0.0'} + '@sapphire/shapeshift@4.0.0': + resolution: {integrity: sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==} + engines: {node: '>=v16'} + + '@sapphire/snowflake@3.5.3': + resolution: {integrity: sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==} + engines: {node: '>=v14.0.0', npm: '>=7.0.0'} + '@sapphire/snowflake@3.5.5': resolution: {integrity: sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==} engines: {node: '>=v14.0.0', npm: '>=7.0.0'} + '@sapphire/ts-config@5.0.3': + resolution: {integrity: sha512-bFyGYHFT3TpOf5Sg2P+zY2ad0t5IA2epc5HtewlghhL7MYvbZvxtKsdaNaMwAdNObBx7hpiQm5OcOhyzEwQvbQ==} + engines: {node: '>=v16.0.0', npm: '>=8.0.0'} + '@sapphire/utilities@3.18.1': resolution: {integrity: sha512-zyEyQOQb2/t2mKRmu8T+M4r1Ulb+54BjwDS5pfzf6abGzTAcUg4VDWjHeKX7p3IgiZTcpN4Ij77b9k+K1KV4Lg==} engines: {node: '>=v14.0.0'} @@ -8409,6 +8575,10 @@ packages: discord-api-types@0.38.36: resolution: {integrity: sha512-qrbUbjjwtyeBg5HsAlm1C859epfOyiLjPqAOzkdWlCNsZCWJrertnETF/NwM8H+waMFU58xGSc5eXUfXah+WTQ==} + discord.js@14.25.1: + resolution: {integrity: sha512-2l0gsPOLPs5t6GFZfQZKnL1OJNYFcuC/ETWsW4VtKVD/tg4ICa9x+jb9bkPffkMdRpRpuUaO/fKkHCBeiCKh8g==} + engines: {node: '>=18'} + dmd@6.2.3: resolution: {integrity: sha512-SIEkjrG7cZ9GWZQYk/mH+mWtcRPly/3ibVuXO/tP/MFoWz6KiRK77tSMq6YQBPl7RljPtXPQ/JhxbNuCdi1bNw==} engines: {node: '>=12'} @@ -13140,6 +13310,11 @@ packages: engines: {node: '>=4.2.0'} hasBin: true + typescript@5.4.5: + resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} + engines: {node: '>=14.17'} + hasBin: true + typescript@5.5.4: resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} engines: {node: '>=14.17'} @@ -13213,6 +13388,10 @@ packages: resolution: {integrity: sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==} engines: {node: '>=14.0'} + undici@6.21.3: + resolution: {integrity: sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==} + engines: {node: '>=18.17'} + undici@7.14.0: resolution: {integrity: sha512-Vqs8HTzjpQXZeXdpsfChQTlafcMQaaIwnGwLam1wudSSjlJeQ3bw1j+TLPePgrCnCpUXx7Ba5Pdpf5OBih62NQ==} engines: {node: '>=20.18.1'} @@ -15357,6 +15536,36 @@ snapshots: dependencies: '@jridgewell/trace-mapping': 0.3.9 + '@discordjs/builders@1.13.0': + dependencies: + '@discordjs/formatters': 0.6.2 + '@discordjs/util': 1.2.0 + '@sapphire/shapeshift': 4.0.0 + discord-api-types: 0.38.36 + fast-deep-equal: 3.1.3 + ts-mixer: 6.0.4 + tslib: 2.8.1 + + '@discordjs/collection@1.5.3': {} + + '@discordjs/collection@2.1.1': {} + + '@discordjs/core@2.4.0(bufferutil@4.0.9)': + dependencies: + '@discordjs/rest': 2.6.0 + '@discordjs/util': 1.2.0 + '@discordjs/ws': 2.0.4(bufferutil@4.0.9) + '@sapphire/snowflake': 3.5.5 + '@vladfrangu/async_event_emitter': 2.4.7 + discord-api-types: 0.38.36 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@discordjs/formatters@0.6.2': + dependencies: + discord-api-types: 0.38.36 + '@discordjs/node-pre-gyp@0.4.5(encoding@0.1.13)': dependencies: detect-libc: 2.1.2 @@ -15380,6 +15589,52 @@ snapshots: - encoding - supports-color + '@discordjs/rest@2.6.0': + dependencies: + '@discordjs/collection': 2.1.1 + '@discordjs/util': 1.2.0 + '@sapphire/async-queue': 1.5.5 + '@sapphire/snowflake': 3.5.5 + '@vladfrangu/async_event_emitter': 2.4.7 + discord-api-types: 0.38.36 + magic-bytes.js: 1.12.1 + tslib: 2.8.1 + undici: 6.21.3 + + '@discordjs/util@1.2.0': + dependencies: + discord-api-types: 0.38.36 + + '@discordjs/ws@1.2.3(bufferutil@4.0.9)': + dependencies: + '@discordjs/collection': 2.1.1 + '@discordjs/rest': 2.6.0 + '@discordjs/util': 1.2.0 + '@sapphire/async-queue': 1.5.5 + '@types/ws': 8.18.1 + '@vladfrangu/async_event_emitter': 2.4.7 + discord-api-types: 0.38.36 + tslib: 2.8.1 + ws: 8.18.3(bufferutil@4.0.9) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@discordjs/ws@2.0.4(bufferutil@4.0.9)': + dependencies: + '@discordjs/collection': 2.1.1 + '@discordjs/rest': 2.6.0 + '@discordjs/util': 1.2.0 + '@sapphire/async-queue': 1.5.5 + '@types/ws': 8.18.1 + '@vladfrangu/async_event_emitter': 2.4.7 + discord-api-types: 0.38.36 + tslib: 2.8.1 + ws: 8.18.3(bufferutil@4.0.9) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + '@dotenvx/dotenvx@1.31.0': dependencies: commander: 11.1.0 @@ -18360,8 +18615,20 @@ snapshots: '@sapphire/result@2.8.0': {} + '@sapphire/shapeshift@4.0.0': + dependencies: + fast-deep-equal: 3.1.3 + lodash: 4.17.21 + + '@sapphire/snowflake@3.5.3': {} + '@sapphire/snowflake@3.5.5': {} + '@sapphire/ts-config@5.0.3': + dependencies: + tslib: 2.8.1 + typescript: 5.4.5 + '@sapphire/utilities@3.18.1': {} '@sapphire/utilities@3.18.2': {} @@ -22043,6 +22310,25 @@ snapshots: discord-api-types@0.38.36: {} + discord.js@14.25.1(bufferutil@4.0.9): + dependencies: + '@discordjs/builders': 1.13.0 + '@discordjs/collection': 1.5.3 + '@discordjs/formatters': 0.6.2 + '@discordjs/rest': 2.6.0 + '@discordjs/util': 1.2.0 + '@discordjs/ws': 1.2.3(bufferutil@4.0.9) + '@sapphire/snowflake': 3.5.3 + discord-api-types: 0.38.36 + fast-deep-equal: 3.1.3 + lodash.snakecase: 4.1.1 + magic-bytes.js: 1.12.1 + tslib: 2.8.1 + undici: 6.21.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dmd@6.2.3: dependencies: array-back: 6.2.2 @@ -28113,6 +28399,8 @@ snapshots: typescript@4.9.5: {} + typescript@5.4.5: {} + typescript@5.5.4: {} typescript@5.8.2: {} @@ -28172,6 +28460,8 @@ snapshots: dependencies: '@fastify/busboy': 2.1.1 + undici@6.21.3: {} + undici@7.14.0: {} undici@7.16.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 024443d80..b2a88de9f 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,6 +1,7 @@ packages: - apps/* - packages/* + - packages/create-discord-bot/template/**/* autoInstallPeers: false