juas.dev 1.0.2 → 1.1.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
@@ -25,17 +25,43 @@ Your project/
25
25
 
26
26
  ---
27
27
 
28
+ ## Authentication & Access Verification
29
+
30
+ Free components can be installed anonymously. To verify your subscription tier, credit balance, or download **Pro / Lifetime** components via CLI, authenticate once:
31
+
32
+ ```bash
33
+ # Interactive browser login (loopback OAuth)
34
+ npx juas.dev login
35
+
36
+ # Headless / CI token login (recommended for servers & CI pipelines)
37
+ npx juas.dev login --token juas_user_your_key_here
38
+
39
+ # Verify your account, subscription tier, credits, and optional component access
40
+ npx juas.dev whoami
41
+ npx juas.dev whoami --check aurora-shader-card
42
+
43
+ # Clear local CLI credentials (~/.juas/credentials.json)
44
+ npx juas.dev logout
45
+ ```
46
+
47
+ You can also pass `JUAS_API_TOKEN` as an environment variable or `--token <key>` per command.
48
+
49
+ ---
50
+
28
51
  ## Quick Start
29
52
 
30
53
  ```bash
31
- # 1. Initialise (creates juas.config.json)
54
+ # 1. Authenticate (optional for free components, required for Pro)
55
+ npx juas.dev login
56
+
57
+ # 2. Initialise (creates juas.config.json)
32
58
  npx juas.dev init
33
59
 
34
- # 2. Add a component by its slug
35
- npx juas.dev add liquid-glass-button
60
+ # 3. Verify plan or component access
61
+ npx juas.dev whoami --check liquid-glass-button
36
62
 
37
- # 3. Import and use it
38
- import { LiquidGlassButton } from "./components/juas/liquid-glass-button/LiquidGlassButton";
63
+ # 4. Add a component by its slug
64
+ npx juas.dev add liquid-glass-button
39
65
  ```
40
66
 
41
67
  ---
@@ -44,8 +70,13 @@ import { LiquidGlassButton } from "./components/juas/liquid-glass-button/LiquidG
44
70
 
45
71
  | Command | Description |
46
72
  |---------|-------------|
73
+ | `npx juas.dev login` | Sign in via browser to authorize the CLI |
74
+ | `npx juas.dev login --token <key>` | Authenticate non-interactively with an API key |
75
+ | `npx juas.dev whoami` | Inspect signed-in account, tier, and credit balance |
76
+ | `npx juas.dev whoami --check <slug>` | Verify whether you can unlock `<slug>` via CLI |
77
+ | `npx juas.dev logout` | Remove saved local CLI credentials |
47
78
  | `npx juas.dev init` | Set up juas in your project |
48
- | `npx juas.dev add <slug>` | Install a component by slug |
79
+ | `npx juas.dev add <slug>` | Install a component by slug (Free or unlocked Pro) |
49
80
  | `npx juas.dev list` | Browse all available components |
50
81
  | `npx juas.dev list --category buttons` | Filter by category |
51
82
  | `npx juas.dev search "glass button"` | Search by name or tag |
