@senvenli/cli 0.0.0-stage → 0.1.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 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
- # Temporary Holding Version
1
+ # @senvenli/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
+ ```
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
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
+ --radius <rem> Base radius, e.g. 0.5
10
+ --control-shape <rounded|pill> Single-line controls follow the radius, or are fully round
11
+ --density <compact|default|comfortable>
12
+ --border-width <0|1|2>
13
+ --out <file> Default: theme.css (or theme.ts with --native)
14
+ --native Write theme.json (hex colors) for native apps instead of CSS
15
+ --tailwind Add a Tailwind v4 @theme inline block`;
16
+ function main(argv) {
17
+ const { positionals, values } = parseArgs({
18
+ args: argv,
19
+ allowPositionals: true,
20
+ options: {
21
+ primary: { type: "string" },
22
+ secondary: { type: "string" },
23
+ tertiary: { type: "string" },
24
+ radius: { type: "string" },
25
+ "control-shape": { type: "string" },
26
+ density: { type: "string" },
27
+ "border-width": { type: "string" },
28
+ out: { type: "string" },
29
+ native: { type: "boolean" },
30
+ tailwind: { type: "boolean" },
31
+ help: { type: "boolean", short: "h" },
32
+ },
33
+ });
34
+ const [command, code] = positionals;
35
+ if (values.help || command !== "theme") {
36
+ console.log(USAGE);
37
+ return values.help ? 0 : 1;
38
+ }
39
+ let input = {};
40
+ if (code) {
41
+ const decoded = decodePreset(code);
42
+ if (!decoded) {
43
+ console.error(`Invalid preset code: ${code}`);
44
+ return 1;
45
+ }
46
+ input = decoded;
47
+ }
48
+ for (const role of ["primary", "secondary", "tertiary"]) {
49
+ if (values[role])
50
+ input[role] = values[role];
51
+ }
52
+ if (values.radius)
53
+ input.radius = Number(values.radius);
54
+ if (values["control-shape"])
55
+ input.controlShape = values["control-shape"];
56
+ if (values.density)
57
+ input.density = values.density;
58
+ if (values["border-width"])
59
+ input.borderWidth = Number(values["border-width"]);
60
+ const theme = createTheme(input);
61
+ const out = values.out ?? (values.native ? "theme.json" : "theme.css");
62
+ const body = values.native
63
+ ? `${JSON.stringify(toNative(theme), null, 2)}\n`
64
+ : toCSS(theme, { tailwind: values.tailwind });
65
+ writeFileSync(out, body);
66
+ const failing = theme.checks.filter((c) => !c.pass).length;
67
+ console.log(`Wrote ${out}. ${failing ? `${failing} pairs below AA.` : "All pairs meet WCAG AA."}`);
68
+ if (theme.adjusted.length)
69
+ console.log(`Adjusted for contrast: ${theme.adjusted.join(", ")}`);
70
+ return 0;
71
+ }
72
+ process.exitCode = main(process.argv.slice(2));
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,EAAmB,MAAM,kBAAkB,CAAC;AAE/F,MAAM,KAAK,GAAG;;;;;;;;;;qFAUuE,CAAC;AAEtF,SAAS,IAAI,CAAC,IAAc;IAC1B,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QACxC,IAAI,EAAE,IAAI;QACV,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE;YACP,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC7B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC5B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACnC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAClC,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACvB,MAAM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: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 --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 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.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.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.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.1.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
  }