myoperator-ui 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +128 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -220,7 +220,86 @@ import fs2 from "fs-extra";
220
220
  import path2 from "path";
221
221
  import prompts2 from "prompts";
222
222
  import ora2 from "ora";
223
- var CSS_VARIABLES = `@tailwind base;
223
+ var CSS_VARIABLES_V4 = `@import "tailwindcss";
224
+
225
+ @theme {
226
+ --color-background: hsl(0 0% 100%);
227
+ --color-foreground: hsl(222.2 84% 4.9%);
228
+ --color-card: hsl(0 0% 100%);
229
+ --color-card-foreground: hsl(222.2 84% 4.9%);
230
+ --color-popover: hsl(0 0% 100%);
231
+ --color-popover-foreground: hsl(222.2 84% 4.9%);
232
+ --color-primary: hsl(222.2 47.4% 11.2%);
233
+ --color-primary-foreground: hsl(210 40% 98%);
234
+ --color-secondary: hsl(210 40% 96.1%);
235
+ --color-secondary-foreground: hsl(222.2 47.4% 11.2%);
236
+ --color-muted: hsl(210 40% 96.1%);
237
+ --color-muted-foreground: hsl(215.4 16.3% 46.9%);
238
+ --color-accent: hsl(210 40% 96.1%);
239
+ --color-accent-foreground: hsl(222.2 47.4% 11.2%);
240
+ --color-destructive: hsl(0 84.2% 60.2%);
241
+ --color-destructive-foreground: hsl(210 40% 98%);
242
+ --color-border: hsl(214.3 31.8% 91.4%);
243
+ --color-input: hsl(214.3 31.8% 91.4%);
244
+ --color-ring: hsl(222.2 84% 4.9%);
245
+ --radius: 0.5rem;
246
+ }
247
+
248
+ :root {
249
+ --background: 0 0% 100%;
250
+ --foreground: 222.2 84% 4.9%;
251
+ --card: 0 0% 100%;
252
+ --card-foreground: 222.2 84% 4.9%;
253
+ --popover: 0 0% 100%;
254
+ --popover-foreground: 222.2 84% 4.9%;
255
+ --primary: 222.2 47.4% 11.2%;
256
+ --primary-foreground: 210 40% 98%;
257
+ --secondary: 210 40% 96.1%;
258
+ --secondary-foreground: 222.2 47.4% 11.2%;
259
+ --muted: 210 40% 96.1%;
260
+ --muted-foreground: 215.4 16.3% 46.9%;
261
+ --accent: 210 40% 96.1%;
262
+ --accent-foreground: 222.2 47.4% 11.2%;
263
+ --destructive: 0 84.2% 60.2%;
264
+ --destructive-foreground: 210 40% 98%;
265
+ --border: 214.3 31.8% 91.4%;
266
+ --input: 214.3 31.8% 91.4%;
267
+ --ring: 222.2 84% 4.9%;
268
+ --radius: 0.5rem;
269
+ }
270
+
271
+ .dark {
272
+ --background: 222.2 84% 4.9%;
273
+ --foreground: 210 40% 98%;
274
+ --card: 222.2 84% 4.9%;
275
+ --card-foreground: 210 40% 98%;
276
+ --popover: 222.2 84% 4.9%;
277
+ --popover-foreground: 210 40% 98%;
278
+ --primary: 210 40% 98%;
279
+ --primary-foreground: 222.2 47.4% 11.2%;
280
+ --secondary: 217.2 32.6% 17.5%;
281
+ --secondary-foreground: 210 40% 98%;
282
+ --muted: 217.2 32.6% 17.5%;
283
+ --muted-foreground: 215 20.2% 65.1%;
284
+ --accent: 217.2 32.6% 17.5%;
285
+ --accent-foreground: 210 40% 98%;
286
+ --destructive: 0 62.8% 30.6%;
287
+ --destructive-foreground: 210 40% 98%;
288
+ --border: 217.2 32.6% 17.5%;
289
+ --input: 217.2 32.6% 17.5%;
290
+ --ring: 212.7 26.8% 83.9%;
291
+ }
292
+
293
+ * {
294
+ border-color: hsl(var(--border));
295
+ }
296
+
297
+ body {
298
+ background-color: hsl(var(--background));
299
+ color: hsl(var(--foreground));
300
+ }
301
+ `;
302
+ var CSS_VARIABLES_V3 = `@tailwind base;
224
303
  @tailwind components;
225
304
  @tailwind utilities;
226
305
 
@@ -387,6 +466,16 @@ async function init() {
387
466
  }
388
467
  }
