Skip to content

Fix/license issues - #8

Merged
JosephMaynard merged 6 commits into
masterfrom
fix/license-issues
Feb 4, 2026
Merged

JosephMaynard merged 6 commits into
masterfrom
fix/license-issues

Conversation

@JosephMaynard

@JosephMaynard JosephMaynard commented Feb 4, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Improved path-based license discovery for more accurate license resolution.
    • Added comprehensive test fixtures for npm, pnpm, and yarn workspace scenarios.
    • Enhanced CLI spinner output to shorten and better fit long messages/paths.
  • Chores

    • Removed large generated dependency-report artifacts from the repository.
    • Updated .gitignore to exclude dependency-radar outputs and common lockfile/noise patterns.
    • Added npm scripts to install and scan the new test fixtures.

@coderabbitai

coderabbitai Bot commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Deleted generated Dependency Radar artifacts, added test-fixtures and fixture-management npm scripts, updated .gitignore, and refactored license discovery to propagate package paths and read licenses from package directories during aggregation.

Changes

Cohort / File(s) Summary
Artifact Cleanup
\.dependency-radar/dependency-radar/*, too-much-data-collected.json
Removed many static Dependency Radar outputs: import graphs, npm/pnpm audit/ls/outdated snapshots, and the large collected dependency JSON.
VCS & Scripts
\.gitignore, package.json
Added ignores for dependency-radar artifacts and lockfiles; added per-fixture and composite npm scripts to install/scan various test-fixtures (npm/pnpm/yarn variants).
License Resolution & Path Propagation
src/utils.ts, src/aggregator.ts, src/runners/npmLs.ts
Added readLicenseFromPackageDir(packageDir) and refactored readLicenseFromPackageJson to delegate; introduced optional path on ResolvedNode/NodeInfo, preserved node.path through normalization, and added --long to npm ls args.
Test Fixtures — Workspace Variants
test-fixtures/*, test-fixtures/.../package.json
Added many fixtures covering: no-node-modules, npm-basic, npm-heavy, optional-deps, pnpm workspaces (including hoisted), yarn workspaces (classic & Berry); includes package.jsons, index.js stubs, workspace configs, and .npmrc.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(220,235,255,0.5)
  participant Runner as Runner (npmLs)
  participant Aggregator as Aggregator
  participant Utils as Utils (license reader)
  participant FS as Filesystem
  end

  Runner->>Aggregator: emit normalized ResolvedNode { name, version, path? }
  Aggregator->>Aggregator: buildNodeMap(node) (preserve node.path into NodeInfo)
  Aggregator->>Utils: readLicenseFromPackageDir(packageDir) if NodeInfo.path present
  Utils->>FS: read package.json & license files under packageDir
  FS-->>Utils: package metadata / license text
  Utils-->>Aggregator: license info (license, licenseFile, licenseText)
  Aggregator-->>Runner: aggregated NodeInfo with license and path
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 I hopped through folders, nudged the clutter free,

Fixtures sprouted where tests now roam with glee,
Paths lead to licenses, found beneath each tree,
Aggregator hums, runners sing in harmony,
A tidy burrow — code and data snug as can be!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix/license issues' directly relates to the main changes: adding path-based license discovery and improvements to license reading logic in src/aggregator.ts, src/utils.ts, and src/runners/npmLs.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/license-issues

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In `@package.json`:
- Around line 34-36: The composite npm scripts fixtures:install, fixtures:scan,
and fixtures:install:all currently omit the npm-heavy variants; update each
composite script to include the corresponding fixtures:install:npm-heavy and
fixtures:scan:npm-heavy entries so that fixtures:install runs
fixtures:install:npm-heavy, fixtures:scan runs fixtures:scan:npm-heavy, and
fixtures:install:all runs fixtures:install:npm-heavy (keeping the existing
ordering/AND chaining).

In `@test-fixtures/npm-basic/index.js`:
- Around line 1-2: The test fixture currently calls require('chalk') which fails
because Chalk v5+ is ESM-only; replace that import with one of the recommended
fixes: either downgrade Chalk to v4 in the fixture's package.json, or convert
the fixture to ESM by adding "type": "module" and changing the require to an ES
import, or (if you must keep CommonJS) replace the synchronous require('chalk')
call with a dynamic import (await import('chalk')).default before using chalk in
the console.log call so the chalk.green(...) invocation no longer throws
ERR_REQUIRE_ESM.

In `@test-fixtures/pnpm-workspace-hoisted/packages/pkg-a/index.js`:
- Line 1: The code uses require('nanoid').nanoid() which fails because nanoid v5
is ESM-only. To fix this in the module.exports assignment, replace the require
call with a dynamic import using async/await inside an async function or use
top-level await if supported. Alternatively, downgrade nanoid to version 3 for
CJS compatibility. Focus on updating the initialization of the id export in the
file to be compatible with ESM nanoid usage.

In `@test-fixtures/pnpm-workspace/packages/pkg-a/index.js`:
- Line 1: The current CommonJS export uses require('nanoid').nanoid(), which
fails with nanoid v5 (ESM-only); either pin nanoid to a CJS-compatible v3.x in
your dependencies and keep module.exports = { id: require('nanoid').nanoid() },
or change the module to use a dynamic import and export an async getter (e.g.,
replace the direct module.exports id with an async function that does const {
nanoid } = await import('nanoid'); return nanoid()) so the ESM package is loaded
correctly at runtime; locate the usage of module.exports and
require('nanoid').nanoid() to apply one of these fixes.

In `@test-fixtures/pnpm-workspace/packages/pkg-a/package.json`:
- Around line 1-9: The project currently depends on nanoid@^5.0.7 (ESM-only)
while pkg-a/index.js uses require('nanoid'); fix by changing the dependency in
package.json to a CommonJS-compatible release (e.g., "nanoid": "^3.0.0") and
reinstalling (pnpm install) so require('nanoid') in pkg-a/index.js works, or
alternatively update pkg-a/index.js to use dynamic import('nanoid')/async import
and adapt call sites if you prefer to keep nanoid@5.x.

Comment thread package.json Outdated
Comment thread test-fixtures/npm-basic/index.js
@@ -0,0 +1 @@
module.exports = { id: require('nanoid').nanoid() };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the hoisted fixture package.json for nanoid
find test-fixtures/pnpm-workspace-hoisted/packages/pkg-a -name "package.json" -exec grep -l "nanoid" {} \;

# Also check parent workspace package.json
find test-fixtures/pnpm-workspace-hoisted -maxdepth 2 -name "package.json" -exec sh -c 'echo "File: $1"; grep "nanoid" "$1" || echo "Not found"' _ {} \;

Repository: JosephMaynard/dependency-radar

Length of output: 204


🏁 Script executed:

cat test-fixtures/pnpm-workspace-hoisted/packages/pkg-a/package.json

Repository: JosephMaynard/dependency-radar

Length of output: 219


🌐 Web query:

nanoid v5 commonjs cjs support module type

💡 Result:

  • Nanoid v5 is published as ESM: its package.json sets "type": "module" and its exports don’t provide a CommonJS (require) entry—only an ESM/default entry (plus browser/react-native mappings). [2]
  • CommonJS (CJS) usage options with nanoid v5:
    • require('nanoid') works only on newer Node setups: Node 22.12+ (works out of the box) or Node 20 with --experimental-require-module. [1]
    • On Node 18, use dynamic import('nanoid') from CJS. [1]
  • If you need “traditional” CJS compatibility without those Node constraints, the project recommends using nanoid@3. [1]

Nanoid v5 is ESM-only; require() usage will fail on most Node versions.

The hoisted fixture declares nanoid@^5.0.7, which is published with "type": "module" and provides no CommonJS export. Using require('nanoid') will only work on Node 22.12+ or Node 20 with the --experimental-require-module flag. On Node 18 and earlier, this will fail at runtime. Either downgrade to nanoid@3 for traditional CJS support, or use dynamic import() with async handling.

🤖 Prompt for AI Agents
In `@test-fixtures/pnpm-workspace-hoisted/packages/pkg-a/index.js` at line 1, The
code uses require('nanoid').nanoid() which fails because nanoid v5 is ESM-only.
To fix this in the module.exports assignment, replace the require call with a
dynamic import using async/await inside an async function or use top-level await
if supported. Alternatively, downgrade nanoid to version 3 for CJS
compatibility. Focus on updating the initialization of the id export in the file
to be compatible with ESM nanoid usage.

Comment thread test-fixtures/pnpm-workspace/packages/pkg-a/index.js
Comment thread test-fixtures/pnpm-workspace/packages/pkg-a/package.json
@JosephMaynard
JosephMaynard merged commit 760a3e2 into master Feb 4, 2026
1 check passed
@JosephMaynard
JosephMaynard deleted the fix/license-issues branch February 4, 2026 20:34
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