kesp-ui 1.0.0 → 1.0.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/index.js CHANGED
@@ -5,6 +5,7 @@ const axios = require("axios");
5
5
  const fs = require("fs-extra");
6
6
  const path = require("path");
7
7
  const chalk = require("chalk");
8
+ const { execSync } = require("child_process");
8
9
 
9
10
  // ── Replace with your actual GitHub username ──────────────────────────────────
10
11
  const GITHUB_USER = "Sankalp-Pradhan";
@@ -12,13 +13,13 @@ const REPO_NAME = "kespUI";
12
13
  const BRANCH = "main";
13
14
 
14
15
  const REGISTRY_URL = `https://raw.githubusercontent.com/${GITHUB_USER}/${REPO_NAME}/${BRANCH}/registry.json`;
15
- const BASE_URL = `https://raw.githubusercontent.com/${GITHUB_USER}/${REPO_NAME}/${BRANCH}/registry`;
16
16
 
17
17
  program
18
18
  .name("kesp-ui")
19
19
  .description("Add kesp-ui components to your project")
20
20
  .version("1.0.0");
21
21
 
22
+
22
23
  // ── LIST command ──────────────────────────────────────────────────────────────
23
24
  program
24
25
  .command("list")
@@ -31,7 +32,7 @@ program
31
32
  registry.items.forEach((item) => {
32
33
  console.log(` ${chalk.green("◆")} ${chalk.bold(item.name)}`);
33
34
  console.log(` ${chalk.gray(item.description)}`);
34
- if (item.dependencies.length > 0) {
35
+ if (item.dependencies?.length) {
35
36
  console.log(` ${chalk.yellow("deps:")} ${item.dependencies.join(", ")}`);
36
37
  }
37
38
  console.log();
@@ -41,6 +42,7 @@ program
41
42
  }
42
43
  });
43
44
 
45
+
44
46
  // ── ADD command ───────────────────────────────────────────────────────────────
45
47
  program
46
48
  .command("add <component>")
@@ -58,40 +60,84 @@ program
58
60
  process.exit(1);
59
61
  }
60
62
 
61
- // Download each file
63
+ // ── Download files ──────────────────────────────────────────────────────
62
64
  for (const file of found.files) {
63
65
  const fileName = path.basename(file.path);
64
- const fileUrl = `${BASE_URL}/${fileName}`;
66
+ const fileUrl = `https://raw.githubusercontent.com/${GITHUB_USER}/${REPO_NAME}/${BRANCH}/${file.path}`;
67
+ const destPath = path.join(process.cwd(), options.path, fileName);
68
+
69
+ // Prevent overwriting existing files (smart installer behavior)
70
+ if (fs.existsSync(destPath)) {
71
+ console.log(chalk.yellow(` ↷ ${fileName} already exists — skipping`));
72
+ continue;
73
+ }
74
+
65
75
  console.log(chalk.gray(` Downloading ${fileName}...`));
66
76
 
67
77
  const { data: content } = await axios.get(fileUrl);
68
78
 
69
- const destPath = path.join(process.cwd(), options.path, fileName);
70
79
  await fs.ensureDir(path.dirname(destPath));
71
80
  await fs.writeFile(destPath, content, "utf8");
72
81
 
73
82
  console.log(chalk.green(` ✔ ${fileName}`) + chalk.gray(` → ${options.path}/${fileName}`));
74
83
  }
75
84
 
