npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@barney-media/crap-typescript

v0.4.1

Published

CLI for CRAP metric analysis in TypeScript projects.

Readme

@barney-media/crap-typescript

CLI for CRAP (Change Risk Anti-Pattern) metric analysis in TypeScript projects.

Install

npm install --save-dev @barney-media/crap-typescript

Usage

npx crap-typescript
npx crap-typescript --changed
npx crap-typescript --format json --output reports/crap.json
npx crap-typescript --agent --junit-report reports/crap-junit.xml
npx crap-typescript --threshold 6
npx crap-typescript --exclude 'packages/api/generated/**'
npx crap-typescript --exclude-path-regex '^src/proto/'
npx crap-typescript --exclude-generated-marker '@custom-generated'
npx crap-typescript src/sample.ts
npx crap-typescript packages/api packages/web

Options

--help                       Print usage to stdout
(no args)                    Analyze all TypeScript files under any nested src/ tree
--changed                    Analyze changed TypeScript files under src/
--exclude <glob>             Exclude source paths by normalized relative glob; repeatable
--exclude-path-regex <regex> Exclude source paths by normalized relative regex; repeatable
--exclude-generated-marker <marker> Exclude leading generated-header markers; repeatable
--use-default-exclusions[=true|false] Enable generated-code defaults (`true` by default)
--package-manager <tool>     Force auto, npm, pnpm, yarn, or bun
--test-runner <runner>       Force auto, vitest, or jest
--format <format>            Emit toon, json, text, junit, or none (default: toon)
--agent                      Default primary output to toon, failures-only, omit-redundancy
--failures-only[=true|false] Emit failed methods only in the primary report
--omit-redundancy[=true|false] Omit redundant per-method status in the primary report
--output <path>              Write the primary report to a file instead of stdout
--junit-report <path>        Also write a full JUnit XML report for CI test-report UIs
--threshold <number>         Override the CRAP threshold (`8.0` by default)
<file ...>                   Analyze explicit TypeScript files
<directory ...>              Analyze TypeScript files under each directory's nested src/ tree

The default toon format is compact and agent-readable. Primary reports include run-level status and threshold; method rows use status, crap, cc, cov, covKind, method, src, lineStart, and lineEnd, with src set to the project-relative source file path. --format none suppresses primary stdout output; when used with --output, it creates an empty primary report file. --failures-only, --failures-only=true, and --failures-only=false control whether the primary report includes only failed method entries. --omit-redundancy, --omit-redundancy=true, and --omit-redundancy=false control whether primary report method rows omit status; with --format junit, they omit the custom testcase status property while preserving JUnit failure and skipped elements. JUnit sidecar reports always include the full method set and method status, regardless of --agent, --failures-only, or --omit-redundancy. JUnit XML is shaped for GitLab's Tests tab with a <testsuites> wrapper, testcase classname/file source paths, method:lineStart testcase names, time="0", and failure/skipped text containing CRAP score, threshold, coverage kind, source path, and line range. --agent is a composite shortcut, not a format: it defaults primary output to --format toon, --failures-only=true, and --omit-redundancy=true. Explicit --format, --failures-only=false, or --omit-redundancy=false options override those defaults.

Baseline analyzability exclusions always skip declarations, test/spec files, __tests__/, dist/, coverage/, and node_modules/. Generated-code defaults then exclude generated directory segments, exact gen directory segments, common generated filename suffixes, protobuf outputs, Angular generated artifacts, and leading generated-header markers before the first non-comment token. User exclusions compose with those defaults unless --use-default-exclusions=false; disabling defaults does not disable the baseline analyzability filter.

Full primary reports and JUnit sidecars include source-exclusion audit counts when files were excluded. Default agent primary output omits those details.

Commands run by the built-in executor, including coverage commands and --changed discovery, time out after 300 seconds by default. Set CRAP_TYPESCRIPT_COMMAND_TIMEOUT_MS to a non-negative millisecond value to override this default; 0 disables the timeout. Captured stdout and stderr are capped at 10 MiB per stream. User-facing command failures may include truncated output, while internal commands that require complete output, such as git status --porcelain -z, fail if the cap is exceeded.

The default threshold is 8.0. Values below 4.0 print a warning because they are likely too noisy; values above 8.0 print a warning because they are too lenient even for hard gates.

Exit Codes

  • 0 success, threshold respected
  • 1 invalid CLI usage or execution failure
  • 2 CRAP threshold exceeded (> configured threshold)

See the main documentation for full details.

License

Apache-2.0