microsoft / types-publisher

This repo has moved:
https://github.com/microsoft/DefinitelyTyped-tools/tree/master/packages/publisher
MIT License
388 stars 151 forks source link

feat(definition-parser): include package name in error #788

Open peterblazejewicz opened 4 years ago

peterblazejewicz commented 4 years ago

This proposed change is intended to allow developers quickly figure out the real reason of getTypingInfo failing due to version mismatch. Current error message and related stack trace does not contain a clue about the package failing and with the context of DT repository and local development artifacts, this removes the problem with definition parser failing on the stale data from local repository (non tracked folders, etc).

Thanks!

peterblazejewicz commented 4 years ago

sample for the context, here is an output of the DT npm test failing with local dev artifacts from other package (not one under test), the package under test is 'abc':

npm test

> definitely-typed@0.0.3 test /Users/piotrblazejewicz/git/DefinitelyTyped
> node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed

Clean data
Clean logs
Clean output
Using local Definitely Typed at /Users/piotrblazejewicz/git/DefinitelyTyped.
Parsing definitions...
Found 6791 packages.
Parsing in parallel...
Error: The latest version is 2.2, so the subdirectory 'v2' is not allowed; since it applies to any 2.* version, up to and including 2.2.
    at /Users/piotrblazejewicz/git/DefinitelyTyped/node_modules/types-publisher/bin/lib/definition-parser.js:31:19
    at Array.map (<anonymous>)
    at Object.getTypingInfo (/Users/piotrblazejewicz/git/DefinitelyTyped/node_modules/types-publisher/bin/lib/definition-parser.js:28:43)
    at /Users/piotrblazejewicz/git/DefinitelyTyped/node_modules/types-publisher/bin/lib/definition-parser-worker.js:17:50
    at Object.logUncaughtErrors (/Users/piotrblazejewicz/git/DefinitelyTyped/node_modules/types-publisher/bin/util/util.js:78:38)
    at process.<anonymous> (/Users/piotrblazejewicz/git/DefinitelyTyped/node_modules/types-publisher/bin/lib/definition-parser-worker.js:15:16)
    at process.emit (events.js:210:5)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
Error: Parsing failed.
    at fail (/Users/piotrblazejewicz/git/DefinitelyTyped/node_modules/types-publisher/bin/util/util.js:272:20)
    at ChildProcess.<anonymous> (/Users/piotrblazejewicz/git/DefinitelyTyped/node_modules/types-publisher/bin/util/util.js:261:21)
    at ChildProcess.emit (events.js:210:5)
    at finish (internal/child_process.js:861:14)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)
npm ERR! Test failed.  See above for more details.

the stack trace has no notion of the package being parsed. Only after the change, one could see that other package (not one under test), was the culprit:

...
Parsing in parallel...
Error: The latest version of the 'terser-webpack-plugin' package is 2.2, so the subdirectory 'v2' is not allowed; since it applies to any 2.* version, up to and including 2.2.
    at /Users/piotrblazejewicz/git/DefinitelyTyped/node_modules/types-publisher/bin/lib/definition-parser.js:31:19
    at Array.map (<anonymous>)
...

after seeing correct report I could issue:

git clean -fxd

to clean local artifacts, install dependencies and run tests again.