package/bin/juas.js CHANGED
@@ -1,62 +1,91 @@
1
- #!/usr/bin/env node
2
- // ============================================================
3
- // juas CLI — entry point
4
- // npx juas init
5
- // npx juas add <slug>
6
- // npx juas list
7
- // npx juas search <query>
8
- // ============================================================
9
- import { createRequire } from "module";
10
- import { program } from "commander";
11
- import { readFileSync } from "fs";
12
- import { fileURLToPath } from "url";
13
- import path from "path";
14
-
15
- import { cmdAdd } from "../src/commands/add.js";
16
- import { cmdInit } from "../src/commands/init.js";
17
- import { cmdList } from "../src/commands/list.js";
18
- import { cmdSearch } from "../src/commands/search.js";
19
-
20
- // ── Read version from package.json ──────────────────────────
21
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
22
- const pkg = JSON.parse(readFileSync(path.join(__dirname, "../package.json"), "utf-8"));
23
-
24
- program
25
- .name("juas")
26
- .description("Official CLI for juas.dev — install beautiful UI components into your project.")
27
- .version(pkg.version, "-v, --version");
28
-
29
- // ── juas init ───────────────────────────────────────────────
30
- program
31
- .command("init")
32
- .description("Initialize juas in your project (creates juas.config.json)")
33
- .option("--ts", "Use TypeScript (default)", true)
34
- .option("--js", "Use JavaScript")
35
- .option("--dir <dir>", "Component output directory", "src/components/juas")
36
- .action(cmdInit);
37
-
38
- // ── juas add <slug> ──────────────────────────────────────────
39
- program
40
- .command("add <slug>")
41
- .description("Add a component by its slug from juas.dev")
42
- .option("--dir <dir>", "Override output directory")
43
- .option("--no-deps", "Skip installing npm dependencies")
44
- .option("--dry-run", "Preview what would be written without writing files")
45
- .action(cmdAdd);
46
-
47
- // ── juas list ────────────────────────────────────────────────
48
- program
49
- .command("list")
50
- .description("List all available components on juas.dev")
51
- .option("--category <cat>", "Filter by category")
52
- .option("--json", "Output raw JSON")
53
- .action(cmdList);
54
-
55
- // ── juas search <query> ──────────────────────────────────────
56
- program
57
- .command("search <query>")
58
- .description("Search components by name, tag or description")
59
- .option("--json", "Output raw JSON")
60
- .action(cmdSearch);
61
-
62
- program.parseAsync(process.argv);
1
+ #!/usr/bin/env node
2
+ // ============================================================
3
+ // juas CLI — entry point
4
+ // npx juas.dev init
5
+ // npx juas.dev add <slug>
6
+ // npx juas.dev list
7
+ // npx juas.dev search <query>
8
+ // ============================================================
9
+ import { createRequire } from "module";
10
+ import { program } from "commander";
11
+ import { readFileSync } from "fs";
12
+ import { fileURLToPath } from "url";
13
+ import path from "path";
14
+
15
+ import { cmdAdd } from "../src/commands/add.js";
16
+ import { cmdInit } from "../src/commands/init.js";
17
+ import { cmdList } from "../src/commands/list.js";
18
+ import { cmdLogin } from "../src/commands/login.js";
19
+ import { cmdLogout } from "../src/commands/logout.js";
20
+ import { cmdSearch } from "../src/commands/search.js";
21
+ import { cmdWhoami } from "../src/commands/whoami.js";
22
+
23
+ // ── Read version from package.json ──────────────────────────
24
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
25
+ const pkg = JSON.parse(readFileSync(path.join(__dirname, "../package.json"), "utf-8"));
26
+
27
+ program
28
+ .name("juas")
29
+ .description("Official CLI for juas.dev — install beautiful UI components into your project.")
30
+ .version(pkg.version, "-v, --version");
31
+
32
+ // ── juas init ───────────────────────────────────────────────
33
+ program
34
+ .command("init")
35
+ .description("Initialize juas in your project (creates juas.config.json)")
36
+ .option("--ts", "Use TypeScript (default)", true)
37
+ .option("--js", "Use JavaScript")
38
+ .option("--dir <dir>", "Component output directory", "src/components/juas")
39
+ .action(cmdInit);
40
+
41
+ // ── juas login ───────────────────────────────────────────────
42
+ program
43
+ .command("login")
44
+ .description("Authenticate CLI with your juas.dev account")
45
+ .option("--token <key>", "Authenticate with an existing Juas API key (CI/headless)")
46
+ .option("--no-browser", "Prompt for API key manually without opening a browser")
47
+ .option("--web-url <url>", "Override juas.dev base URL")
48
+ .action(cmdLogin);
49
+
50
+ // ── juas logout ──────────────────────────────────────────────
51
+ program
52
+ .command("logout")
53
+ .description("Remove saved local juas.dev credentials")
54
+ .action(cmdLogout);
55
+
56
+ // ── juas whoami ──────────────────────────────────────────────
57
+ program
58
+ .command("whoami")
59
+ .description("Verify current account identity, plan tier, credits, and access")
60
+ .option("--check <slug>", "Verify download entitlement for a specific component slug")
61
+ .option("--token <key>", "Verify a specific token without reading ~/.juas")
62
+ .option("--web-url <url>", "Override juas.dev base URL")
63
+ .option("--json", "Output machine-readable JSON")
64
+ .action(cmdWhoami);
65
+
66
+ // ── juas add <slug> ──────────────────────────────────────────
67
+ program
68
+ .command("add <slug>")
69
+ .description("Add a component by its slug from juas.dev")
70
+ .option("--dir <dir>", "Override output directory")
71
+ .option("--token <key>", "Authenticate this request with a specific token")
72
+ .option("--no-deps", "Skip installing npm dependencies")
73
+ .option("--dry-run", "Preview what would be written without writing files")
74
+ .action(cmdAdd);
75
+
76
+ // ── juas list ────────────────────────────────────────────────
77
+ program
78
+ .command("list")
79
+ .description("List all available components on juas.dev")
80
+ .option("--category <cat>", "Filter by category")
81
+ .option("--json", "Output raw JSON")
82
+ .action(cmdList);
83
+
84
+ // ── juas search <query> ──────────────────────────────────────
85
+ program
86
+ .command("search <query>")
87
+ .description("Search components by name, tag or description")
88
+ .option("--json", "Output raw JSON")
89
+ .action(cmdSearch);
90
+
91
+ program.parseAsync(process.argv);
package/package.json CHANGED
@@ -1,49 +1,50 @@
1
- {
2
- "name": "juas.dev",
3
- "version": "1.0.2",
4
- "description": "Official CLI for juas.dev — install beautiful UI components directly into your React project as source files.",
5
- "type": "module",
6
- "bin": {
7
- "juas": "bin/juas.js"
8
- },
9
- "files": [
10
- "bin",
11
- "src",
12
- "README.md"
13
- ],
14
- "scripts": {
15
- "dev": "node bin/juas.js",
16
- "test": "node bin/juas.js --version"
17
- },
18
- "keywords": [
19
- "juas",
20
- "juas.dev",
21
- "ui",
22
- "components",
23
- "cli",
24
- "react",
25
- "tailwindcss",
26
- "design-system",
27
- "shadcn",
28
- "source-first"
29
- ],
30
- "author": "dhileepkumar",
31
- "license": "MIT",
32
- "dependencies": {
33
- "commander": "^13.1.0",
34
- "fs-extra": "^11.3.0",
35
- "ora": "^8.2.0",
36
- "picocolors": "^1.1.1"
37
- },
38
- "engines": {
39
- "node": ">=18.0.0"
40
- },
41
- "publishConfig": {
42
- "access": "public"
43
- },
44
- "repository": {
45
- "type": "git",
46
- "url": "https://github.com/dhileepkumar/juas.dev"
47
- },
48
- "homepage": "https://juas.dev"
49
- }
1
+ {
2
+ "name": "juas.dev",
3
+ "version": "1.1.1",
4
+ "description": "Official CLI for juas.dev — install beautiful UI components directly into your React project as source files.",
5
+ "type": "module",
6
+ "bin": {
7
+ "juas": "bin/juas.js",
8
+ "juas.dev": "bin/juas.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "src",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "dev": "node bin/juas.js",
17
+ "test": "node bin/juas.js --version"
18
+ },
19
+ "keywords": [
20
+ "juas",
21
+ "juas.dev",
22
+ "ui",
23
+ "components",
24
+ "cli",
25
+ "react",
26
+ "tailwindcss",
27
+ "design-system",
28
+ "shadcn",
29
+ "source-first"
30
+ ],
31
+ "author": "dhileepkumar",
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "commander": "^13.1.0",
35
+ "fs-extra": "^11.3.0",
36
+ "ora": "^8.2.0",
37
+ "picocolors": "^1.1.1"
38
+ },
39
+ "engines": {
40
+ "node": ">=18.0.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/dhiluxui/juas.dev.git"
48
+ },
49
+ "homepage": "https://juas.dev"
50
+ }
@@ -1,78 +1,155 @@
1
1
  // ============================================================
