-
-
Notifications
You must be signed in to change notification settings - Fork 955
refactor(cli): smarter pattern analysis #5038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for unocss ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this 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 refactors the CLI to implement smarter pattern analysis with significant structural changes to how files are processed and cached.
- Extracts test utilities into a dedicated
utils.tsfile for better test organization - Refactors the main build logic to support multiple entry points with different output files and smarter CSS file detection
- Removes default config and preset dependencies to make the engine more agnostic
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
packages-engine/cli/test/utils.ts |
New file containing extracted test helper functions including runCli, sleep, and test directory management utilities |
packages-engine/cli/test/cli.test.ts |
Simplified to 2 active tests with snapshot assertions; 9 tests commented out reducing test coverage |
packages-engine/cli/test/__snapshots__/cli.test.ts.snap |
Deleted old inline snapshot file |
packages-engine/cli/test/__snapshots__/cli-scan-and-transform-css.snapshot.css |
New CSS snapshot file with absolute paths (needs fixing) |
packages-engine/cli/test/__snapshots__/cli-build-uno.css.snapshot.css |
New CSS snapshot file for basic build test |
packages-engine/cli/src/watcher.ts |
Updated type from CliOptions to ResolvedCliOptions; added mock watcher return for test cases |
packages-engine/cli/src/types.ts |
Expanded with comprehensive JSDoc; restructured CliOptions and ResolvedCliOptions with new properties for entries and context |
packages-engine/cli/src/index.ts |
Major refactor: new file cache structure, separate handling for CSS vs non-CSS files, extracted initializeConfig and generateSingle functions |
packages-engine/cli/src/config.ts |
Removed default config that included preset-uno |
packages-engine/cli/src/cli-start.ts |
Simplified entry handling; renamed --write-transformed to --rewrite; moved config loading into build function |
packages-engine/cli/package.json |
Removed dependencies: @jridgewell/remapping, @unocss/preset-uno, unplugin-utils |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages-engine/cli/test/__snapshots__/cli-scan-and-transform-css.snapshot.css
Outdated
Show resolved
Hide resolved
packages-engine/cli/test/__snapshots__/cli-scan-and-transform-css.snapshot.css
Outdated
Show resolved
Hide resolved
|
commit: |
|
Done! |
This PR changes the following:
Breaking Changes
presetUnoconfiguration; users now need to configure it manually--preset wind3or--preset wind4to switch as your default preset. But if you have configured uno.config, this option will be ignored.--write-transformedwith--rewriteNew Features and Optimizations
debugmode, allowing you to clearly see which files are scanned and collected. Enable with--debugrewritethe transformer for custom scanned files.{ cli: { entry: { patterns: [ './src/pages/**/*.vue', ], outFile: './src/unocss-generated.css', + rewrite: true }, }, transformers: [ transformerDirectives(), ], }--split-css${outFile}-[hash]outFile-merged.cssThis resolves the previous issue where CSS files would be automatically discarded when detected during scanning.
Fixed #4902
{ cli: { entry: { patterns: [ './src/pages/**/*.css', ], outFile: './src/unocss-generated.css', + splitCss: true }, }, transformers: [ transformerDirectives(), ], }