mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix: failed build in node and bad lints (#10444)
* fix: failed build in node and bad lints * chore: update tsconfigs --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
dist
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user