license-checker-rseidelsohn icon indicating copy to clipboard operation
license-checker-rseidelsohn copied to clipboard

--customPath not working as expected

Open atheck opened this issue 1 year ago • 7 comments

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/[email protected]": {
        "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.

atheck avatar Nov 04 '23 19:11 atheck

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

Prishii avatar Nov 14 '23 15:11 Prishii

Hello @Prishii ,

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

RSeidelsohn avatar Nov 24 '23 13:11 RSeidelsohn

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!

RSeidelsohn avatar Dec 08 '23 12:12 RSeidelsohn

@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).

{
    "[email protected]": {
        "licenses": "UNLICENSED",
        "private": true,
        "copyright": "",
        "description": "",
        "email": "",
        "name": "lcr-bug",
        "publisher": "",
        "repository": "",
        "url": ""
    },
    "[email protected]": {
        "licenses": "BSD-3-Clause",
        "repository": "https://github.com/RSeidelsohn/license-checker-rseidelsohn",
        "publisher": "Roman Seidelsohn",
        "email": "[email protected]",
        "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": ""
    },
    "[email protected]": {
        "licenses": "MIT",
        "repository": "https://github.com/lodash/lodash",
        "publisher": "John-David Dalton",
        "email": "[email protected]",
        "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>
    "[email protected]": {
        "licenses": "BSD-3-Clause",
        "repository": "https://github.com/RSeidelsohn/license-checker-rseidelsohn",
        "publisher": "Roman Seidelsohn",
        "email": "[email protected]",
        "path": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\license-checker-rseidelsohn",
        "licenseFile": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\license-checker-rseidelsohn\\LICENSE"
    },
<skip>
    "[email protected]": {
        "licenses": "MIT",
        "repository": "https://github.com/lodash/lodash",
        "publisher": "John-David Dalton",
        "email": "[email protected]",
        "path": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\lodash",
        "licenseFile": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\lodash\\LICENSE"
    },
<skip>

vladlen-g avatar Jan 05 '24 12:01 vladlen-g

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.

mrfigg avatar Apr 18 '24 00:04 mrfigg

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.

vladlen-g avatar Jul 17 '24 10:07 vladlen-g

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

atheck avatar Jul 24 '24 18:07 atheck