vibe-design-system 2.8.40 → 2.8.42

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/bin/init.js CHANGED
@@ -95,12 +95,14 @@ Storybook stilleri sayfalardan farklıysa: .storybook/preview.ts içinde uygulam
95
95
  `;
96
96
 
97
97
  const WATCH_MJS = `#!/usr/bin/env node
98
- import { watch } from 'fs';
98
+ import { watch, existsSync } from 'fs';
99
99
  import { execSync } from 'child_process';
100
100
  import { resolve } from 'path';
101
101
 
102
102
  const ROOT = resolve(process.cwd());
103
- const SRC = resolve(ROOT, 'src');
103
+ // Auto-detect frontend src dir (supports fullstack projects)
104
+ const SRC_CANDIDATES = ['src', 'client/src', 'frontend/src', 'web/src'];
105
+ const SRC = resolve(ROOT, SRC_CANDIDATES.find((p) => existsSync(resolve(ROOT, p, 'components'))) || SRC_CANDIDATES.find((p) => existsSync(resolve(ROOT, p))) || 'src');
104
106
  let timeout = null;
105
107
 
106
108
  function run() {
@@ -145,6 +147,25 @@ function getProjectRoot() {
145
147
  return process.cwd();
146
148
  }
147
149
 
150
+ /**
151
+ * Fullstack proje desteği: client/src, frontend/src, web/src varsa onu döndür.
152
+ * Yoksa standart "src" döndür.
153
+ */
154
+ function detectFrontendSrcDir(projectRoot) {
155
+ // Check fullstack prefixes FIRST — they take priority over bare src/
156
+ // e.g. crypto project has empty src/ (only stories/) but real code in client/src/
157
+ for (const prefix of ["client/src", "frontend/src", "web/src"]) {
158
+ const full = path.join(projectRoot, prefix);
159
+ if (fs.existsSync(full) && fs.statSync(full).isDirectory()) {
160
+ const hasComponents = fs.existsSync(path.join(full, "components"));
161
+ const hasAppFiles = fs.readdirSync(full).some((f) => /\.(tsx|jsx)$/i.test(f));
162
+ if (hasComponents || hasAppFiles) return prefix;
163
+ }
164
+ }
165
+ // Fallback: standard src/
166
+ return "src";
167
+ }
168
+
148
169
  function readPackageJson(projectRoot) {
149
170
  const pkgPath = path.join(projectRoot, "package.json");
150
171
  if (!fs.existsSync(pkgPath)) return null;
@@ -223,51 +244,25 @@ function detectFramework(pkg) {
223
244
  return "vite";
224
245
  }
225
246
 
226
- /** Vite 7+ kullanılıyorsa Storybook 8 peer dep çakışır.
227
- * .npmrc'ye legacy-peer-deps=true ekleyerek tüm npm komutlarını bağışık hale getirir. */
228
- function ensureLegacyPeerDepsIfNeeded(projectRoot, pkg) {
229
- const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
230
- const viteVersion = allDeps["vite"] || "";
231
- // "^7.x", "~7.x", "7.x" gibi tüm Vite 7+ versiyonlarını yakala
232
- const isVite7Plus = /^\^?~?[7-9]\d*\./.test(viteVersion) || /^\^?~?[1-9]\d+\./.test(viteVersion);
233
- if (!isVite7Plus) return;
234
- const npmrcPath = path.join(projectRoot, ".npmrc");
235
- let content = fs.existsSync(npmrcPath) ? fs.readFileSync(npmrcPath, "utf-8") : "";
236
- if (content.includes("legacy-peer-deps")) return; // idempotent
237
- content = content ? content.trimEnd() + "\nlegacy-peer-deps=true\n" : "legacy-peer-deps=true\n";
238
- fs.writeFileSync(npmrcPath, content, "utf-8");
239
- console.log("📝 .npmrc: legacy-peer-deps=true eklendi (Vite 7+ / Storybook 8 uyumluluk).");
240
- }
241
-
242
247
  /** Framework'e göre Storybook framework paket adı */
243
248
  function storybookFrameworkPackage(framework) {
244
249
  if (framework === "nextjs") return "@storybook/nextjs";
245
250
  return "@storybook/react-vite"; // vite & remix
246
251
  }
247
252
 
248
- /** Projenin gerçek frontend src dizinini tespit eder.
249
- * Fullstack projelerde (client/, frontend/, web/) doğru alias için gerekli. */
250
- function detectFrontendSrcDir(projectRoot) {
251
- // Fullstack / monorepo: frontend ayrı bir klasörde olabilir
252
- const candidates = [
253
- "client/src",
254
- "frontend/src",
255
- "web/src",
256
- ];
257
- for (const c of candidates) {
258
- if (fs.existsSync(path.join(projectRoot, c))) return c;
259
- }
260
- return "src"; // varsayılan
261
- }
262
-
263
253
  /** Framework'e göre .storybook/main.ts içeriği */
264
- function buildStorybookMainTs(framework, projectRoot) {
254
+ function buildStorybookMainTs(framework, srcPrefix) {
255
+ // Fullstack projects: include both srcPrefix AND src/ globs so stories in either location are found
256
+ const extraStoriesGlob = srcPrefix !== "src"
257
+ ? `\n "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)",`
258
+ : "";
259
+
265
260
  if (framework === "nextjs") {
266
261
  return `import type { StorybookConfig } from "@storybook/nextjs";
267
262
 
268
263
  const config: StorybookConfig = {
269
264
  stories: [
270
- "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)",
265
+ "../${srcPrefix}/**/*.stories.@(js|jsx|mjs|ts|tsx)",${extraStoriesGlob}
271
266
  "../app/**/*.stories.@(js|jsx|mjs|ts|tsx)",
272
267
  ],
273
268
  addons: ["@storybook/addon-essentials", "@storybook/addon-a11y"],
@@ -281,13 +276,14 @@ export default config;
281
276
  `;
282
277
  }
283
278
  // vite (default) & remix
284
- const srcDir = detectFrontendSrcDir(projectRoot || process.cwd());
285
279
  return `import type { StorybookConfig } from "@storybook/react-vite";
286
280
  import { mergeConfig } from "vite";
287
281
  import path from "path";
288
282
 
289
283
  const config: StorybookConfig = {
290
- stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
284
+ stories: [
285
+ "../${srcPrefix}/**/*.stories.@(js|jsx|mjs|ts|tsx)",${extraStoriesGlob}
286
+ ],
291
287
  addons: ["@storybook/addon-essentials", "@storybook/addon-a11y"],
292
288
  framework: {
293
289
  name: "@storybook/react-vite",
@@ -297,7 +293,7 @@ const config: StorybookConfig = {
297
293
  return mergeConfig(config, {
298
294
  resolve: {
299
295
  alias: {
300
- "@": path.resolve(process.cwd(), "${srcDir}"),
296
+ "@": path.resolve(process.cwd(), "${srcPrefix}"),
301
297
  },
302
298
  },
303
299
  });
@@ -310,18 +306,14 @@ export default config;
310
306
 
311
307
  /** Framework'e göre CSS import path'i */
312
308
  function buildStorybookPreviewTs(framework, projectRoot) {
313
- // CSS dosyasını bul
309
+ // CSS dosyasını bul — fullstack projeler (client/src, frontend/src, web/src) dahil
310
+ const frontendPrefixes = ["src", "client/src", "frontend/src", "web/src"];
314
311
  const cssCandidates = [
315
- ["src/index.css", "../src/index.css"],
316
- ["src/globals.css", "../src/globals.css"],
317
- ["src/styles/globals.css", "../src/styles/globals.css"],
312
+ ...frontendPrefixes.map((p) => [p + "/index.css", "../" + p + "/index.css"]),
313
+ ...frontendPrefixes.map((p) => [p + "/globals.css", "../" + p + "/globals.css"]),
314
+ ...frontendPrefixes.map((p) => [p + "/styles/globals.css", "../" + p + "/styles/globals.css"]),
315
+ ...frontendPrefixes.map((p) => [p + "/App.css", "../" + p + "/App.css"]),
318
316
  ["app/globals.css", "../app/globals.css"],
319
- // Fullstack / monorepo patterns (client/, frontend/, web/)
320
- ["client/src/index.css", "../client/src/index.css"],
321
- ["client/src/globals.css", "../client/src/globals.css"],
322
- ["frontend/src/index.css", "../frontend/src/index.css"],
323
- ["frontend/src/globals.css", "../frontend/src/globals.css"],
324
- ["web/src/index.css", "../web/src/index.css"],
325
317
  ];
326
318
  let cssImport = '// CSS bulunamadı — projenizin global CSS dosyasını buraya ekleyin';
327
319
  for (const [rel, importPath] of cssCandidates) {
@@ -361,10 +353,10 @@ export default preview;
361
353
  // ADIM 1 — Bağımlılık kontrolü
362
354
  function needsStorybook(projectRoot, framework) {
363
355
  const pkg = readPackageJson(projectRoot);
364
- if (!pkg) return true; // package.json yok → yükle (main guard zaten önce hata verecek)
365
- const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
356
+ if (!pkg) return false;
357
+ const dev = pkg.devDependencies || {};
366
358
  const fwPkg = storybookFrameworkPackage(framework);
367
- return !(allDeps.storybook && allDeps[fwPkg]);
359
+ return !(dev.storybook && dev[fwPkg]);
368
360
  }
369
361
 
370
362
  // Storybook 8.6.x — aynı minor sürümde tutarak addon uyumluluk uyarısını önler
@@ -373,41 +365,62 @@ const STORYBOOK_VERSION = "8.6.17";
373
365
  function installStorybook(projectRoot, framework) {
374
366
  const fwPkg = storybookFrameworkPackage(framework);
375
367
  console.log(`📚 Storybook v8 (${fwPkg}) kuruluyor...`);
376
- const r = spawnSync(
377
- "npm",
378
- [
379
- "install",
380
- "--save-dev",
381
- "--save-exact",
382
- "--legacy-peer-deps",
383
- `storybook@${STORYBOOK_VERSION}`,
384
- `${fwPkg}@${STORYBOOK_VERSION}`,
385
- `@storybook/react@${STORYBOOK_VERSION}`,
386
- `@storybook/addon-essentials@${STORYBOOK_VERSION}`,
387
- `@storybook/addon-a11y@${STORYBOOK_VERSION}`,
388
- `@storybook/blocks@${STORYBOOK_VERSION}`,
389
- ],
390
- { cwd: projectRoot, stdio: "inherit", shell: true }
391
- );
368
+ // No extra deps — @tailwindcss/vite removed (causes ERESOLVE in non-Tailwind projects)
369
+
370
+ // Vite 7+ peer dependency conflict: Storybook 8 requires vite ^4/5/6 but project has vite 7+
371
+ // Detect Vite version and add --legacy-peer-deps if needed
372
+ const pkg = readPackageJson(projectRoot);
373
+ const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
374
+ const viteVer = deps?.vite || "";
375
+ const viteIsMajor7Plus = /^[\^~]?[7-9]/.test(viteVer) || /^\d+/.test(viteVer) && parseInt(viteVer) >= 7;
376
+ const needsLegacyPeers = viteIsMajor7Plus;
377
+
378
+ if (needsLegacyPeers) {
379
+ console.log("⚠️ Vite 7+ algılandı — --legacy-peer-deps ile kurulum yapılıyor...");
380
+ // Ensure .npmrc has legacy-peer-deps for future installs too
381
+ const npmrcPath = path.join(projectRoot, ".npmrc");
382
+ const npmrcContent = fs.existsSync(npmrcPath) ? fs.readFileSync(npmrcPath, "utf-8") : "";
383
+ if (!npmrcContent.includes("legacy-peer-deps")) {
384
+ fs.appendFileSync(npmrcPath, "\nlegacy-peer-deps=true\n", "utf-8");
385
+ }
386
+ }
387
+
388
+ const installArgs = [
389
+ "install",
390
+ "--save-dev",
391
+ "--save-exact",
392
+ ...(needsLegacyPeers ? ["--legacy-peer-deps"] : []),
393
+ `storybook@${STORYBOOK_VERSION}`,
394
+ `${fwPkg}@${STORYBOOK_VERSION}`,
395
+ `@storybook/react@${STORYBOOK_VERSION}`,
396
+ `@storybook/addon-essentials@${STORYBOOK_VERSION}`,
397
+ `@storybook/addon-a11y@${STORYBOOK_VERSION}`,
398
+ `@storybook/blocks@${STORYBOOK_VERSION}`,
399
+ ];
400
+
401
+ const r = spawnSync("npm", installArgs, {
402
+ cwd: projectRoot,
403
+ stdio: "inherit",
404
+ shell: true,
405
+ });
392
406
  if (r.status !== 0) {
393
- console.error("❌ npm install storybook başarısız oldu. VDS kurulumu durduruluyor.");
407
+ console.error("❌ npm install storybook başarısız oldu.");
394
408
  process.exit(1);
395
409
  }
396
410
  }
397
411
 
398
412
  // ADIM 2 — .storybook/
399
- function ensureStorybook(projectRoot, framework) {
413
+ function ensureStorybook(projectRoot, framework, srcPrefix) {
400
414
  const storybookDir = path.join(projectRoot, ".storybook");
401
415
  if (!fs.existsSync(storybookDir)) {
402
416
  fs.mkdirSync(storybookDir, { recursive: true });
403
417
  console.log("📁 .storybook/ oluşturuldu.");
404
418
  }
405
419
 
406
- const mainTs = buildStorybookMainTs(framework, projectRoot);
420
+ const mainTs = buildStorybookMainTs(framework, srcPrefix);
407
421
  const mainPath = path.join(storybookDir, "main.ts");
408
422
  fs.writeFileSync(mainPath, mainTs, "utf-8");
409
- const detectedSrc = detectFrontendSrcDir(projectRoot);
410
- console.log(`📝 .storybook/main.ts yazıldı (framework: ${framework}, @ alias: ${detectedSrc}).`);
423
+ console.log(`📝 .storybook/main.ts yazıldı (framework: ${framework}).`);
411
424
 
412
425
  const previewTs = buildStorybookPreviewTs(framework, projectRoot);
413
426
 
@@ -525,17 +538,15 @@ function ensureCursorrules(projectRoot) {
525
538
  console.log("📄 .cursorrules yazıldı.");
526
539
  }
527
540
 
528
- // ADIM 6 — src/stories/ oluştur (scan artık klasörü kendisi buluyor; zorla yaratmaya gerek yok)
529
- function ensureStoriesDir(projectRoot) {
530
- const srcDir = path.join(projectRoot, "src");
541
+ // ADIM 6 — stories/ oluştur (scan artık klasörü kendisi buluyor; zorla yaratmaya gerek yok)
542
+ function ensureStoriesDir(projectRoot, srcPrefix) {
543
+ const srcDir = path.join(projectRoot, srcPrefix);
531
544
  if (!fs.existsSync(srcDir)) fs.mkdirSync(srcDir, { recursive: true });
532
545
  const storiesDir = path.join(srcDir, "stories");
533
546
  if (!fs.existsSync(storiesDir)) {
534
547
  fs.mkdirSync(storiesDir, { recursive: true });
535
- console.log("📁 src/stories/ oluşturuldu.");
548
+ console.log(`📁 ${srcPrefix}/stories/ oluşturuldu.`);
536
549
  }
537
- // scan.mjs artık klasörü kendisi buluyor (src/components → components → app/components → ...)
538
- // Klasör yoksa oluşturma — projeye ait mevcut yapıyı koruyalım.
539
550
  }
540
551
 
541
552
  // ADIM 7 — İlk tarama
@@ -607,15 +618,15 @@ module.exports = {
607
618
  }
608
619
 
609
620
  // ADIM 9 — Storybook örnek dosyalarını sil
610
- function removeStorybookExamples(projectRoot) {
611
- const storiesDir = path.join(projectRoot, "src", "stories");
621
+ function removeStorybookExamples(projectRoot, srcPrefix) {
622
+ const storiesDir = path.join(projectRoot, srcPrefix, "stories");
612
623
  if (!fs.existsSync(storiesDir)) return;
613
624
  for (const name of STORYBOOK_EXAMPLE_FILES) {
614
625
  const filePath = path.join(storiesDir, name);
615
626
  if (fs.existsSync(filePath)) {
616
627
  try {
617
628
  fs.unlinkSync(filePath);
618
- console.log("🗑️ Silindi: src/stories/" + name);
629
+ console.log(`🗑️ Silindi: ${srcPrefix}/stories/${name}`);
619
630
  } catch (_) {}
620
631
  }
621
632
  }
@@ -649,10 +660,10 @@ if (monorepoPackages.length > 0 && pkg.workspaces) {
649
660
  }
650
661
 
651
662
  const framework = detectFramework(pkg);
652
- console.log(`🔍 Framework tespit edildi: ${framework}\n`);
653
-
654
- // Vite 7+ projelerinde Storybook 8 peer dep çakışmasını önle
655
- ensureLegacyPeerDepsIfNeeded(projectRoot, pkg);
663
+ const srcPrefix = detectFrontendSrcDir(projectRoot);
664
+ console.log(`🔍 Framework tespit edildi: ${framework}`);
665
+ if (srcPrefix !== "src") console.log(`📂 Fullstack proje algılandı: kaynak dizin → ${srcPrefix}`);
666
+ console.log("");
656
667
 
657
668
  // ADIM 1
658
669
  if (needsStorybook(projectRoot, framework)) {
@@ -662,7 +673,7 @@ if (needsStorybook(projectRoot, framework)) {
662
673
  }
663
674
 
664
675
  // ADIM 2
665
- ensureStorybook(projectRoot, framework);
676
+ ensureStorybook(projectRoot, framework, srcPrefix);
666
677
 
667
678
  // ADIM 3
668
679
  ensureVdsCore(projectRoot);
@@ -674,10 +685,10 @@ addScripts(projectRoot);
674
685
  ensureCursorrules(projectRoot);
675
686
 
676
687
  // ADIM 6
677
- ensureStoriesDir(projectRoot);
688
+ ensureStoriesDir(projectRoot, srcPrefix);
678
689
 
679
690
  // ADIM 9 (örnek dosyaları taramadan önce silebiliriz; scan src/components ve src/pages tarar, src/stories değil)
680
- removeStorybookExamples(projectRoot);
691
+ removeStorybookExamples(projectRoot, srcPrefix);
681
692
 
682
693
  // ADIM 9b
683
694
  ensureVdsConfig(projectRoot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-design-system",
3
- "version": "2.8.40",
3
+ "version": "2.8.42",
4
4
  "description": "Auto-generate design systems for vibe coding projects",
5
5
  "homepage": "https://vibedesign.tech",
6
6
  "repository": {