Brightspace / d2l-license-checker

Simple tool to continuously check for D2L accepted licenses of all npm dependencies in a project.
4 stars 2 forks source link

Handle missing version when multiple range keys exist #75

Closed hekard2l closed 6 years ago

hekard2l commented 6 years ago

Ranges map may contain * as an override, but the existing range is still being checked. In the case that a package contains no version, the @* override should result in no version being made.

zommerfelds commented 6 years ago

It's been a while since working on this, so can you give me some context? I.e. what actual example fails that you fixed now? Do we need to update documentation?

zommerfelds commented 6 years ago

Regarding documentation: maybe it's not something you introduced, but it would be nice to put an example in the README about how to use multiple ranges.

hekard2l commented 6 years ago

Existing behaviour:

λ  node .\node_modules\@d2l\license-checker-ci\bin\license-checker-ci . .\.licensechecker.bower.json
ERROR: Uncaught exception. Details:
       {}

After "fix":

λ  node .\node_modules\@d2l\license-checker-ci\bin\license-checker-ci . .\.licensechecker.bower.json
Warning: TypeError: Invalid Version: undefined
    at new SemVer (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\node_modules\semver\semver.js:293:11)
    at Range.test (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\node_modules\semver\semver.js:1036:15)
    at Function.satisfies (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\node_modules\semver\semver.js:1085:16)
    at OverrideHelper.find (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\lib\override-helper.js:58:34)
    at _.forEach (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\bin\license-checker-ci:108:34)
    at C:\rakeh\code\manager-view-fra\node_modules\lodash\lodash.js:4944:15
    at baseForOwn (C:\rakeh\code\manager-view-fra\node_modules\lodash\lodash.js:3001:24)
    at C:\rakeh\code\manager-view-fra\node_modules\lodash\lodash.js:4913:18
    at Function.forEach (C:\rakeh\code\manager-view-fra\node_modules\lodash\lodash.js:9359:14)
    at processLicenseCheckerOutput (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\bin\license-checker-ci:106:4)
    at licenseChecker.(anonymous function).catch.then.json (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\bin\license-checker-ci:164:17)
    at tryCatcher (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (C:\rakeh\code\manager-view-fra\node_modules\@d2l\license-checker-ci\node_modules\bluebird\js\release\promise.js:693:18) { name: 'neon-animation',
  version: 'undefined',
  ranges:
   Map {
     '<2.0.0' => { name: 'neon-animation',
     version: '<2',
     key: 'neon-animation@<2',
     license: 'BSD-3-Clause' },
     '*' => { name: 'neon-animation',
     version: '*',
     key: 'neon-animation@*',
     license: 'BSD-3-Clause' } } }
WARNING: Manual override "iron-selector@*" is never used, consider removing it.

All licenses passed the check.
zommerfelds commented 6 years ago

How do you trigger this error though? With something like "some-package@*": "MIT"? Also, that warning looks really verbose, do we want that?

hekard2l commented 6 years ago

I'm not using multiple ranges as a user. For some reason there are multiple ranges being listed, even though there's an override.

I'd have assumed:

  ranges:
   Map {
     '<2.0.0' => { name: 'neon-animation',
     version: '<2',
     key: 'neon-animation@<2',
     license: 'BSD-3-Clause' },
     '*' => { name: 'neon-animation',
     version: '*',
     key: 'neon-animation@*',
     license: 'BSD-3-Clause' } } }

Would be

  ranges:
   Map {
     '*' => { name: 'neon-animation',
     version: '*',
     key: 'neon-animation@*',
     license: 'BSD-3-Clause' } } }
hekard2l commented 6 years ago

Trigger the error by including neon-animation which doesn't have its version number properly defined.

Fix the error by adding the override (and using this PR)

"neon-animation@*": "BSD-3-Clause",

The warning is pretty verbose. I was hoping to add --verbose to the tool in the future, but not sure yet