76
- // Show dependency install hint
85
+ // ── Install registryDependencies (shadcn components) ──────────────────────
86
+ if (found.registryDependencies && found.registryDependencies.length > 0) {
87
+ console.log(chalk.cyan("\nInstalling registry dependencies (shadcn components)...\n"));
88
+
89
+ for (const dep of found.registryDependencies) {
90
+ console.log(chalk.gray(` Installing shadcn component: ${dep}...`));
91
+ try {
92
+ execSync(`npx shadcn@latest add ${dep} --yes`, {
93
+ stdio: "inherit",
94
+ cwd: process.cwd(),
95
+ });
96
+ console.log(chalk.green(` ✔ ${dep} installed`));
97
+ } catch {
98
+ console.log(chalk.yellow(` ⚠ Could not auto-install "${dep}". Run manually: npx shadcn@latest add ${dep}`));
99
+ }
100
+ }
101
+ }
102
+
103
+ // ── Install dependencies (AUTO DETECT PM) ───────────────────────────────
77
104
  if (found.dependencies && found.dependencies.length > 0) {
78
- console.log(
79
- chalk.yellow(`\n Install dependencies:\n`) +
80
- chalk.white(` npm install ${found.dependencies.join(" ")}\n`)
81
- );
82
- } else {
83
- console.log();
105
+ console.log(chalk.cyan("\nInstalling dependencies...\n"));
106
+
107
+ let pkgManager = "npm";
108
+
109
+ if (fs.existsSync(path.join(process.cwd(), "pnpm-lock.yaml"))) pkgManager = "pnpm";
110
+ else if (fs.existsSync(path.join(process.cwd(), "yarn.lock"))) pkgManager = "yarn";
111
+ else if (fs.existsSync(path.join(process.cwd(), "bun.lockb"))) pkgManager = "bun";
112
+
113
+ const installCmd =
114
+ pkgManager === "npm"
115
+ ? `npm install ${found.dependencies.join(" ")}`
116
+ : `${pkgManager} add ${found.dependencies.join(" ")}`;
117
+
118
+ try {
119
+ execSync(installCmd, {
120
+ stdio: "inherit",
121
+ cwd: process.cwd(),
122
+ });
123
+
124
+ console.log(chalk.green("\n✔ Dependencies installed\n"));
125
+ } catch {
126
+ console.log(chalk.red("Failed to install dependencies"));
127
+ }
84
128
  }
85
129
 
86
130
  console.log(chalk.green(`✔ Done! `) + chalk.gray(`Import with:`));
87
131
  console.log(
88
132
  chalk.white(` import ${toPascalCase(component)} from "@/components/ui/${component}";\n`)
89
133
  );
134
+
90
135
  } catch (err) {
91
136
  console.error(chalk.red("Error:"), err.message);
92
137
  }
93
138
  });
94
139
 
140
+
95
141
  // ── Helper ────────────────────────────────────────────────────────────────────
96
142
  function toPascalCase(str) {
97
143
  return str
@@ -100,4 +146,4 @@ function toPascalCase(str) {
100
146
  .join("");
101
147
  }
102
148
 
103
- program.parse();
149
+ program.parse();
package/package.json CHANGED
@@ -1,30 +1,37 @@
1
- {
2
- "name": "kesp-ui",
3
- "version": "1.0.0",
4
- "description": "CLI to add kesp-ui components to your project",
5
- "main": "index.js",
6
- "bin": {
7
- "kesp-ui": "./index.js"
8
- },
9
- "scripts": {
10
- "start": "node index.js"
11
- },
12
- "keywords": [
13
- "ui",
14
- "components",
15
- "react",
16
- "nextjs",
17
- "tailwindcss",
18
- "india",
19
- "aadhaar",
20
- "pan"
21
- ],
22
- "author": "yourusername",
23
- "license": "MIT",
24
- "dependencies": {
25
- "axios": "^1.6.0",
26
- "chalk": "^4.1.2",
27
- "commander": "^11.0.0",
28
- "fs-extra": "^11.2.0"
29
- }
30
- }
1
+ {
2
+ "name": "kesp-ui",
3
+ "version": "1.0.1",
4
+ "description": "CLI to add kesp-ui components to your project",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "kesp-ui": "./index.js"
8
+ },
9
+ "scripts": {
10
+ "start": "node index.js"
11
+ },
12
+ "keywords": [
13
+ "ui",
14
+ "components",
15
+ "react",
16
+ "nextjs",
17
+ "tailwindcss",
18
+ "india",
19
+ "aadhaar",
20
+ "pan"
21
+ ],
22
+ "author": "yourusername",
23
+ "license": "MIT",
24
+ "dependencies": {
25
+ "axios": "^1.6.0",
26
+ "chalk": "^4.1.2",
27
+ "commander": "^11.0.0",
28
+ "fs-extra": "^11.2.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^19.2.14",
32
+ "@types/react-dom": "^19.2.3",
33
+ "react": "^19.2.4",
34
+ "react-dom": "^19.2.4",
35
+ "typescript": "^5.9.3"
36
+ }
37
+ }
@@ -1,5 +1,7 @@
1
+ "use client"
2
+
1
3
  import React, { useState, useRef, useCallback } from "react";
2
- import { cn } from "@/lib/utils";
4
+ import { cn } from "./utils";
3
5
  import { Check, AlertCircle, CreditCard } from "lucide-react";
4
6
 
5
7
  // ─── Verhoeff Algorithm ───────────────────────────────────────────────────────
@@ -1,5 +1,7 @@
1
+ "use client"
2
+
1
3
  import React, { useState, useRef, useCallback } from "react";
2
- import { cn } from "@/lib/utils";
4
+ import { cn } from "./utils";
3
5
  import { Upload, X, Eye, EyeOff, ShieldCheck, AlertCircle } from "lucide-react";
4
6
 
5
7
  interface MaskedAadhaarUploadProps {
@@ -1,3 +1,5 @@
1
+ "use client"
2
+
1
3
  import { useState, useRef, useCallback, useEffect, KeyboardEvent, ClipboardEvent } from "react";
2
4
  import { Timer, RotateCcw, CheckCircle2, ShieldCheck } from "lucide-react";
3
5
  import { Button } from "@/components/ui/button";
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
package/registry.json CHANGED
@@ -10,9 +10,17 @@
10
10
  {
11
11
  "path": "registry/aadhaar-input.tsx",
12
12
  "type": "registry:ui"
13
+ },
14
+ {
15
+ "path": "registry/utils.ts",
16
+ "type": "registry:lib"
13
17
  }
14
18
  ],
15
- "dependencies": ["lucide-react"],
19
+ "dependencies": [
20
+ "lucide-react",
21
+ "clsx",
22
+ "tailwind-merge"
23
+ ],
16
24
  "devDependencies": [],
17
25
  "tailwind": {},
18
26
  "cssVars": {}
@@ -25,9 +33,16 @@
25
33
  {
26
34
  "path": "registry/pan-input.tsx",
27
35
  "type": "registry:ui"
36
+ },
37
+ {
38
+ "path": "registry/utils.ts",
39
+ "type": "registry:lib"
28
40
  }
29
41
  ],
30
- "dependencies": [],
42
+ "dependencies": [
43
+ "clsx",
44
+ "tailwind-merge"
45
+ ],
31
46
  "devDependencies": [],
32
47
  "tailwind": {},
33
48
  "cssVars": {}
@@ -40,12 +55,23 @@
40
55
  {
41
56
  "path": "registry/otp-input.tsx",
42
57
  "type": "registry:ui"
58
+ },
59
+ {
60
+ "path": "registry/utils.ts",
61
+ "type": "registry:lib"
43
62
  }
44
63
  ],
45
- "dependencies": ["lucide-react"],
64
+ "dependencies": [
65
+ "lucide-react",
66
+ "clsx",
67
+ "tailwind-merge"
68
+ ],
69
+ "registryDependencies": [
70
+ "button"
71
+ ],
46
72
  "devDependencies": [],
47
73
  "tailwind": {},
48
74
  "cssVars": {}
49
75
  }
50
76
  ]
51
- }
77
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ "moduleResolution": "node",
5
+ "target": "ES2020",
6
+ "skipLibCheck": true,
7
+ "esModuleInterop": true
8
+ },
9
+ "include": ["registry"]
10
+ }
File without changes