mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix: minify mainlib docs json (#9963)
* fix: minify mainlib docs json * fix: minify them all
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||||
// See LICENSE in the project root for license information.
|
// See LICENSE in the project root for license information.
|
||||||
|
|
||||||
|
import { Buffer } from 'node:buffer';
|
||||||
import { TSDocConfiguration } from '@microsoft/tsdoc';
|
import { TSDocConfiguration } from '@microsoft/tsdoc';
|
||||||
import { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js';
|
import { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js';
|
||||||
import { TSDocConfigFile } from '@microsoft/tsdoc-config';
|
import { TSDocConfigFile } from '@microsoft/tsdoc-config';
|
||||||
@@ -10,6 +11,7 @@ import {
|
|||||||
PackageJsonLookup,
|
PackageJsonLookup,
|
||||||
type IPackageJson,
|
type IPackageJson,
|
||||||
type JsonObject,
|
type JsonObject,
|
||||||
|
FileSystem,
|
||||||
} from '@rushstack/node-core-library';
|
} from '@rushstack/node-core-library';
|
||||||
import { ApiDocumentedItem, type IApiDocumentedItemOptions } from '../items/ApiDocumentedItem.js';
|
import { ApiDocumentedItem, type IApiDocumentedItemOptions } from '../items/ApiDocumentedItem.js';
|
||||||
import { ApiItem, ApiItemKind, type IApiItemJson } from '../items/ApiItem.js';
|
import { ApiItem, ApiItemKind, type IApiItemJson } from '../items/ApiItem.js';
|
||||||
@@ -98,6 +100,11 @@ export interface IApiPackageJson extends IApiItemJson {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export interface IApiPackageSaveOptions extends IJsonFileSaveOptions {
|
export interface IApiPackageSaveOptions extends IJsonFileSaveOptions {
|
||||||
|
/**
|
||||||
|
* Set to true to not have indentation or newlines in resulting JSON.
|
||||||
|
*/
|
||||||
|
minify?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true only when invoking API Extractor's test harness.
|
* Set to true only when invoking API Extractor's test harness.
|
||||||
*
|
*
|
||||||
@@ -300,7 +307,13 @@ export class ApiPackage extends ApiItemContainerMixin(ApiNameMixin(ApiDocumented
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.serializeInto(jsonObject);
|
this.serializeInto(jsonObject);
|
||||||
JsonFile.save(jsonObject, apiJsonFilename, ioptions);
|
if (ioptions.minify) {
|
||||||
|
FileSystem.writeFile(apiJsonFilename, Buffer.from(JSON.stringify(jsonObject), 'utf8'), {
|
||||||
|
ensureFolderExists: ioptions.ensureFolderExists ?? true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
JsonFile.save(jsonObject, apiJsonFilename, ioptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ export interface IExtractorInvokeOptions {
|
|||||||
*/
|
*/
|
||||||
compilerState?: CompilerState;
|
compilerState?: CompilerState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to minify the resulting doc model JSON, i.e. without any indentation or newlines.
|
||||||
|
*/
|
||||||
|
docModelMinify?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that API Extractor is running as part of a local build, e.g. on developer's
|
* Indicates that API Extractor is running as part of a local build, e.g. on developer's
|
||||||
* machine.
|
* machine.
|
||||||
@@ -270,7 +275,7 @@ export class Extractor {
|
|||||||
apiPackage.saveToJsonFile(extractorConfig.apiJsonFilePath, {
|
apiPackage.saveToJsonFile(extractorConfig.apiJsonFilePath, {
|
||||||
toolPackage: Extractor.packageName,
|
toolPackage: Extractor.packageName,
|
||||||
toolVersion: Extractor.version,
|
toolVersion: Extractor.version,
|
||||||
|
minify: options?.docModelMinify ?? false,
|
||||||
newlineConversion: extractorConfig.newlineKind,
|
newlineConversion: extractorConfig.newlineKind,
|
||||||
ensureFolderExists: true,
|
ensureFolderExists: true,
|
||||||
testMode: extractorConfig.testMode,
|
testMode: extractorConfig.testMode,
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ export class RunAction extends CommandLineAction {
|
|||||||
|
|
||||||
private readonly _typescriptCompilerFolder: CommandLineStringParameter;
|
private readonly _typescriptCompilerFolder: CommandLineStringParameter;
|
||||||
|
|
||||||
|
private readonly _minify: CommandLineFlagParameter;
|
||||||
|
|
||||||
public constructor(_parser: ApiExtractorCommandLine) {
|
public constructor(_parser: ApiExtractorCommandLine) {
|
||||||
super({
|
super({
|
||||||
actionName: 'run',
|
actionName: 'run',
|
||||||
@@ -57,6 +59,12 @@ export class RunAction extends CommandLineAction {
|
|||||||
description: 'Show additional informational messages in the output.',
|
description: 'Show additional informational messages in the output.',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._minify = this.defineFlagParameter({
|
||||||
|
parameterLongName: '--minify',
|
||||||
|
parameterShortName: '-m',
|
||||||
|
description: 'Minify the resulting doc model JSON, i.e. without any indentation or newlines.',
|
||||||
|
});
|
||||||
|
|
||||||
this._diagnosticsParameter = this.defineFlagParameter({
|
this._diagnosticsParameter = this.defineFlagParameter({
|
||||||
parameterLongName: '--diagnostics',
|
parameterLongName: '--diagnostics',
|
||||||
description:
|
description:
|
||||||
@@ -136,6 +144,7 @@ export class RunAction extends CommandLineAction {
|
|||||||
|
|
||||||
const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, {
|
const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, {
|
||||||
localBuild: this._localParameter.value,
|
localBuild: this._localParameter.value,
|
||||||
|
docModelMinify: this._minify.value,
|
||||||
showVerboseMessages: this._verboseParameter.value,
|
showVerboseMessages: this._verboseParameter.value,
|
||||||
showDiagnostics: this._diagnosticsParameter.value,
|
showDiagnostics: this._diagnosticsParameter.value,
|
||||||
typescriptCompilerFolder,
|
typescriptCompilerFolder,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"fmt": "pnpm run format",
|
"fmt": "pnpm run format",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/brokers/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/brokers/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"fmt": "pnpm run format",
|
"fmt": "pnpm run format",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"fmt": "pnpm run format",
|
"fmt": "pnpm run format",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"build:docs": "tsc -p tsconfig.docs.json",
|
"build:docs": "tsc -p tsconfig.docs.json",
|
||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run build && pnpm run lint",
|
"prepack": "pnpm run build && pnpm run lint",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/core/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/core/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"fmt": "pnpm run format",
|
"fmt": "pnpm run format",
|
||||||
"docs": "docgen -i './src/*.js' './src/**/*.js' -c ./docs/index.json -r ../../ -o ./docs/docs.json && pnpm run docs:new",
|
"docs": "docgen -i './src/*.js' './src/**/*.js' -c ./docs/index.json -r ../../ -o ./docs/docs.json && pnpm run docs:new",
|
||||||
"docs:test": "docgen -i './src/*.js' './src/**/*.js' -c ./docs/index.json -r ../../",
|
"docs:test": "docgen -i './src/*.js' './src/**/*.js' -c ./docs/index.json -r ../../",
|
||||||
"docs:new": "api-extractor -d run --local",
|
"docs:new": "api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run lint && pnpm run test",
|
"prepack": "pnpm run lint && pnpm run test",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/discord.js/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/discord.js/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"build:docs": "tsc -p tsconfig.docs.json",
|
"build:docs": "tsc -p tsconfig.docs.json",
|
||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run build && pnpm run lint",
|
"prepack": "pnpm run build && pnpm run lint",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/formatters/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/formatters/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"build:docs": "tsc -p tsconfig.docs.json",
|
"build:docs": "tsc -p tsconfig.docs.json",
|
||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run build && pnpm run lint",
|
"prepack": "pnpm run build && pnpm run lint",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/next/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/next/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"fmt": "pnpm run format",
|
"fmt": "pnpm run format",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"fmt": "pnpm run format",
|
"fmt": "pnpm run format",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
|
||||||
"fmt": "pnpm run format",
|
"fmt": "pnpm run format",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/util/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/util/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"fmt": "pnpm run format",
|
"fmt": "pnpm run format",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
"prepack": "pnpm run lint && pnpm run test && pnpm run build",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"build:docs": "tsc -p tsconfig.docs.json",
|
"build:docs": "tsc -p tsconfig.docs.json",
|
||||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||||
"prepack": "pnpm run build && pnpm run lint",
|
"prepack": "pnpm run build && pnpm run lint",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/ws/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/ws/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
|
|||||||
Reference in New Issue
Block a user