praxys-ui 0.1.0

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,232 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import chalk from "chalk";
4
+ import ora from "ora";
5
+ import prompts from "prompts";
6
+ import { existsSync, mkdirSync, writeFileSync } from "fs";
7
+ import { join } from "path";
8
+ import { execSync } from "child_process";
9
+ const VERSION = "0.1.0";
10
+ // ─── Utility file contents ──────────────────────────────
11
+ const UTILS_CONTENT = `import { clsx, type ClassValue } from "clsx";
12
+ import { twMerge } from "tailwind-merge";
13
+
14
+ export function cn(...inputs: ClassValue[]) {
15
+ return twMerge(clsx(inputs));
16
+ }
17
+ `;
18
+ // ─── Component registry (slug → raw GitHub URL) ─────────
19
+ const COMPONENTS_BASE_URL = "https://raw.githubusercontent.com/sushanttverma/Praxys-UI/main/app/components/ui";
20
+ const COMPONENT_LIST = [
21
+ "animated-button",
22
+ "animated-hero",
23
+ "animated-number",
24
+ "creepy-button",
25
+ "displacement-text",
26
+ "expandable-bento-grid",
27
+ "flip-fade-text",
28
+ "flip-text",
29
+ "folder-preview",
30
+ "glass-dock",
31
+ "glow-border-card",
32
+ "interactive-book",
33
+ "light-lines",
34
+ "line-hover-link",
35
+ "liquid-metal",
36
+ "liquid-ocean",
37
+ "logo-slider",
38
+ "masked-avatars",
39
+ "perspective-grid",
40
+ "reveal-loader",
41
+ "social-flip-button",
42
+ "spotlight-navbar",
43
+ "staggered-grid",
44
+ "testimonials-card",
45
+ ];
46
+ // ─── Helpers ─────────────────────────────────────────────
47
+ function detectPackageManager() {
48
+ const cwd = process.cwd();
49
+ if (existsSync(join(cwd, "bun.lockb")) || existsSync(join(cwd, "bun.lock")))
50
+ return "bun";
51
+ if (existsSync(join(cwd, "pnpm-lock.yaml")))
52
+ return "pnpm";
53
+ if (existsSync(join(cwd, "yarn.lock")))
54
+ return "yarn";
55
+ return "npm";
56
+ }
57
+ function installCmd(pm, deps) {
58
+ const d = deps.join(" ");
59
+ switch (pm) {
60
+ case "pnpm":
61
+ return `pnpm add ${d}`;
62
+ case "yarn":
63
+ return `yarn add ${d}`;
64
+ case "bun":
65
+ return `bun add ${d}`;
66
+ default:
67
+ return `npm install ${d}`;
68
+ }
69
+ }
70
+ function ensureDir(dir) {
71
+ if (!existsSync(dir)) {
72
+ mkdirSync(dir, { recursive: true });
73
+ }
74
+ }
75
+ async function fetchComponent(slug) {
76
+ const url = `${COMPONENTS_BASE_URL}/${slug}.tsx`;
77
+ const res = await fetch(url);
78
+ if (!res.ok) {
79
+ throw new Error(`Failed to fetch ${slug}: ${res.status} ${res.statusText}`);
80
+ }
81
+ return res.text();
82
+ }
83
+ // ─── Commands ────────────────────────────────────────────
84
+ const program = new Command();
85
+ program
86
+ .name("praxys-ui")
87
+ .description("CLI for scaffolding Praxys UI components")
88
+ .version(VERSION);
89
+ // ── init ─────────────────────────────────────────────────
90
+ program
91
+ .command("init")
92
+ .description("Initialize Praxys UI in your project")
93
+ .action(async () => {
94
+ console.log("");
95
+ console.log(chalk.bold(` ${chalk.hex("#E84E2D")("Praxys UI")} — init`));
96
+ console.log("");
97
+ // Detect package manager
98
+ const pm = detectPackageManager();
99
+ console.log(chalk.dim(` Package manager: ${pm}`));
100
+ // Ask for component directory
101
+ const { componentDir } = await prompts({
102
+ type: "text",
103
+ name: "componentDir",
104
+ message: "Where should components be installed?",
105
+ initial: "components/ui",
106
+ });
107
+ if (!componentDir) {
108
+ console.log(chalk.yellow(" Cancelled."));
109
+ return;
110
+ }
111
+ const { utilsDir } = await prompts({
112
+ type: "text",
113
+ name: "utilsDir",
114
+ message: "Where should the utils file be created?",
115
+ initial: "lib",
116
+ });
117
+ if (!utilsDir) {
118
+ console.log(chalk.yellow(" Cancelled."));
119
+ return;
120
+ }
121
+ // 1. Install dependencies
122
+ const spinner = ora("Installing dependencies...").start();
123
+ try {
124
+ const deps = ["clsx", "tailwind-merge", "framer-motion"];
125
+ execSync(installCmd(pm, deps), { stdio: "pipe", cwd: process.cwd() });
126
+ spinner.succeed("Dependencies installed");
127
+ }
128
+ catch {
129
+ spinner.fail("Failed to install dependencies");
130
+ console.log(chalk.dim(" Run manually: " +
131
+ installCmd(pm, ["clsx", "tailwind-merge", "framer-motion"])));
132
+ }
133
+ // 2. Create utils file
134
+ const utilsSpinner = ora("Creating utility files...").start();
135
+ try {
136
+ const utilsPath = join(process.cwd(), utilsDir);
137
+ ensureDir(utilsPath);
138
+ const utilsFile = join(utilsPath, "utils.ts");
139
+ if (existsSync(utilsFile)) {
140
+ utilsSpinner.warn("utils.ts already exists, skipping");
141
+ }
142
+ else {
143
+ writeFileSync(utilsFile, UTILS_CONTENT, "utf-8");
144
+ utilsSpinner.succeed(`Created ${utilsDir}/utils.ts`);
145
+ }
146
+ }
147
+ catch {
148
+ utilsSpinner.fail("Failed to create utils file");
149
+ }
150
+ // 3. Create component directory
151
+ const compPath = join(process.cwd(), componentDir);
152
+ ensureDir(compPath);
153
+ console.log("");
154
+ console.log(chalk.green(" ✓ Praxys UI initialized!"));
155
+ console.log("");
156
+ console.log(chalk.dim(` Add components with: ${chalk.bold("npx praxys-ui add <component>")}`));
157
+ console.log(chalk.dim(` Browse components: ${chalk.bold("https://github.com/sushanttverma/Praxys-UI")}`));
158
+ console.log("");
159
+ });
160
+ // ── add <component> ──────────────────────────────────────
161
+ program
162
+ .command("add")
163
+ .description("Add a component to your project")
164
+ .argument("<component>", "Component slug (e.g. animated-button)")
165
+ .option("-d, --dir <directory>", "Component directory", "components/ui")
166
+ .action(async (component, opts) => {
167
+ console.log("");
168
+ console.log(chalk.bold(` ${chalk.hex("#E84E2D")("Praxys UI")} — add ${chalk.cyan(component)}`));
169
+ console.log("");
170
+ // Validate component name
171
+ if (!COMPONENT_LIST.includes(component)) {
172
+ console.log(chalk.red(` Component "${component}" not found.`));
173
+ console.log("");
174
+ console.log(chalk.dim(" Available components:"));
175
+ COMPONENT_LIST.forEach((c) => console.log(chalk.dim(` - ${c}`)));
176
+ console.log("");
177
+ return;
178
+ }
179
+ const spinner = ora(`Fetching ${component}...`).start();
180
+ try {
181
+ const source = await fetchComponent(component);
182
+ // Keep source as-is; import path @/lib/utils works with standard Next.js alias
183
+ const rewritten = source;
184
+ const compDir = join(process.cwd(), opts.dir);
185
+ ensureDir(compDir);
186
+ const filePath = join(compDir, `${component}.tsx`);
187
+ if (existsSync(filePath)) {
188
+ spinner.stop();
189
+ const { overwrite } = await prompts({
190
+ type: "confirm",
191
+ name: "overwrite",
192
+ message: `${component}.tsx already exists. Overwrite?`,
193
+ initial: false,
194
+ });
195
+ if (!overwrite) {
196
+ console.log(chalk.yellow(" Skipped."));
197
+ return;
198
+ }
199
+ }
200
+ writeFileSync(filePath, rewritten, "utf-8");
201
+ spinner.succeed(`Added ${opts.dir}/${component}.tsx`);
202
+ console.log("");
203
+ console.log(chalk.dim(` Import: ${chalk.bold(`import ${toPascalCase(component)} from '@/${opts.dir}/${component}'`)}`));
204
+ console.log("");
205
+ }
206
+ catch (err) {
207
+ spinner.fail(`Failed to fetch ${component}`);
208
+ console.log(chalk.dim(` ${err instanceof Error ? err.message : "Unknown error"}`));
209
+ }
210
+ });
211
+ // ── list ─────────────────────────────────────────────────
212
+ program
213
+ .command("list")
214
+ .description("List all available components")
215
+ .action(() => {
216
+ console.log("");
217
+ console.log(chalk.bold(` ${chalk.hex("#E84E2D")("Praxys UI")} — components`));
218
+ console.log("");
219
+ COMPONENT_LIST.forEach((c) => console.log(` ${chalk.hex("#E84E2D")("●")} ${c}`));
220
+ console.log("");
221
+ console.log(chalk.dim(` ${COMPONENT_LIST.length} components available`));
222
+ console.log("");
223
+ });
224
+ // ── helpers ──────────────────────────────────────────────
225
+ function toPascalCase(slug) {
226
+ return slug
227
+ .split("-")
228
+ .map((s) => s.charAt(0).toUpperCase() + s.slice(1))
229
+ .join("");
230
+ }
231
+ // ── run ──────────────────────────────────────────────────
232
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "praxys-ui",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "CLI for scaffolding Praxys UI components into your project",
6
+ "bin": {
7
+ "praxys-ui": "./dist/index.js"
8
+ },
9
+ "files": ["dist"],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "ts-node src/index.ts"
13
+ },
14
+ "keywords": ["react", "components", "ui", "cli", "tailwind", "framer-motion"],
15
+ "author": "Sushant Verma",
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "chalk": "^5.3.0",
19
+ "commander": "^12.1.0",
20
+ "ora": "^8.1.0",
21
+ "prompts": "^2.4.2"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^22.0.0",
25
+ "@types/prompts": "^2.4.9",
26
+ "typescript": "^5.7.0"
27
+ }
28
+ }