2
- // commands/add.js
3
- // npx juas add <slug>
4
- //
5
- // 1. Fetch component + latest version code from Supabase
6
- // 2. Write TSX/JSX + optional CSS to outputDir
7
- // 3. Install missing npm dependencies
8
- // 4. Print usage snippet
2
+ // commands/add.js — `juas add <slug>`
9
3
  // ============================================================
10
- import path from "path";
11
- import fs from "fs-extra";
12
- import ora from "ora";
13
- import pc from "picocolors";
4
+ import fs from "fs-extra";
5
+ import ora from "ora";
6
+ import path from "path";
7
+ import pc from "picocolors";
8
+ import { fetchCliComponent } from "../lib/authApi.js";
9
+ import { loadConfig } from "../lib/config.js";
10
+ import { getActiveToken } from "../lib/credentials.js";
11
+ import { detectPackageManager, getMissingPackages, installDependencies } from "../lib/deps.js";
12
+ import { logger } from "../lib/logger.js";
13
+ import { fetchComponentBySlug } from "../lib/supabase.js";
14
14
 
15
- import { logger } from "../lib/logger.js";
16
- import { loadConfig } from "../lib/config.js";
17
- import { fetchComponentBySlug } from "../lib/supabase.js";
18
- import { getMissingPackages, installDependencies, detectPackageManager }
19
- from "../lib/deps.js";
15
+ /**
16
+ * Fetches component payload from the Worker CLI gateway (supporting Pro, Credit,
17
+ * and Free tiers) with a safe free-only anon Supabase fallback on transport errors.
18
+ */
19
+ async function resolveComponentPayload(slug, token, baseUrl) {
20
+ try {
21
+ const gatewayRes = await fetchCliComponent(slug, { token, baseUrl });
22
+ if (gatewayRes.status === 404) {
23
+ return { notFound: true };
24
+ }
25
+ if (gatewayRes.ok && gatewayRes.data) {
26
+ const payload = gatewayRes.data;
27
+ if (payload.status === "locked") {
28
+ return {
29
+ locked: true,
30
+ component: { name: payload.name, slug: payload.slug, pricing_tier: payload.pricingTier },
31
+ message: payload.message,
32
+ unlockUrl: payload.unlockUrl,
33
+ };
34
+ }
35
+ if (payload.status === "unlocked") {
36
+ return {
37
+ unlocked: true,
38
+ component: {
39
+ name: payload.name,
40
+ slug: payload.slug,
41
+ description: payload.description,
42
+ pricing_tier: payload.pricingTier || "free",
43
+ project_files: payload.projectFiles,
44
+ },
45
+ version: {
46
+ code_tsx: payload.code,
47
+ code_css: payload.codeCss || "",
48
+ dependencies: payload.dependencies || [],
49
+ },
50
+ };
51
+ }
52
+ }
53
+ } catch {
54
+ // Fallback strictly for free components if edge gateway is unreachable
55
+ }
56
+
57
+ const direct = await fetchComponentBySlug(slug);
58
+ if (!direct) {
59
+ return { notFound: true };
60
+ }
61
+
62
+ const { component, version } = direct;
63
+ if (component.pricing_tier && component.pricing_tier !== "free") {
64
+ return {
65
+ locked: true,
66
+ component,
67
+ message: token
68
+ ? "Could not verify Pro entitlement cleanly against gateway."
69
+ : "Authentication required for Pro components. Run `npx juas.dev login`.",
70
+ unlockUrl: `https://juas.dev/component/${slug}`,
71
+ };
72
+ }
73
+
74
+ return { unlocked: true, component, version };
75
+ }
20
76
 
