cleanup: remove dead code, unreferenced barrels, and unused/unlisted deps - #209
Open
5PK wants to merge 2 commits into
Open
cleanup: remove dead code, unreferenced barrels, and unused/unlisted deps#2095PK wants to merge 2 commits into
5PK wants to merge 2 commits into
Conversation
PROD-2431/2435/2442 fixed ContentFieldMapper's remap of a linked-content field's companion column (LinkeContentDropdownValueField/SortIDFieldName), but two sibling utilities that scan the same content-item field data for different purposes were never updated to match — both still assumed a reference is only ever shaped as a contentid/contentID/sortids object key, with no knowledge of an arbitrarily-named companion field. 1. has-unresolved-content-references.ts (the PROD-2309 pre-push guard): collectUnresolvedContentReferences() now takes the source model and also checks each Content field's companion column. Previously an unresolved reference living only in a companion field shipped to the target undetected — the field mapper leaves it as the SOURCE id and only warns (not errors), which content-batch-processor.ts doesn't log or block on — reproducing the exact opaque server NullReferenceException PROD-2309 was built to prevent. 2. collect-content-id-references.ts (push-order dependency detection): collectContentIDReferences() now takes the source model too, so an item referenced only through a companion field is recognized as a dependency and promoted to push first (get-content-item-types.ts resolves each item's own source model via modelMapper to supply it). Extracted the companion-field-pair lookup (previously private inside ContentFieldMapper) into a shared src/lib/content/linked-content-companion-fields.ts (getLinkedContentCompanionFields/findFieldKey), used by all three now instead of duplicating the logic a third time. Added regression tests for both utilities (arbitrarily-named companion, SortIDFieldName companion, case-insensitive match, sentinel/no-model back-compat) plus a get-content-item-types push-order test proving an item referenced only via a companion field gets promoted to linked. Full suite: 105 suites / 1924 tests passing. npm run build compiles clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…deps
Audit (knip + manual grep verification) for exports/files with zero
consumers outside their own tests. Holding a fourth category (~74 unused
exports cascading through still-live barrel index.ts re-exports, e.g.
lib/shared/index.ts, lib/workflows/index.ts) for a separate pass — riskier
to trim piecemeal than deleting standalone dead files.
Dead files/classes removed (each confirmed to have no importer besides its
own test file):
- ContentClassifier (content-classifier.ts) — superseded by
getContentItemTypes, never wired into the live push flow
- LinkTypeDetector (link-type-detector.ts) — never imported anywhere
- areContentDependenciesResolved (are-content-dependencies-resolved.ts) and
its sole dependency hasUnresolvedContentReferences (the boolean variant
in has-unresolved-content-references.ts) — collectUnresolvedContentReferences,
which IS used, is untouched
- core.content class (core/content.ts) — updateContentItems()'s container
lookup guesses a cache path via a camelize() transform that doesn't match
how any downloader actually stores containers (by contentViewID); not
called anywhere in the CLI
- types/comparisonResult.ts — an empty {[key:string]:any} interface;
types/index.ts already had a comment noting it exports nothing
Unreferenced barrel index.ts files removed (zero internal importers, and
per .npmignore only dist/index.js ships — not src/ — so they can't be
reaching external library consumers either, unlike core/index.ts which
src/index.ts genuinely imports from):
- lib/downloaders/index.ts, lib/getters/filesystem/index.ts,
lib/pushers/index.ts (which also had a literal duplicate
content-pusher re-export line), lib/ui/console/index.ts,
lib/ui/progress/index.ts
Removed the now-dangling re-export lines for deleted files from
lib/content/index.ts, lib/shared/index.ts, and core/index.ts.
package.json: dropped 10 unused runtime deps + 1 unused devDependency
(each verified via grep to have no real import — a couple of knip's
matches were coincidental substring hits, e.g. "ora" inside "restore";
one has an explicit "Remove blessed case - no longer supported" comment
already in the code). Added 4 deps that were imported but never declared
(proper-lockfile, dotenv, lodash, axios) — previously working only via
some other package's transitive install. package-lock.json/yarn.lock
regenerated to match.
Full suite: 101 suites / 1834 tests passing (down from 105/1924, matching
the removed dead tests). npm run build compiles clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dead-code cleanup, audited with
knip(unused files/exports/dependencies) plus manual grep verification for anything only referenced by its own test file (knip's default settings don't catch that). Holding a fourth category — ~74 unused exports that cascade through still-live barrelindex.tsre-exports (e.g.lib/shared/index.ts,lib/workflows/index.ts) — for a separate pass, since trimming individual exports out of a barrel that's genuinely imported elsewhere is a different, higher-touch kind of change than deleting a standalone dead file.Dead files/classes removed
Each confirmed via grep to have zero importers besides its own test file:
ContentClassifier(content-classifier.ts) — superseded bygetContentItemTypes, never wired into the live push flowLinkTypeDetector(link-type-detector.ts) — never imported anywhereareContentDependenciesResolved(are-content-dependencies-resolved.ts) and its sole dependency, the booleanhasUnresolvedContentReferencesinhas-unresolved-content-references.ts—collectUnresolvedContentReferences, which is used (by the PROD-2309 guard), is untouchedcore.contentclass (core/content.ts) — its only method,updateContentItems(), guesses a container's cache path via acamelize()transform that doesn't match how any downloader actually stores containers (bycontentViewID); not called anywhere in the CLItypes/comparisonResult.ts— an empty{[key:string]:any}interface;types/index.tsalready had a comment noting it exports nothingUnreferenced barrel
index.tsfiles removedZero internal importers, and per
.npmignoreonlydist/index.jsships (notsrc/), so these can't be reaching external library consumers either — unlikecore/index.ts, whichsrc/index.tsgenuinely imports from:lib/downloaders/index.ts,lib/getters/filesystem/index.ts,lib/pushers/index.ts(which also had a literal duplicatecontent-pusherre-export line),lib/ui/console/index.ts,lib/ui/progress/index.tsRemoved the now-dangling re-export lines for the deleted files from
lib/content/index.ts,lib/shared/index.ts, andcore/index.ts.package.json
import/require(a couple of knip's matches were coincidental substring hits — e.g."ora"inside"restore"; one dependency,blessed, has an explicit// Remove blessed case - no longer supportedcomment already in the code).proper-lockfile,dotenv,lodash,axios— previously working only because some other package's transitive install happened to provide them.package-lock.json/yarn.lockregenerated to match.Testing
npm test— 101 suites / 1834 tests passing (down from 105/1924, matching the removed dead tests — no other regressions).npm run build— compiles clean.knipafter the cleanup: the "Unused files" / "Unused dependencies" / "Unlisted dependencies" / "Unused devDependencies" sections are all now empty; only the held-back "Unused exports" (Tier 4) category remains.🤖 Generated with Claude Code