@srcroot/ui 0.0.7 → 0.0.11

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 +27 -62
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -363,8 +363,8 @@ async function init(options) {
363
363
  console.log(chalk.red("Error: No package.json found. Please run this in a project directory."));
364
364
  process.exit(1);
365
365
  }
366
- const srcDir = path.join(cwd, "src");
367
- const appDir = path.join(cwd, "app");
366
+ const srcDir = fs.existsSync(path.join(cwd, "src")) ? path.join(cwd, "src") : cwd;
367
+ const appDir = path.join(srcDir, "app");
368
368
  const isAppRouter = fs.existsSync(appDir);
369
369
  const libDir = path.join(srcDir, "lib");
370
370
  const componentsDir = path.join(srcDir, "components", "ui");
@@ -387,93 +387,58 @@ async function init(options) {
387
387
  selectedTheme = themeResponse.theme;
388
388
  }
389
389
  }
390
- if (!options.yes) {
391
- const response = await prompts([
392
- {
393
- type: "confirm",
394
- name: "proceed",
395
- message: `This will create files in ${chalk.cyan(cwd)} with ${chalk.cyan(THEMES[selectedTheme].name)} theme. Continue?`,
396
- initial: true
397
- }
398
- ]);
399
- if (!response.proceed) {
400
- console.log(chalk.yellow("Cancelled."));
401
- process.exit(0);
402
- }
403
- }
404
390
  const spinner = ora("Creating project structure...").start();
