33
44import * as path from 'path' ;
55import * as ts from 'typescript' ;
6- import * as resolve from 'resolve' ;
76import lodash = require( 'lodash' ) ;
87import colors = require( 'colors' ) ;
98
109import {
1110 JsonFile ,
12- JsonSchema ,
1311 Path ,
1412 FileSystem ,
1513 NewlineKind ,
@@ -18,10 +16,9 @@ import {
1816} from '@microsoft/node-core-library' ;
1917import {
2018 IExtractorConfig ,
21- IExtractorProjectConfig ,
2219 IExtractorDtsRollupConfig ,
23- IExtractorApiJsonFileConfig
2420} from './IExtractorConfig' ;
21+ import { ExtractorConfig } from './ExtractorConfig' ;
2522import { ILogger } from './ILogger' ;
2623import { Collector } from '../collector/Collector' ;
2724import { DtsRollupGenerator , DtsRollupKind } from '../generators/DtsRollupGenerator' ;
@@ -91,12 +88,6 @@ export interface IExtractorOptions {
9188 * @public
9289 */
9390export class Extractor {
94- /**
95- * The JSON Schema for API Extractor config file (api-extractor.schema.json).
96- */
97- public static jsonSchema : JsonSchema = JsonSchema . fromFile (
98- path . join ( __dirname , '../schemas/api-extractor.schema.json' ) ) ;
99-
10091 /**
10192 * Returns the version number of the API Extractor NPM package.
10293 */
@@ -115,9 +106,6 @@ export class Extractor {
115106 return PackageJsonLookup . loadOwnPackageJson ( __dirname ) ;
116107 }
117108
118- private static _defaultConfig : Partial < IExtractorConfig > = JsonFile . load ( path . join ( __dirname ,
119- '../schemas/api-extractor-defaults.json' ) ) ;
120-
121109 private static _declarationFileExtensionRegExp : RegExp = / \. d \. t s $ / i;
122110
123111 private static _defaultLogger : ILogger = {
@@ -183,57 +171,6 @@ export class Extractor {
183171 extractor . processProject ( ) ;
184172 }
185173
186- /**
187- * Loads the api extractor config file in Extractor Config object.
188- * The jsonConfigFile path specified is relative to project directory path.
189- * @param jsonConfigFile - Path to api extractor json config file.
190- */
191- public static loadConfigObject ( jsonConfigFile : string ) : IExtractorConfig {
192- // Set to keep track of config files which have been processed.
193- const pathSet : Set < string > = new Set < string > ( ) ;
194- // Get absolute path of config file.
195- let currentConfigFilePath : string = path . resolve ( process . cwd ( ) , jsonConfigFile ) ;
196- pathSet . add ( currentConfigFilePath ) ;
197-
198- const originalConfigFileFolder : string = path . dirname ( currentConfigFilePath ) ;
199-
200- let extractorConfig : IExtractorConfig = JsonFile . load ( jsonConfigFile ) ;
201-
202- while ( extractorConfig . extends ) {
203- if ( extractorConfig . extends . match ( / ^ \. / ) ) {
204- // If extends has relative path.
205- // Populate the api extractor config path defined in extends relative to current config path.
206- currentConfigFilePath = path . resolve ( originalConfigFileFolder , extractorConfig . extends ) ;
207- } else {
208- // If extends has package path.
209- currentConfigFilePath = resolve . sync (
210- extractorConfig . extends ,
211- {
212- basedir : originalConfigFileFolder
213- }
214- ) ;
215- }
216- // Check if this file was already processed.
217- if ( pathSet . has ( currentConfigFilePath ) ) {
218- throw new Error ( `The API Extractor config files contain a cycle. "${ currentConfigFilePath } "`
219- + ` is included twice. Please check the "extends" values in config files.` ) ;
220- }
221- pathSet . add ( currentConfigFilePath ) ;
222-
223- // Remove extends property from config for current config.
224- delete extractorConfig . extends ;
225-
226- // Load the extractor config defined in extends property.
227- const baseConfig : IExtractorConfig = JsonFile . load ( currentConfigFilePath ) ;
228- lodash . merge ( baseConfig , extractorConfig ) ;
229- extractorConfig = baseConfig ;
230- }
231-
232- // Validate if the extractor config generated adheres to schema.
233- Extractor . jsonSchema . validateObject ( extractorConfig , jsonConfigFile ) ;
234- return extractorConfig ;
235- }
236-
237174 private static _applyConfigDefaults ( config : IExtractorConfig ) : IExtractorConfig {
238175 // Use the provided config to override the defaults
239176 const normalized : IExtractorConfig = lodash . merge (
0 commit comments