@senvenli/cli 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Senvenli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @senvenli/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
```sh
|
|
4
|
+
npx @senvenli/cli theme <preset-code> # theme.css from a builder code
|
|
5
|
+
npx @senvenli/cli theme --primary "#1268ae" --tailwind
|
|
6
|
+
npx @senvenli/cli theme <preset-code> --native # theme.json (hex) for native iOS/Android apps
|
|
7
|
+
```
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { writeFileSync } from "node:fs";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { createTheme, decodePreset, toCSS, toNative } from "@senvenli/tokens";
|
|
5
|
+
const USAGE = `Usage: npx @senvenli/cli theme [preset-code] [options]
|
|
6
|
+
|
|
7
|
+
Options:
|
|
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)
|
|
10
|
+
--radius <rem> Base radius, e.g. 0.5
|
|
11
|
+
--control-shape <rounded|pill> Single-line controls follow the radius, or are fully round
|
|
12
|
+
--density <compact|default|comfortable>
|
|
13
|
+
--border-width <0|1|2>
|
|
14
|
+
--out <file> Default: theme.css (or theme.ts with --native)
|
|
15
|
+
--native Write theme.json (hex colors) for native apps instead of CSS
|
|
16
|
+
--tailwind Add a Tailwind v4 @theme inline block`;
|
|
17
|
+
function main(argv) {
|
|
18
|
+
const { positionals, values } = parseArgs({
|
|
19
|
+
args: argv,
|
|
20
|
+
allowPositionals: true,
|
|
21
|
+
options: {
|
|
22
|
+
primary: { type: "string" },
|
|
23
|
+
secondary: { type: "string" },
|
|
24
|
+
tertiary: { type: "string" },
|
|
25
|
+
"primary-dark": { type: "string" },
|
|
26
|
+
radius: { type: "string" },
|
|
27
|
+
"control-shape": { type: "string" },
|
|
28
|
+
density: { type: "string" },
|
|
29
|
+
"border-width": { type: "string" },
|
|
30
|
+
out: { type: "string" },
|
|
31
|
+
native: { type: "boolean" },
|
|
32
|
+
tailwind: { type: "boolean" },
|
|
33
|
+
help: { type: "boolean", short: "h" },
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const [command, code] = positionals;
|
|
37
|
+
if (values.help || command !== "theme") {
|
|
38
|
+
console.log(USAGE);
|
|
39
|
+
return values.help ? 0 : 1;
|
|
40
|
+
}
|
|
41
|
+
let input = {};
|
|
42
|
+
if (code) {
|
|
43
|
+
const decoded = decodePreset(code);
|
|
44
|
+
if (!decoded) {
|
|
45
|
+
console.error(`Invalid preset code: ${code}`);
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
input = decoded;
|
|
49
|
+
}
|
|
50
|
+
for (const role of ["primary", "secondary", "tertiary"]) {
|
|
51
|
+
if (values[role])
|
|
52
|
+
input[role] = values[role];
|
|
53
|
+
}
|
|
54
|
+
if (values["primary-dark"])
|
|
55
|
+
input.darkColors = { ...input.darkColors, primary: values["primary-dark"] };
|
|
56
|
+
if (values.radius)
|
|
57
|
+
input.radius = Number(values.radius);
|
|
58
|
+
if (values["control-shape"])
|
|
59
|
+
input.controlShape = values["control-shape"];
|
|
60
|
+
if (values.density)
|
|
61
|
+
input.density = values.density;
|
|
62
|
+
if (values["border-width"])
|
|
63
|
+
input.borderWidth = Number(values["border-width"]);
|
|
64
|
+
const theme = createTheme(input);
|
|
65
|
+
const out = values.out ?? (values.native ? "theme.json" : "theme.css");
|
|
66
|
+
const body = values.native
|
|
67
|
+
? `${JSON.stringify(toNative(theme), null, 2)}\n`
|
|
68
|
+
: toCSS(theme, { tailwind: values.tailwind });
|
|
69
|
+
writeFileSync(out, body);
|
|
70
|
+
const failing = theme.checks.filter((c) => !c.pass).length;
|
|
71
|
+
console.log(`Wrote ${out}. ${failing ? `${failing} pairs below AA.` : "All pairs meet WCAG AA."}`);
|
|
72
|
+
if (theme.adjusted.length)
|
|
73
|
+
console.log(`Adjusted for contrast: ${theme.adjusted.join(", ")}`);
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
process.exitCode =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CAAC,cAAc,CAAC,CAA8B,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,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senvenli/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Write Senvenli UI theme files from a preset code or options.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Senvenli",
|
|
7
|
+
"homepage": "https://design.senvenli.com",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Senvenli/Senvenli-UI.git",
|
|
11
|
+
"directory": "packages/cli"
|
|
12
|
+
},
|
|
13
|
+
"bugs": "https://github.com/Senvenli/Senvenli-UI/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"design-system",
|
|
16
|
+
"theme",
|
|
17
|
+
"cli",
|
|
18
|
+
"tailwindcss",
|
|
19
|
+
"wcag"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"bin": {
|
|
23
|
+
"senvenli-ui": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@senvenli/tokens": "^0.2.0"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.json",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
40
|
+
}
|
|
6
41
|
}
|