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,EAAE;gBAClC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,gBAAM,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC,CAAC;aACzE;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,gBAAM,CAAC,MAAM,CAAC,uCAAuC,CAAC,CAAC,CAAC;aAC9E;SACF;IACH,CAAC;CACF;AArID,8BAqIC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport colors from 'colors';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { PackageJsonLookup, FileSystem, type IPackageJson, Path } from '@rushstack/node-core-library';\n\nimport {\n CommandLineAction,\n type CommandLineStringParameter,\n type CommandLineFlagParameter\n} from '@rushstack/ts-command-line';\n\nimport { Extractor, type ExtractorResult } from '../api/Extractor';\n\nimport type { ApiExtractorCommandLine } from './ApiExtractorCommandLine';\nimport { ExtractorConfig, type IExtractorConfigPrepareOptions } from '../api/ExtractorConfig';\n\nexport class RunAction extends CommandLineAction {\n private readonly _configFileParameter: CommandLineStringParameter;\n private readonly _localParameter: CommandLineFlagParameter;\n private readonly _verboseParameter: CommandLineFlagParameter;\n private readonly _diagnosticsParameter: CommandLineFlagParameter;\n private readonly _typescriptCompilerFolder: CommandLineStringParameter;\n\n public constructor(parser: ApiExtractorCommandLine) {\n super({\n actionName: 'run',\n summary: 'Invoke API Extractor on a project',\n documentation: 'Invoke API Extractor on a project'\n });\n\n this._configFileParameter = this.defineStringParameter({\n parameterLongName: '--config',\n parameterShortName: '-c',\n argumentName: 'FILE',\n description: `Use the specified ${ExtractorConfig.FILENAME} file path, rather than guessing its location`\n });\n\n this._localParameter = this.defineFlagParameter({\n parameterLongName: '--local',\n parameterShortName: '-l',\n description:\n 'Indicates that API Extractor is running as part of a local build,' +\n \" e.g. on a developer's machine. This disables certain validation that would\" +\n ' normally be performed for a ship/production build. For example, the *.api.md' +\n ' report file is automatically copied in a local build.'\n });\n\n this._verboseParameter = this.defineFlagParameter({\n parameterLongName: '--verbose',\n parameterShortName: '-v',\n description: 'Show additional informational messages in the output.'\n });\n\n this._diagnosticsParameter = this.defineFlagParameter({\n parameterLongName: '--diagnostics',\n description:\n 'Show diagnostic messages used for troubleshooting problems with API Extractor.' +\n ' This flag also enables the \"--verbose\" flag.'\n });\n\n this._typescriptCompilerFolder = this.defineStringParameter({\n parameterLongName: '--typescript-compiler-folder',\n argumentName: 'PATH',\n description:\n 'API Extractor uses its own TypeScript compiler engine to analyze your project. If your project' +\n ' is built with a significantly different TypeScript version, sometimes API Extractor may report compilation' +\n ' errors due to differences in the system typings (e.g. lib.dom.d.ts). You can use the' +\n ' \"--typescriptCompilerFolder\" option to specify the folder path where you installed the TypeScript package,' +\n \" and API Extractor's compiler will use those system typings instead.\"\n });\n }\n\n protected async onExecute(): Promise {\n // override\n const lookup: PackageJsonLookup = new PackageJsonLookup();\n let configFilename: string;\n\n let typescriptCompilerFolder: string | undefined = this._typescriptCompilerFolder.value;\n if (typescriptCompilerFolder) {\n typescriptCompilerFolder = path.normalize(typescriptCompilerFolder);\n\n if (FileSystem.exists(typescriptCompilerFolder)) {\n typescriptCompilerFolder = lookup.tryGetPackageFolderFor(typescriptCompilerFolder);\n const typescriptCompilerPackageJson: IPackageJson | undefined = typescriptCompilerFolder\n ? lookup.tryLoadPackageJsonFor(typescriptCompilerFolder)\n : undefined;\n if (!typescriptCompilerPackageJson) {\n throw new Error(\n `The path specified in the ${this._typescriptCompilerFolder.longName} parameter is not a package.`\n );\n } else if (typescriptCompilerPackageJson.name !== 'typescript') {\n throw new Error(\n `The path specified in the ${this._typescriptCompilerFolder.longName} parameter is not a TypeScript` +\n ' compiler package.'\n );\n }\n } else {\n throw new Error(\n `The path specified in the ${this._typescriptCompilerFolder.longName} parameter does not exist.`\n );\n }\n }\n\n let extractorConfig: ExtractorConfig;\n\n if (this._configFileParameter.value) {\n configFilename = path.normalize(this._configFileParameter.value);\n if (!FileSystem.exists(configFilename)) {\n throw new Error('Config file not found: ' + this._configFileParameter.value);\n }\n\n extractorConfig = ExtractorConfig.loadFileAndPrepare(configFilename);\n } else {\n const prepareOptions: IExtractorConfigPrepareOptions | undefined = ExtractorConfig.tryLoadForFolder({\n startingFolder: '.'\n });\n\n if (!prepareOptions || !prepareOptions.configObjectFullPath) {\n throw new Error(`Unable to find an ${ExtractorConfig.FILENAME} file`);\n }\n\n const configObjectShortPath: string = Path.formatConcisely({\n pathToConvert: prepareOptions.configObjectFullPath,\n baseFolder: process.cwd()\n });\n console.log(`Using configuration from ${configObjectShortPath}`);\n\n extractorConfig = ExtractorConfig.prepare(prepareOptions);\n }\n\n const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, {\n localBuild: this._localParameter.value,\n showVerboseMessages: this._verboseParameter.value,\n showDiagnostics: this._diagnosticsParameter.value,\n typescriptCompilerFolder: typescriptCompilerFolder\n });\n\n if (extractorResult.succeeded) {\n console.log(os.EOL + 'API Extractor completed successfully');\n } else {\n process.exitCode = 1;\n\n if (extractorResult.errorCount > 0) {\n console.log(os.EOL + colors.red('API Extractor completed with errors'));\n } else {\n console.log(os.EOL + colors.yellow('API Extractor completed with warnings'));\n }\n }\n }\n}\n"]}