@senvenli/cli 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const USAGE = `Usage: npx @senvenli/cli theme [preset-code] [options]
|
|
|
6
6
|
|
|
7
7
|
Options:
|
|
8
8
|
--primary, --secondary, --tertiary <color> Brand colors (#hex or oklch()); all optional
|
|
9
|
+
--primary-dark <color> A hand-picked primary for dark mode (default: derived)
|
|
9
10
|
--radius <rem> Base radius, e.g. 0.5
|
|
10
11
|
--control-shape <rounded|pill> Single-line controls follow the radius, or are fully round
|
|
11
12
|
--density <compact|default|comfortable>
|
|
@@ -21,6 +22,7 @@ function main(argv) {
|
|
|
21
22
|
primary: { type: "string" },
|
|
22
23
|
secondary: { type: "string" },
|
|
23
24
|
tertiary: { type: "string" },
|
|
25
|
+
"primary-dark": { type: "string" },
|
|
24
26
|
radius: { type: "string" },
|
|
25
27
|
"control-shape": { type: "string" },
|
|
26
28
|
density: { type: "string" },
|
|
@@ -49,6 +51,8 @@ function main(argv) {
|
|
|
49
51
|
if (values[role])
|
|
50
52
|
input[role] = values[role];
|
|
51
53
|
}
|
|
54
|
+
if (values["primary-dark"])
|
|
55
|
+
input.darkColors = { ...input.darkColors, primary: values["primary-dark"] };
|
|
52
56
|
if (values.radius)
|
|
53
57
|
input.radius = Number(values.radius);
|
|
54
58
|
if (values["control-shape"])
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EA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8B,CAAC;IAE5G,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM;QACxB,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI;QACjD,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChD,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzB,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,kBAAkB,CAAC,CAAC,CAAC,yBAAyB,EAAE,CAAC,CAAC;IACnG,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9F,OAAO,CAAC,CAAC;AACX,CAAC;AAED,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { writeFileSync } from \"node:fs\";\nimport { parseArgs } from \"node:util\";\nimport { createTheme, decodePreset, toCSS, toNative, type ThemeInput } from \"@senvenli/tokens\";\n\nconst USAGE = `Usage: npx @senvenli/cli theme [preset-code] [options]\n\nOptions:\n --primary, --secondary, --tertiary <color> Brand colors (#hex or oklch()); all optional\n --primary-dark <color> A hand-picked primary for dark mode (default: derived)\n --radius <rem> Base radius, e.g. 0.5\n --control-shape <rounded|pill> Single-line controls follow the radius, or are fully round\n --density <compact|default|comfortable>\n --border-width <0|1|2>\n --out <file> Default: theme.css (or theme.ts with --native)\n --native Write theme.json (hex colors) for native apps instead of CSS\n --tailwind Add a Tailwind v4 @theme inline block`;\n\nfunction main(argv: string[]): number {\n const { positionals, values } = parseArgs({\n args: argv,\n allowPositionals: true,\n options: {\n primary: { type: \"string\" },\n secondary: { type: \"string\" },\n tertiary: { type: \"string\" },\n \"primary-dark\": { type: \"string\" },\n radius: { type: \"string\" },\n \"control-shape\": { type: \"string\" },\n density: { type: \"string\" },\n \"border-width\": { type: \"string\" },\n out: { type: \"string\" },\n native: { type: \"boolean\" },\n tailwind: { type: \"boolean\" },\n help: { type: \"boolean\", short: \"h\" },\n },\n });\n const [command, code] = positionals;\n if (values.help || command !== \"theme\") {\n console.log(USAGE);\n return values.help ? 0 : 1;\n }\n let input: ThemeInput = {};\n if (code) {\n const decoded = decodePreset(code);\n if (!decoded) {\n console.error(`Invalid preset code: ${code}`);\n return 1;\n }\n input = decoded;\n }\n for (const role of [\"primary\", \"secondary\", \"tertiary\"] as const) {\n if (values[role]) input[role] = values[role];\n }\n if (values[\"primary-dark\"]) input.darkColors = { ...input.darkColors, primary: values[\"primary-dark\"] };\n if (values.radius) input.radius = Number(values.radius);\n if (values[\"control-shape\"]) input.controlShape = values[\"control-shape\"] as ThemeInput[\"controlShape\"];\n if (values.density) input.density = values.density as ThemeInput[\"density\"];\n if (values[\"border-width\"]) input.borderWidth = Number(values[\"border-width\"]) as ThemeInput[\"borderWidth\"];\n\n const theme = createTheme(input);\n const out = values.out ?? (values.native ? \"theme.json\" : \"theme.css\");\n const body = values.native\n ? `${JSON.stringify(toNative(theme), null, 2)}\\n`\n : toCSS(theme, { tailwind: values.tailwind });\n writeFileSync(out, body);\n const failing = theme.checks.filter((c) => !c.pass).length;\n console.log(`Wrote ${out}. ${failing ? `${failing} pairs below AA.` : \"All pairs meet WCAG AA.\"}`);\n if (theme.adjusted.length) console.log(`Adjusted for contrast: ${theme.adjusted.join(\", \")}`);\n return 0;\n}\n\nprocess.exitCode = main(process.argv.slice(2));\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senvenli/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Write Senvenli UI theme files from a preset code or options.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Senvenli",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@senvenli/tokens": "^0.
|
|
29
|
+
"@senvenli/tokens": "^0.3.0"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=20"
|