Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-extractor] Rename "API Review File" to "API Report File" #1213

Merged
merged 5 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api-extractor/src/api/ConsoleMessageId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const enum ConsoleMessageId {
ApiReportUnchanged = 'console-api-report-unchanged',

/**
* "The API review file has not been set up. Do this by copying ___ to ___ and committing it."
* "The API report file has not been set up. Do this by copying ___ to ___ and committing it."
*/
ApiReportMissing = 'console-api-report-missing'
}
36 changes: 18 additions & 18 deletions apps/api-extractor/src/api/Extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface IExtractorInvokeOptions {
/**
* Indicates that API Extractor is running as part of a local build, e.g. on developer's
* machine. This disables certain validation that would normally be performed
* for a ship/production build. For example, the *.api.md review file is
* for a ship/production build. For example, the *.api.md report file is
* automatically updated in a local build.
*
* The default value is false.
Expand Down Expand Up @@ -209,40 +209,40 @@ export class Extractor {

if (extractorConfig.apiReportEnabled) {
const actualApiReportPath: string = extractorConfig.reportTempFilePath;
const actualApiReviewShortPath: string = extractorConfig._getShortFilePath(extractorConfig.reportTempFilePath);
const actualApiReportShortPath: string = extractorConfig._getShortFilePath(extractorConfig.reportTempFilePath);

const expectedApiReviewPath: string = extractorConfig.reportFilePath;
const expectedApiReviewShortPath: string = extractorConfig._getShortFilePath(extractorConfig.reportFilePath);
const expectedApiReportPath: string = extractorConfig.reportFilePath;
const expectedApiReportShortPath: string = extractorConfig._getShortFilePath(extractorConfig.reportFilePath);

const actualApiReviewContent: string = ReviewFileGenerator.generateReviewFileContent(collector);
const actualApiReportContent: string = ReviewFileGenerator.generateReviewFileContent(collector);

// Write the actual file
FileSystem.writeFile(actualApiReportPath, actualApiReviewContent, {
FileSystem.writeFile(actualApiReportPath, actualApiReportContent, {
ensureFolderExists: true,
convertLineEndings: NewlineKind.CrLf
});

// Compare it against the expected file
if (FileSystem.exists(expectedApiReviewPath)) {
const expectedApiReviewContent: string = FileSystem.readFile(expectedApiReviewPath);
if (FileSystem.exists(expectedApiReportPath)) {
const expectedApiReportContent: string = FileSystem.readFile(expectedApiReportPath);

if (!ReviewFileGenerator.areEquivalentApiFileContents(actualApiReviewContent, expectedApiReviewContent)) {
if (!ReviewFileGenerator.areEquivalentApiFileContents(actualApiReportContent, expectedApiReportContent)) {
if (!localBuild) {
// For production, issue a warning that will break the CI build.
messageRouter.logWarning(ConsoleMessageId.ApiReportNotCopied,
'You have changed the public API signature for this project.'
// @microsoft/gulp-core-build seems to run JSON.stringify() on the error messages for some reason,
// so try to avoid escaped characters:
+ ` Please overwrite ${expectedApiReviewShortPath} with a`
+ ` copy of ${actualApiReviewShortPath}`
+ ` Please overwrite ${expectedApiReportShortPath} with a`
+ ` copy of ${actualApiReportShortPath}`
+ ' and then request an API review. See the Git repository README.md for more info.');
} else {
// For a local build, just copy the file automatically.
messageRouter.logWarning(ConsoleMessageId.ApiReportCopied,
'You have changed the public API signature for this project.'
+ ` Updating ${expectedApiReviewShortPath}`);
+ ` Updating ${expectedApiReportShortPath}`);

FileSystem.writeFile(expectedApiReviewPath, actualApiReviewContent, {
FileSystem.writeFile(expectedApiReportPath, actualApiReportContent, {
ensureFolderExists: true,
convertLineEndings: NewlineKind.CrLf
});
Expand All @@ -251,15 +251,15 @@ export class Extractor {
apiReportChanged = true;
} else {
messageRouter.logVerbose(ConsoleMessageId.ApiReportUnchanged,
`The API signature is up to date: ${actualApiReviewShortPath}`);
`The API signature is up to date: ${actualApiReportShortPath}`);
}
} else {
// NOTE: This warning seems like a nuisance, but it has caught genuine mistakes.
// For example, when projects were moved into category folders, the relative path for
// the API review files ended up in the wrong place.
messageRouter.logError(ConsoleMessageId.ApiReportMissing, `The API review file has not been set up.`
+ ` Do this by copying ${actualApiReviewShortPath}`
+ ` to ${expectedApiReviewShortPath} and committing it.`);
// the API report files ended up in the wrong place.
messageRouter.logError(ConsoleMessageId.ApiReportMissing, `The API report file has not been set up.`
+ ` Do this by copying ${actualApiReportShortPath}`
+ ` to ${expectedApiReportShortPath} and committing it.`);
}
}

Expand Down
10 changes: 5 additions & 5 deletions apps/api-extractor/src/api/IConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface IConfigCompiler {
}

/**
* Configures how the API review files (*.api.md) will be generated.
* Configures how the API report files (*.api.md) will be generated.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
Expand Down Expand Up @@ -213,16 +213,16 @@ export interface IConfigMessageReportingRule {
* Specifies whether the message should be written to the the tool's output log.
*
* @remarks
* Note that the `addToApiReviewFile` property may supersede this option.
* Note that the `addToApiReportFile` property may supersede this option.
*/
logLevel: ExtractorLogLevel;

/**
* If API Extractor is configured to write an API review file (.api.md), then the message will be written
* inside that file. If the API review file is NOT being written, then the message is instead logged according
* If API Extractor is configured to write an API report file (.api.md), then the message will be written
* inside that file. If the API report file is NOT being written, then the message is instead logged according
* to the `logLevel` option.
*/
addToApiReviewFile?: boolean;
addToApiReportFile?: boolean;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/api-extractor/src/cli/RunAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class RunAction extends CommandLineAction {
description: 'Indicates that API Extractor is running as part of a local build,'
+ ' e.g. on a developer\'s machine. This disables certain validation that would'
+ ' normally be performed for a ship/production build. For example, the *.api.md'
+ ' review file is automatically copied in a local build.'
+ ' report file is automatically copied in a local build.'
});

