Skip to content

Comments

Add depth and isDevDependency CSV columns / module info; recurse direct dependencies#139

Open
laurence-myers wants to merge 1 commit intoRSeidelsohn:masterfrom
laurence-myers:csv-columns-dev-dep-and-depth
Open

Add depth and isDevDependency CSV columns / module info; recurse direct dependencies#139
laurence-myers wants to merge 1 commit intoRSeidelsohn:masterfrom
laurence-myers:csv-columns-dev-dep-and-depth

Conversation

@laurence-myers
Copy link

@laurence-myers laurence-myers commented Jan 27, 2026

This adds the option to include the columns depth and isDevDependency when outputting CSV files. This allows you to easily filter the data later - e.g. you can produce a single file containing all dev dependencies, and dependencies from any depth, and then filter the data later to only show the direct dependencies (depth = 1) or Prod dependencies isDevDependency = false.

I found that the tool was iterating dependencies, which seems to be a flat array of all dependencies. I changed it to iterate _dependencies, which only includes the direct dependencies. This gives proper values of depth and isDevDependency based on whether the parent was a dev dependency. I haven't fully tested the consequences of this (the unit tests do not run in NodeJS v24, because it tries to load CommonJS modules as ECMAScript modules).

There might be a better name for these new columns.

I based this off tag v4.4.2, because master had an issue (the bin does not work because it tries to call the function parse(), but it was renamed to parseArgs()), so I didn't know what the current state of development was.

@laurence-myers laurence-myers marked this pull request as draft January 27, 2026 06:45
@laurence-myers
Copy link
Author

Needs some work; recursion doesn't work how I expected, so the depth and dev values are incorrect. I also need to add tests.

@laurence-myers laurence-myers force-pushed the csv-columns-dev-dep-and-depth branch from ac05e04 to ddab259 Compare January 27, 2026 06:59
@laurence-myers laurence-myers changed the title Add depth and isDevDependency CSV columns / module info Add depth and isDevDependency CSV columns / module info; recurse direct dependencies Jan 27, 2026
@laurence-myers
Copy link
Author

I was unable to run the unit tests, they do not run in NodeJS v24, because the unit tests are written as CommonJS modules, but NodeJS tries to load them as ECMAScript modules, due to the presence of "type": "module" in package.json.

As such, I have not added a unit test.

Fixing the existing unit test execution was out of scope for this PR.

@laurence-myers laurence-myers marked this pull request as ready for review January 27, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant