@@ -15,16 +15,13 @@ import {
1515import {
1616 IExtractorConfig ,
1717 IExtractorProjectConfig ,
18- IExtractorApiJsonFileConfig ,
1918 IExtractorDtsRollupConfig
2019} from './IExtractorConfig' ;
21- import { ExtractorContext } from '../ExtractorContext' ;
2220import { ILogger } from './ILogger' ;
23- import { ApiJsonGenerator } from '../generators/ApiJsonGenerator' ;
24- import { ApiFileGenerator } from '../generators/ApiFileGenerator' ;
25- import { DtsRollupGenerator , DtsRollupKind } from '../generators/dtsRollup/DtsRollupGenerator' ;
21+ import { ExtractorContext } from '../analyzer/ExtractorContext' ;
22+ import { DtsRollupGenerator , DtsRollupKind } from '../generators/DtsRollupGenerator' ;
2623import { MonitoredLogger } from './MonitoredLogger' ;
27- import { TypeScriptMessageFormatter } from '../utils /TypeScriptMessageFormatter' ;
24+ import { TypeScriptMessageFormatter } from '../analyzer /TypeScriptMessageFormatter' ;
2825
2926/**
3027 * Options for {@link Extractor.processProject}.
@@ -99,10 +96,10 @@ export class Extractor {
9996 * The JSON Schema for API Extractor config file (api-extractor-config.schema.json).
10097 */
10198 public static jsonSchema : JsonSchema = JsonSchema . fromFile (
102- path . join ( __dirname , './api-extractor.schema.json' ) ) ;
99+ path . join ( __dirname , '../schemas /api-extractor.schema.json' ) ) ;
103100
104101 private static _defaultConfig : Partial < IExtractorConfig > = JsonFile . load ( path . join ( __dirname ,
105- './api-extractor-defaults.json' ) ) ;
102+ '../schemas /api-extractor-defaults.json' ) ) ;
106103
107104 private static _declarationFileExtensionRegExp : RegExp = / \. d \. t s $ / i;
108105
@@ -315,77 +312,6 @@ export class Extractor {
315312 validationRules : this . actualConfig . validationRules
316313 } ) ;
317314
318- for ( const externalJsonFileFolder of projectConfig . externalJsonFileFolders || [ ] ) {
319- context . loadExternalPackages ( path . resolve ( this . _absoluteRootFolder , externalJsonFileFolder ) ) ;
320- }
321-
322- const packageBaseName : string = path . basename ( context . packageName ) ;
323-
324- const apiJsonFileConfig : IExtractorApiJsonFileConfig = this . actualConfig . apiJsonFile ;
325-
326- if ( apiJsonFileConfig . enabled ) {
327- const outputFolder : string = path . resolve ( this . _absoluteRootFolder ,
328- apiJsonFileConfig . outputFolder ) ;
329-
330- const jsonGenerator : ApiJsonGenerator = new ApiJsonGenerator ( ) ;
331- const apiJsonFilename : string = path . join ( outputFolder , packageBaseName + '.api.json' ) ;
332-
333- this . _monitoredLogger . logVerbose ( 'Writing: ' + apiJsonFilename ) ;
334- jsonGenerator . writeJsonFile ( apiJsonFilename , context ) ;
335- }
336-
337- if ( this . actualConfig . apiReviewFile . enabled ) {
338- const generator : ApiFileGenerator = new ApiFileGenerator ( ) ;
339- const apiReviewFilename : string = packageBaseName + '.api.ts' ;
340-
341- const actualApiReviewPath : string = path . resolve ( this . _absoluteRootFolder ,
342- this . actualConfig . apiReviewFile . tempFolder , apiReviewFilename ) ;
343- const actualApiReviewShortPath : string = this . _getShortFilePath ( actualApiReviewPath ) ;
344-
345- const expectedApiReviewPath : string = path . resolve ( this . _absoluteRootFolder ,
346- this . actualConfig . apiReviewFile . apiReviewFolder , apiReviewFilename ) ;
347- const expectedApiReviewShortPath : string = this . _getShortFilePath ( expectedApiReviewPath ) ;
348-
349- const actualApiReviewContent : string = generator . generateApiFileContent ( context ) ;
350-
351- // Write the actual file
352- FileSystem . writeFile ( actualApiReviewPath , actualApiReviewContent , {
353- ensureFolderExists : true
354- } ) ;
355-
356- // Compare it against the expected file
357- if ( FileSystem . exists ( expectedApiReviewPath ) ) {
358- const expectedApiReviewContent : string = FileSystem . readFile ( expectedApiReviewPath ) ;
359-
360- if ( ! ApiFileGenerator . areEquivalentApiFileContents ( actualApiReviewContent , expectedApiReviewContent ) ) {
361- if ( ! this . _localBuild ) {
362- // For production, issue a warning that will break the CI build.
363- this . _monitoredLogger . logWarning ( 'You have changed the public API signature for this project.'
364- // @microsoft /gulp-core-build seems to run JSON.stringify() on the error messages for some reason,
365- // so try to avoid escaped characters:
366- + ` Please overwrite ${ expectedApiReviewShortPath } with a`
367- + ` copy of ${ actualApiReviewShortPath } `
368- + ' and then request an API review. See the Git repository README.md for more info.' ) ;
369- } else {
370- // For a local build, just copy the file automatically.
371- this . _monitoredLogger . logWarning ( 'You have changed the public API signature for this project.'
372- + ` Updating ${ expectedApiReviewShortPath } ` ) ;
373-
374- FileSystem . writeFile ( expectedApiReviewPath , actualApiReviewContent ) ;
375- }
376- } else {
377- this . _monitoredLogger . logVerbose ( `The API signature is up to date: ${ actualApiReviewShortPath } ` ) ;
378- }
379- } else {
380- // NOTE: This warning seems like a nuisance, but it has caught genuine mistakes.
381- // For example, when projects were moved into category folders, the relative path for
382- // the API review files ended up in the wrong place.
383- this . _monitoredLogger . logError ( `The API review file has not been set up.`
384- + ` Do this by copying ${ actualApiReviewShortPath } `
385- + ` to ${ expectedApiReviewShortPath } and committing it.` ) ;
386- }
387- }
388-
389315 this . _generateRollupDtsFiles ( context ) ;
390316
391317 if ( this . _localBuild ) {
@@ -477,13 +403,6 @@ export class Extractor {
477403 dtsRollupGenerator . writeTypingsFile ( mainDtsRollupFullPath , dtsKind ) ;
478404 }
479405
480- private _getShortFilePath ( absolutePath : string ) : string {
481- if ( ! path . isAbsolute ( absolutePath ) ) {
482- throw new Error ( 'Expected absolute path: ' + absolutePath ) ;
483- }
484- return path . relative ( this . _absoluteRootFolder , absolutePath ) . replace ( / \\ / g, '/' ) ;
485- }
486-
487406 /**
488407 * Update the parsed command line to use paths from the specified TS compiler folder, if
489408 * a TS compiler folder is specified.
0 commit comments