breaking! feat: add CLI interface for format-css package#170
Open
bartveneman wants to merge 7 commits intomainfrom
Open
breaking! feat: add CLI interface for format-css package#170bartveneman wants to merge 7 commits intomainfrom
bartveneman wants to merge 7 commits intomainfrom
Conversation
Implements a CLI entrypoint that formats CSS files via stdin or file arguments, supporting --minify and --tab-size options with built-in help. Follows the lib/cli split pattern from css-code-coverage: separate tsdown entries, CLI platform set to node, lib marked as external to avoid duplication. Closes #123 https://claude.ai/code/session_01QXPADk12xcj6p5nGFNJHsh
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
===========================================
- Coverage 100.00% 96.98% -3.02%
===========================================
Files 1 2 +1
Lines 320 365 +45
Branches 112 124 +12
===========================================
+ Hits 320 354 +34
- Misses 0 10 +10
- Partials 0 1 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 2.77kB (11.2%) ⬆️
|
Reject any file path that resolves outside the current working directory, matching the same guard used in css-code-coverage. https://claude.ai/code/session_01QXPADk12xcj6p5nGFNJHsh
Refactors cli.ts to export parse_arguments() and run() with a CliIO dependency injection interface, making both independently testable. Guards top-level execution behind import.meta.url so importing the module in tests does not trigger stdin reads. Adds 23 tests covering argument validation (tab-size, minify, path traversal), help output, stdin/file/TTY routing, and formatting options. Aliases @projectwallace/format-css to the source entry in vitest config so tests run without a prior build step. https://claude.ai/code/session_01QXPADk12xcj6p5nGFNJHsh
tsdown outputs dist/cli.mjs for node platform builds, but package.json was pointing to dist/cli.js, causing publint to fail. https://claude.ai/code/session_01QXPADk12xcj6p5nGFNJHsh
styleText (node:util) was introduced in Node 20.12.0, making that the actual minimum supported version. The previous >=18.0.0 was too low. https://claude.ai/code/session_01QXPADk12xcj6p5nGFNJHsh
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
This PR adds a command-line interface (CLI) to the format-css package, allowing users to format CSS files directly from the terminal.
Key Changes
New CLI module (
src/cli/cli.ts): Implements a complete command-line interface with support for:--minifyflag to minify CSS output--tab-size=<n>option to customize indentation--help/-hflag with formatted usage documentationBuild configuration (
tsdown.config.ts): Updated to build both the library and CLI:Package metadata (
package.json): Addedbinfield to register theformat-csscommand, making it available as an executable when installed globally or locallyImplementation Details
parseArgs,styleText) for argument parsing and formatted output--tab-sizeparameter to ensure it's a positive integerhttps://claude.ai/code/session_01QXPADk12xcj6p5nGFNJHsh
Breaking because the supported node version went from >=18.0.0 to >=20.12.0