Repository navigation
[api-extractor] Add a "--diagnostics" command-line option - #1359
Conversation
…geFolderPath" to be undefined (e.g. if there isn't one)
…stics" command-line option that we will use to print diagnostic output; Refactor MessageRouter to get initialized in Extractor.ts instead of Collector.ts
| return outputObject; | ||
| } | ||
|
|
||
| return undefined; |
There was a problem hiding this comment.
Do you want to return something more useful if the parameter is a function. Maybe <function>?
There was a problem hiding this comment.
Not really. The idea is that this function crawls through an object and picks out the printable stuff, ignoring any other members.
Ideally I would have just used JSON.serialize(); however, we need to dump the object returned by TypeScript's ts.program.getCompilerOptions(). I was paranoid that future compiler releases might add some methods to that object.
| * or `undefined` if the input cannot be represented as JSON | ||
| */ | ||
| // tslint:disable-next-line:no-any | ||
| public static buildJsonDumpObject(input: any): any | undefined { |
There was a problem hiding this comment.
It'd be useful to have some unit tests for this.
There was a problem hiding this comment.
I considered promoting this to a real utility in node-core-library, in which case I definitely would have added tests.
However, the concept of buildJsonDumpObject() seems lazy and half-baked. A "correct" implementation would use JSON.serialize() for actual data objects, or for other objects we should implement a proper printer/serializer (that knows all the members and how to format them). In my example output, you can see that dumped options aren't very readable (e.g. "target": 2).
I took the lazy approach because I didn't want to spend too much time on this --diagnostics feature initially. I know that we need some way to investigate API Extractor issues without resorting to a debugger. But this PR is merely a guess about what logging is actually useful.
This PR adds a new command-line option
--diagnosticsand corresponding APIIExtractorInvokeOptions.showDiagnosticsto help when troubleshooting problems with API Extractor.In the initial implementation,
--diagnosticsadds the following information:ExtractorConfigproperties--verboseloggingThe diagnostic information is printed to the
ExtractorMessageCategory.Consolestream as delimited blocks with aDIAGNOSTIC:header.Below is an sample output when invoking API Extractor on the
api-extractor-test-01test project: