Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds gradient generation support to bdsg-cli, aligning it with the bdsg v0.2.0 library release. The new generate gradient command enables OKLCH-based color gradient creation with easing functions and hue direction control.
Changes:
- Added
bdsg generate gradientcommand with OKLCH interpolation, easing functions (linear, easeIn, easeOut, easeInOut), and hue direction control (shorter, longer, increasing, decreasing) - Updated bdsg dependency from ^0.1.3 to ^0.2.0 and bumped CLI version to 0.2.0
- Updated README.md and CHANGELOG.md with v0.2.0 release documentation
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/bdsg-cli/src/commands/generate.ts | Added new gradient command with options for name, steps, easing, direction, output directory, and format |
| packages/bdsg-cli/package.json | Bumped version to 0.2.0 and updated bdsg dependency to ^0.2.0 |
| packages/bdsg-cli/README.md | Added gradient command documentation with usage examples and available options |
| CHANGELOG.md | Added v0.2.0 release notes for bdsg-cli with gradient command features |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const easingFn = | ||
| EASING[options.easing as keyof typeof EASING] || EASING.linear; | ||
|
|
There was a problem hiding this comment.
The easing option validation should fail with a clear error message when an invalid value is provided, rather than silently falling back to EASING.linear. This could confuse users who make typos or provide invalid easing function names. Consider validating the easing option against the valid values (linear, easeIn, easeOut, easeInOut) and throwing an error if invalid.
| const easingFn = | |
| EASING[options.easing as keyof typeof EASING] || EASING.linear; | |
| const validEasings = ["linear", "easeIn", "easeOut", "easeInOut"] as const; | |
| if (!validEasings.includes(options.easing)) { | |
| throw new Error( | |
| `Invalid easing option "${options.easing}". Valid options are: ${validEasings.join( | |
| ", ", | |
| )}.`, | |
| ); | |
| } | |
| const easingFn = EASING[options.easing as keyof typeof EASING]; |
| const spinner = ora("Generating gradient...").start(); | ||
|
|
||
| try { | ||
| const steps = Number.parseInt(options.steps, 10); |
There was a problem hiding this comment.
The steps option should be validated before parsing to ensure it's a valid numeric string. If a user provides a non-numeric value, Number.parseInt will return NaN, which will cause a less user-friendly error message from the library validation. Consider adding validation to check if options.steps is a valid number string and provide a clear error message if not.
| const steps = Number.parseInt(options.steps, 10); | |
| const stepsRaw = options.steps; | |
| if (!/^\d+$/.test(stepsRaw)) { | |
| throw new Error( | |
| `Invalid value for --steps: "${stepsRaw}". Please provide a positive integer.`, | |
| ); | |
| } | |
| const steps = Number.parseInt(stepsRaw, 10); |
| if (options.format === "json") { | ||
| const gradient: Record<string, unknown> = { | ||
| name: options.name, | ||
| start: startColor, | ||
| end: endColor, | ||
| steps, | ||
| colors, | ||
| css: { | ||
| linear: toCssGradient("linear", colors, 90), | ||
| radial: toCssGradient("radial", colors), | ||
| }, | ||
| }; | ||
| await writeFile( | ||
| join(options.output, `${options.name}.json`), | ||
| JSON.stringify({ gradient }, null, 2), | ||
| ); | ||
| } else { |
There was a problem hiding this comment.
The format option should be validated to ensure it's either "css" or "json". If a user provides an invalid format value, the code currently defaults to CSS output without any warning to the user. Consider validating the format option and providing a clear error message for invalid values.
* Release v0.2.0 bdsg (#11) * feat(bdsg): add okloch color space, feat palettes with olock, gradient system - two colors and multi colors; reorder imports in others files * generate test file * chore: add suport validation zod in gradient file * refactor: remove zod schemas from files and centralized in a single file * chore: biome write files * chore: move gradient tests out of oklch tests * docs(bdsg): update readme * docs: update changelog * tests: generate new tests suites * docs: update readme * refactor: remove unused interpolation property and fix version notation * ci: add dev branch to workflow * Release v0.2.0 cli (#13) * feat(bdsg-cli): add new options and new outputs css variables + gradients linear/radials * docs: update readme * docs: update changelog * docs: update version to reflet package * feat(bdsg-cli): add gradient command and input validation
* Release v0.2.0 bdsg (#11) * feat(bdsg): add okloch color space, feat palettes with olock, gradient system - two colors and multi colors; reorder imports in others files * generate test file * chore: add suport validation zod in gradient file * refactor: remove zod schemas from files and centralized in a single file * chore: biome write files * chore: move gradient tests out of oklch tests * docs(bdsg): update readme * docs: update changelog * tests: generate new tests suites * docs: update readme * refactor: remove unused interpolation property and fix version notation * ci: add dev branch to workflow * Release v0.2.0 cli (#13) * feat(bdsg-cli): add new options and new outputs css variables + gradients linear/radials * docs: update readme * docs: update changelog * docs: update version to reflet package * feat(bdsg-cli): add gradient command and input validation
Description
Add gradient generation support to bdsg-cli, enabling OKLCH-based color gradient creation from the command line. This aligns the CLI with bdsg v0.2.0 features.
Type of Change
feat: New featurefix: Bug fixdocs: Documentation onlyrefactor: Code refactoring (no functional changes)perf: Performance improvementtest: Adding or updating testschore: Maintenance (dependencies, config, etc.)Changes
bdsg generate gradientcommand with OKLCH interpolationlinear,easeIn,easeOut,easeInOutshorter,longer,increasing,decreasingbdsgdependency from^0.1.3to^0.2.00.2.0Testing
bun test)bun run check-types)bun run check)bdsg generate gradient "#FF0000" "#0000FF" -s 5Breaking Changes
Checklist