Skip to content

Commit cdb1e6e

Browse files
committed
Rename "rootFolder" to "projectFolder"
1 parent 4da4b42 commit cdb1e6e

4 files changed

Lines changed: 54 additions & 53 deletions

File tree

‎apps/api-extractor/src/api/CompilerState.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ export class CompilerState {
5252
let tsconfig: {} | undefined = extractorConfig.overrideTsconfig;
5353
if (!tsconfig) {
5454
// If it wasn't overridden, then load it from disk
55-
tsconfig = JsonFile.load(path.join(extractorConfig.rootFolder, 'tsconfig.json'));
55+
tsconfig = JsonFile.load(path.join(extractorConfig.projectFolder, 'tsconfig.json'));
5656
}
5757

5858
const commandLine: ts.ParsedCommandLine = ts.parseJsonConfigFileContent(
5959
tsconfig,
6060
ts.sys,
61-
extractorConfig.rootFolder
61+
extractorConfig.projectFolder
6262
);
6363

6464
if (!commandLine.options.skipLibCheck && extractorConfig.skipLibCheck) {

‎apps/api-extractor/src/api/ExtractorConfig.ts‎

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface IExtractorConfigTokenContext {
4141
*/
4242
packageName: string;
4343

44-
rootFolder: string;
44+
projectFolder: string;
4545
}
4646

4747
/**
@@ -61,7 +61,7 @@ export interface IExtractorConfigPrepareOptions {
6161
*
6262
* @remarks
6363
*
64-
* If this is omitted, then the `rootFolder` must not be specified using the `<lookup>` token.
64+
* If this is omitted, then the `projectFolder` must not be specified using the `<lookup>` token.
6565
*/
6666
configObjectFullPath: string | undefined;
6767

@@ -89,7 +89,7 @@ export interface IExtractorConfigPrepareOptions {
8989
}
9090

9191
interface IExtractorConfigParameters {
92-
rootFolder: string;
92+
projectFolder: string;
9393
packageJson: INodePackageJson | undefined;
9494
packageJsonFullPath: string | undefined;
9595
mainEntryPointFile: string;
@@ -131,8 +131,8 @@ export class ExtractorConfig {
131131

132132
private static readonly _declarationFileExtensionRegExp: RegExp = /\.d\.ts$/i;
133133

134-
/** {@inheritDoc IConfigCompiler.rootFolder} */
135-
public readonly rootFolder: string;
134+
/** {@inheritDoc IConfigFile.projectFolder} */
135+
public readonly projectFolder: string;
136136

137137
/**
138138
* The parsed package.json file for the working package, or undefined if API Extractor was invoked without
@@ -189,7 +189,7 @@ export class ExtractorConfig {
189189
public readonly testMode: boolean;
190190

191191
private constructor(parameters: IExtractorConfigParameters) {
192-
this.rootFolder = parameters.rootFolder;
192+
this.projectFolder = parameters.projectFolder;
193193
this.packageJson = parameters.packageJson;
194194
this.packageJsonFullPath = parameters.packageJsonFullPath;
195195
this.mainEntryPointFile = parameters.mainEntryPointFile;
@@ -218,7 +218,7 @@ export class ExtractorConfig {
218218
if (!path.isAbsolute(absolutePath)) {
219219
throw new InternalError('Expected absolute path: ' + absolutePath);
220220
}
221-
return path.relative(this.rootFolder, absolutePath).replace(/\\/g, '/');
221+
return path.relative(this.projectFolder, absolutePath).replace(/\\/g, '/');
222222
}
223223

224224
/**
@@ -355,12 +355,17 @@ export class ExtractorConfig {
355355
throw new Error('The "compiler" section is missing');
356356
}
357357

358-
let rootFolder: string;
359-
if (configObject.compiler.rootFolder.trim() === '<lookup>') {
358+
if (!configObject.projectFolder) {
359+
// A merged configuration should have this
360+
throw new Error('The "projectFolder" section is missing');
361+
}
362+
363+
let projectFolder: string;
364+
if (configObject.projectFolder.trim() === '<lookup>') {
360365
if (!options.configObjectFullPath) {
361366
throw new Error('The "<lookup>" token cannot be expanded because configObjectFullPath was not specified');
362367
}
363-
// "The default value for `rootFolder` is the token `<lookup>`, which means the folder is determined
368+
// "The default value for `projectFolder` is the token `<lookup>`, which means the folder is determined
364369
// by traversing parent folders, starting from the folder containing api-extractor.json, and stopping
365370
// at the first folder that contains a tsconfig.json file. If a tsconfig.json file cannot be found in
366371
// this way, then an error will be reported."
@@ -369,34 +374,30 @@ export class ExtractorConfig {
369374
for (; ; ) {
370375
const tsconfigPath: string = path.join(currentFolder, 'tsconfig.json');
371376
if (FileSystem.exists(tsconfigPath)) {
372-
rootFolder = currentFolder;
377+
projectFolder = currentFolder;
373378
break;
374379
}
375380
const parentFolder: string = path.dirname(currentFolder);
376381
if (parentFolder === '' || parentFolder === currentFolder) {
377-
throw new Error('The rootFolder was set to "<lookup>", but a tsconfig.json file cannot be'
382+
throw new Error('The projectFolder was set to "<lookup>", but a tsconfig.json file cannot be'
378383
+ ' found in this folder or any parent folder.');
379384
}
380385
currentFolder = parentFolder;
381386
}
382387
} else {
383-
if (!configObject.compiler.rootFolder) {
384-
throw new Error('The rootFolder must be specified');
385-
}
386-
387-
ExtractorConfig._rejectAnyTokensInPath(configObject.compiler.rootFolder, 'rootFolder');
388+
ExtractorConfig._rejectAnyTokensInPath(configObject.projectFolder, 'projectFolder');
388389

389-
if (!FileSystem.exists(configObject.compiler.rootFolder)) {
390-
throw new Error('The specified rootFolder does not exist: ' + configObject.compiler.rootFolder);
390+
if (!FileSystem.exists(configObject.projectFolder)) {
391+
throw new Error('The specified projectFolder does not exist: ' + configObject.projectFolder);
391392
}
392393

393-
rootFolder = configObject.compiler.rootFolder;
394+
projectFolder = configObject.projectFolder;
394395
}
395396

396397
const tokenContext: IExtractorConfigTokenContext = {
397398
unscopedPackageName: 'unknown-package',
398399
packageName: 'unknown-package',
399-
rootFolder
400+
projectFolder: projectFolder
400401
};
401402

402403
if (packageJson) {
@@ -464,11 +465,11 @@ export class ExtractorConfig {
464465

465466
if (tsdocMetadataFilePath.trim() === '<lookup>') {
466467
if (!packageJson) {
467-
throw new Error('The "<lookup>" token cannot be used with compiler.rootFolder because'
468+
throw new Error('The "<lookup>" token cannot be used with compiler.projectFolder because'
468469
+ 'the "packageJson" option was not provided');
469470
}
470471
if (!packageJsonFullPath) {
471-
throw new Error('The "<lookup>" token cannot be used with compiler.rootFolder because'
472+
throw new Error('The "<lookup>" token cannot be used with compiler.projectFolder because'
472473
+ 'the "packageJsonFullPath" option was not provided');
473474
}
474475
tsdocMetadataFilePath = PackageMetadataManager.resolveTsdocMetadataPath(
@@ -502,7 +503,7 @@ export class ExtractorConfig {
502503
}
503504

504505
return new ExtractorConfig({
505-
rootFolder,
506+
projectFolder: projectFolder,
506507
packageJson,
507508
packageJsonFullPath,
508509
mainEntryPointFile,
@@ -533,7 +534,7 @@ export class ExtractorConfig {
533534

534535
value = ExtractorConfig._expandStringWithTokens(fieldName, value, tokenContext);
535536
if (value !== '') {
536-
value = path.resolve(tokenContext.rootFolder, value);
537+
value = path.resolve(tokenContext.projectFolder, value);
537538
}
538539
return value;
539540
}
@@ -560,7 +561,7 @@ export class ExtractorConfig {
560561
}
561562

562563
/**
563-
* Given a path string that may have originally contained expandable tokens such as `<rootFolder>"`
564+
* Given a path string that may have originally contained expandable tokens such as `<projectFolder>"`
564565
* this reports an error if any token-looking substrings remain after expansion (e.g. `c:\blah\<invalid>\blah`).
565566
*/
566567
private static _rejectAnyTokensInPath(value: string, fieldName: string): void {

‎apps/api-extractor/src/api/IConfigFile.ts‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,6 @@ import { ExtractorLogLevel } from './ExtractorLogLevel';
1313
*/
1414
export interface IConfigCompiler {
1515

16-
/**
17-
* The root folder for the project. This folder typically contains the tsconfig.json and package.json
18-
* config files.
19-
*
20-
* @remarks
21-
*
22-
* The `rootFolder` path is resolved relative to the folder containing api-extractor.json.
23-
*
24-
* The default value for `rootFolder` is the token `<lookup>`, which means the folder is determined by traversing
25-
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
26-
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
27-
* will be reported.
28-
*/
29-
rootFolder: string;
30-
3116
/**
3217
* Provides already parsed tsconfig.json contents.
3318
*
@@ -36,7 +21,7 @@ export interface IConfigCompiler {
3621
*
3722
* http://json.schemastore.org/tsconfig
3823
*
39-
* If omitted, then the tsconfig.json file will instead be read from the rootFolder.
24+
* If omitted, then the tsconfig.json file will instead be read from the projectFolder.
4025
*/
4126
overrideTsconfig?: { };
4227

@@ -83,7 +68,7 @@ export interface IConfigApiReport {
8368
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
8469
* e.g. for an API review.
8570
*
86-
* The path is resolved relative to the `rootFolder` location.
71+
* The path is resolved relative to the `projectFolder` location.
8772
*/
8873
reportFolder?: string;
8974

@@ -95,7 +80,7 @@ export interface IConfigApiReport {
9580
* After the temporary file is written to disk, it is compared with the file in the `reportFolder`.
9681
* If they are different, a production build will fail.
9782
*
98-
* The path is resolved relative to the `rootFolder` location.
83+
* The path is resolved relative to the `projectFolder` location.
9984
*/
10085
reportTempFolder?: string;
10186
}
@@ -119,7 +104,7 @@ export interface IConfigDocModel {
119104
*
120105
* @remarks
121106
* The file extension should be ".api.json".
122-
* The path is resolved relative to the `rootFolder` location.
107+
* The path is resolved relative to the `projectFolder` location.
123108
*/
124109
apiJsonFilePath?: string;
125110
}
@@ -146,7 +131,7 @@ export interface IConfigDtsRollup {
146131
*
147132
* If the path is an empty string, then this file will not be written.
148133
*
149-
* The path is resolved relative to the `rootFolder` location.
134+
* The path is resolved relative to the `projectFolder` location.
150135
*/
151136
untrimmedFilePath?: string;
152137

@@ -158,7 +143,7 @@ export interface IConfigDtsRollup {
158143
*
159144
* If the path is an empty string, then this file will not be written.
160145
*
161-
* The path is resolved relative to the `rootFolder` location.
146+
* The path is resolved relative to the `projectFolder` location.
162147
*/
163148
betaTrimmedFilePath?: string;
164149

@@ -170,7 +155,7 @@ export interface IConfigDtsRollup {
170155
*
171156
* If the path is an empty string, then this file will not be written.
172157
*
173-
* The path is resolved relative to the `rootFolder` location.
158+
* The path is resolved relative to the `projectFolder` location.
174159
*/
175160
publicTrimmedFilePath?: string;
176161
}
@@ -282,14 +267,29 @@ export interface IConfigFile {
282267
*/
283268
extends?: string;
284269

270+
/**
271+
* The root folder for the project. This folder typically contains the tsconfig.json and package.json
272+
* config files.
273+
*
274+
* @remarks
275+
*
276+
* The `projectFolder` path is resolved relative to the folder containing api-extractor.json.
277+
*
278+
* The default value for `projectFolder` is the token `<lookup>`, which means the folder is determined by traversing
279+
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
280+
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
281+
* will be reported.
282+
*/
283+
projectFolder?: string;
284+
285285
/**
286286
* Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
287287
* analyzes the symbols exported by this module.
288288
*
289289
* @remarks
290290
*
291291
* The file extension must be ".d.ts" and not ".ts".
292-
* The path is resolved relative to the "rootFolder" location.
292+
* The path is resolved relative to the "projectFolder" location.
293293
*/
294294
mainEntryPointFile: string;
295295

‎common/reviews/api/api-extractor.api.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ export class ExtractorConfig {
5454
readonly packageJson: INodePackageJson | undefined;
5555
readonly packageJsonFullPath: string | undefined;
5656
static prepare(options: IExtractorConfigPrepareOptions): ExtractorConfig;
57+
readonly projectFolder: string;
5758
readonly publicTrimmedFilePath: string;
5859
readonly reportFilePath: string;
5960
readonly reportTempFilePath: string;
6061
readonly rollupEnabled: boolean;
61-
readonly rootFolder: string;
6262
readonly skipLibCheck: boolean;
6363
readonly testMode: boolean;
6464
readonly tsdocMetadataEnabled: boolean;
@@ -149,7 +149,6 @@ export interface IConfigApiReport {
149149
// @public
150150
export interface IConfigCompiler {
151151
overrideTsconfig?: {};
152-
rootFolder: string;
153152
skipLibCheck?: boolean;
154153
}
155154

@@ -177,6 +176,7 @@ export interface IConfigFile {
177176
extends?: string;
178177
mainEntryPointFile: string;
179178
messages?: IExtractorMessagesConfig;
179+
projectFolder?: string;
180180
testMode?: boolean;
181181
// @beta
182182
tsdocMetadata?: IConfigTsdocMetadata;

0 commit comments

Comments
 (0)