vibe-design-system 2.4.10 → 2.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-design-system",
3
- "version": "2.4.10",
3
+ "version": "2.5.0",
4
4
  "description": "Auto-generate design systems for vibe coding projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -517,6 +517,7 @@ function extractComponentSuggestions() {
517
517
  byPattern.set(raw, {
518
518
  count: 0,
519
519
  files: new Set(),
520
+ tagName,
520
521
  snippet: `<${tagName} className="${raw}">...</${tagName}>`,
521
522
  });
522
523
  }
@@ -527,14 +528,15 @@ function extractComponentSuggestions() {
527
528
  }
528
529
 
529
530
  const suggestions = [];
530
- for (const [pattern, { count, files, snippet }] of byPattern.entries()) {
531
+ for (const [pattern, { count, files, snippet, tagName }] of byPattern.entries()) {
531
532
  if (count < 2) continue;
532
533
  const suggestedName = suggestNameFromPattern(pattern);
533
534
  suggestions.push({
534
535
  suggestedName,
536
+ tagName: tagName || "div",
537
+ pattern,
535
538
  occurrences: count,
536
539
  foundIn: [...files].sort(),
537
- pattern,
538
540
  snippet,
539
541
  reason: `Same className cluster appears ${count} times`,
540
542
  });
@@ -542,6 +544,51 @@ function extractComponentSuggestions() {
542
544
  return suggestions;
543
545
  }
544
546
 
547
+ const VDS_GENERATED_DIR = path.join(COMPONENTS_DIR, "vds-generated");
548
+
549
+ /** Write extracted components to src/components/vds-generated/*.tsx and return component entries for output. */
550
+ function writeVdsGeneratedComponents(suggestions) {
551
+ if (!Array.isArray(suggestions) || suggestions.length === 0) return [];
552
+ if (!fs.existsSync(VDS_GENERATED_DIR)) fs.mkdirSync(VDS_GENERATED_DIR, { recursive: true });
553
+ const usedNames = new Set();
554
+ const entries = [];
555
+ for (let i = 0; i < suggestions.length; i++) {
556
+ const s = suggestions[i];
557
+ let baseName = s.suggestedName.replace(/\s+/g, "");
558
+ if (!baseName) baseName = "Extracted";
559
+ let fileName = baseName + ".tsx";
560
+ if (usedNames.has(fileName)) {
561
+ fileName = baseName + String(i + 1) + ".tsx";
562
+ }
563
+ usedNames.add(fileName);
564
+ const componentName = fileName.replace(/\.tsx$/, "");
565
+ const tagName = s.tagName || "div";
566
+ const className = s.pattern || "";
567
+ const relPath = "vds-generated/" + fileName;
568
+ const fullPath = path.join(COMPONENTS_DIR, relPath);
569
+ const content = `import * as React from "react";
570
+
571
+ export function ${componentName}({ children }: { children?: React.ReactNode }) {
572
+ return (
573
+ <${tagName} className={\`${className.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`}>
574
+ {children ?? null}
575
+ </${tagName}>
576
+ );
577
+ }
578
+ `;
579
+ fs.writeFileSync(fullPath, content, "utf-8");
580
+ entries.push({
581
+ file: relPath,
582
+ name: componentName.replace(/([A-Z])/g, " $1").trim(),
583
+ group: "VDS Generated",
584
+ category: "Extracted",
585
+ description: "Auto-extracted from repeated className patterns.",
586
+ tokens: (className || "").split(/\s+/).filter(Boolean),
587
+ });
588
+ }
589
+ return entries;
590
+ }
591
+
545
592
  function extractTailwindTokens(content) {
546
593
  const tokens = new Set();
547
594
  const patterns = [
@@ -942,6 +989,8 @@ function scan() {
942
989
  foundations.icons = extractLucideIconsUsed(SRC_DIR);
943
990
  foundations.brand = { assets: extractBrandAssets() };
944
991
  const componentSuggestions = extractComponentSuggestions();
992
+ const vdsGeneratedEntries = writeVdsGeneratedComponents(componentSuggestions);
993
+ results.push(...vdsGeneratedEntries);
945
994
  const output = {
946
995
  branch: getGitBranch(),
947
996
  engineer: getGitEngineer(),
@@ -536,9 +536,9 @@ function buildStoryFileContent(comp) {
536
536
  const fileNoExt = comp.file.replace(/\.(tsx|jsx)$/, "");
537
537
  let importPath = "";
538
538
  if (fileNoExt.startsWith("pages/")) {
539
- importPath = "@/" + fileNoExt;
539
+ importPath = "../" + fileNoExt; // Sonuç: "../pages/Home" olacak
540
540
  } else {
541
- importPath = "@/components/" + fileNoExt;
541
+ importPath = "../components/" + fileNoExt; // Sonuç: "../components/ui/button" olacak
542
542
  }
543
543
  const group = comp.group || "Components";
544
544
  const category = comp.category || null;
@@ -785,6 +785,40 @@ function writeFoundationsStories(foundations) {
785
785
  ].join("\n");
786
786
  fs.writeFileSync(path.join(foundationsDir, "Brand.stories.tsx"), brandContent, "utf-8");
787
787
  console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Brand.stories.tsx")));
788
+
789
+ const iconNames = Array.isArray(foundations?.icons) ? foundations.icons : [];
790
+ if (iconNames.length > 0) {
791
+ const iconsContent =
792
+ [
793
+ "import type { Meta, StoryObj } from \"@storybook/react\";",
794
+ "import * as Lucide from \"lucide-react\";",
795
+ "",
796
+ "const meta = { title: \"Foundations/Icons\" } satisfies Meta;",
797
+ "export default meta;",
798
+ "type Story = StoryObj;",
799
+ "",
800
+ `const iconNames = ${JSON.stringify(iconNames)};`,
801
+ "",
802
+ "export const Default: Story = {",
803
+ " render: () => (",
804
+ " <div style={{ display: \"grid\", gridTemplateColumns: \"repeat(auto-fill, minmax(100px, 1fr))\", gap: 16, padding: 24 }}>",
805
+ " {iconNames.map((name) => {",
806
+ " const Icon = Lucide[name];",
807
+ " if (!Icon) return null;",
808
+ " return (",
809
+ " <div key={name} style={{ display: \"flex\", flexDirection: \"column\", alignItems: \"center\", gap: 8, padding: 12, border: \"1px solid #333\", borderRadius: 8 }}>",
810
+ " <Icon size={24} />",
811
+ " <span style={{ fontSize: 11, color: \"#888\" }}>{name}</span>",
812
+ " </div>",
813
+ " );",
814
+ " })}",
815
+ " </div>",
816
+ " ),",
817
+ "};",
818
+ ].join("\n");
819
+ fs.writeFileSync(path.join(foundationsDir, "Icons.stories.tsx"), iconsContent, "utf-8");
820
+ console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Icons.stories.tsx")));
821
+ }
788
822
  }
789
823
 
790
824
  function writeComponentSuggestionsStory(componentSuggestions) {