Skip to content

Reduce runtime dependencies from 6 to 4#9

Merged
mensfeld merged 1 commit into
masterfrom
reduce-runtime-dependencies
Mar 26, 2026
Merged

Reduce runtime dependencies from 6 to 4#9
mensfeld merged 1 commit into
masterfrom
reduce-runtime-dependencies

Conversation

@mensfeld
Copy link
Copy Markdown
Owner

Summary

  • Replaced chalk with inline ANSI escape code helpers (~10 lines, covers all 6 used styles)
  • Replaced commander with Node.js built-in node:util parseArgs (stable since Node 18.3)
  • Replaced micromatch with picomatch (already a transitive dep via fast-glob)
  • Bumped version to 0.4.1

Before (6 deps): chalk, commander, fast-glob, micromatch, smol-toml, yaml
After (4 deps): fast-glob, picomatch, smol-toml, yaml

Test plan

  • npm run build compiles cleanly
  • npm run test — all 303 tests pass
  • npm run selfcheck — CLI works end-to-end
  • npm ls --prod --depth=0 confirms 4 direct dependencies

Replace chalk with inline ANSI helpers, commander with node:util parseArgs,
and micromatch with picomatch (already a transitive dep via fast-glob).

Bumps version to 0.4.1.
@mensfeld mensfeld requested a review from Copilot March 26, 2026 20:03
@mensfeld mensfeld self-assigned this Mar 26, 2026
@mensfeld mensfeld merged commit b04093f into master Mar 26, 2026
6 checks passed
@mensfeld mensfeld deleted the reduce-runtime-dependencies branch March 26, 2026 20:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces direct runtime dependencies by replacing third-party CLI/color/glob utilities with Node built-ins and smaller libraries, and bumps the package version to 0.4.1.

Changes:

  • Replace commander with node:util parseArgs and update CLI help/version handling.
  • Replace chalk with small inline ANSI helpers for text output coloring.
  • Replace micromatch with picomatch, and update dependency/lockfile/changelog/versioning.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/integration/cli.test.ts Updates CLI version assertion to 0.4.1.
src/validator/glob.ts Swaps micromatch-based matching for picomatch-based matching.
src/output/text.ts Removes chalk and introduces inline ANSI formatting helpers.
src/cli.ts Replaces commander with parseArgs, adds manual help text, bumps CLI version constant.
package.json Removes chalk/commander/micromatch, adds picomatch and bumps version to 0.4.1.
package-lock.json Reflects dependency removals/additions and version bump.
CHANGELOG.md Adds 0.4.1 release notes and updates compare links.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/validator/glob.ts
Comment on lines +36 to 38
const isMatch = picomatch(normalizedPattern, {
dot,
matchBase: !normalizedPattern.includes('/')
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

picomatch doesn’t support micromatch’s matchBase option; it will be ignored, which changes behavior for patterns without a / (previously they matched against basenames). To preserve the old semantics, switch to the picomatch equivalent (e.g., basename: true when the pattern has no path separator), or otherwise adjust matching logic so foo.txt matches dir/foo.txt like before.

Suggested change
const isMatch = picomatch(normalizedPattern, {
dot,
matchBase: !normalizedPattern.includes('/')
const hasPathSeparator = normalizedPattern.includes('/');
const isMatch = picomatch(normalizedPattern, {
dot,
...(hasPathSeparator ? {} : { basename: true })

Copilot uses AI. Check for mistakes.
Comment thread src/cli.ts
Comment on lines +7 to 8
import { parseArgs } from 'node:util';
import fs from 'fs/promises';
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This switch to node:util parseArgs effectively requires Node versions where parseArgs is stable/available (noted in the PR description as 18.3+). However, package.json still declares node >=18.0.0, which can lead to runtime failures or unsupported behavior on 18.0–18.2. Consider bumping the engine requirement to >=18.3.0 (or add a small fallback/guard) so the published package matches the CLI’s runtime needs.

Copilot uses AI. Check for mistakes.
Comment thread src/cli.ts
Comment on lines +48 to +52
include: { type: 'string' as const, multiple: true },
exclude: { type: 'string' as const, multiple: true },
'skip-ignore-files': { type: 'boolean' as const, default: false },
'exclude-parsers': { type: 'string' as const, multiple: true },
'min-severity': { type: 'string' as const, default: 'medium' },
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

parseArgs with multiple: true makes --include/--exclude/--exclude-parsers repeatable, but it does not accept the previous commander-style variadic form (e.g. --include a b from the README’s --include <glob...>), and extra values will be treated as positionals (scan paths). Either add backwards-compatible parsing for space-separated lists or update the public docs/help to clearly reflect the new required syntax.

Copilot uses AI. Check for mistakes.
Comment thread src/output/text.ts
Comment on lines +7 to +14
/** Inline ANSI color helpers (replaces chalk) */
const ansi = (code: number, close: number) => (s: string) => `\x1b[${code}m${s}\x1b[${close}m`;
const gray = ansi(90, 39);
const yellow = ansi(33, 39);
const red = ansi(31, 39);
const cyan = ansi(36, 39);
const dim = ansi(2, 22);
const green = ansi(32, 39);
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The new inline ANSI helpers always emit escape codes, whereas chalk previously disabled color automatically in non-TTY contexts and commonly respects NO_COLOR/TERM=dumb. This can introduce escape sequences in redirected output/files and CI logs. Consider gating coloring behind a simple “color enabled” check (TTY + env vars) and falling back to identity functions when disabled.

Copilot uses AI. Check for mistakes.
Comment thread src/cli.ts
Comment on lines +43 to +58
const options = {
version: { type: 'boolean' as const, short: 'V' },
help: { type: 'boolean' as const, short: 'h' },
format: { type: 'string' as const, short: 'f', default: 'text' },
output: { type: 'string' as const, short: 'o' },
include: { type: 'string' as const, multiple: true },
exclude: { type: 'string' as const, multiple: true },
'skip-ignore-files': { type: 'boolean' as const, default: false },
'exclude-parsers': { type: 'string' as const, multiple: true },
'min-severity': { type: 'string' as const, default: 'medium' },
'show-all': { type: 'boolean' as const, default: false },
'fail-on-stale': { type: 'boolean' as const, default: false },
quiet: { type: 'boolean' as const, short: 'q', default: false },
verbose: { type: 'boolean' as const, short: 'v', default: false },
progress: { type: 'boolean' as const, default: true }
};
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

CLI tests cover --include/--exclude with a single value, but there’s no coverage for the new parseArgs multi-value behavior (repeatable flags) or for the legacy --include a b style that commander previously supported. Adding an integration test for repeated --include/--exclude (and, if supported, the space-separated form) would prevent regressions in argument parsing.

Copilot uses AI. Check for mistakes.
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.

2 participants