389
468
  const response = await prompts2([
469
+ {
470
+ type: "select",
471
+ name: "tailwindVersion",
472
+ message: "Which Tailwind CSS version are you using?",
473
+ choices: [
474
+ { title: "Tailwind CSS v4 (latest)", value: "v4" },
475
+ { title: "Tailwind CSS v3", value: "v3" }
476
+ ],
477
+ initial: 0
478
+ },
390
479
  {
391
480
  type: "text",
392
481
  name: "componentsPath",
@@ -400,7 +489,7 @@ async function init() {
400
489
  initial: "src/lib/utils.ts"
401
490
  },
402
491
  {
403
- type: "text",
492
+ type: (prev, values) => values.tailwindVersion === "v3" ? "text" : null,
404
493
  name: "tailwindConfig",
405
494
  message: "Where is your tailwind.config.js?",
406
495
  initial: "tailwind.config.js"
@@ -444,10 +533,11 @@ export function cn(...inputs: ClassValue[]) {
444
533
  const componentsPath = path2.join(cwd, response.componentsPath);
445
534
  await fs2.ensureDir(componentsPath);
446
535
  const globalCssPath = path2.join(cwd, response.globalCss);
536
+ const cssContent = response.tailwindVersion === "v4" ? CSS_VARIABLES_V4 : CSS_VARIABLES_V3;
447
537
  let cssUpdated = false;
448
538
  if (!await fs2.pathExists(globalCssPath)) {
449
539
  await fs2.ensureDir(path2.dirname(globalCssPath));
450
- await fs2.writeFile(globalCssPath, CSS_VARIABLES);
540
+ await fs2.writeFile(globalCssPath, cssContent);
451
541
  cssUpdated = true;
452
542
  } else {
453
543
  const existingCss = await fs2.readFile(globalCssPath, "utf-8");
@@ -461,30 +551,32 @@ export function cn(...inputs: ClassValue[]) {
461
551
  });
462
552
  spinner.start("Initializing project...");
463
553
  if (updateCss) {
464
- await fs2.writeFile(globalCssPath, CSS_VARIABLES);
554
+ await fs2.writeFile(globalCssPath, cssContent);
465
555
  cssUpdated = true;
466
556
  }
467
557
  }
468
558
  }
469
- const tailwindConfigPath = path2.join(cwd, response.tailwindConfig);
470
559
  let tailwindUpdated = false;
471
- if (!await fs2.pathExists(tailwindConfigPath)) {
472
- await fs2.writeFile(tailwindConfigPath, TAILWIND_CONFIG);
473
- tailwindUpdated = true;
474
- } else {
475
- const existingConfig = await fs2.readFile(tailwindConfigPath, "utf-8");
476
- if (!existingConfig.includes("hsl(var(--destructive))") && !existingConfig.includes("hsl(var(--ring))")) {
477
- spinner.stop();
478
- const { updateTailwind } = await prompts2({
479
- type: "confirm",
480
- name: "updateTailwind",
481
- message: `${response.tailwindConfig} exists. Update with myOperator UI theme colors?`,
482
- initial: true
483
- });
484
- spinner.start("Initializing project...");
485
- if (updateTailwind) {
486
- await fs2.writeFile(tailwindConfigPath, TAILWIND_CONFIG);
487
- tailwindUpdated = true;
560
+ if (response.tailwindVersion === "v3" && response.tailwindConfig) {
561
+ const tailwindConfigPath = path2.join(cwd, response.tailwindConfig);
562
+ if (!await fs2.pathExists(tailwindConfigPath)) {
563
+ await fs2.writeFile(tailwindConfigPath, TAILWIND_CONFIG);
564
+ tailwindUpdated = true;
565
+ } else {
566
+ const existingConfig = await fs2.readFile(tailwindConfigPath, "utf-8");
567
+ if (!existingConfig.includes("hsl(var(--destructive))") && !existingConfig.includes("hsl(var(--ring))")) {
568
+ spinner.stop();
569
+ const { updateTailwind } = await prompts2({
570
+ type: "confirm",
571
+ name: "updateTailwind",
572
+ message: `${response.tailwindConfig} exists. Update with myOperator UI theme colors?`,
573
+ initial: true
574
+ });
575
+ spinner.start("Initializing project...");
576
+ if (updateTailwind) {
577
+ await fs2.writeFile(tailwindConfigPath, TAILWIND_CONFIG);
578
+ tailwindUpdated = true;
579
+ }
488
580
  }
489
581
  }
490
582
  }
@@ -529,11 +621,20 @@ export function cn(...inputs: ClassValue[]) {
529
621
  console.log("");
530
622
  console.log(chalk2.bold(" Next steps:\n"));
531
623
  console.log(" 1. Install core dependencies:");
532
- console.log(chalk2.cyan(" npm install clsx tailwind-merge class-variance-authority @radix-ui/react-slot lucide-react tailwindcss-animate\n"));
533
- console.log(" 2. Install PostCSS plugin (if not already installed):");
534
- console.log(chalk2.cyan(" npm install -D @tailwindcss/postcss\n"));
535
- console.log(" 3. Add your first component:");
536
- console.log(chalk2.cyan(" npx myoperator-ui add button\n"));
624
+ if (response.tailwindVersion === "v4") {
625
+ console.log(chalk2.cyan(" npm install clsx tailwind-merge class-variance-authority @radix-ui/react-slot lucide-react\n"));
626
+ } else {
627
+ console.log(chalk2.cyan(" npm install clsx tailwind-merge class-variance-authority @radix-ui/react-slot lucide-react tailwindcss-animate\n"));
628
+ }
629
+ if (response.tailwindVersion === "v4") {
630
+ console.log(" 2. Add your first component:");
631
+ console.log(chalk2.cyan(" npx myoperator-ui add button\n"));
632
+ } else {
633
+ console.log(" 2. Install PostCSS plugin (if not already installed):");
634
+ console.log(chalk2.cyan(" npm install -D @tailwindcss/postcss\n"));
635
+ console.log(" 3. Add your first component:");
636
+ console.log(chalk2.cyan(" npx myoperator-ui add button\n"));
637
+ }
537
638
  } catch (error) {
538
639
  spinner.fail("Failed to initialize project");
539
640
  console.error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myoperator-ui",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "CLI for adding myOperator UI components to your project",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",