405
391
  try {
406
392
  await fs.ensureDir(libDir);
407
393
  await fs.ensureDir(componentsDir);
408
394
  const utilsPath = path.join(libDir, "utils.ts");
409
395
  await fs.writeFile(utilsPath, UTILS_CONTENT);
410
- spinner.succeed(`Created ${chalk.cyan("src/lib/utils.ts")}`);
396
+ spinner.succeed(`Created ${chalk.cyan(path.relative(cwd, utilsPath))}`);
411
397
  spinner.start(`Setting up ${chalk.cyan(THEMES[selectedTheme].name)} theme...`);
412
398
  const stylesDir = path.dirname(globalsPath);
413
399
  await fs.ensureDir(stylesDir);
414
400
  const cssContent = generateCssVariables(selectedTheme);
415
- if (fs.existsSync(globalsPath)) {
416
- const existingCss = await fs.readFile(globalsPath, "utf-8");
417
- if (!existingCss.includes("--background:")) {
418
- await fs.writeFile(globalsPath, cssContent + "\n" + existingCss);
419
- spinner.succeed(`Updated ${chalk.cyan(path.relative(cwd, globalsPath))} with ${chalk.cyan(THEMES[selectedTheme].name)} theme`);
420
- } else {
421
- spinner.info(`CSS variables already exist in ${chalk.cyan(path.relative(cwd, globalsPath))}`);
422
- }
423
- } else {
424
- await fs.writeFile(globalsPath, cssContent);
425
- spinner.succeed(`Created ${chalk.cyan(path.relative(cwd, globalsPath))} with ${chalk.cyan(THEMES[selectedTheme].name)} theme`);
426
- }
401
+ await fs.writeFile(globalsPath, cssContent);
402
+ spinner.succeed(`Updated ${chalk.cyan(path.relative(cwd, globalsPath))} with ${chalk.cyan(THEMES[selectedTheme].name)} theme`);
427
403
  spinner.start("Setting up Tailwind config...");
428
404
  const tailwindConfigPath = path.join(cwd, "tailwind.config.ts");
429
- if (!fs.existsSync(tailwindConfigPath)) {
430
- await fs.writeFile(tailwindConfigPath, TAILWIND_CONFIG);
431
- spinner.succeed(`Created ${chalk.cyan("tailwind.config.ts")}`);
432
- } else {
433
- spinner.info(`${chalk.cyan("tailwind.config.ts")} already exists, skipping`);
434
- }
405
+ await fs.writeFile(tailwindConfigPath, TAILWIND_CONFIG);
406
+ spinner.succeed(`Created ${chalk.cyan("tailwind.config.ts")}`);
435
407
  spinner.start("Checking dependencies...");
436
408
  const pkg = await fs.readJson(packageJsonPath);
437
409
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
438
410
  const missing = [];
439
- const requiredDeps = ["clsx", "tailwind-merge", "class-variance-authority", "lucide-react"];
440
- for (const dep of requiredDeps) {
441
- if (!deps[dep]) {
442
- missing.push(dep);
411
+ const requiredDeps = {
412
+ "clsx": "clsx@2.1.1",
413
+ "tailwind-merge": "tailwind-merge@3.4.0",
414
+ "class-variance-authority": "class-variance-authority@0.7.1",
415
+ "lucide-react": "lucide-react@0.561.0"
416
+ };
417
+ for (const [depName, installCmd] of Object.entries(requiredDeps)) {
418
+ if (!deps[depName]) {
419
+ missing.push(installCmd);
443
420
  }
444
421
  }
445
422
  if (missing.length > 0) {
446
- spinner.stop();
447
- const { install } = await prompts({
448
- type: "confirm",
449
- name: "install",
450
- message: `Missing dependencies: ${missing.join(", ")}. Install now?`,
451
- initial: true
452
- });
453
- if (install) {
454
- spinner.start(`Installing dependencies...`);
455
- import("child_process").then(({ execSync }) => {
456
- execSync(`npm install ${missing.join(" ")}`, { stdio: "ignore", cwd });
457
- spinner.succeed("Dependencies installed");
458
- }).catch(() => {
459
- spinner.fail("Failed to install dependencies automatically.");
460
- console.log(chalk.dim(`
461
- Please manually run: npm install ${missing.join(" ")}
462
- `));
463
- });
464
- } else {
423
+ spinner.text = `Installing dependencies: ${missing.join(", ")}...`;
424
+ try {
425
+ const { execSync } = await import("child_process");
426
+ execSync(`npm install ${missing.join(" ")}`, { stdio: "ignore", cwd });
427
+ spinner.succeed("Dependencies installed");
428
+ } catch {
429
+ spinner.fail("Failed to install dependencies automatically");
465
430
  console.log(chalk.dim(`
466
431
  Please manually run: npm install ${missing.join(" ")}
467
432
  `));
468
433
  }
469
434
  } else {
470
- spinner.succeed("All dependencies installed");
435
+ spinner.succeed("All dependencies already installed");
471
436
  }
472
437
  console.log(chalk.green("\n\u2705 Project initialized successfully!\n"));
473
438
  console.log(`Theme: ${chalk.cyan(THEMES[selectedTheme].name)}`);
474
439
  console.log("\nNext steps:");
475
- console.log(chalk.dim(" 1. Install missing dependencies (if any)"));
476
- console.log(chalk.dim(" 2. Run: npx srcroot-ui add button"));
440
+ console.log(chalk.dim(" npx @srcroot/ui add button"));
441
+ console.log(chalk.dim(" npx @srcroot/ui add --all"));
477
442
  console.log();
478
443
  } catch (error) {
479
444
  spinner.fail("Failed to initialize project");
@@ -963,7 +928,7 @@ async function list() {
963
928
 
964
929
  // src/cli/index.ts
965
930
  var program = new Command();
966
- program.name("@srcroot/ui").description("Add polymorphic, accessible UI components to your project").version("0.0.1");
931
+ program.name("@srcroot/ui").description("Add polymorphic, accessible UI components to your project").version("0.0.8");
967
932
  program.command("init").description("Initialize your project with srcroot-ui").option("-y, --yes", "Skip confirmation prompts", false).option("-t, --theme <theme>", "Color theme (slate, neutral, stone, zinc, gray)").option("--cwd <path>", "Working directory", process.cwd()).action(init);
968
933
  program.command("add").description("Add components to your project").argument("[components...]", "Components to add").option("-y, --yes", "Skip confirmation prompts", false).option("-o, --overwrite", "Overwrite existing files", false).option("-a, --all", "Add all available components", false).option("--cwd <path>", "Working directory", process.cwd()).action(add);
969
934
  program.command("list").description("List all available components").action(list);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcroot/ui",
3
- "version": "0.0.7",
3
+ "version": "0.0.11",
4
4
  "description": "A shadcn-style CLI UI library with polymorphic, accessible React components",
5
5
  "type": "module",
6
6
  "bin": {
@@ -39,11 +39,11 @@
39
39
  "peerDependencies": {
40
40
  "react": "^18.0.0 || ^19.0.0",
41
41
  "react-dom": "^18.0.0 || ^19.0.0",
42
- "lucide-react": "^0.460.0",
42
+ "lucide-react": "^0.561.0",
43
43
  "cmdk": "^1.0.0",
44
- "class-variance-authority": "^0.7.0",
45
- "clsx": "^2.0.0",
46
- "tailwind-merge": "^2.0.0",
44
+ "class-variance-authority": "^0.7.1",
45
+ "clsx": "^2.1.1",
46
+ "tailwind-merge": "^3.4.0",
47
47
  "tailwindcss": "^3.0.0 || ^4.0.0"
48
48
  },
49
49
  "peerDependenciesMeta": {