Skip to content

Feat: Fix more PNPM Workspace Issues and Add Tests - #11

Merged
JosephMaynard merged 10 commits into
masterfrom
feat/fix-workspace-issues-and-add-tests
Feb 18, 2026
Merged

JosephMaynard merged 10 commits into
masterfrom
feat/fix-workspace-issues-and-add-tests

Conversation

@JosephMaynard

@JosephMaynard JosephMaynard commented Feb 18, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • PNPM-aware scanning: reports only on-disk (installed) packages and improves workspace detection.
    • Local node_modules crawling to collect package metadata and license artifacts.
    • Dynamic call-to-action URLs and refreshed report UI/layout/assets.
  • Documentation

    • Expanded README with PNPM workflow, node_modules crawling details, workspace hardening notes, and updated output sequencing.
  • Tests

    • Added unit and fixture integration tests, fixture orchestration scripts, and Vitest-based test commands.

@coderabbitai

coderabbitai Bot commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Adds PNPM-aware install-state checks and local node_modules crawling, centralizes fixture orchestration and Vitest-based tests, introduces unit tests for aggregation/license/npmLs/utils, updates report UI and dynamic CTA handling, and expands README with PNPM workspace crawling and hardening details.

Changes

Cohort / File(s) Summary
Docs
README.md
Expanded PNPM workflow: installed-only filtering, node_modules crawling, PNPM virtual-store-aware package.json resolution, license discovery variants, workspace hardening, and reordered output steps.
Test config & tooling
package.json, vitest.config.ts, tsconfig.json
Replaced many fixture scripts with Vitest-driven scripts, added vitest devDependency, and excluded src/**/*.test.ts from TS program.
Unit tests
src/aggregator.test.ts, src/license.test.ts, src/runners/npmLs.test.ts, src/utils.test.ts
Added tests for workspace-origin merging, SPDX/license inference & risk mapping, PNPM/npm normalization and install-state behavior, and utility functions (JSONL parsing, license resolution, package.json resolution).
PNPM install-state & normalization
src/runners/npmLs.ts, src/utils.ts
Introduced PnpmInstallState, createPnpmInstallState, isPnpmPackageInstalled, package-directory/version checks, safe FS helpers, and extractPnpmStoreEntryPrefix; normalization functions now accept/use installState to filter PNPM trees.
Report UI & CTA
report-ui/index.html, report-ui/main.ts, src/report.ts, report-ui/style.css
Reworked index.html structure and SVG/favicon, added CTA builder integration (buildCtaUrl), updated GitHub link UI, and adjusted CTA/layout styles.
Fixture orchestration & scripts
test-fixtures/package.json, test-fixtures/scripts/run-suite.js, test-fixtures/scripts/clean.js, test-fixtures/scripts/assert-suite.js
Centralized fixture suite with install/scan/assert flows, cleanup helpers, and assertions validating PNPM installed-only behavior, license resolution, execution signals, and registry behaviors.
Fixtures added/removed/edited
test-fixtures/pnpm-*, test-fixtures/npm-registry-signals/*, test-fixtures/* (removed: npm-basic, npm-heavy, optional-deps, yarn-berry-workspace)
Added PNPM-targeted fixtures (installed-only, license-resolution), registry-signals fixture; removed several legacy fixture manifests and console side-effects; updated .gitignore entries for fixture outputs.
New CTA helper
src/cta.ts
Added CTA_BASE_URL constant and `buildCtaUrl(version: string
Misc
various .gitignore, test-fixtures/*
Ignore generated outputs (node_modules/, .dependency-radar/, dependency-radar.json); small fixture file edits and removals.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as "CLI (dist/cli.js)"
  participant Runner as "npmLs runner"
  participant FS as "Filesystem (node_modules, .pnpm)"
  participant Store as "PNPM virtual store"
  participant Aggregator as "Aggregator / Normalizer"

  CLI->>Runner: run scan --project /path --json
  Runner->>FS: createPnpmInstallState(projectPath)
  FS->>Store: read .pnpm virtual store entries & node_modules roots
  Store-->>FS: store index & roots
  FS-->>Runner: installState (store index, roots, caches)
  Runner->>Runner: isPnpmPackageInstalled(name, version, installState)
  alt package installed via virtual store
    Runner->>Store: lookup store entry
  else package linked / workspace
    Runner->>FS: check node_modules/workspace links
  end
  Runner->>Aggregator: normalized dependency nodes (installed-only filter applied)
  Aggregator->>FS: read local package.json & license artifacts
  Aggregator-->>CLI: write dependency-radar.json / dependency-radar.html
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through node_modules with care,

PNPM stores and links laid bare,
Tests hum softly, fixtures run,
Vitest cheers as checks are done,
A carrot-coded report to share 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.33% 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 clearly describes the main changes: fixing PNPM workspace issues and adding comprehensive test coverage across multiple modules.

✏️ 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 feat/fix-workspace-issues-and-add-tests

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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/aggregator.test.ts`:
- Around line 31-37: The test is passing an unrecognized field packageJson to
aggregateData so the override is ignored; change the call to pass the correct
property name projectPackageJson (or use pkgOverride if you only mean to
override dependencies) so AggregateInput receives the intended override. Update
the aggregateData invocation in the test to replace packageJson with
projectPackageJson (or use pkgOverride for dependency-only overrides) so the
test uses the provided metadata instead of the on-disk package.json.

In `@src/runners/npmLs.test.ts`:
- Around line 36-57: The helper buildPnpmTreePayload currently relies on type
inference; add an explicit TypeScript return type for buildPnpmTreePayload
(e.g., a small typed payload/interface or a precise inline type describing the
outer array and nested dependencies objects) and update its signature to include
that return type and keep 2-space indentation, single quotes and semicolons;
ensure the declared type covers the nested dependency shape (name, version,
optional dependencies) so the test compiles under strict mode.

In `@test-fixtures/scripts/assert-suite.js`:
- Around line 148-153: The predicate in hasOutdated uses an invalid status check
(status === 'outdated') against targetDeps' outdatedStatus; update the condition
to treat documented update statuses as outdated by checking that status is one
of 'patch', 'minor' or 'major' (e.g.,
['patch','minor','major'].includes(status)) so that entries with no
latestVersion but with an update status are correctly flagged; modify the logic
in the hasOutdated computation (the arrow function that inspects
entry.package.version, entry.upgrade.latestVersion, and
entry.upgrade.outdatedStatus) to use that status membership check.

Comment thread src/aggregator.test.ts Outdated
Comment thread src/runners/npmLs.test.ts Outdated
Comment thread test-fixtures/scripts/assert-suite.js

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

🧹 Nitpick comments (1)
test-fixtures/scripts/assert-suite.js (1)

23-40: Consider guarding JSON parse errors to preserve aggregated failures.

A malformed report will currently throw and bypass the consolidated failure summary. Capturing parse failures keeps the suite behavior consistent with other assertions.

Suggested change
 function loadReport(fixtureName) {
   const reportPath = path.join(fixturesRoot, fixtureName, 'dependency-radar.json');
   if (!fs.existsSync(reportPath)) {
     failures.push(`[${fixtureName}] missing report: ${reportPath}`);
     return null;
   }
-  return JSON.parse(fs.readFileSync(reportPath, 'utf8'));
+  try {
+    return JSON.parse(fs.readFileSync(reportPath, 'utf8'));
+  } catch (error) {
+    failures.push(`[${fixtureName}] failed to parse report: ${reportPath} (${error.message})`);
+    return null;
+  }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test-fixtures/scripts/assert-suite.js` around lines 23 - 40, The loadReport
function can throw if JSON.parse fails, which aborts the test run; wrap the file
read/parse in a try/catch so malformed JSON doesn't throw but instead pushes a
descriptive failure into the failures array (include fixtureName and the parse
error message) and return null; update loadReport to catch errors from
JSON.parse (and fs.readFileSync) and push e.g. `[${fixtureName}] invalid report:
${error.message}` to failures to preserve aggregated failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test-fixtures/scripts/assert-suite.js`:
- Around line 23-40: The loadReport function can throw if JSON.parse fails,
which aborts the test run; wrap the file read/parse in a try/catch so malformed
JSON doesn't throw but instead pushes a descriptive failure into the failures
array (include fixtureName and the parse error message) and return null; update
loadReport to catch errors from JSON.parse (and fs.readFileSync) and push e.g.
`[${fixtureName}] invalid report: ${error.message}` to failures to preserve
aggregated failures.

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

🧹 Nitpick comments (1)
src/report.ts (1)

6-6: CTA URL constant and builder are duplicated across files.

CTA_BASE_URL is defined identically in both src/report.ts (line 6) and report-ui/main.ts (line 15). The URL construction logic is also duplicated in report-ui/main.ts (lines 1582-1584).

Consider extracting this constant and the URL building logic into a shared module to maintain a single source of truth.

Also applies to: 14-19

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/report.ts` at line 6, Extract the duplicated CTA_BASE_URL constant and
the URL-construction logic into a new shared module (e.g., export const
CTA_BASE_URL and export function buildCtaUrl(...)) and replace the duplicated
declarations in src/report.ts and report-ui/main.ts by importing those exports;
update references to CTA_BASE_URL and the inline builder in both places to use
the shared buildCtaUrl function so there is a single source of truth for the CTA
URL logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/report.ts`:
- Line 6: Extract the duplicated CTA_BASE_URL constant and the URL-construction
logic into a new shared module (e.g., export const CTA_BASE_URL and export
function buildCtaUrl(...)) and replace the duplicated declarations in
src/report.ts and report-ui/main.ts by importing those exports; update
references to CTA_BASE_URL and the inline builder in both places to use the
shared buildCtaUrl function so there is a single source of truth for the CTA URL
logic.

@JosephMaynard
JosephMaynard merged commit cacb10d into master Feb 18, 2026
1 check passed
@JosephMaynard
JosephMaynard deleted the feat/fix-workspace-issues-and-add-tests branch February 18, 2026 20:58
@JosephMaynard
JosephMaynard restored the feat/fix-workspace-issues-and-add-tests branch February 21, 2026 12:13
@JosephMaynard
JosephMaynard deleted the feat/fix-workspace-issues-and-add-tests branch February 21, 2026 12:14
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