-
Notifications
You must be signed in to change notification settings - Fork 0
Release v0.2.0 cli #13
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
Changes from 4 commits
385974e
7f7854f
30b1e5d
6aff3d0
4b941a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,13 @@ | ||||||||||||||||||||||||||||
| import { mkdir, writeFile } from "node:fs/promises"; | ||||||||||||||||||||||||||||
| import { join } from "node:path"; | ||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||
| EASING, | ||||||||||||||||||||||||||||
| generateGradient, | ||||||||||||||||||||||||||||
| generatePalette, | ||||||||||||||||||||||||||||
| generateShadows, | ||||||||||||||||||||||||||||
| generateSpacingScale, | ||||||||||||||||||||||||||||
| generateTypographyScale, | ||||||||||||||||||||||||||||
| toCssGradient, | ||||||||||||||||||||||||||||
| } from "bdsg"; | ||||||||||||||||||||||||||||
| import chalk from "chalk"; | ||||||||||||||||||||||||||||
| import { Command } from "commander"; | ||||||||||||||||||||||||||||
|
|
@@ -233,4 +236,90 @@ export const generateCommand = new Command("generate") | |||||||||||||||||||||||||||
| process.exit(1); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| .addCommand( | ||||||||||||||||||||||||||||
| new Command("gradient") | ||||||||||||||||||||||||||||
| .description("Generate a color gradient") | ||||||||||||||||||||||||||||
| .argument("<startColor>", "Start color in hex format (e.g., #FF0000)") | ||||||||||||||||||||||||||||
| .argument("<endColor>", "End color in hex format (e.g., #0000FF)") | ||||||||||||||||||||||||||||
| .option("-n, --name <name>", "Gradient name", "gradient") | ||||||||||||||||||||||||||||
| .option("-s, --steps <steps>", "Number of color steps", "5") | ||||||||||||||||||||||||||||
| .option( | ||||||||||||||||||||||||||||
| "-e, --easing <easing>", | ||||||||||||||||||||||||||||
| "Easing function (linear, easeIn, easeOut, easeInOut)", | ||||||||||||||||||||||||||||
| "linear", | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| .option( | ||||||||||||||||||||||||||||
| "-d, --direction <direction>", | ||||||||||||||||||||||||||||
| "Hue direction (shorter, longer, increasing, decreasing)", | ||||||||||||||||||||||||||||
| "shorter", | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| .option("-o, --output <dir>", "Output directory", "./tokens") | ||||||||||||||||||||||||||||
| .option("-f, --format <format>", "Output format (css, json)", "css") | ||||||||||||||||||||||||||||
| .action(async (startColor, endColor, options) => { | ||||||||||||||||||||||||||||
| const spinner = ora("Generating gradient...").start(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| const steps = Number.parseInt(options.steps, 10); | ||||||||||||||||||||||||||||
| const easingFn = | ||||||||||||||||||||||||||||
| EASING[options.easing as keyof typeof EASING] || EASING.linear; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| 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]; |
Copilot
AI
Jan 15, 2026
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.
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.
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.
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.