mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
build: pnpm (#9806)
This commit is contained in:
@@ -4,16 +4,17 @@
|
||||
"version": "0.2.1",
|
||||
"description": "A simple way to create a startup Discord bot.",
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"build": "tsc --noEmit && tsup",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
|
||||
"prepack": "yarn build && yarn lint",
|
||||
"prepack": "pnpm run build && pnpm run lint",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/create-discord-bot/*'",
|
||||
"release": "cliff-jumper"
|
||||
},
|
||||
"type": "module",
|
||||
"bin": "./dist/index.js",
|
||||
"directories": {
|
||||
"bin": "bin",
|
||||
"lib": "src"
|
||||
},
|
||||
"files": [
|
||||
@@ -59,19 +60,19 @@
|
||||
"@types/node": "16.18.44",
|
||||
"@types/prompts": "^2.4.4",
|
||||
"@types/validate-npm-package-name": "^4.0.0",
|
||||
"@vitest/coverage-v8": "^0.34.2",
|
||||
"@vitest/coverage-v8": "^0.34.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.47.0",
|
||||
"eslint": "^8.48.0",
|
||||
"eslint-config-neon": "^0.1.56",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.2",
|
||||
"terser": "^5.19.2",
|
||||
"tsup": "^7.2.0",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^0.34.2"
|
||||
"vitest": "^0.34.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.16.0"
|
||||
"node": ">=18.17.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -4,7 +4,7 @@ import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { URL } from 'node:url';
|
||||
import glob from 'fast-glob';
|
||||
import { red, yellow, green, cyan } from 'picocolors';
|
||||
import picocolors from 'picocolors';
|
||||
import type { PackageManager } from './helpers/packageManager.js';
|
||||
import { install } from './helpers/packageManager.js';
|
||||
import { GUIDE_URL } from './util/constants.js';
|
||||
@@ -34,12 +34,16 @@ export async function createDiscordBot({ directory, installPackages, typescript,
|
||||
|
||||
// If the directory is actually a file or if it's not empty, throw an error.
|
||||
if (!directoryStats.isDirectory() || (await readdir(root)).length > 0) {
|
||||
console.error(red(`The directory ${yellow(`"${directoryName}"`)} is either not a directory or is not empty.`));
|
||||
console.error(red(`Please specify an empty directory.`));
|
||||
console.error(
|
||||
picocolors.red(
|
||||
`The directory ${picocolors.yellow(`"${directoryName}"`)} is either not a directory or is not empty.`,
|
||||
),
|
||||
);
|
||||
console.error(picocolors.red(`Please specify an empty directory.`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Creating ${directoryName} in ${green(root)}.`);
|
||||
console.log(`Creating ${directoryName} in ${picocolors.green(root)}.`);
|
||||
const deno = packageManager === 'deno';
|
||||
await cp(new URL(`../template/${deno ? 'Deno' : typescript ? 'TypeScript' : 'JavaScript'}`, import.meta.url), root, {
|
||||
recursive: true,
|
||||
@@ -82,12 +86,14 @@ export async function createDiscordBot({ directory, installPackages, typescript,
|
||||
await writeFile(file, newData);
|
||||
}
|
||||
|
||||
const newPackageJSON = await readFile('./package.json', { encoding: 'utf8' }).then((str) => {
|
||||
let newStr = str.replace('[REPLACE_ME]', directoryName);
|
||||
newStr = newStr.replaceAll('[REPLACE_IMPORT_EXT]', typescript ? 'ts' : 'js');
|
||||
return newStr;
|
||||
});
|
||||
await writeFile('./package.json', newPackageJSON);
|
||||
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 ? 'ts' : 'js');
|
||||
return newStr;
|
||||
});
|
||||
await writeFile('./package.json', newPackageJSON);
|
||||
}
|
||||
|
||||
if (installPackages) {
|
||||
try {
|
||||
@@ -96,15 +102,15 @@ export async function createDiscordBot({ directory, installPackages, typescript,
|
||||
console.log();
|
||||
const err = error as ExecException;
|
||||
if (err.signal === 'SIGINT') {
|
||||
console.log(red('Installation aborted.'));
|
||||
console.log(picocolors.red('Installation aborted.'));
|
||||
} else {
|
||||
console.error(red('Installation failed.'));
|
||||
console.error(picocolors.red('Installation failed.'));
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log();
|
||||
console.log(green('All done! Be sure to read through the discord.js guide for help on your journey.'));
|
||||
console.log(`Link: ${cyan(GUIDE_URL)}`);
|
||||
console.log(picocolors.green('All done! Be sure to read through the discord.js guide for help on your journey.'));
|
||||
console.log(`Link: ${picocolors.cyan(GUIDE_URL)}`);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
import process from 'node:process';
|
||||
import { yellow } from 'picocolors';
|
||||
import picocolors from 'picocolors';
|
||||
import { DEFAULT_PACKAGE_MANAGER } from '../util/constants.js';
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ export function resolvePackageManager(): PackageManager {
|
||||
}
|
||||
|
||||
console.error(
|
||||
yellow(
|
||||
picocolors.yellow(
|
||||
`Detected an unsupported package manager (${npmConfigUserAgent}). Falling back to ${DEFAULT_PACKAGE_MANAGER}.`,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"devDependencies": {
|
||||
"@sapphire/ts-config": "^4.0.1",
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-config-neon": "^0.1.47",
|
||||
"eslint-config-neon": "^0.1.56",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.2"
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
"@sapphire/ts-config": "^4.0.1",
|
||||
"bun-types": "^0.7.3",
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-config-neon": "^0.1.47",
|
||||
"eslint-config-neon": "^0.1.56",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.2",
|
||||
"typescript": "^5.1.6"
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-config-neon": "^0.1.47",
|
||||
"eslint-config-neon": "^0.1.56",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.2"
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sapphire/ts-config": "^4.0.1",
|
||||
"@types/node": "^18.17.6",
|
||||
"@types/node": "^18.17.11",
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-config-neon": "^0.1.47",
|
||||
"eslint-config-neon": "^0.1.56",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.2",
|
||||
"typescript": "^5.1.6"
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,5 @@ export default createTsupConfig({
|
||||
dts: false,
|
||||
format: 'esm',
|
||||
minify: 'terser',
|
||||
keepNames: false,
|
||||
sourcemap: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user