inai-react-components 0.1.3 → 0.1.5
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/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +121 -2
- package/dist/commands/init.d.ts +231 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +136 -6
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/theme.d.ts.map +1 -1
- package/dist/commands/theme.js +16 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,aAAa,CAAC;AASrB,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IAChD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAQA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE;IAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAAC,SAAS,EAAE,iBAAiB,EAAE,CAAA;CAAE,EAC1G,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,iBAAiB,GAAG,IAAI,CAc1B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9C,MAAM,CAUR;AAED,wBAAsB,MAAM,CAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,CAsHpB;AAuBD,wBAAsB,UAAU,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BtE"}
|
package/dist/commands/add.js
CHANGED
|
@@ -5,6 +5,7 @@ import ora from "ora";
|
|
|
5
5
|
import prompts from "prompts";
|
|
6
6
|
import { readComponentsJson, readRegistryJson, } from "./status.js";
|
|
7
7
|
import { resolveRegistryDir } from "../utils/registry-resolver.js";
|
|
8
|
+
import { normalizeThemeCss, getLocalTailwindCssTemplate, getLegacyTailwindCssTemplate, } from "./init.js";
|
|
8
9
|
/**
|
|
9
10
|
* Parse a component spec like "button", "block/auth-login", or "template/admin-dashboard"
|
|
10
11
|
* into its type prefix and name.
|
|
@@ -190,6 +191,105 @@ export async function addCommand(componentSpec) {
|
|
|
190
191
|
process.exit(1);
|
|
191
192
|
}
|
|
192
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Discover available themes from the registry's tokens directory.
|
|
196
|
+
*/
|
|
197
|
+
function discoverThemes(registryDir) {
|
|
198
|
+
const themesDir = path.join(registryDir, "packages", "tokens", "src", "themes");
|
|
199
|
+
if (fs.existsSync(themesDir)) {
|
|
200
|
+
return fs
|
|
201
|
+
.readdirSync(themesDir)
|
|
202
|
+
.filter((f) => f.endsWith(".css"))
|
|
203
|
+
.map((f) => f.replace(/\.css$/, ""))
|
|
204
|
+
.sort();
|
|
205
|
+
}
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Switch the project's theme. Copies the new theme CSS (normalized),
|
|
210
|
+
* updates components.json, and regenerates the CSS entry point.
|
|
211
|
+
*/
|
|
212
|
+
async function changeTheme(rootDir, registryDir) {
|
|
213
|
+
const componentsJson = readComponentsJson(rootDir);
|
|
214
|
+
const currentTheme = componentsJson.theme ?? "monday";
|
|
215
|
+
const themes = discoverThemes(registryDir);
|
|
216
|
+
if (themes.length === 0) {
|
|
217
|
+
console.log(chalk.red("No themes found in registry."));
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const currentIdx = themes.indexOf(currentTheme);
|
|
221
|
+
const response = await prompts({
|
|
222
|
+
type: "select",
|
|
223
|
+
name: "theme",
|
|
224
|
+
message: `Select a theme ${chalk.dim(`(current: ${currentTheme})`)}`,
|
|
225
|
+
choices: themes.map((t) => ({
|
|
226
|
+
title: t === currentTheme ? `${t} ${chalk.green("(current)")}` : t,
|
|
227
|
+
value: t,
|
|
228
|
+
})),
|
|
229
|
+
initial: currentIdx >= 0 ? currentIdx : 0,
|
|
230
|
+
});
|
|
231
|
+
if (!response.theme) {
|
|
232
|
+
console.log(chalk.yellow("\nTheme change cancelled."));
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const newTheme = response.theme;
|
|
236
|
+
if (newTheme === currentTheme) {
|
|
237
|
+
console.log(chalk.dim("\nTheme unchanged."));
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const spinner = ora(`Switching theme to "${newTheme}"...`).start();
|
|
241
|
+
try {
|
|
242
|
+
const tokensSrc = path.join(registryDir, "packages", "tokens", "src");
|
|
243
|
+
const isRemote = !!componentsJson.registrySource;
|
|
244
|
+
if (isRemote) {
|
|
245
|
+
// Remote mode: copy and normalize theme file
|
|
246
|
+
const themesSrc = path.join(tokensSrc, "themes");
|
|
247
|
+
const themesDest = path.join(rootDir, "src", "styles", "tokens", "themes");
|
|
248
|
+
// Remove old theme file
|
|
249
|
+
const oldThemeFile = path.join(themesDest, `${currentTheme}.css`);
|
|
250
|
+
if (fs.existsSync(oldThemeFile)) {
|
|
251
|
+
fs.unlinkSync(oldThemeFile);
|
|
252
|
+
}
|
|
253
|
+
// Copy and normalize new theme
|
|
254
|
+
const newThemeSrc = path.join(themesSrc, `${newTheme}.css`);
|
|
255
|
+
if (fs.existsSync(newThemeSrc)) {
|
|
256
|
+
fs.mkdirSync(themesDest, { recursive: true });
|
|
257
|
+
const rawCss = fs.readFileSync(newThemeSrc, "utf-8");
|
|
258
|
+
const normalizedCss = normalizeThemeCss(rawCss, newTheme);
|
|
259
|
+
fs.writeFileSync(path.join(themesDest, `${newTheme}.css`), normalizedCss);
|
|
260
|
+
}
|
|
261
|
+
// Regenerate index.css
|
|
262
|
+
const font = componentsJson.font ?? { body: "outfit", heading: "outfit" };
|
|
263
|
+
const radius = componentsJson.radius ?? 0.5;
|
|
264
|
+
const cssPath = path.join(rootDir, "src", "index.css");
|
|
265
|
+
fs.writeFileSync(cssPath, getLocalTailwindCssTemplate(newTheme, font.body, font.heading, radius));
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
// Local mode: just regenerate index.css with new import
|
|
269
|
+
const font = componentsJson.font ?? { body: "outfit", heading: "outfit" };
|
|
270
|
+
const radius = componentsJson.radius ?? 0.5;
|
|
271
|
+
const cssPath = path.join(rootDir, "src", "index.css");
|
|
272
|
+
fs.writeFileSync(cssPath, getLegacyTailwindCssTemplate(newTheme, font.body, font.heading, radius));
|
|
273
|
+
}
|
|
274
|
+
// Update components.json
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
276
|
+
componentsJson.theme = newTheme;
|
|
277
|
+
const componentsJsonPath = path.join(rootDir, "components.json");
|
|
278
|
+
fs.writeFileSync(componentsJsonPath, JSON.stringify(componentsJson, null, 2) + "\n");
|
|
279
|
+
spinner.succeed(`Theme switched to "${newTheme}"`);
|
|
280
|
+
console.log(chalk.green("\nUpdated files:"));
|
|
281
|
+
console.log(chalk.dim(" - components.json"));
|
|
282
|
+
console.log(chalk.dim(" - src/index.css"));
|
|
283
|
+
if (componentsJson.registrySource) {
|
|
284
|
+
console.log(chalk.dim(` - src/styles/tokens/themes/${newTheme}.css`));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
spinner.fail("Failed to switch theme.");
|
|
289
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
290
|
+
console.error(chalk.red(`\nError: ${message}`));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
193
293
|
async function interactiveAdd() {
|
|
194
294
|
const rootDir = process.cwd();
|
|
195
295
|
const componentsJson = readComponentsJson(rootDir);
|
|
@@ -204,6 +304,26 @@ async function interactiveAdd() {
|
|
|
204
304
|
console.log(chalk.red("Registry not found. Ensure your project is initialized correctly."));
|
|
205
305
|
process.exit(1);
|
|
206
306
|
}
|
|
307
|
+
// First: ask what the user wants to do
|
|
308
|
+
console.log(chalk.bold("\nInAI UI - Interactive Menu\n"));
|
|
309
|
+
const actionResponse = await prompts({
|
|
310
|
+
type: "select",
|
|
311
|
+
name: "action",
|
|
312
|
+
message: "What would you like to do?",
|
|
313
|
+
choices: [
|
|
314
|
+
{ title: "Add components", value: "components", description: "Browse and install components, blocks, or templates" },
|
|
315
|
+
{ title: "Change theme", value: "theme", description: `Current: ${componentsJson.theme ?? "monday"}` },
|
|
316
|
+
],
|
|
317
|
+
});
|
|
318
|
+
if (!actionResponse.action) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
// Theme change flow
|
|
322
|
+
if (actionResponse.action === "theme") {
|
|
323
|
+
await changeTheme(rootDir, registryDir);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
// Component picker flow
|
|
207
327
|
const allItems = [
|
|
208
328
|
...registry.components,
|
|
209
329
|
...registry.blocks,
|
|
@@ -227,8 +347,7 @@ async function interactiveAdd() {
|
|
|
227
347
|
selected: false,
|
|
228
348
|
};
|
|
229
349
|
});
|
|
230
|
-
console.log(chalk.
|
|
231
|
-
console.log(chalk.dim("Select components to add or update. Already installed components will be updated.\n"));
|
|
350
|
+
console.log(chalk.dim("\nSelect components to add or update. Already installed components will be updated.\n"));
|
|
232
351
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
233
352
|
const response = await prompts({
|
|
234
353
|
type: "multiselect",
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1,9 +1,226 @@
|
|
|
1
1
|
declare const AVAILABLE_THEMES: readonly ["monday", "linear", "notion", "vercel", "inai", "anthropic", "shadcn-default", "shadcn-blue", "shadcn-green", "shadcn-orange", "shadcn-red", "shadcn-rose", "shadcn-violet", "shadcn-yellow"];
|
|
2
2
|
type Theme = (typeof AVAILABLE_THEMES)[number];
|
|
3
|
+
declare const FONT_PRESETS: readonly [{
|
|
4
|
+
readonly name: "outfit";
|
|
5
|
+
readonly label: "Outfit";
|
|
6
|
+
readonly family: "'Outfit', system-ui, sans-serif";
|
|
7
|
+
}, {
|
|
8
|
+
readonly name: "inter";
|
|
9
|
+
readonly label: "Inter";
|
|
10
|
+
readonly family: "'Inter', system-ui, sans-serif";
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: "geist";
|
|
13
|
+
readonly label: "Geist";
|
|
14
|
+
readonly family: "'Geist', system-ui, sans-serif";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "plus-jakarta-sans";
|
|
17
|
+
readonly label: "Plus Jakarta Sans";
|
|
18
|
+
readonly family: "'Plus Jakarta Sans', system-ui, sans-serif";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "dm-sans";
|
|
21
|
+
readonly label: "DM Sans";
|
|
22
|
+
readonly family: "'DM Sans', system-ui, sans-serif";
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "albert-sans";
|
|
25
|
+
readonly label: "Albert Sans";
|
|
26
|
+
readonly family: "'Albert Sans', system-ui, sans-serif";
|
|
27
|
+
}, {
|
|
28
|
+
readonly name: "general-sans";
|
|
29
|
+
readonly label: "General Sans";
|
|
30
|
+
readonly family: "'General Sans', system-ui, sans-serif";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "cabinet-grotesk";
|
|
33
|
+
readonly label: "Cabinet Grotesk";
|
|
34
|
+
readonly family: "'Cabinet Grotesk', system-ui, sans-serif";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "satoshi";
|
|
37
|
+
readonly label: "Satoshi";
|
|
38
|
+
readonly family: "'Satoshi', system-ui, sans-serif";
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "clash-display";
|
|
41
|
+
readonly label: "Clash Display";
|
|
42
|
+
readonly family: "'Clash Display', system-ui, sans-serif";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "nunito";
|
|
45
|
+
readonly label: "Nunito";
|
|
46
|
+
readonly family: "'Nunito', system-ui, sans-serif";
|
|
47
|
+
}, {
|
|
48
|
+
readonly name: "nunito-sans";
|
|
49
|
+
readonly label: "Nunito Sans";
|
|
50
|
+
readonly family: "'Nunito Sans', system-ui, sans-serif";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "rubik";
|
|
53
|
+
readonly label: "Rubik";
|
|
54
|
+
readonly family: "'Rubik', system-ui, sans-serif";
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: "poppins";
|
|
57
|
+
readonly label: "Poppins";
|
|
58
|
+
readonly family: "'Poppins', system-ui, sans-serif";
|
|
59
|
+
}, {
|
|
60
|
+
readonly name: "manrope";
|
|
61
|
+
readonly label: "Manrope";
|
|
62
|
+
readonly family: "'Manrope', system-ui, sans-serif";
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "sora";
|
|
65
|
+
readonly label: "Sora";
|
|
66
|
+
readonly family: "'Sora', system-ui, sans-serif";
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "figtree";
|
|
69
|
+
readonly label: "Figtree";
|
|
70
|
+
readonly family: "'Figtree', system-ui, sans-serif";
|
|
71
|
+
}, {
|
|
72
|
+
readonly name: "be-vietnam-pro";
|
|
73
|
+
readonly label: "Be Vietnam Pro";
|
|
74
|
+
readonly family: "'Be Vietnam Pro', system-ui, sans-serif";
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "open-sans";
|
|
77
|
+
readonly label: "Open Sans";
|
|
78
|
+
readonly family: "'Open Sans', system-ui, sans-serif";
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "roboto";
|
|
81
|
+
readonly label: "Roboto";
|
|
82
|
+
readonly family: "'Roboto', system-ui, sans-serif";
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "lato";
|
|
85
|
+
readonly label: "Lato";
|
|
86
|
+
readonly family: "'Lato', system-ui, sans-serif";
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "montserrat";
|
|
89
|
+
readonly label: "Montserrat";
|
|
90
|
+
readonly family: "'Montserrat', system-ui, sans-serif";
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "raleway";
|
|
93
|
+
readonly label: "Raleway";
|
|
94
|
+
readonly family: "'Raleway', system-ui, sans-serif";
|
|
95
|
+
}, {
|
|
96
|
+
readonly name: "work-sans";
|
|
97
|
+
readonly label: "Work Sans";
|
|
98
|
+
readonly family: "'Work Sans', system-ui, sans-serif";
|
|
99
|
+
}, {
|
|
100
|
+
readonly name: "source-sans-3";
|
|
101
|
+
readonly label: "Source Sans 3";
|
|
102
|
+
readonly family: "'Source Sans 3', system-ui, sans-serif";
|
|
103
|
+
}, {
|
|
104
|
+
readonly name: "barlow";
|
|
105
|
+
readonly label: "Barlow";
|
|
106
|
+
readonly family: "'Barlow', system-ui, sans-serif";
|
|
107
|
+
}, {
|
|
108
|
+
readonly name: "red-hat-display";
|
|
109
|
+
readonly label: "Red Hat Display";
|
|
110
|
+
readonly family: "'Red Hat Display', system-ui, sans-serif";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "red-hat-text";
|
|
113
|
+
readonly label: "Red Hat Text";
|
|
114
|
+
readonly family: "'Red Hat Text', system-ui, sans-serif";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "space-grotesk";
|
|
117
|
+
readonly label: "Space Grotesk";
|
|
118
|
+
readonly family: "'Space Grotesk', system-ui, sans-serif";
|
|
119
|
+
}, {
|
|
120
|
+
readonly name: "archivo";
|
|
121
|
+
readonly label: "Archivo";
|
|
122
|
+
readonly family: "'Archivo', system-ui, sans-serif";
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "overpass";
|
|
125
|
+
readonly label: "Overpass";
|
|
126
|
+
readonly family: "'Overpass', system-ui, sans-serif";
|
|
127
|
+
}, {
|
|
128
|
+
readonly name: "urbanist";
|
|
129
|
+
readonly label: "Urbanist";
|
|
130
|
+
readonly family: "'Urbanist', system-ui, sans-serif";
|
|
131
|
+
}, {
|
|
132
|
+
readonly name: "lexend";
|
|
133
|
+
readonly label: "Lexend";
|
|
134
|
+
readonly family: "'Lexend', system-ui, sans-serif";
|
|
135
|
+
}, {
|
|
136
|
+
readonly name: "playfair-display";
|
|
137
|
+
readonly label: "Playfair Display";
|
|
138
|
+
readonly family: "'Playfair Display', Georgia, serif";
|
|
139
|
+
}, {
|
|
140
|
+
readonly name: "lora";
|
|
141
|
+
readonly label: "Lora";
|
|
142
|
+
readonly family: "'Lora', Georgia, serif";
|
|
143
|
+
}, {
|
|
144
|
+
readonly name: "merriweather";
|
|
145
|
+
readonly label: "Merriweather";
|
|
146
|
+
readonly family: "'Merriweather', Georgia, serif";
|
|
147
|
+
}, {
|
|
148
|
+
readonly name: "dm-serif-display";
|
|
149
|
+
readonly label: "DM Serif Display";
|
|
150
|
+
readonly family: "'DM Serif Display', Georgia, serif";
|
|
151
|
+
}, {
|
|
152
|
+
readonly name: "dm-serif-text";
|
|
153
|
+
readonly label: "DM Serif Text";
|
|
154
|
+
readonly family: "'DM Serif Text', Georgia, serif";
|
|
155
|
+
}, {
|
|
156
|
+
readonly name: "fraunces";
|
|
157
|
+
readonly label: "Fraunces";
|
|
158
|
+
readonly family: "'Fraunces', Georgia, serif";
|
|
159
|
+
}, {
|
|
160
|
+
readonly name: "source-serif-4";
|
|
161
|
+
readonly label: "Source Serif 4";
|
|
162
|
+
readonly family: "'Source Serif 4', Georgia, serif";
|
|
163
|
+
}, {
|
|
164
|
+
readonly name: "bitter";
|
|
165
|
+
readonly label: "Bitter";
|
|
166
|
+
readonly family: "'Bitter', Georgia, serif";
|
|
167
|
+
}, {
|
|
168
|
+
readonly name: "crimson-pro";
|
|
169
|
+
readonly label: "Crimson Pro";
|
|
170
|
+
readonly family: "'Crimson Pro', Georgia, serif";
|
|
171
|
+
}, {
|
|
172
|
+
readonly name: "libre-baskerville";
|
|
173
|
+
readonly label: "Libre Baskerville";
|
|
174
|
+
readonly family: "'Libre Baskerville', Georgia, serif";
|
|
175
|
+
}, {
|
|
176
|
+
readonly name: "eb-garamond";
|
|
177
|
+
readonly label: "EB Garamond";
|
|
178
|
+
readonly family: "'EB Garamond', Georgia, serif";
|
|
179
|
+
}, {
|
|
180
|
+
readonly name: "cormorant";
|
|
181
|
+
readonly label: "Cormorant";
|
|
182
|
+
readonly family: "'Cormorant', Georgia, serif";
|
|
183
|
+
}, {
|
|
184
|
+
readonly name: "instrument-serif";
|
|
185
|
+
readonly label: "Instrument Serif";
|
|
186
|
+
readonly family: "'Instrument Serif', Georgia, serif";
|
|
187
|
+
}, {
|
|
188
|
+
readonly name: "young-serif";
|
|
189
|
+
readonly label: "Young Serif";
|
|
190
|
+
readonly family: "'Young Serif', Georgia, serif";
|
|
191
|
+
}, {
|
|
192
|
+
readonly name: "jetbrains-mono";
|
|
193
|
+
readonly label: "JetBrains Mono";
|
|
194
|
+
readonly family: "'JetBrains Mono', ui-monospace, monospace";
|
|
195
|
+
}, {
|
|
196
|
+
readonly name: "fira-code";
|
|
197
|
+
readonly label: "Fira Code";
|
|
198
|
+
readonly family: "'Fira Code', ui-monospace, monospace";
|
|
199
|
+
}, {
|
|
200
|
+
readonly name: "source-code-pro";
|
|
201
|
+
readonly label: "Source Code Pro";
|
|
202
|
+
readonly family: "'Source Code Pro', ui-monospace, monospace";
|
|
203
|
+
}, {
|
|
204
|
+
readonly name: "ibm-plex-mono";
|
|
205
|
+
readonly label: "IBM Plex Mono";
|
|
206
|
+
readonly family: "'IBM Plex Mono', ui-monospace, monospace";
|
|
207
|
+
}, {
|
|
208
|
+
readonly name: "space-mono";
|
|
209
|
+
readonly label: "Space Mono";
|
|
210
|
+
readonly family: "'Space Mono', ui-monospace, monospace";
|
|
211
|
+
}, {
|
|
212
|
+
readonly name: "system";
|
|
213
|
+
readonly label: "System Default";
|
|
214
|
+
readonly family: "system-ui, -apple-system, sans-serif";
|
|
215
|
+
}];
|
|
216
|
+
type FontPreset = (typeof FONT_PRESETS)[number]["name"];
|
|
3
217
|
export interface InitConfig {
|
|
4
218
|
componentPath: string;
|
|
5
219
|
blockPath: string;
|
|
6
220
|
theme: Theme;
|
|
221
|
+
fontBody: FontPreset;
|
|
222
|
+
fontHeading: FontPreset;
|
|
223
|
+
radius: number;
|
|
7
224
|
importAlias: string;
|
|
8
225
|
utilsAlias: string;
|
|
9
226
|
tanstackRouter: boolean;
|
|
@@ -25,6 +242,11 @@ export interface ComponentsJson {
|
|
|
25
242
|
utils: string;
|
|
26
243
|
};
|
|
27
244
|
theme: Theme;
|
|
245
|
+
font: {
|
|
246
|
+
body: FontPreset;
|
|
247
|
+
heading: FontPreset;
|
|
248
|
+
};
|
|
249
|
+
radius: number;
|
|
28
250
|
tanstack: {
|
|
29
251
|
router: boolean;
|
|
30
252
|
query: boolean;
|
|
@@ -35,8 +257,15 @@ export interface ComponentsJson {
|
|
|
35
257
|
export declare function promptInitConfig(registryDir?: string): Promise<InitConfig | null>;
|
|
36
258
|
export declare function buildComponentsJson(config: InitConfig, repoUrl?: string): ComponentsJson;
|
|
37
259
|
export declare function getCnTemplate(): string;
|
|
38
|
-
export declare function getLocalTailwindCssTemplate(theme: Theme): string;
|
|
39
|
-
export declare function getLegacyTailwindCssTemplate(theme: Theme): string;
|
|
260
|
+
export declare function getLocalTailwindCssTemplate(theme: Theme, fontBody: FontPreset, fontHeading: FontPreset, radius: number): string;
|
|
261
|
+
export declare function getLegacyTailwindCssTemplate(theme: Theme, fontBody: FontPreset, fontHeading: FontPreset, radius: number): string;
|
|
262
|
+
/**
|
|
263
|
+
* Strip the `[data-theme="<name>"]` selector from theme CSS so it applies
|
|
264
|
+
* directly on `:root` / `.dark`. This is used when copying a single theme
|
|
265
|
+
* for a project — the theme becomes the default without needing a
|
|
266
|
+
* `data-theme` attribute on the HTML element.
|
|
267
|
+
*/
|
|
268
|
+
export declare function normalizeThemeCss(css: string, theme: string): string;
|
|
40
269
|
export declare function runInit(config: InitConfig, targetDir: string, repoUrl?: string): Promise<{
|
|
41
270
|
success: boolean;
|
|
42
271
|
filesCreated: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,gBAAgB,yMAeZ,CAAC;AACX,KAAK,KAAK,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,K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,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBpE;AA6ED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA4CvD;AAED,wBAAsB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0DjE"}
|
package/dist/commands/init.js
CHANGED
|
@@ -20,6 +20,74 @@ const AVAILABLE_THEMES = [
|
|
|
20
20
|
"shadcn-violet",
|
|
21
21
|
"shadcn-yellow",
|
|
22
22
|
];
|
|
23
|
+
const FONT_PRESETS = [
|
|
24
|
+
// Sans-serif — geometric & modern
|
|
25
|
+
{ name: "outfit", label: "Outfit", family: "'Outfit', system-ui, sans-serif" },
|
|
26
|
+
{ name: "inter", label: "Inter", family: "'Inter', system-ui, sans-serif" },
|
|
27
|
+
{ name: "geist", label: "Geist", family: "'Geist', system-ui, sans-serif" },
|
|
28
|
+
{ name: "plus-jakarta-sans", label: "Plus Jakarta Sans", family: "'Plus Jakarta Sans', system-ui, sans-serif" },
|
|
29
|
+
{ name: "dm-sans", label: "DM Sans", family: "'DM Sans', system-ui, sans-serif" },
|
|
30
|
+
{ name: "albert-sans", label: "Albert Sans", family: "'Albert Sans', system-ui, sans-serif" },
|
|
31
|
+
{ name: "general-sans", label: "General Sans", family: "'General Sans', system-ui, sans-serif" },
|
|
32
|
+
{ name: "cabinet-grotesk", label: "Cabinet Grotesk", family: "'Cabinet Grotesk', system-ui, sans-serif" },
|
|
33
|
+
{ name: "satoshi", label: "Satoshi", family: "'Satoshi', system-ui, sans-serif" },
|
|
34
|
+
{ name: "clash-display", label: "Clash Display", family: "'Clash Display', system-ui, sans-serif" },
|
|
35
|
+
// Sans-serif — humanist & rounded
|
|
36
|
+
{ name: "nunito", label: "Nunito", family: "'Nunito', system-ui, sans-serif" },
|
|
37
|
+
{ name: "nunito-sans", label: "Nunito Sans", family: "'Nunito Sans', system-ui, sans-serif" },
|
|
38
|
+
{ name: "rubik", label: "Rubik", family: "'Rubik', system-ui, sans-serif" },
|
|
39
|
+
{ name: "poppins", label: "Poppins", family: "'Poppins', system-ui, sans-serif" },
|
|
40
|
+
{ name: "manrope", label: "Manrope", family: "'Manrope', system-ui, sans-serif" },
|
|
41
|
+
{ name: "sora", label: "Sora", family: "'Sora', system-ui, sans-serif" },
|
|
42
|
+
{ name: "figtree", label: "Figtree", family: "'Figtree', system-ui, sans-serif" },
|
|
43
|
+
{ name: "be-vietnam-pro", label: "Be Vietnam Pro", family: "'Be Vietnam Pro', system-ui, sans-serif" },
|
|
44
|
+
// Sans-serif — neo-grotesque & neutral
|
|
45
|
+
{ name: "open-sans", label: "Open Sans", family: "'Open Sans', system-ui, sans-serif" },
|
|
46
|
+
{ name: "roboto", label: "Roboto", family: "'Roboto', system-ui, sans-serif" },
|
|
47
|
+
{ name: "lato", label: "Lato", family: "'Lato', system-ui, sans-serif" },
|
|
48
|
+
{ name: "montserrat", label: "Montserrat", family: "'Montserrat', system-ui, sans-serif" },
|
|
49
|
+
{ name: "raleway", label: "Raleway", family: "'Raleway', system-ui, sans-serif" },
|
|
50
|
+
{ name: "work-sans", label: "Work Sans", family: "'Work Sans', system-ui, sans-serif" },
|
|
51
|
+
{ name: "source-sans-3", label: "Source Sans 3", family: "'Source Sans 3', system-ui, sans-serif" },
|
|
52
|
+
{ name: "barlow", label: "Barlow", family: "'Barlow', system-ui, sans-serif" },
|
|
53
|
+
{ name: "red-hat-display", label: "Red Hat Display", family: "'Red Hat Display', system-ui, sans-serif" },
|
|
54
|
+
{ name: "red-hat-text", label: "Red Hat Text", family: "'Red Hat Text', system-ui, sans-serif" },
|
|
55
|
+
{ name: "space-grotesk", label: "Space Grotesk", family: "'Space Grotesk', system-ui, sans-serif" },
|
|
56
|
+
{ name: "archivo", label: "Archivo", family: "'Archivo', system-ui, sans-serif" },
|
|
57
|
+
{ name: "overpass", label: "Overpass", family: "'Overpass', system-ui, sans-serif" },
|
|
58
|
+
{ name: "urbanist", label: "Urbanist", family: "'Urbanist', system-ui, sans-serif" },
|
|
59
|
+
{ name: "lexend", label: "Lexend", family: "'Lexend', system-ui, sans-serif" },
|
|
60
|
+
// Serif — editorial & elegant
|
|
61
|
+
{ name: "playfair-display", label: "Playfair Display", family: "'Playfair Display', Georgia, serif" },
|
|
62
|
+
{ name: "lora", label: "Lora", family: "'Lora', Georgia, serif" },
|
|
63
|
+
{ name: "merriweather", label: "Merriweather", family: "'Merriweather', Georgia, serif" },
|
|
64
|
+
{ name: "dm-serif-display", label: "DM Serif Display", family: "'DM Serif Display', Georgia, serif" },
|
|
65
|
+
{ name: "dm-serif-text", label: "DM Serif Text", family: "'DM Serif Text', Georgia, serif" },
|
|
66
|
+
{ name: "fraunces", label: "Fraunces", family: "'Fraunces', Georgia, serif" },
|
|
67
|
+
{ name: "source-serif-4", label: "Source Serif 4", family: "'Source Serif 4', Georgia, serif" },
|
|
68
|
+
{ name: "bitter", label: "Bitter", family: "'Bitter', Georgia, serif" },
|
|
69
|
+
{ name: "crimson-pro", label: "Crimson Pro", family: "'Crimson Pro', Georgia, serif" },
|
|
70
|
+
{ name: "libre-baskerville", label: "Libre Baskerville", family: "'Libre Baskerville', Georgia, serif" },
|
|
71
|
+
{ name: "eb-garamond", label: "EB Garamond", family: "'EB Garamond', Georgia, serif" },
|
|
72
|
+
{ name: "cormorant", label: "Cormorant", family: "'Cormorant', Georgia, serif" },
|
|
73
|
+
{ name: "instrument-serif", label: "Instrument Serif", family: "'Instrument Serif', Georgia, serif" },
|
|
74
|
+
{ name: "young-serif", label: "Young Serif", family: "'Young Serif', Georgia, serif" },
|
|
75
|
+
// Monospace
|
|
76
|
+
{ name: "jetbrains-mono", label: "JetBrains Mono", family: "'JetBrains Mono', ui-monospace, monospace" },
|
|
77
|
+
{ name: "fira-code", label: "Fira Code", family: "'Fira Code', ui-monospace, monospace" },
|
|
78
|
+
{ name: "source-code-pro", label: "Source Code Pro", family: "'Source Code Pro', ui-monospace, monospace" },
|
|
79
|
+
{ name: "ibm-plex-mono", label: "IBM Plex Mono", family: "'IBM Plex Mono', ui-monospace, monospace" },
|
|
80
|
+
{ name: "space-mono", label: "Space Mono", family: "'Space Mono', ui-monospace, monospace" },
|
|
81
|
+
// System
|
|
82
|
+
{ name: "system", label: "System Default", family: "system-ui, -apple-system, sans-serif" },
|
|
83
|
+
];
|
|
84
|
+
const RADIUS_OPTIONS = [
|
|
85
|
+
{ label: "None (0)", value: 0 },
|
|
86
|
+
{ label: "Small (0.25rem)", value: 0.25 },
|
|
87
|
+
{ label: "Medium (0.5rem)", value: 0.5 },
|
|
88
|
+
{ label: "Large (0.75rem)", value: 0.75 },
|
|
89
|
+
{ label: "Full (1rem)", value: 1.0 },
|
|
90
|
+
];
|
|
23
91
|
function discoverThemes(registryDir) {
|
|
24
92
|
if (registryDir) {
|
|
25
93
|
const themesDir = path.join(registryDir, "packages", "tokens", "src", "themes");
|
|
@@ -55,6 +123,27 @@ export async function promptInitConfig(registryDir) {
|
|
|
55
123
|
choices: themes.map((t) => ({ title: t, value: t })),
|
|
56
124
|
initial: 0,
|
|
57
125
|
},
|
|
126
|
+
{
|
|
127
|
+
type: "autocomplete",
|
|
128
|
+
name: "fontBody",
|
|
129
|
+
message: "Which font for body text?",
|
|
130
|
+
choices: FONT_PRESETS.map((f) => ({ title: f.label, value: f.name })),
|
|
131
|
+
initial: 0,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "autocomplete",
|
|
135
|
+
name: "fontHeading",
|
|
136
|
+
message: "Which font for headings?",
|
|
137
|
+
choices: FONT_PRESETS.map((f) => ({ title: f.label, value: f.name })),
|
|
138
|
+
initial: 0,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
type: "select",
|
|
142
|
+
name: "radius",
|
|
143
|
+
message: "Which border radius would you like to use?",
|
|
144
|
+
choices: RADIUS_OPTIONS.map((r) => ({ title: r.label, value: r.value })),
|
|
145
|
+
initial: 2,
|
|
146
|
+
},
|
|
58
147
|
{
|
|
59
148
|
type: "text",
|
|
60
149
|
name: "importAlias",
|
|
@@ -117,6 +206,11 @@ export function buildComponentsJson(config, repoUrl) {
|
|
|
117
206
|
utils: config.utilsAlias,
|
|
118
207
|
},
|
|
119
208
|
theme: config.theme,
|
|
209
|
+
font: {
|
|
210
|
+
body: config.fontBody,
|
|
211
|
+
heading: config.fontHeading,
|
|
212
|
+
},
|
|
213
|
+
radius: config.radius,
|
|
120
214
|
tanstack: {
|
|
121
215
|
router: config.tanstackRouter,
|
|
122
216
|
query: config.tanstackQuery,
|
|
@@ -138,22 +232,56 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
138
232
|
}
|
|
139
233
|
`;
|
|
140
234
|
}
|
|
141
|
-
|
|
235
|
+
function getFontFamily(font) {
|
|
236
|
+
const preset = FONT_PRESETS.find((f) => f.name === font);
|
|
237
|
+
return preset?.family ?? "'Outfit', system-ui, sans-serif";
|
|
238
|
+
}
|
|
239
|
+
export function getLocalTailwindCssTemplate(theme, fontBody, fontHeading, radius) {
|
|
142
240
|
return `@import "tailwindcss";
|
|
143
241
|
@import "./styles/tokens/index.css";
|
|
144
242
|
@import "./styles/tokens/themes/${theme}.css";
|
|
145
243
|
@import "./styles/tokens/presets/typography.css";
|
|
146
244
|
@import "./styles/tokens/presets/animations.css";
|
|
245
|
+
|
|
246
|
+
:root {
|
|
247
|
+
--radius: ${radius}rem;
|
|
248
|
+
--font-body: ${getFontFamily(fontBody)};
|
|
249
|
+
--font-heading: ${getFontFamily(fontHeading)};
|
|
250
|
+
}
|
|
147
251
|
`;
|
|
148
252
|
}
|
|
149
|
-
export function getLegacyTailwindCssTemplate(theme) {
|
|
253
|
+
export function getLegacyTailwindCssTemplate(theme, fontBody, fontHeading, radius) {
|
|
150
254
|
return `@import "tailwindcss";
|
|
151
255
|
@import "@company/tokens";
|
|
152
256
|
@import "@company/tokens/themes/${theme}.css";
|
|
153
257
|
@import "@company/tokens/presets/typography.css";
|
|
154
258
|
@import "@company/tokens/presets/animations.css";
|
|
259
|
+
|
|
260
|
+
:root {
|
|
261
|
+
--radius: ${radius}rem;
|
|
262
|
+
--font-body: ${getFontFamily(fontBody)};
|
|
263
|
+
--font-heading: ${getFontFamily(fontHeading)};
|
|
264
|
+
}
|
|
155
265
|
`;
|
|
156
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Strip the `[data-theme="<name>"]` selector from theme CSS so it applies
|
|
269
|
+
* directly on `:root` / `.dark`. This is used when copying a single theme
|
|
270
|
+
* for a project — the theme becomes the default without needing a
|
|
271
|
+
* `data-theme` attribute on the HTML element.
|
|
272
|
+
*/
|
|
273
|
+
export function normalizeThemeCss(css, theme) {
|
|
274
|
+
// Replace `:root[data-theme="<name>"],\n[data-theme="<name>"]` → `:root`
|
|
275
|
+
const rootSelector = new RegExp(`:root\\[data-theme="${theme}"\\],?\\s*\\n?\\[data-theme="${theme}"\\]`, "g");
|
|
276
|
+
let normalized = css.replace(rootSelector, ":root");
|
|
277
|
+
// Replace `.dark[data-theme="<name>"],\n[data-theme="<name>"].dark` → `.dark`
|
|
278
|
+
const darkSelector = new RegExp(`\\.dark\\[data-theme="${theme}"\\],?\\s*\\n?\\[data-theme="${theme}"\\]\\.dark`, "g");
|
|
279
|
+
normalized = normalized.replace(darkSelector, ".dark");
|
|
280
|
+
// Catch any remaining standalone `[data-theme="<name>"]` selectors
|
|
281
|
+
const standaloneSelector = new RegExp(`\\[data-theme="${theme}"\\]`, "g");
|
|
282
|
+
normalized = normalized.replace(standaloneSelector, "");
|
|
283
|
+
return normalized;
|
|
284
|
+
}
|
|
157
285
|
function copyDirRecursive(src, dest) {
|
|
158
286
|
const copied = [];
|
|
159
287
|
if (!fs.existsSync(src))
|
|
@@ -187,7 +315,7 @@ function copyTokensToProject(registryDir, targetDir, theme) {
|
|
|
187
315
|
copied.push(`src/styles/tokens/${file}`);
|
|
188
316
|
}
|
|
189
317
|
}
|
|
190
|
-
// Copy selected theme
|
|
318
|
+
// Copy selected theme (normalized so it applies without data-theme attribute)
|
|
191
319
|
const themesSrc = path.join(tokensSrc, "themes");
|
|
192
320
|
const themesDest = path.join(tokensDest, "themes");
|
|
193
321
|
if (fs.existsSync(themesSrc)) {
|
|
@@ -195,7 +323,9 @@ function copyTokensToProject(registryDir, targetDir, theme) {
|
|
|
195
323
|
const themeFile = `${theme}.css`;
|
|
196
324
|
const themeSrc = path.join(themesSrc, themeFile);
|
|
197
325
|
if (fs.existsSync(themeSrc)) {
|
|
198
|
-
fs.
|
|
326
|
+
const rawCss = fs.readFileSync(themeSrc, "utf-8");
|
|
327
|
+
const normalizedCss = normalizeThemeCss(rawCss, theme);
|
|
328
|
+
fs.writeFileSync(path.join(themesDest, themeFile), normalizedCss);
|
|
199
329
|
copied.push(`src/styles/tokens/themes/${themeFile}`);
|
|
200
330
|
}
|
|
201
331
|
}
|
|
@@ -241,11 +371,11 @@ export async function runInit(config, targetDir, repoUrl) {
|
|
|
241
371
|
const registryDir = getCacheDir();
|
|
242
372
|
const tokenFiles = copyTokensToProject(registryDir, targetDir, config.theme);
|
|
243
373
|
filesCreated.push(...tokenFiles);
|
|
244
|
-
fs.writeFileSync(cssPath, getLocalTailwindCssTemplate(config.theme));
|
|
374
|
+
fs.writeFileSync(cssPath, getLocalTailwindCssTemplate(config.theme, config.fontBody, config.fontHeading, config.radius));
|
|
245
375
|
}
|
|
246
376
|
else {
|
|
247
377
|
// Local mode: reference @company/tokens package
|
|
248
|
-
fs.writeFileSync(cssPath, getLegacyTailwindCssTemplate(config.theme));
|
|
378
|
+
fs.writeFileSync(cssPath, getLegacyTailwindCssTemplate(config.theme, config.fontBody, config.fontHeading, config.radius));
|
|
249
379
|
}
|
|
250
380
|
filesCreated.push("src/index.css");
|
|
251
381
|
return { success: true, filesCreated };
|
|
@@ -1 +1 @@
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MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAO7E;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAM1E;AAED,wBAAgB,iBAAiB,CAC/B,mBAAmB,EAAE,kBAAkB,EAAE,EACzC,eAAe,EAAE,MAAM,GACtB,MAAM,CAuBR;AAOD,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBhE;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAcnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/commands/theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/commands/theme.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMhF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgB3F;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAoDlE;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBnF"}
|
package/dist/commands/theme.js
CHANGED
|
@@ -2,7 +2,22 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import ora from "ora";
|
|
5
|
-
const AVAILABLE_THEMES = [
|
|
5
|
+
const AVAILABLE_THEMES = [
|
|
6
|
+
"monday",
|
|
7
|
+
"linear",
|
|
8
|
+
"notion",
|
|
9
|
+
"vercel",
|
|
10
|
+
"inai",
|
|
11
|
+
"anthropic",
|
|
12
|
+
"shadcn-default",
|
|
13
|
+
"shadcn-blue",
|
|
14
|
+
"shadcn-green",
|
|
15
|
+
"shadcn-orange",
|
|
16
|
+
"shadcn-red",
|
|
17
|
+
"shadcn-rose",
|
|
18
|
+
"shadcn-violet",
|
|
19
|
+
"shadcn-yellow",
|
|
20
|
+
];
|
|
6
21
|
export function resolveThemesDir(rootDir) {
|
|
7
22
|
return path.join(rootDir, "packages", "tokens", "src", "themes");
|
|
8
23
|
}
|
package/package.json
CHANGED