Skip to content

Conversation

dreyfus92
Copy link
Contributor

@dreyfus92 dreyfus92 commented Jul 24, 2025

Add knip as peer dependency plugin with feature flags

Implements #41 by integrating knip as an optional peer dependency that runs via npx.

Changes

  • Plugin Architecture: knip runs as part of the existing plugin system in analyze command
  • Feature Flags: New --features flag controls which analysis tools run:
    • --features unused - runs only knip
    • --features types,publish - runs attw + publint, skips knip
    • No flags = runs all available plugins
  • Peer Dependency: knip is not a hard dependency; runs automatically if installed locally/globally
  • Local FS Only: knip only runs on local directories, not tarball files

Usage

# Run all analysis (including knip if installed)
npm run cli analyze

# Run only knip analysis
npm run cli analyze --features <file-name>

# Run types + publish analysis (skip knip)
npm run cli analyze --features types,publish

Closes #41

Copy link

pkg-pr-new bot commented Jul 24, 2025

Open in StackBlitz

npm i https://pkg.pr.new/e18e/cli/@e18e/cli@45

commit: 6e30495

@dreyfus92 dreyfus92 marked this pull request as draft July 24, 2025 08:33
@dreyfus92 dreyfus92 marked this pull request as ready for review July 25, 2025 19:58
} else if (stat.isDirectory()) {
// If it's a directory, use it as the root for local file system
// Set pack to 'none' to use LocalFileSystem
pack = 'none';
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the purpose of this?

the pack type mirrors whats in publint so im surprised this works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the purpose of setting pack = 'none' when a directory is detected is to use LocalFileSystem instead of TarballFileSystem.
the current behavior:
No path provided → pack = 'auto' → packs directory → TarballFileSystem → publint ✅ works
Directory path provided → pack = 'none' → LocalFileSystem → publint ❌ skipped

The inconsistency is that directory paths bypass the packing process while everything else uses tarballs. This is why knip works with directories but publint/attw don't.

"Always pack, separate knip command" would mean:

  • Remove the pack = 'none' override for directories
  • Always pack directories (like the default behavior)
  • Add a separate command/flag for knip analysis that works with local filesystem

so let me know if we should refactor it.


async function which(cmd: string): Promise<string | null> {
return new Promise((resolve) => {
const proc = spawn('which', [cmd]);

Choose a reason for hiding this comment

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

I don't believe which will run on Windows. Is that a concern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hello @michaelfaith, nice catch, but i don't think it is a concern right now, since we are in early development 😁

Copy link
Contributor Author

@dreyfus92 dreyfus92 Aug 30, 2025

Choose a reason for hiding this comment

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

also we stumbled upon a big rabbit hole with this one that's why it has become stale.

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.

Consider running knip as a peer

3 participants