Skip to content

Commit 351a809

Browse files
committed
Add support for an alphaTrimmedFilePath.
1 parent 1bf145c commit 351a809

File tree

13 files changed

+78
-3
lines changed

13 files changed

+78
-3
lines changed

apps/api-extractor/src/api/Extractor.ts

+6
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,12 @@ export class Extractor {
384384
DtsRollupKind.PublicRelease,
385385
extractorConfig.newlineKind
386386
);
387+
Extractor._generateRollupDtsFile(
388+
collector,
389+
extractorConfig.alphaTrimmedFilePath,
390+
DtsRollupKind.AlphaRelease,
391+
extractorConfig.newlineKind
392+
);
387393
Extractor._generateRollupDtsFile(
388394
collector,
389395
extractorConfig.betaTrimmedFilePath,

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

+18
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ interface IExtractorConfigParameters {
153153
apiJsonFilePath: string;
154154
rollupEnabled: boolean;
155155
untrimmedFilePath: string;
156+
alphaTrimmedFilePath: string;
156157
betaTrimmedFilePath: string;
157158
publicTrimmedFilePath: string;
158159
omitTrimmingComments: boolean;
@@ -245,6 +246,8 @@ export class ExtractorConfig {
245246
public readonly rollupEnabled: boolean;
246247
/** {@inheritDoc IConfigDtsRollup.untrimmedFilePath} */
247248
public readonly untrimmedFilePath: string;
249+
/** {@inheritDoc IConfigDtsRollup.alphaTrimmedFilePath} */
250+
public readonly alphaTrimmedFilePath: string;
248251
/** {@inheritDoc IConfigDtsRollup.betaTrimmedFilePath} */
249252
public readonly betaTrimmedFilePath: string;
250253
/** {@inheritDoc IConfigDtsRollup.publicTrimmedFilePath} */
@@ -295,6 +298,7 @@ export class ExtractorConfig {
295298
this.apiJsonFilePath = parameters.apiJsonFilePath;
296299
this.rollupEnabled = parameters.rollupEnabled;
297300
this.untrimmedFilePath = parameters.untrimmedFilePath;
301+
this.alphaTrimmedFilePath = parameters.alphaTrimmedFilePath;
298302
this.betaTrimmedFilePath = parameters.betaTrimmedFilePath;
299303
this.publicTrimmedFilePath = parameters.publicTrimmedFilePath;
300304
this.omitTrimmingComments = parameters.omitTrimmingComments;
@@ -611,6 +615,13 @@ export class ExtractorConfig {
611615
currentConfigFolderPath
612616
);
613617
}
618+
if (configFile.dtsRollup.alphaTrimmedFilePath) {
619+
configFile.dtsRollup.alphaTrimmedFilePath = ExtractorConfig._resolveConfigFileRelativePath(
620+
'alphaTrimmedFilePath',
621+
configFile.dtsRollup.alphaTrimmedFilePath,
622+
currentConfigFolderPath
623+
);
624+
}
614625
if (configFile.dtsRollup.betaTrimmedFilePath) {
615626
configFile.dtsRollup.betaTrimmedFilePath = ExtractorConfig._resolveConfigFileRelativePath(
616627
'betaTrimmedFilePath',
@@ -912,6 +923,7 @@ export class ExtractorConfig {
912923
let rollupEnabled: boolean = false;
913924
let untrimmedFilePath: string = '';
914925
let betaTrimmedFilePath: string = '';
926+
let alphaTrimmedFilePath: string = '';
915927
let publicTrimmedFilePath: string = '';
916928
let omitTrimmingComments: boolean = false;
917929

@@ -922,6 +934,11 @@ export class ExtractorConfig {
922934
configObject.dtsRollup.untrimmedFilePath,
923935
tokenContext
924936
);
937+
alphaTrimmedFilePath = ExtractorConfig._resolvePathWithTokens(
938+
'alphaTrimmedFilePath',
939+
configObject.dtsRollup.alphaTrimmedFilePath,
940+
tokenContext
941+
);
925942
betaTrimmedFilePath = ExtractorConfig._resolvePathWithTokens(
926943
'betaTrimmedFilePath',
927944
configObject.dtsRollup.betaTrimmedFilePath,
@@ -963,6 +980,7 @@ export class ExtractorConfig {
963980
apiJsonFilePath,
964981
rollupEnabled,
965982
untrimmedFilePath,
983+
alphaTrimmedFilePath,
966984
betaTrimmedFilePath,
967985
publicTrimmedFilePath,
968986
omitTrimmingComments,

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

+11
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ export interface IConfigDtsRollup {
148148
*/
149149
untrimmedFilePath?: string;
150150

151+
/**
152+
* Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release.
153+
*
154+
* @remarks
155+
* This file will include only declarations that are marked as `@public`, `@beta`, or `@alpha`.
156+
*
157+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
158+
* prepend a folder token such as `<projectFolder>`.
159+
*/
160+
alphaTrimmedFilePath?: string;
161+
151162
/**
152163
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
153164
*

apps/api-extractor/src/generators/DtsRollupGenerator.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ export enum DtsRollupKind {
3434
*/
3535
InternalRelease,
3636

37+
/**
38+
* Generate a *.d.ts file for a preview release.
39+
* This output file will contain all definitions that are reachable from the entry point,
40+
* except definitions marked as \@internal.
41+
*/
42+
AlphaRelease,
43+
3744
/**
3845
* Generate a *.d.ts file for a preview release.
3946
* This output file will contain all definitions that are reachable from the entry point,
@@ -445,10 +452,20 @@ export class DtsRollupGenerator {
445452
switch (dtsKind) {
446453
case DtsRollupKind.InternalRelease:
447454
return true;
455+
case DtsRollupKind.AlphaRelease:
456+
return (
457+
releaseTag === ReleaseTag.Alpha ||
458+
releaseTag === ReleaseTag.Beta ||
459+
releaseTag === ReleaseTag.Public ||
460+
// NOTE: If the release tag is "None", then we don't have enough information to trim it
461+
releaseTag === ReleaseTag.None
462+
);
448463
case DtsRollupKind.BetaRelease:
449-
// NOTE: If the release tag is "None", then we don't have enough information to trim it
450464
return (
451-
releaseTag === ReleaseTag.Beta || releaseTag === ReleaseTag.Public || releaseTag === ReleaseTag.None
465+
releaseTag === ReleaseTag.Beta ||
466+
releaseTag === ReleaseTag.Public ||
467+
// NOTE: If the release tag is "None", then we don't have enough information to trim it
468+
releaseTag === ReleaseTag.None
452469
);
453470
case DtsRollupKind.PublicRelease:
454471
return releaseTag === ReleaseTag.Public || releaseTag === ReleaseTag.None;

apps/api-extractor/src/schemas/api-extractor-defaults.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
// ("enabled" is required)
2929

3030
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
31+
"alphaTrimmedFilePath": "",
3132
"betaTrimmedFilePath": "",
3233
"publicTrimmedFilePath": "",
3334
"omitTrimmingComments": false

apps/api-extractor/src/schemas/api-extractor-template.json

+12
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@
197197
*/
198198
// "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
199199

200+
/**
201+
* Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release.
202+
* This file will include only declarations that are marked as "@public", "@beta", or "@alpha".
203+
*
204+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
205+
* prepend a folder token such as "<projectFolder>".
206+
*
207+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
208+
* DEFAULT VALUE: ""
209+
*/
210+
// "alphaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-alpha.d.ts",
211+
200212
/**
201213
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
202214
* This file will include only declarations that are marked as "@public" or "@beta".

apps/api-extractor/src/schemas/api-extractor.schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
"description": "Specifies the output path for a .d.ts rollup file to be generated without any trimming. This file will include all declarations that are exported by the main entry point. If the path is an empty string, then this file will not be written. The path is resolved relative to the folder of the config file that contains the setting; to change this, prepend a folder token such as \"<projectFolder>\".",
109109
"type": "string"
110110
},
111+
"alphaTrimmedFilePath": {
112+
"description": "Specifies the output path for a .d.ts rollup file to be generated with trimming for an \"alpha\" release. This file will include only declarations that are marked as \"@public\", \"@beta\", or \"@alpha\". The path is resolved relative to the folder of the config file that contains the setting; to change this, prepend a folder token such as \"<projectFolder>\".",
113+
"type": "string"
114+
},
111115
"betaTrimmedFilePath": {
112116
"description": "Specifies the output path for a .d.ts rollup file to be generated with trimming for a \"beta\" release. This file will include only declarations that are marked as \"@public\" or \"@beta\". The path is resolved relative to the folder of the config file that contains the setting; to change this, prepend a folder token such as \"<projectFolder>\".",
113117
"type": "string"

build-tests/api-extractor-scenarios/src/functionOverload/config/api-extractor-overrides.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"dtsRollup": {
33
"enabled": true,
44
"untrimmedFilePath": "<projectFolder>/etc/test-outputs/functionOverload/rollup.d.ts",
5+
"alphaTrimmedFilePath": "<projectFolder>/etc/test-outputs/functionOverload/alpha-rollup.d.ts",
56
"betaTrimmedFilePath": "<projectFolder>/etc/test-outputs/functionOverload/beta-rollup.d.ts",
67
"publicTrimmedFilePath": "<projectFolder>/etc/test-outputs/functionOverload/public-rollup.d.ts"
78
}

build-tests/api-extractor-test-01/config/api-extractor.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"dtsRollup": {
1515
"enabled": true,
1616

17+
"alphaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-alpha.d.ts",
1718
"betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
1819
"publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts"
1920
},

build-tests/api-extractor-test-02/config/api-extractor.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"dtsRollup": {
1515
"enabled": true,
1616

17+
"alphaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-alpha.d.ts",
1718
"betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
1819
"publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts"
1920
},

build-tests/api-extractor-test-04/config/api-extractor.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"dtsRollup": {
1515
"enabled": true,
1616

17+
"alphaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-alpha.d.ts",
1718
"betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
1819
"publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts"
1920
},

build-tests/heft-node-everything-test/config/api-extractor.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"dtsRollup": {
1313
"enabled": true,
14+
"alphaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-alpha.d.ts",
1415
"betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts"
1516
}
1617
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class Extractor {
4545

4646
// @public
4747
export class ExtractorConfig {
48+
readonly alphaTrimmedFilePath: string;
4849
readonly apiJsonFilePath: string;
4950
readonly apiReportEnabled: boolean;
5051
readonly betaTrimmedFilePath: string;
@@ -184,6 +185,7 @@ export interface IConfigDocModel {
184185

185186
// @public
186187
export interface IConfigDtsRollup {
188+
alphaTrimmedFilePath?: string;
187189
betaTrimmedFilePath?: string;
188190
enabled: boolean;
189191
omitTrimmingComments?: boolean;
@@ -265,5 +267,4 @@ export interface IExtractorMessagesConfig {
265267
tsdocMessageReporting?: IConfigMessageReportingTable;
266268
}
267269

268-
269270
```

0 commit comments

Comments
 (0)