jixoai-ui 0.1.0 → 0.1.2
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/bin/jixoai-ui.mjs +21 -10
- package/package.json +2 -2
package/bin/jixoai-ui.mjs
CHANGED
|
@@ -98,19 +98,30 @@ function applyHue(cssPath, hue) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
function shadcn(args, cwd) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
function shadcn(args, cwd, configPath, config) {
|
|
102
|
+
// shadcn 4.18 rejects unknown top-level keys (our jixoai block), so the
|
|
103
|
+
// extension fields are stripped for the call and restored afterwards.
|
|
104
|
+
const { jixoai, ...rest } = config;
|
|
105
|
+
writeConfig(configPath, rest);
|
|
106
|
+
const result = spawnSync(
|
|
107
|
+
"npx",
|
|
108
|
+
["--yes", "shadcn", ...args, "--yes"],
|
|
109
|
+
{ stdio: "inherit", cwd, env: { ...process.env, npm_config_yes: "true" } },
|
|
110
|
+
);
|
|
106
111
|
if (result.status !== 0) {
|
|
112
|
+
writeConfig(configPath, config); // restore even on failure
|
|
107
113
|
fail(`\`shadcn ${args.join(" ")}\` exited with ${result.status}`);
|
|
108
114
|
}
|
|
115
|
+
const after = readConfig(cwd);
|
|
116
|
+
after.config.jixoai = jixoai;
|
|
117
|
+
writeConfig(after.path, after.config);
|
|
109
118
|
}
|
|
110
119
|
|
|
111
120
|
function hueFromArgs(args, fallback = DEFAULT_HUE) {
|
|
121
|
+
// accepts --hue <n> OR a bare positional degree value
|
|
122
|
+
const positional = args.find((a, i) => i > 0 && Number.isFinite(Number(a)));
|
|
112
123
|
const index = args.indexOf("--hue");
|
|
113
|
-
const value = index !== -1 ? Number(args[index + 1]) : fallback;
|
|
124
|
+
const value = index !== -1 ? Number(args[index + 1]) : (positional !== undefined ? Number(positional) : fallback);
|
|
114
125
|
if (!Number.isFinite(value) || value < 0 || value >= 360) {
|
|
115
126
|
fail("hue must be a number in [0, 360)");
|
|
116
127
|
}
|
|
@@ -128,12 +139,12 @@ switch (command) {
|
|
|
128
139
|
config.jixoai = { ...(config.jixoai ?? {}), brandHue: hue };
|
|
129
140
|
writeConfig(path, config);
|
|
130
141
|
console.log(`jixoai-ui: ${NAMESPACE} namespace + jixoai config written → ${path}`);
|
|
131
|
-
shadcn(["add", `${NAMESPACE}/${THEME_ITEM}`], cwd);
|
|
142
|
+
shadcn(["add", `${NAMESPACE}/${THEME_ITEM}`], cwd, path, config);
|
|
132
143
|
applyHue(themeCssPath(config, cwd), hue);
|
|
133
144
|
break;
|
|
134
145
|
}
|
|
135
146
|
case "hue": {
|
|
136
|
-
const hue = hueFromArgs([
|
|
147
|
+
const hue = hueFromArgs(["--hue", rest[0]]);
|
|
137
148
|
const { path, config } = readConfig(cwd);
|
|
138
149
|
config.jixoai = { ...(config.jixoai ?? {}), brandHue: hue };
|
|
139
150
|
writeConfig(path, config);
|
|
@@ -142,10 +153,10 @@ switch (command) {
|
|
|
142
153
|
}
|
|
143
154
|
case "add": {
|
|
144
155
|
if (rest.length === 0) fail("add needs at least one item name (e.g. `toc`)");
|
|
145
|
-
const { config } = readConfig(cwd);
|
|
156
|
+
const { path, config } = readConfig(cwd);
|
|
146
157
|
const hue = config.jixoai?.brandHue ?? DEFAULT_HUE;
|
|
147
158
|
for (const item of rest) {
|
|
148
|
-
shadcn(["add", `${NAMESPACE}/${item}`], cwd);
|
|
159
|
+
shadcn(["add", `${NAMESPACE}/${item}`], cwd, path, readConfig(cwd).config);
|
|
149
160
|
}
|
|
150
161
|
applyHue(themeCssPath(config, cwd), hue);
|
|
151
162
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jixoai-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Official jixoai design-language CLI: initializes the @jixoai shadcn registry namespace, manages the jixoai extension fields in components.json, and applies the per-project brand hue.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,4 +29,4 @@
|
|
|
29
29
|
"url": "https://github.com/jixoai/ui",
|
|
30
30
|
"directory": "cli"
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
}
|