feat(bazel): update to the latest @microsoft/api-extractor
(#32185)
PR Close #32185
This commit is contained in:

committed by
Matias Niemelä

parent
8c388e3730
commit
350ea47def
@ -10,7 +10,7 @@
|
||||
/// <reference lib="es2017"/>
|
||||
|
||||
import {format, parseTsconfig} from '@bazel/typescript';
|
||||
import {Extractor, ExtractorValidationRulePolicy, IExtractorConfig, IExtractorOptions} from '@microsoft/api-extractor';
|
||||
import {Extractor, ExtractorConfig, IConfigFile, IExtractorConfigPrepareOptions, IExtractorInvokeOptions} from '@microsoft/api-extractor';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@ -55,51 +55,46 @@ export function runMain(
|
||||
});
|
||||
}
|
||||
|
||||
const extractorOptions: IExtractorOptions = {
|
||||
const extractorOptions: IExtractorInvokeOptions = {
|
||||
localBuild: acceptApiUpdates,
|
||||
customLogger: DEBUG ? undefined : {
|
||||
// don't log verbose messages when not in debug mode
|
||||
logVerbose: _message => {}
|
||||
}
|
||||
};
|
||||
|
||||
const extractorConfig: IExtractorConfig = {
|
||||
const configObject: IConfigFile = {
|
||||
compiler: {
|
||||
configType: 'tsconfig',
|
||||
overrideTsconfig: parsedTsConfig,
|
||||
rootFolder: path.resolve(path.dirname(tsConfig))
|
||||
},
|
||||
project: {
|
||||
entryPointSourceFile: path.resolve(entryPoint),
|
||||
},
|
||||
apiReviewFile: {
|
||||
projectFolder: path.resolve(path.dirname(tsConfig)),
|
||||
mainEntryPointFilePath: path.resolve(entryPoint),
|
||||
apiReport: {
|
||||
enabled: !!apiReviewFolder,
|
||||
apiReviewFolder: apiReviewFolder && path.resolve(apiReviewFolder),
|
||||
// TODO(alan-agius4): remove this folder name when the below issue is solved upstream
|
||||
// See: https://github.com/microsoft/web-build-tools/issues/1470
|
||||
reportFileName: apiReviewFolder && path.resolve(apiReviewFolder) || 'invalid',
|
||||
},
|
||||
apiJsonFile: {
|
||||
docModel: {
|
||||
enabled: false,
|
||||
},
|
||||
policies: {
|
||||
namespaceSupport: 'permissive',
|
||||
},
|
||||
validationRules: {
|
||||
missingReleaseTags: ExtractorValidationRulePolicy.allow,
|
||||
},
|
||||
dtsRollup: {
|
||||
enabled: !!dtsBundleOut,
|
||||
publishFolder: dtsBundleOut && path.resolve(path.dirname(dtsBundleOut)),
|
||||
mainDtsRollupPath: dtsBundleOut && path.basename(dtsBundleOut),
|
||||
untrimmedFilePath: dtsBundleOut && path.resolve(dtsBundleOut),
|
||||
},
|
||||
tsdocMetadata: {
|
||||
enabled: false,
|
||||
}
|
||||
};
|
||||
|
||||
const extractor = new Extractor(extractorConfig, extractorOptions);
|
||||
const isSuccessful = extractor.processProject();
|
||||
const options: IExtractorConfigPrepareOptions = {
|
||||
configObject,
|
||||
packageJson: undefined,
|
||||
packageJsonFullPath: pkgJson,
|
||||
configObjectFullPath: undefined,
|
||||
};
|
||||
|
||||
const extractorConfig = ExtractorConfig.prepare(options);
|
||||
const {succeeded} = Extractor.invoke(extractorConfig, extractorOptions);
|
||||
|
||||
// API extractor errors are emitted by it's logger.
|
||||
return isSuccessful ? 0 : 1;
|
||||
return succeeded ? 0 : 1;
|
||||
}
|
||||
|
||||
// Entry point
|
||||
|
Reference in New Issue
Block a user