21
77
  export async function cmdAdd(slug, options) {
22
78
  logger.banner();
23
- logger.info(`Adding component: ${pc.bold(slug)}`);
24
- logger.blank();
25
-
26
- const cwd = process.cwd();
27
- const config = loadConfig(cwd);
28
79
 
29
- // Allow --dir override
30
- const outDir = options.dir
31
- ? path.resolve(cwd, options.dir)
32
- : path.resolve(cwd, config.outputDir);
80
+ const cwd = process.cwd();
81
+ const config = await loadConfig(cwd);
82
+ const outDir = path.resolve(cwd, options.dir || config.outputDir || "src/components/juas");
83
+ const { token, baseUrl } = getActiveToken(options.token);
33
84
 
85
+ // ── Fetch component from Juas CLI Gateway ───────────────────
34
86
  const spinner = ora(`Fetching ${pc.bold(slug)} from juas.dev…`).start();
35
87
 
36
- let result;
88
+ let resolved;
37
89
  try {
38
- result = await fetchComponentBySlug(slug);
90
+ resolved = await resolveComponentPayload(slug, token, baseUrl);
39
91
  } catch (err) {
40
92
  spinner.fail("Network error.");
41
93
  logger.error(err.message);
42
94
  process.exit(1);
43
95
  }
44
96
 
45
- if (!result) {
97
+ if (resolved.notFound) {
46
98
  spinner.fail(`Component "${slug}" not found on juas.dev.`);
47
99
  logger.blank();
48
- logger.info(`Search available components: ${pc.bold("npx juas search " + slug)}`);
100
+ logger.info(`Search available components: ${pc.bold("npx juas.dev search " + slug)}`);
49
101
  logger.info(`Browse all: ${pc.underline("https://juas.dev")}`);
50
102
  process.exit(1);
51
103
  }
52
104
 
53
- const { component, version } = result;
105
+ if (resolved.locked) {
106
+ const compName = resolved.component?.name || slug;
107
+ spinner.fail(`"${compName}" requires a Pro license or 1 credit to unlock source.`);
108
+ if (resolved.message) {
109
+ logger.warn(resolved.message);
110
+ }
111
+ if (!token) {
112
+ logger.info(`Sign in via CLI: ${pc.bold("npx juas.dev login")}`);
113
+ } else {
114
+ logger.info(`Check entitlement: ${pc.bold("npx juas.dev whoami --check " + slug)}`);
115
+ }
116
+ logger.info(`Unlock on web: ${pc.underline(resolved.unlockUrl || "https://juas.dev/component/" + slug)}`);
117
+ process.exit(1);
118
+ }
119
+
120
+ const { component, version } = resolved;
121
+ const projectFiles = parseProjectFiles(component.project_files);
122
+ const projectFileEntries = Object.entries(projectFiles);
54
123
 
55
- if (!version?.code_tsx) {
124
+ if (!version?.code_tsx && projectFileEntries.length === 0) {
56
125
  spinner.fail(`"${slug}" has no source code yet. It may still be processing.`);
57
126
  process.exit(1);
58
127
  }
59
128
 
60
- spinner.succeed(`Found: ${pc.bold(component.name)} v${version.version}`);
129
+ spinner.succeed(`Found ${pc.bold(component.name)}`);
61
130
 
62
131
  // ── Build file paths ────────────────────────────────────────
63
- const useTs = config.typescript !== false;
64
- const ext = useTs ? ".tsx" : ".jsx";
65
- const compDir = path.join(outDir, slug);
132
+ const useTs = config.typescript !== false;
133
+ const ext = useTs ? ".tsx" : ".jsx";
134
+ const compDir = path.resolve(outDir, slug);
66
135
  const tsxFile = path.join(compDir, `${toPascalCase(slug)}${ext}`);
67
136
  const cssFile = path.join(compDir, `${toPascalCase(slug)}.css`);
68
137
 
138
+ const safeMultiFiles = projectFileEntries
139
+ .map(([rawRel, content]) => ({ target: resolveSafeChildPath(compDir, rawRel), content }))
140
+ .filter((entry) => entry.target && typeof entry.content === "string");
141
+
69
142
  if (options.dryRun) {
70
143
  logger.blank();
71
144
  logger.warn("Dry run — no files written.");
72
- logger.label("Would write TSX", tsxFile);
73
- if (version.code_css) logger.label("Would write CSS", cssFile);
145
+ if (safeMultiFiles.length > 0) {
146
+ safeMultiFiles.forEach((f) => logger.label("Would write", f.target));
147
+ } else {
148
+ logger.label("Would write TSX", tsxFile);
149
+ if (version?.code_css) logger.label("Would write CSS", cssFile);
150
+ }
74
151
  logger.blank();
75
- showUsageSnippet(slug, component.name);
152
+ showUsageSnippet(slug);
76
153
  return;
77
154
  }
78
155
 
@@ -80,9 +157,15 @@ export async function cmdAdd(slug, options) {
80
157
  const fileSpinner = ora("Writing component files…").start();
81
158
  try {
82
159
  await fs.ensureDir(compDir);
83
- await fs.outputFile(tsxFile, version.code_tsx, "utf-8");
84
- if (version.code_css?.trim()) {
85
- await fs.outputFile(cssFile, version.code_css, "utf-8");
160
+ if (safeMultiFiles.length > 0) {
161
+ for (const f of safeMultiFiles) {
162
+ await fs.outputFile(f.target, f.content, "utf-8");
163
+ }
164
+ } else {
165
+ await fs.outputFile(tsxFile, version.code_tsx, "utf-8");
166
+ if (version?.code_css?.trim()) {
167
+ await fs.outputFile(cssFile, version.code_css, "utf-8");
168
+ }
86
169
  }
87
170
  fileSpinner.succeed("Files written.");
88
171
  } catch (err) {
@@ -92,17 +175,19 @@ export async function cmdAdd(slug, options) {
92
175
  }
93
176
 
94
177
  // ── Install missing npm dependencies ──────────────────────
95
- const declaredDeps = version.dependencies ?? [];
178
+ const declaredDeps = version?.dependencies ?? [];
96
179
 
97
180
  if (declaredDeps.length && options.deps !== false) {
98
181
  const missing = getMissingPackages(declaredDeps, cwd);
99
182
  if (missing.length) {
100
183
  const pm = detectPackageManager(cwd);
101
- const depSpinner = ora(`Installing ${missing.length} dependenc${missing.length > 1 ? "ies" : "y"} via ${pm}…`).start();
184
+ const depSpinner = ora(
185
+ `Installing ${missing.length} dependenc${missing.length > 1 ? "ies" : "y"} via ${pm}…`
186
+ ).start();
102
187
  try {
103
188
  installDependencies(missing, cwd);
104
189
  depSpinner.succeed("Dependencies installed.");
105
- } catch (err) {
190
+ } catch {
106
191
  depSpinner.fail("Dependency install failed — install manually.");
107
192
  logger.warn(`Run: ${pc.bold(pm + " install " + missing.join(" "))}`);
108
193
  }
@@ -117,18 +202,51 @@ export async function cmdAdd(slug, options) {
117
202
  logger.success(pc.bold(`${component.name} installed!`));
118
203
  logger.divider();
119
204
  logger.blank();
120
- logger.label("File", path.relative(cwd, tsxFile));
121
- if (version.code_css?.trim()) logger.label("CSS", path.relative(cwd, cssFile));
122
- if (component.description) logger.label("About", component.description);
205
+ if (safeMultiFiles.length > 0) {
206
+ safeMultiFiles.forEach((f) => logger.label("File", path.relative(cwd, f.target)));
207
+ } else {
208
+ logger.label("File", path.relative(cwd, tsxFile));
209
+ if (version?.code_css?.trim()) logger.label("CSS", path.relative(cwd, cssFile));
210
+ }
211
+ if (component.description) logger.label("About", component.description);
123
212
  logger.blank();
124
- showUsageSnippet(slug, component.name);
213
+ showUsageSnippet(slug);
125
214
  logger.blank();
126
- logger.info(`View on web: ${pc.underline("https://juas.dev/components/" + slug)}`);
215
+ logger.info(`View on web: ${pc.underline("https://juas.dev/component/" + slug)}`);
127
216
  logger.blank();
128
217
  }
129
218
 
130
219
  // ── Helpers ──────────────────────────────────────────────────
131
220
 
221
+ function parseProjectFiles(raw) {
222
+ let obj = raw;
223
+ if (typeof obj === "string" && obj.trim().startsWith("{")) {
224
+ try {
225
+ obj = JSON.parse(obj);
226
+ } catch {
227
+ return {};
228
+ }
229
+ }
230
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) return {};
231
+ const out = {};
232
+ for (const [k, v] of Object.entries(obj)) {
233
+ const content =
234
+ typeof v === "string" ? v : v && typeof v === "object" ? v.code || v.content : "";
235
+ if (typeof content === "string" && content.length > 0) {
236
+ out[k] = content;
237
+ }
238
+ }
239
+ return out;
240
+ }
241
+
242
+ function resolveSafeChildPath(rootDir, rawRel) {
243
+ const cleaned = String(rawRel || "").replace(/^[/\\]+/, "").replace(/\\/g, "/");
244
+ if (!cleaned || cleaned.includes("\0")) return null;
245
+ const resolved = path.resolve(rootDir, cleaned);
246
+ if (!resolved.startsWith(rootDir + path.sep)) return null;
247
+ return resolved;
248
+ }
249
+
132
250
  function toPascalCase(str) {
133
251
  return str
134
252
  .split(/[-_\s]+/)
@@ -136,7 +254,7 @@ function toPascalCase(str) {
136
254
  .join("");
137
255
  }
138
256
 
139
- function showUsageSnippet(slug, name) {
257
+ function showUsageSnippet(slug) {
140
258
  const pascal = toPascalCase(slug);
141
259
  console.log(pc.dim(" Usage:"));
142
260
  console.log(pc.cyan(` import { ${pascal} } from "./${slug}/${pascal}";`));