diff --git a/packages/create-discord-bot/src/create-discord-bot.ts b/packages/create-discord-bot/src/create-discord-bot.ts index 55b4ef1ce4e8..ce347f6dee49 100644 --- a/packages/create-discord-bot/src/create-discord-bot.ts +++ b/packages/create-discord-bot/src/create-discord-bot.ts @@ -6,7 +6,7 @@ import { URL } from 'node:url'; import glob from 'fast-glob'; import picocolors from 'picocolors'; import type { PackageManager } from './helpers/packageManager.js'; -import { install } from './helpers/packageManager.js'; +import { install, isNodePackageManager } from './helpers/packageManager.js'; import { GUIDE_URL } from './util/constants.js'; interface Options { @@ -83,7 +83,7 @@ export async function createDiscordBot({ directory, installPackages, typescript, const globStream = glob.stream('./src/**/*.ts'); for await (const file of globStream) { const newData = await readFile(file, { encoding: 'utf8' }).then((str) => - str.replaceAll('[REPLACE_IMPORT_EXT]', typescript ? 'ts' : 'js'), + str.replaceAll('[REPLACE_IMPORT_EXT]', typescript && !isNodePackageManager(packageManager) ? 'ts' : 'js'), ); await writeFile(file, newData); } @@ -93,7 +93,10 @@ export async function createDiscordBot({ directory, installPackages, typescript, encoding: 'utf8', }).then((str) => { let newStr = str.replace('[REPLACE_ME]', directoryName); - newStr = newStr.replaceAll('[REPLACE_IMPORT_EXT]', typescript ? 'ts' : 'js'); + newStr = newStr.replaceAll( + '[REPLACE_IMPORT_EXT]', + typescript && !isNodePackageManager(packageManager) ? 'ts' : 'js', + ); return newStr; }); await writeFile('./package.json', newPackageJSON); diff --git a/packages/create-discord-bot/src/helpers/packageManager.ts b/packages/create-discord-bot/src/helpers/packageManager.ts index 210f37f8973e..0eacc1c3b8be 100644 --- a/packages/create-discord-bot/src/helpers/packageManager.ts +++ b/packages/create-discord-bot/src/helpers/packageManager.ts @@ -1,7 +1,7 @@ import { execSync } from 'node:child_process'; import process from 'node:process'; import picocolors from 'picocolors'; -import { DEFAULT_PACKAGE_MANAGER } from '../util/constants.js'; +import { DEFAULT_PACKAGE_MANAGER, NODE_PACKAGE_MANAGERS } from '../util/constants.js'; /** * A union of supported package managers. @@ -110,3 +110,12 @@ 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 ff5fc9a5dcd4..d7cc03b5abff 100644 --- a/packages/create-discord-bot/src/util/constants.ts +++ b/packages/create-discord-bot/src/util/constants.ts @@ -13,6 +13,11 @@ 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/TypeScript/tsconfig.json b/packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json index 72fe8bda9e28..8b24501273e1 100644 --- a/packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json +++ b/packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "@sapphire/ts-config/extra-strict", + "extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict"], "compilerOptions": { "declaration": false, "declarationMap": false, diff --git a/packages/create-discord-bot/template/TypeScript/.prettierignore b/packages/create-discord-bot/template/TypeScript/.prettierignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/packages/create-discord-bot/template/TypeScript/.prettierignore @@ -0,0 +1 @@ +dist diff --git a/packages/create-discord-bot/template/TypeScript/tsconfig.json b/packages/create-discord-bot/template/TypeScript/tsconfig.json index c1ce19819910..01a98906e8eb 100644 --- a/packages/create-discord-bot/template/TypeScript/tsconfig.json +++ b/packages/create-discord-bot/template/TypeScript/tsconfig.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "@sapphire/ts-config/extra-strict", + "extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict"], "compilerOptions": { "declaration": false, "declarationMap": false,