mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
build: switch to esbuild-plugin-version-injector for injecting version strings (#8723)
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
"@vitest/coverage-c8": "^0.24.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"downlevel-dts": "^0.10.1",
|
||||
"esbuild-plugin-version-injector": "^1.0.0",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-neon": "^0.1.35",
|
||||
"prettier": "^2.7.1",
|
||||
|
||||
@@ -40,3 +40,12 @@ export * from './util/componentUtil.js';
|
||||
export * from './util/normalizeArray.js';
|
||||
export * from './util/validation.js';
|
||||
export * from '@discordjs/util';
|
||||
|
||||
/**
|
||||
* The [\@discordjs/builders](https://github.com/discordjs/discord.js/blob/main/packages/builders/#readme) version
|
||||
* that you are currently using.
|
||||
*
|
||||
* Note to developers: This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
export const version: string = '[VI]{{inject}}[/VI]';
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
|
||||
import { createTsupConfig } from '../../tsup.config.js';
|
||||
|
||||
export default createTsupConfig();
|
||||
export default createTsupConfig({
|
||||
esbuildPlugins: [esbuildPluginVersionInjector()],
|
||||
});
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"@vitest/coverage-c8": "^0.24.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"downlevel-dts": "^0.10.1",
|
||||
"esbuild-plugin-version-injector": "^1.0.0",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-neon": "^0.1.35",
|
||||
"prettier": "^2.7.1",
|
||||
|
||||
@@ -1 +1,10 @@
|
||||
export * from './collection.js';
|
||||
|
||||
/**
|
||||
* The [\@discordjs/collection](https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme) version
|
||||
* that you are currently using.
|
||||
*
|
||||
* Note to developers: This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
export const version: string = '[VI]{{inject}}[/VI]';
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
|
||||
import { createTsupConfig } from '../../tsup.config.js';
|
||||
|
||||
export default createTsupConfig();
|
||||
export default createTsupConfig({
|
||||
esbuildPlugins: [esbuildPluginVersionInjector()],
|
||||
});
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
"@vitest/coverage-c8": "^0.24.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"downlevel-dts": "^0.10.1",
|
||||
"esbuild-plugin-version-injector": "^1.0.0",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-neon": "^0.1.35",
|
||||
"prettier": "^2.7.1",
|
||||
|
||||
@@ -6,3 +6,12 @@ export * from './lib/RequestManager.js';
|
||||
export * from './lib/REST.js';
|
||||
export * from './lib/utils/constants.js';
|
||||
export { makeURLSearchParams, parseResponse } from './lib/utils/utils.js';
|
||||
|
||||
/**
|
||||
* The [\@discordjs/rest](https://github.com/discordjs/discord.js/blob/main/packages/rest/#readme) version
|
||||
* that you are currently using.
|
||||
*
|
||||
* Note to developers: This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
export const version: string = '[VI]{{inject}}[/VI]';
|
||||
|
||||
@@ -2,10 +2,8 @@ import process from 'node:process';
|
||||
import { APIVersion } from 'discord-api-types/v10';
|
||||
import { Agent } from 'undici';
|
||||
import type { RESTOptions } from '../REST.js';
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
||||
const Package = require('../../../package.json');
|
||||
|
||||
export const DefaultUserAgent = `DiscordBot (${Package.homepage}, ${Package.version})`;
|
||||
export const DefaultUserAgent = `DiscordBot (https://discord.js.org, [VI]{{inject}}[/VI])`;
|
||||
|
||||
export const DefaultRestOptions: Required<RESTOptions> = {
|
||||
get agent() {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
|
||||
import { createTsupConfig } from '../../tsup.config.js';
|
||||
|
||||
export default createTsupConfig();
|
||||
export default createTsupConfig({
|
||||
esbuildPlugins: [esbuildPluginVersionInjector()],
|
||||
});
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
"@types/node": "^16.11.64",
|
||||
"cross-env": "^7.0.3",
|
||||
"downlevel-dts": "^0.10.1",
|
||||
"esbuild-plugin-version-injector": "^1.0.0",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-neon": "^0.1.35",
|
||||
"jest": "^29.1.2",
|
||||
|
||||
@@ -19,3 +19,12 @@ export {
|
||||
} from './VoiceConnection';
|
||||
|
||||
export { type JoinConfig, getVoiceConnection, getVoiceConnections, getGroups } from './DataStore';
|
||||
|
||||
/**
|
||||
* The [\@discordjs/voice](https://github.com/discordjs/discord.js/blob/main/packages/voice/#readme) version
|
||||
* that you are currently using.
|
||||
*
|
||||
* Note to developers: This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
export const version: string = '[VI]{{inject}}[/VI]';
|
||||
|
||||
@@ -33,10 +33,11 @@ function findPackageJSON(
|
||||
*/
|
||||
function version(name: string): string {
|
||||
try {
|
||||
const pkg =
|
||||
name === '@discordjs/voice'
|
||||
? require('../../package.json')
|
||||
: findPackageJSON(dirname(require.resolve(name)), name, 3);
|
||||
if (name === '@discordjs/voice') {
|
||||
return '[VI]{{inject}}[/VI]';
|
||||
}
|
||||
|
||||
const pkg = findPackageJSON(dirname(require.resolve(name)), name, 3);
|
||||
return pkg?.version ?? 'not found';
|
||||
} catch {
|
||||
return 'not found';
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
|
||||
import { createTsupConfig } from '../../tsup.config.js';
|
||||
|
||||
export default createTsupConfig();
|
||||
export default createTsupConfig({
|
||||
esbuildPlugins: [esbuildPluginVersionInjector()],
|
||||
});
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
"@vitest/coverage-c8": "^0.24.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"downlevel-dts": "^0.10.1",
|
||||
"esbuild-plugin-version-injector": "^1.0.0",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-neon": "^0.1.35",
|
||||
"mock-socket": "^9.1.5",
|
||||
|
||||
@@ -11,3 +11,12 @@ export * from './utils/IdentifyThrottler.js';
|
||||
|
||||
export * from './ws/WebSocketManager.js';
|
||||
export * from './ws/WebSocketShard.js';
|
||||
|
||||
/**
|
||||
* The [\@discordjs/voice](https://github.com/discordjs/discord.js/blob/main/packages/voice/#readme) version
|
||||
* that you are currently using.
|
||||
*
|
||||
* Note to developers: This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
export const version: string = '[VI]{{inject}}[/VI]';
|
||||
|
||||
@@ -2,7 +2,6 @@ import process from 'node:process';
|
||||
import { Collection } from '@discordjs/collection';
|
||||
import { lazy } from '@discordjs/util';
|
||||
import { APIVersion, GatewayOpcodes } from 'discord-api-types/v10';
|
||||
import { version } from '../../package.json';
|
||||
import type { OptionalWebSocketManagerOptions, SessionInfo } from '../ws/WebSocketManager.js';
|
||||
|
||||
/**
|
||||
@@ -19,7 +18,7 @@ export enum CompressionMethod {
|
||||
ZlibStream = 'zlib-stream',
|
||||
}
|
||||
|
||||
export const DefaultDeviceProperty = `@discordjs/ws ${version}`;
|
||||
export const DefaultDeviceProperty = `@discordjs/ws [VI]{{inject}}[/VI]`;
|
||||
|
||||
const getDefaultSessionStore = lazy(() => new Collection<number, SessionInfo | null>());
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
|
||||
import { createTsupConfig } from '../../tsup.config.js';
|
||||
|
||||
export default createTsupConfig({
|
||||
@@ -6,4 +7,5 @@ export default createTsupConfig({
|
||||
worker: 'src/strategies/sharding/worker.ts',
|
||||
},
|
||||
external: ['zlib-sync'],
|
||||
esbuildPlugins: [esbuildPluginVersionInjector()],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user