RSeidelsohn / license-checker-rseidelsohn

Extract NPM package licenses. Enhanced and updated fork of Dav Glass' original (but abandoned) license-checker.
https://www.npmjs.com/package/license-checker-rseidelsohn
Other
136 stars 35 forks source link

--customPath not working as expected #103

Open atheck opened 12 months ago

atheck commented 12 months ago

Hi, first of all thank you for your work!

Since version 4.2.10 I see an issue when using the --customPath option with a json file.

My format.json file looks like this:

{
    "name": "",
    "version": "",
    "description": "",
    "licenses": "",
    "licenseText": ""
}

But the output looks like this:

{
    "@babel/core@7.23.2": {
        "licenses": "MIT",
        "repository": "https://github.com/babel/babel",
        "publisher": "The Babel Team",
        "path": ".../node_modules/@babel/core",
        "licenseFile": ".../node_modules/@babel/core/LICENSE"
    },
}

It is missing the required fields for name, version, description, ...

With version 4.2.9 it works as expected.

Prishii commented 11 months ago

license-checker-rseidelsohn --direct --customPath apps/proj-mobile/src/assets/config/customExample.json --json > apps/proj-mobile/src/assets/licenses/licenses.json

Tried above it is not working with 4.2.9 and 4.2.10 either

RSeidelsohn commented 11 months ago

Hello @Prishii ,

thanks for your report. Actually, I am not able to reproduce your issue. Do you run it under Windows?

RSeidelsohn commented 11 months ago

Hello @atheck , I appreciate your bug report, but I can't reproduce it. Are you running it under Windows? Any more details would be great. Thanks a lot!

vladlen-g commented 10 months ago

@RSeidelsohn I'm experiencing the same issue which forced me to go back to 4.2.9 which works fine for me. I was able to reproduce it both on Linux and Windows. I've created a test app to illustrate the problem, here's my setup.

package.json

{
  "name": "lcr-bug",
  "version": "0.0.0",
  "scripts": {
    "generate-packages-metadata": "npx --no-install license-checker-rseidelsohn --json --out packages_metadata.json --direct --customPath packages_metadata_format.json"
  },
  "private": true,
  "dependencies": {
    "lodash": "4"
  },
  "devDependencies": {
    "license-checker-rseidelsohn": "4.2.9"
  }
}

packages_metadata_format.json

{
  "copyright": "",
  "description": "",
  "email": "",
  "licenses": "",
  "name": "",
  "publisher": "",
  "repository": "",
  "url": "",

  "licenseFile": false,
  "licenseModified": false,
  "licenseText": false,
  "noticeFile": false,
  "path": false,
  "private": false,
  "version": false
}

packages_metadata.json with 4.2.9 (output is following the format from --customPath as expected).

{
    "lcr-bug@0.0.0": {
        "licenses": "UNLICENSED",
        "private": true,
        "copyright": "",
        "description": "",
        "email": "",
        "name": "lcr-bug",
        "publisher": "",
        "repository": "",
        "url": ""
    },
    "license-checker-rseidelsohn@4.2.9": {
        "licenses": "BSD-3-Clause",
        "repository": "https://github.com/RSeidelsohn/license-checker-rseidelsohn",
        "publisher": "Roman Seidelsohn",
        "email": "rseidelsohn@gmail.com",
        "copyright": "Copyright 2012 Yahoo Inc.",
        "description": "Extract NPM package licenses - Feature enhanced version of the original license-checker v25.0.1",
        "name": "license-checker-rseidelsohn",
        "url": ""
    },
    "lodash@4.17.21": {
        "licenses": "MIT",
        "repository": "https://github.com/lodash/lodash",
        "publisher": "John-David Dalton",
        "email": "john.david.dalton@gmail.com",
        "copyright": "Copyright OpenJS Foundation and other contributors <https://openjsf.org/>",
        "description": "Lodash modular utilities.",
        "name": "lodash",
        "url": ""
    }
}

packages_metadata.json with 4.2.10 (output is obviously using the default format, --customPath flag doesn't seem to be working, also --direct seems to be ignored as well).

<skip>
    "license-checker-rseidelsohn@4.2.10": {
        "licenses": "BSD-3-Clause",
        "repository": "https://github.com/RSeidelsohn/license-checker-rseidelsohn",
        "publisher": "Roman Seidelsohn",
        "email": "rseidelsohn@gmail.com",
        "path": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\license-checker-rseidelsohn",
        "licenseFile": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\license-checker-rseidelsohn\\LICENSE"
    },
<skip>
    "lodash@4.17.21": {
        "licenses": "MIT",
        "repository": "https://github.com/lodash/lodash",
        "publisher": "John-David Dalton",
        "email": "john.david.dalton@gmail.com",
        "path": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\lodash",
        "licenseFile": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\lodash\\LICENSE"
    },
<skip>
mrfigg commented 6 months ago

Just found this out myself, if you are requiring this package instead of using it from the command line make sure to use customPath: "path/to/customFormat.json" or customFormat: { /* custom format object */ }.

@RSeidelsohn The customFormat option isn't included in the options list in the readme, it's only mentioned in the clarificationsFile option entry.

vladlen-g commented 3 months ago

OK, I take it back, I wasn't paying attention. In my case the issue was caused by passing '--direct' without a value which messed up subsequent '--customPath packages_metadata_format.json'. As soon as I replaced '--direct' with '--depth 0' the issue went away and now '--customPath packages_metadata_format.json' works as expected. Using '--direct' without a value was working up until 4.2.10 came along with some changes aimed to make the 'direct' flag less confusing.

atheck commented 3 months ago

OK, I take it back, I wasn't paying attention. In my case the issue was caused by passing '--direct' without a value which messed up subsequent '--customPath packages_metadata_format.json'. As soon as I replaced '--direct' with '--depth 0' the issue went away and now '--customPath packages_metadata_format.json' works as expected. Using '--direct' without a value was working up until 4.2.10 came along with some changes aimed to make the 'direct' flag less confusing.

Oh I see, now it's working again as expected. Thank you @vladlen-g and @RSeidelsohn