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.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
import { Buffer } from 'node:buffer';
|
||||
import { TSDocConfiguration } from '@microsoft/tsdoc';
|
||||
import { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js';
|
||||
import { TSDocConfigFile } from '@microsoft/tsdoc-config';
|
||||
@@ -10,6 +11,7 @@ import {
|
||||
PackageJsonLookup,
|
||||
type IPackageJson,
|
||||
type JsonObject,
|
||||
FileSystem,
|
||||
} from '@rushstack/node-core-library';
|
||||
import { ApiDocumentedItem, type IApiDocumentedItemOptions } from '../items/ApiDocumentedItem.js';
|
||||
import { ApiItem, ApiItemKind, type IApiItemJson } from '../items/ApiItem.js';
|
||||
@@ -98,6 +100,11 @@ export interface IApiPackageJson extends IApiItemJson {
|
||||
* @public
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@@ -300,7 +307,13 @@ export class ApiPackage extends ApiItemContainerMixin(ApiNameMixin(ApiDocumented
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* machine.
|
||||
@@ -270,7 +275,7 @@ export class Extractor {
|
||||
apiPackage.saveToJsonFile(extractorConfig.apiJsonFilePath, {
|
||||
toolPackage: Extractor.packageName,
|
||||
toolVersion: Extractor.version,
|
||||
|
||||
minify: options?.docModelMinify ?? false,
|
||||
newlineConversion: extractorConfig.newlineKind,
|
||||
ensureFolderExists: true,
|
||||
testMode: extractorConfig.testMode,
|
||||
|
||||
@@ -27,6 +27,8 @@ export class RunAction extends CommandLineAction {
|
||||
|
||||
private readonly _typescriptCompilerFolder: CommandLineStringParameter;
|
||||
|
||||
private readonly _minify: CommandLineFlagParameter;
|
||||
|
||||
public constructor(_parser: ApiExtractorCommandLine) {
|
||||
super({
|
||||
actionName: 'run',
|
||||
@@ -57,6 +59,12 @@ export class RunAction extends CommandLineAction {
|
||||
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({
|
||||
parameterLongName: '--diagnostics',
|
||||
description:
|
||||
@@ -136,6 +144,7 @@ export class RunAction extends CommandLineAction {
|
||||
|
||||
const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, {
|
||||
localBuild: this._localParameter.value,
|
||||
docModelMinify: this._minify.value,
|
||||
showVerboseMessages: this._verboseParameter.value,
|
||||
showDiagnostics: this._diagnosticsParameter.value,
|
||||
typescriptCompilerFolder,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/brokers/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/core/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"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: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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/discord.js/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/formatters/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/next/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/util/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"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__",
|
||||
"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",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/ws/*'",
|
||||
"release": "cliff-jumper"
|
||||
|
||||
Reference in New Issue
Block a user