mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
feat: add Bun templates for create-discord-bot (#11348)
* feat: add Bun templates for create-discord-bot - Add TypeScript Bun template with complete src structure - Add JavaScript Bun template with complete src structure - Both templates mirror the Node.js versions with Bun-specific configuration Closes #11346 * fix: update template and bun template loading --------- Co-authored-by: almeidx <github@almeidx.dev> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -44,27 +44,17 @@ export async function createDiscordBot({ directory, installPackages, typescript,
|
||||
}
|
||||
|
||||
console.log(`Creating ${directoryName} in ${styleText('green', root)}.`);
|
||||
|
||||
const deno = packageManager === 'deno';
|
||||
await cp(new URL(`../template/${deno ? 'Deno' : typescript ? 'TypeScript' : 'JavaScript'}`, import.meta.url), root, {
|
||||
const bun = packageManager === 'bun';
|
||||
|
||||
const lang = typescript ? 'TypeScript' : 'JavaScript';
|
||||
const templateBasePath = deno ? 'Deno' : bun ? `Bun/${lang}` : lang;
|
||||
|
||||
await cp(new URL(`../template/${templateBasePath}`, import.meta.url), root, {
|
||||
recursive: true,
|
||||
});
|
||||
|
||||
const bun = packageManager === 'bun';
|
||||
if (bun) {
|
||||
await cp(
|
||||
new URL(`../template/Bun/${typescript ? 'TypeScript' : 'JavaScript'}/package.json`, import.meta.url),
|
||||
`${root}/package.json`,
|
||||
);
|
||||
|
||||
if (typescript) {
|
||||
await cp(
|
||||
new URL('../template/Bun/TypeScript/tsconfig.eslint.json', import.meta.url),
|
||||
`${root}/tsconfig.eslint.json`,
|
||||
);
|
||||
await cp(new URL('../template/Bun/TypeScript/tsconfig.json', import.meta.url), `${root}/tsconfig.json`);
|
||||
}
|
||||
}
|
||||
|
||||
process.chdir(root);
|
||||
|
||||
const newVSCodeSettings = await readFile('./.vscode/settings.json', { encoding: 'utf8' });
|
||||
|
||||
@@ -19,6 +19,10 @@ export function resolvePackageManager(): PackageManager {
|
||||
return 'deno';
|
||||
}
|
||||
|
||||
if (process.versions.bun) {
|
||||
return 'bun';
|
||||
}
|
||||
|
||||
// If this is not present, return the default package manager.
|
||||
if (!npmConfigUserAgent) {
|
||||
return DEFAULT_PACKAGE_MANAGER;
|
||||
|
||||
Reference in New Issue
Block a user