this._verboseParameter = this.defineFlagParameter({
Expand Down
46 changes: 23 additions & 23 deletions apps/api-extractor/src/collector/MessageRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { ConsoleMessageId } from '../api/ConsoleMessageId';

interface IReportingRule {
logLevel: ExtractorLogLevel;
addToApiReviewFile: boolean;
addToApiReportFile: boolean;
}

export class MessageRouter {
Expand All @@ -37,19 +37,19 @@ export class MessageRouter {
// All messages
private readonly _messages: ExtractorMessage[];

// For each AstDeclaration, the messages associated with it. This is used when addToApiReviewFile=true
// For each AstDeclaration, the messages associated with it. This is used when addToApiReportFile=true
private readonly _associatedMessagesForAstDeclaration: Map<AstDeclaration, ExtractorMessage[]>;

private readonly _sourceMapper: SourceMapper;

// Normalized representation of the routing rules from api-extractor.json
private _reportingRuleByMessageId: Map<string, IReportingRule> = new Map<string, IReportingRule>();
private _compilerDefaultRule: IReportingRule = { logLevel: ExtractorLogLevel.None,
addToApiReviewFile: false };
addToApiReportFile: false };
private _extractorDefaultRule: IReportingRule = { logLevel: ExtractorLogLevel.None,
addToApiReviewFile: false };
addToApiReportFile: false };
private _tsdocDefaultRule: IReportingRule = { logLevel: ExtractorLogLevel.None,
addToApiReviewFile: false };
addToApiReportFile: false };

public errorCount: number = 0;
public warningCount: number = 0;
Expand Down Expand Up @@ -131,7 +131,7 @@ export class MessageRouter {
private static _getNormalizedRule(rule: IConfigMessageReportingRule): IReportingRule {
return {
logLevel: rule.logLevel || 'none',
addToApiReviewFile: rule.addToApiReviewFile || false
addToApiReportFile: rule.addToApiReportFile || false
};
}

Expand Down Expand Up @@ -265,61 +265,61 @@ export class MessageRouter {
}

/**
* This is used when writing the API review file. It looks up any messages that were configured to get emitted
* in the API review file and returns them. It also records that they were emitted, which suppresses them from
* This is used when writing the API report file. It looks up any messages that were configured to get emitted
* in the API report file and returns them. It also records that they were emitted, which suppresses them from
* being shown on the console.
*/
public fetchAssociatedMessagesForReviewFile(astDeclaration: AstDeclaration): ExtractorMessage[] {
const messagesForApiReviewFile: ExtractorMessage[] = [];
const messagesForApiReportFile: ExtractorMessage[] = [];

const associatedMessages: ExtractorMessage[] = this._associatedMessagesForAstDeclaration.get(astDeclaration) || [];
for (const associatedMessage of associatedMessages) {

// Make sure we didn't already report this message for some reason
if (!associatedMessage.handled) {

// Is this message type configured to go in the API review file?
// Is this message type configured to go in the API report file?
const reportingRule: IReportingRule = this._getRuleForMessage(associatedMessage);
if (reportingRule.addToApiReviewFile) {
if (reportingRule.addToApiReportFile) {

// Include it in the result, and record that it went to the API review file
messagesForApiReviewFile.push(associatedMessage);
// Include it in the result, and record that it went to the API report file
messagesForApiReportFile.push(associatedMessage);
associatedMessage.handled = true;
}
}

}

this._sortMessagesForOutput(messagesForApiReviewFile);
return messagesForApiReviewFile;
this._sortMessagesForOutput(messagesForApiReportFile);
return messagesForApiReportFile;
}

/**
* This returns all remaining messages that were flagged with `addToApiReviewFile`, but which were not
* This returns all remaining messages that were flagged with `addToApiReportFile`, but which were not
* retreieved using `fetchAssociatedMessagesForReviewFile()`.
*/
public fetchUnassociatedMessagesForReviewFile(): ExtractorMessage[] {
const messagesForApiReviewFile: ExtractorMessage[] = [];
const messagesForApiReportFile: ExtractorMessage[] = [];

for (const unassociatedMessage of this.messages) {

// Make sure we didn't already report this message for some reason
if (!unassociatedMessage.handled) {

// Is this message type configured to go in the API review file?
// Is this message type configured to go in the API report file?
const reportingRule: IReportingRule = this._getRuleForMessage(unassociatedMessage);
if (reportingRule.addToApiReviewFile) {
if (reportingRule.addToApiReportFile) {

// Include it in the result, and record that it went to the API review file
messagesForApiReviewFile.push(unassociatedMessage);
// Include it in the result, and record that it went to the API report file
messagesForApiReportFile.push(unassociatedMessage);
unassociatedMessage.handled = true;
}
}

}

this._sortMessagesForOutput(messagesForApiReviewFile);
return messagesForApiReviewFile;
this._sortMessagesForOutput(messagesForApiReportFile);
return messagesForApiReportFile;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/api-extractor/src/generators/ReviewFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class ReviewFileGenerator {
const stringWriter: StringWriter = new StringWriter();

stringWriter.writeLine([
`## API Review File for "${collector.workingPackage.name}"`,
`## API Report File for "${collector.workingPackage.name}"`,
``,
`> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).`,
``
Expand Down
10 changes: 5 additions & 5 deletions apps/api-extractor/src/schemas/api-extractor-defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@
},
"ae-forgotten-export": {
"logLevel": "warning",
"addToApiReviewFile": true
"addToApiReportFile": true
},
"ae-incompatible-release-tags": {
"logLevel": "warning",
"addToApiReviewFile": true
"addToApiReportFile": true
},
"ae-internal-missing-underscore": {
"logLevel": "warning",
"addToApiReviewFile": true
"addToApiReportFile": true
},
"ae-unresolved-inheritdoc-reference": {
"logLevel": "warning",
"addToApiReviewFile": true
"addToApiReportFile": true
},
"ae-unresolved-inheritdoc-base": {
"logLevel": "warning",
"addToApiReviewFile": true
"addToApiReportFile": true
}
},
"tsdocMessageReporting": {
Expand Down
16 changes: 8 additions & 8 deletions apps/api-extractor/src/schemas/api-extractor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
"default": {
/**
* Specifies whether the message should be written to the the tool's output log. Note that
* the "addToApiReviewFile" property may supersede this option.
* the "addToApiReportFile" property may supersede this option.
*
* Possible values: "error", "warning", "none"
*
Expand All @@ -239,18 +239,18 @@
// "logLevel": "warning",

/**
* When addToApiReviewFile is true: If API Extractor is configured to write an API report file (.api.md),
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
* then the message will be written inside that file; otherwise, the message is instead logged according to
* the "logLevel" option.
*
* DEFAULT VALUE: false
*/
// "addToApiReviewFile": false
// "addToApiReportFile": false
},

// "TS2551": {
// "logLevel": "warning",
// "addToApiReviewFile": true
// "addToApiReportFile": true
// },
//
// . . .
Expand All @@ -266,12 +266,12 @@
"extractorMessageReporting": {
"default": {
// "logLevel": "warning",
// "addToApiReviewFile": false
// "addToApiReportFile": false
},

// "ae-extra-release-tag": {
// "logLevel": "warning",
// "addToApiReviewFile": true
// "addToApiReportFile": true
// },
//
// . . .
Expand All @@ -287,12 +287,12 @@
"tsdocMessageReporting": {
"default": {
// "logLevel": "warning",
// "addToApiReviewFile": false
// "addToApiReportFile": false
}

// "tsdoc-link-tag-unescaped-text": {
// "logLevel": "warning",
// "addToApiReviewFile": true
// "addToApiReportFile": true
// },
//
// . . .
Expand Down
4 changes: 2 additions & 2 deletions apps/api-extractor/src/schemas/api-extractor.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@
"properties": {
"logLevel": {
"type": "string",
"description": "Specifies whether the message should be written to the the tool's output log. Note that the \"addToApiReviewFile\" property may supersede this option.",
"description": "Specifies whether the message should be written to the the tool's output log. Note that the \"addToApiReportFile\" property may supersede this option.",
"enum": [ "error", "warning", "none" ]
},
"addToApiReviewFile": {
"addToApiReportFile": {
"type": "boolean",
"description": "If API Extractor is configured to write an API review file (.api.md), then the message will be written inside that file. If the API review file is NOT being written, then the message is instead logged according to the \"logLevel\" option."
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Review File for "api-documenter-test"
## API Report File for "api-documenter-test"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Review File for "api-extractor-lib1-test"
## API Report File for "api-extractor-lib1-test"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Review File for "api-extractor-lib2-test"
## API Report File for "api-extractor-lib2-test"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Review File for "api-extractor-lib3-test"
## API Report File for "api-extractor-lib3-test"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Review File for "api-extractor-scenarios"
## API Report File for "api-extractor-scenarios"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Review File for "api-extractor-scenarios"
## API Report File for "api-extractor-scenarios"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

Expand Down
Loading