shadcn-ui-react 0.6.0 → 0.6.1

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/README.md CHANGED
@@ -18,6 +18,16 @@ pnpm add shadcn-ui-react
18
18
 
19
19
  ---
20
20
 
21
+ ### Tailwind IntelliSense (VS Code)
22
+
23
+ To enable Tailwind CSS IntelliSense to detect classes within `cn(...)` and other utilities:
24
+
25
+ ```bash
26
+ npx shadcn-ui-react init-vscode
27
+ ```
28
+
29
+ ---
30
+
21
31
  ## 🚀 Getting Started
22
32
 
23
33
  ### 1. Import Global Styles
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ const cmd = process.argv[2];
10
+
11
+ const uniq = (arr) => {
12
+ const seen = new Set();
13
+ const out = [];
14
+ for (const item of arr) {
15
+ const key = JSON.stringify(item);
16
+ if (seen.has(key)) continue;
17
+ seen.add(key);
18
+ out.push(item);
19
+ }
20
+ return out;
21
+ };
22
+
23
+ function ensureDir(dir) {
24
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
25
+ }
26
+
27
+ function readJson(p) {
28
+ if (!fs.existsSync(p)) return null;
29
+ try {
30
+ return JSON.parse(fs.readFileSync(p, "utf8"));
31
+ } catch (e) {
32
+ console.error(`❌ No pude leer JSON: ${p}`);
33
+ console.error(e?.message ?? e);
34
+ process.exit(1);
35
+ }
36
+ }
37
+
38
+ function writeJson(p, obj) {
39
+ fs.writeFileSync(p, JSON.stringify(obj, null, 2) + "\n", "utf8");
40
+ }
41
+
42
+ function initVscode() {
43
+ const tplPath = path.join(__dirname, "..", "templates", "vscode-settings.json");
44
+ const tpl = readJson(tplPath) ?? {};
45
+
46
+ const vscodeDir = path.join(process.cwd(), ".vscode");
47
+ const settingsPath = path.join(vscodeDir, "settings.json");
48
+
49
+ ensureDir(vscodeDir);
50
+
51
+ const current = readJson(settingsPath) ?? {};
52
+ const next = { ...current };
53
+
54
+ // classRegex (merge + dedupe)
55
+ const curRegex = current["tailwindCSS.experimental.classRegex"] ?? [];
56
+ const tplRegex = tpl["tailwindCSS.experimental.classRegex"] ?? [];
57
+ next["tailwindCSS.experimental.classRegex"] = uniq([
58
+ ...(Array.isArray(curRegex) ? curRegex : []),
59
+ ...(Array.isArray(tplRegex) ? tplRegex : [])
60
+ ]);
61
+
62
+ // includeLanguages (merge)
63
+ const curLang = current["tailwindCSS.includeLanguages"] ?? {};
64
+ const tplLang = tpl["tailwindCSS.includeLanguages"] ?? {};
65
+ next["tailwindCSS.includeLanguages"] = { ...(curLang || {}), ...(tplLang || {}) };
66
+
67
+ writeJson(settingsPath, next);
68
+ console.log("✅ Listo: actualizado .vscode/settings.json (Tailwind IntelliSense).");
69
+ }
70
+
71
+ function initExtensions() {
72
+ const vscodeDir = path.join(process.cwd(), ".vscode");
73
+ const extPath = path.join(vscodeDir, "extensions.json");
74
+ ensureDir(vscodeDir);
75
+
76
+ const current = readJson(extPath) ?? {};
77
+ const recs = Array.isArray(current.recommendations) ? current.recommendations : [];
78
+ const add = "bradlc.vscode-tailwindcss";
79
+
80
+ const next = {
81
+ ...current,
82
+ recommendations: Array.from(new Set([...recs, add]))
83
+ };
84
+
85
+ writeJson(extPath, next);
86
+ console.log("✅ Listo: actualizado .vscode/extensions.json (recomendación Tailwind CSS).");
87
+ }
88
+
89
+ switch (cmd) {
90
+ case "init-vscode":
91
+ initVscode();
92
+ initExtensions();
93
+ break;
94
+ default:
95
+ console.log(`Uso:
96
+ npx shadcn-ui-react init-vscode
97
+ `);
98
+ process.exit(cmd ? 1 : 0);
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadcn-ui-react",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "private": false,
5
5
  "author": "Bleker Cordova <bleker@gliyen.com>",
6
6
  "description": "A collection of components for building beautiful and accessible user interfaces with React and Tailwind CSS.",
@@ -14,8 +14,13 @@
14
14
  "style": "dist/style.css",
15
15
  "files": [
16
16
  "dist",
17
- "dist/style.css"
17
+ "dist/style.css",
18
+ "bin",
19
+ "templates"
18
20
  ],
21
+ "bin": {
22
+ "shadcn-ui-react": "./bin/shadcn-ui-react.mjs"
23
+ },
19
24
  "sideEffects": [
20
25
  "dist/*.css"
21
26
  ],
@@ -0,0 +1,11 @@
1
+ {
2
+ "tailwindCSS.experimental.classRegex": [
3
+ ["cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*?)[\"'`]"],
4
+ ["classNames\\s*=\\s*\\{\\{([\\s\\S]*?)\\}\\}", "[\"'`]([^\"'`]*?)[\"'`]"]
5
+ ],
6
+ "tailwindCSS.includeLanguages": {
7
+ "typescript": "javascript",
8
+ "typescriptreact": "javascript",
9
+ "javascriptreact": "javascript"
10
+ }
11
+ }