From e60b5ddf54012d6ea4dde1987842032bce2421e4 Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Wed, 15 Jun 2022 15:43:22 -0700 Subject: [PATCH 1/6] Allow for the extractor configuration to be loaded without validation of existing targets --- apps/api-extractor/src/api/ExtractorConfig.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/api-extractor/src/api/ExtractorConfig.ts b/apps/api-extractor/src/api/ExtractorConfig.ts index c487250a70..fe0dc2e54d 100644 --- a/apps/api-extractor/src/api/ExtractorConfig.ts +++ b/apps/api-extractor/src/api/ExtractorConfig.ts @@ -135,6 +135,13 @@ export interface IExtractorConfigPrepareOptions { * `@microsoft/api-extractor/extends/tsdoc-base.json`. */ tsdocConfigFile?: TSDocConfigFile; + + /** + * When preparing the configuration object, folder and file paths referenced in the configuration are checked + * for existence, and an error is reported if they are not found. This option can be used to disable this + * check. This may be useful when preparing a configuration file for an un-built project. + */ + ignoreMissingConfigTargets?: boolean; } interface IExtractorConfigParameters { @@ -732,7 +739,7 @@ export class ExtractorConfig { // Use the manually specified "" value projectFolder = options.projectFolderLookupToken; - if (!FileSystem.exists(options.projectFolderLookupToken)) { + if (!options.ignoreMissingConfigTargets && !FileSystem.exists(options.projectFolderLookupToken)) { throw new Error( 'The specified "projectFolderLookupToken" path does not exist: ' + options.projectFolderLookupToken @@ -771,7 +778,7 @@ export class ExtractorConfig { } else { ExtractorConfig._rejectAnyTokensInPath(configObject.projectFolder, 'projectFolder'); - if (!FileSystem.exists(configObject.projectFolder)) { + if (!options.ignoreMissingConfigTargets && !FileSystem.exists(configObject.projectFolder)) { throw new Error('The specified "projectFolder" path does not exist: ' + configObject.projectFolder); } @@ -805,7 +812,7 @@ export class ExtractorConfig { ); } - if (!FileSystem.exists(mainEntryPointFilePath)) { + if (!options.ignoreMissingConfigTargets && !FileSystem.exists(mainEntryPointFilePath)) { throw new Error('The "mainEntryPointFilePath" path does not exist: ' + mainEntryPointFilePath); } @@ -826,7 +833,7 @@ export class ExtractorConfig { if (!tsconfigFilePath) { throw new Error('Either the "tsconfigFilePath" or "overrideTsconfig" setting must be specified'); } - if (!FileSystem.exists(tsconfigFilePath)) { + if (!options.ignoreMissingConfigTargets && !FileSystem.exists(tsconfigFilePath)) { throw new Error('The file referenced by "tsconfigFilePath" does not exist: ' + tsconfigFilePath); } } From 5563dfd419698f3683641bde99d6a83f8bc09a2c Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Wed, 15 Jun 2022 15:45:19 -0700 Subject: [PATCH 2/6] Rush change --- ...danade-ApiExtractorConfigLoad_2022-06-15-22-45.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@microsoft/api-extractor/user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json diff --git a/common/changes/@microsoft/api-extractor/user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json b/common/changes/@microsoft/api-extractor/user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json new file mode 100644 index 0000000000..db207ee54f --- /dev/null +++ b/common/changes/@microsoft/api-extractor/user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/api-extractor", + "comment": "Add support for loading the ExtractorConfig without validating the existence of target typings files", + "type": "minor" + } + ], + "packageName": "@microsoft/api-extractor" +} \ No newline at end of file From 5a14aa7be2914f9ee2916255c31a2a73d52101bd Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Wed, 15 Jun 2022 15:47:06 -0700 Subject: [PATCH 3/6] Add updated api-extractor report --- common/reviews/api/api-extractor.api.md | 1 + 1 file changed, 1 insertion(+) diff --git a/common/reviews/api/api-extractor.api.md b/common/reviews/api/api-extractor.api.md index 1d4b950507..abe85f445d 100644 --- a/common/reviews/api/api-extractor.api.md +++ b/common/reviews/api/api-extractor.api.md @@ -240,6 +240,7 @@ export interface IExtractorConfigLoadForFolderOptions { export interface IExtractorConfigPrepareOptions { configObject: IConfigFile; configObjectFullPath: string | undefined; + ignoreMissingConfigTargets?: boolean; packageJson?: INodePackageJson | undefined; packageJsonFullPath: string | undefined; projectFolderLookupToken?: string; From 9ef1725a7e349a31fb096bd65759b0a3ba72bd15 Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 27 Jun 2022 12:35:29 -0700 Subject: [PATCH 4/6] Change name of option and avoid ignoring unrelated checks --- apps/api-extractor/src/api/ExtractorConfig.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/api-extractor/src/api/ExtractorConfig.ts b/apps/api-extractor/src/api/ExtractorConfig.ts index fe0dc2e54d..8b4fb40855 100644 --- a/apps/api-extractor/src/api/ExtractorConfig.ts +++ b/apps/api-extractor/src/api/ExtractorConfig.ts @@ -139,9 +139,10 @@ export interface IExtractorConfigPrepareOptions { /** * When preparing the configuration object, folder and file paths referenced in the configuration are checked * for existence, and an error is reported if they are not found. This option can be used to disable this - * check. This may be useful when preparing a configuration file for an un-built project. + * check for the main entry point module. This may be useful when preparing a configuration file for an + * un-built project. */ - ignoreMissingConfigTargets?: boolean; + ignoreMissingEntryPoint?: boolean; } interface IExtractorConfigParameters { @@ -739,7 +740,7 @@ export class ExtractorConfig { // Use the manually specified "" value projectFolder = options.projectFolderLookupToken; - if (!options.ignoreMissingConfigTargets && !FileSystem.exists(options.projectFolderLookupToken)) { + if (!FileSystem.exists(options.projectFolderLookupToken)) { throw new Error( 'The specified "projectFolderLookupToken" path does not exist: ' + options.projectFolderLookupToken @@ -778,7 +779,7 @@ export class ExtractorConfig { } else { ExtractorConfig._rejectAnyTokensInPath(configObject.projectFolder, 'projectFolder'); - if (!options.ignoreMissingConfigTargets && !FileSystem.exists(configObject.projectFolder)) { + if (!FileSystem.exists(configObject.projectFolder)) { throw new Error('The specified "projectFolder" path does not exist: ' + configObject.projectFolder); } @@ -812,7 +813,7 @@ export class ExtractorConfig { ); } - if (!options.ignoreMissingConfigTargets && !FileSystem.exists(mainEntryPointFilePath)) { + if (!options.ignoreMissingEntryPoint && !FileSystem.exists(mainEntryPointFilePath)) { throw new Error('The "mainEntryPointFilePath" path does not exist: ' + mainEntryPointFilePath); } @@ -833,7 +834,7 @@ export class ExtractorConfig { if (!tsconfigFilePath) { throw new Error('Either the "tsconfigFilePath" or "overrideTsconfig" setting must be specified'); } - if (!options.ignoreMissingConfigTargets && !FileSystem.exists(tsconfigFilePath)) { + if (!FileSystem.exists(tsconfigFilePath)) { throw new Error('The file referenced by "tsconfigFilePath" does not exist: ' + tsconfigFilePath); } } From bba823575d77179162b5b869d6d822c1875a0656 Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 27 Jun 2022 12:38:01 -0700 Subject: [PATCH 5/6] Update changelog --- .../user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/changes/@microsoft/api-extractor/user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json b/common/changes/@microsoft/api-extractor/user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json index db207ee54f..4e80aeec12 100644 --- a/common/changes/@microsoft/api-extractor/user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json +++ b/common/changes/@microsoft/api-extractor/user-danade-ApiExtractorConfigLoad_2022-06-15-22-45.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@microsoft/api-extractor", - "comment": "Add support for loading the ExtractorConfig without validating the existence of target typings files", + "comment": "Add support for the \"ignoreMissingEntryPoint\" ExtractorConfig option to allow for loading an ExtractorConfig before the target project is built.", "type": "minor" } ], From 3cd3837c6f04af53693f8120c6f876d1c1ee76fe Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 27 Jun 2022 12:47:31 -0700 Subject: [PATCH 6/6] Update API review file --- common/reviews/api/api-extractor.api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/reviews/api/api-extractor.api.md b/common/reviews/api/api-extractor.api.md index abe85f445d..f91898d05f 100644 --- a/common/reviews/api/api-extractor.api.md +++ b/common/reviews/api/api-extractor.api.md @@ -240,7 +240,7 @@ export interface IExtractorConfigLoadForFolderOptions { export interface IExtractorConfigPrepareOptions { configObject: IConfigFile; configObjectFullPath: string | undefined; - ignoreMissingConfigTargets?: boolean; + ignoreMissingEntryPoint?: boolean; packageJson?: INodePackageJson | undefined; packageJsonFullPath: string | undefined; projectFolderLookupToken?: string;