vibe-design-system 2.8.40 → 2.8.41

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,20 @@ 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) {
265
255
  if (framework === "nextjs") {
266
256
  return `import type { StorybookConfig } from "@storybook/nextjs";
267
257
 
268
258
  const config: StorybookConfig = {
269
259
  stories: [
270
- "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)",
260
+ "../${srcPrefix}/**/*.stories.@(js|jsx|mjs|ts|tsx)",
271
261
  "../app/**/*.stories.@(js|jsx|mjs|ts|tsx)",
272
262
  ],
273
263
  addons: ["@storybook/addon-essentials", "@storybook/addon-a11y"],
@@ -281,13 +271,12 @@ export default config;
281
271
  `;
282
272
  }
283
273
  // vite (default) & remix
284
- const srcDir = detectFrontendSrcDir(projectRoot || process.cwd());
285
274
  return `import type { StorybookConfig } from "@storybook/react-vite";
286
275
  import { mergeConfig } from "vite";
287
276
  import path from "path";
288
277
 
289
278
  const config: StorybookConfig = {
290
- stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
279
+ stories: ["../${srcPrefix}/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
291
280
  addons: ["@storybook/addon-essentials", "@storybook/addon-a11y"],
292
281
  framework: {
293
282
  name: "@storybook/react-vite",
@@ -297,7 +286,7 @@ const config: StorybookConfig = {
297
286
  return mergeConfig(config, {
298
287
  resolve: {
299
288
  alias: {
300
- "@": path.resolve(process.cwd(), "${srcDir}"),
289
+ "@": path.resolve(process.cwd(), "${srcPrefix}"),
301
290
  },
302
291
  },
303
292
  });
@@ -310,18 +299,14 @@ export default config;
310
299
 
311
300
  /** Framework'e göre CSS import path'i */
312
301
  function buildStorybookPreviewTs(framework, projectRoot) {
313
- // CSS dosyasını bul
302
+ // CSS dosyasını bul — fullstack projeler (client/src, frontend/src, web/src) dahil
303
+ const frontendPrefixes = ["src", "client/src", "frontend/src", "web/src"];
314
304
  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"],
305
+ ...frontendPrefixes.map((p) => [p + "/index.css", "../" + p + "/index.css"]),
306
+ ...frontendPrefixes.map((p) => [p + "/globals.css", "../" + p + "/globals.css"]),
307
+ ...frontendPrefixes.map((p) => [p + "/styles/globals.css", "../" + p + "/styles/globals.css"]),
308
+ ...frontendPrefixes.map((p) => [p + "/App.css", "../" + p + "/App.css"]),
318
309
  ["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
310
  ];
326
311
  let cssImport = '// CSS bulunamadı — projenizin global CSS dosyasını buraya ekleyin';
327
312
  for (const [rel, importPath] of cssCandidates) {
@@ -361,10 +346,10 @@ export default preview;
361
346
  // ADIM 1 — Bağımlılık kontrolü
362
347
  function needsStorybook(projectRoot, framework) {
363
348
  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 };
349
+ if (!pkg) return false;
350
+ const dev = pkg.devDependencies || {};
366
351
  const fwPkg = storybookFrameworkPackage(framework);
367
- return !(allDeps.storybook && allDeps[fwPkg]);
352
+ return !(dev.storybook && dev[fwPkg]);
368
353
  }
369
354
 
370
355
  // Storybook 8.6.x — aynı minor sürümde tutarak addon uyumluluk uyarısını önler
@@ -373,41 +358,62 @@ const STORYBOOK_VERSION = "8.6.17";
373
358
  function installStorybook(projectRoot, framework) {
374
359
  const fwPkg = storybookFrameworkPackage(framework);
375
360
  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
- );
361
+ // No extra deps — @tailwindcss/vite removed (causes ERESOLVE in non-Tailwind projects)
362
+
363
+ // Vite 7+ peer dependency conflict: Storybook 8 requires vite ^4/5/6 but project has vite 7+
364
+ // Detect Vite version and add --legacy-peer-deps if needed
365
+ const pkg = readPackageJson(projectRoot);
366
+ const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
367
+ const viteVer = deps?.vite || "";
368
+ const viteIsMajor7Plus = /^[\^~]?[7-9]/.test(viteVer) || /^\d+/.test(viteVer) && parseInt(viteVer) >= 7;
369
+ const needsLegacyPeers = viteIsMajor7Plus;
370
+
371
+ if (needsLegacyPeers) {
372
+ console.log("⚠️ Vite 7+ algılandı — --legacy-peer-deps ile kurulum yapılıyor...");
373
+ // Ensure .npmrc has legacy-peer-deps for future installs too
374
+ const npmrcPath = path.join(projectRoot, ".npmrc");
375
+ const npmrcContent = fs.existsSync(npmrcPath) ? fs.readFileSync(npmrcPath, "utf-8") : "";
376
+ if (!npmrcContent.includes("legacy-peer-deps")) {
377
+ fs.appendFileSync(npmrcPath, "\nlegacy-peer-deps=true\n", "utf-8");
378
+ }
379
+ }
380
+
381
+ const installArgs = [
382
+ "install",
383
+ "--save-dev",
384
+ "--save-exact",
385
+ ...(needsLegacyPeers ? ["--legacy-peer-deps"] : []),
386
+ `storybook@${STORYBOOK_VERSION}`,
387
+ `${fwPkg}@${STORYBOOK_VERSION}`,
388
+ `@storybook/react@${STORYBOOK_VERSION}`,
389
+ `@storybook/addon-essentials@${STORYBOOK_VERSION}`,
390
+ `@storybook/addon-a11y@${STORYBOOK_VERSION}`,
391
+ `@storybook/blocks@${STORYBOOK_VERSION}`,
392
+ ];
393
+
394
+ const r = spawnSync("npm", installArgs, {
395
+ cwd: projectRoot,
396
+ stdio: "inherit",
397
+ shell: true,
398
+ });
392
399
  if (r.status !== 0) {
393
- console.error("❌ npm install storybook başarısız oldu. VDS kurulumu durduruluyor.");
400
+ console.error("❌ npm install storybook başarısız oldu.");
394
401
  process.exit(1);
395
402
  }
396
403
  }
397
404
 
398
405
  // ADIM 2 — .storybook/
399
- function ensureStorybook(projectRoot, framework) {
406
+ function ensureStorybook(projectRoot, framework, srcPrefix) {
400
407
  const storybookDir = path.join(projectRoot, ".storybook");
401
408
  if (!fs.existsSync(storybookDir)) {
402
409
  fs.mkdirSync(storybookDir, { recursive: true });
403
410
  console.log("📁 .storybook/ oluşturuldu.");
404
411
  }
405
412
 
406
- const mainTs = buildStorybookMainTs(framework, projectRoot);
413
+ const mainTs = buildStorybookMainTs(framework, srcPrefix);
407
414
  const mainPath = path.join(storybookDir, "main.ts");
408
415
  fs.writeFileSync(mainPath, mainTs, "utf-8");
409
- const detectedSrc = detectFrontendSrcDir(projectRoot);
410
- console.log(`📝 .storybook/main.ts yazıldı (framework: ${framework}, @ alias: ${detectedSrc}).`);
416
+ console.log(`📝 .storybook/main.ts yazıldı (framework: ${framework}).`);
411
417
 
412
418
  const previewTs = buildStorybookPreviewTs(framework, projectRoot);
413
419
 
@@ -525,17 +531,15 @@ function ensureCursorrules(projectRoot) {
525
531
  console.log("📄 .cursorrules yazıldı.");
526
532
  }
527
533
 
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");
534
+ // ADIM 6 — stories/ oluştur (scan artık klasörü kendisi buluyor; zorla yaratmaya gerek yok)
535
+ function ensureStoriesDir(projectRoot, srcPrefix) {
536
+ const srcDir = path.join(projectRoot, srcPrefix);
531
537
  if (!fs.existsSync(srcDir)) fs.mkdirSync(srcDir, { recursive: true });
532
538
  const storiesDir = path.join(srcDir, "stories");
533
539
  if (!fs.existsSync(storiesDir)) {
534
540
  fs.mkdirSync(storiesDir, { recursive: true });
535
- console.log("📁 src/stories/ oluşturuldu.");
541
+ console.log(`📁 ${srcPrefix}/stories/ oluşturuldu.`);
536
542
  }
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
543
  }
540
544
 
541
545
  // ADIM 7 — İlk tarama
@@ -607,15 +611,15 @@ module.exports = {
607
611
  }
608
612
 
609
613
  // ADIM 9 — Storybook örnek dosyalarını sil
610
- function removeStorybookExamples(projectRoot) {
611
- const storiesDir = path.join(projectRoot, "src", "stories");
614
+ function removeStorybookExamples(projectRoot, srcPrefix) {
615
+ const storiesDir = path.join(projectRoot, srcPrefix, "stories");
612
616
  if (!fs.existsSync(storiesDir)) return;
613
617
  for (const name of STORYBOOK_EXAMPLE_FILES) {
614
618
  const filePath = path.join(storiesDir, name);
615
619
  if (fs.existsSync(filePath)) {
616
620
  try {
617
621
  fs.unlinkSync(filePath);
618
- console.log("🗑️ Silindi: src/stories/" + name);
622
+ console.log(`🗑️ Silindi: ${srcPrefix}/stories/${name}`);
619
623
  } catch (_) {}
620
624
  }
621
625
  }
@@ -649,10 +653,10 @@ if (monorepoPackages.length > 0 && pkg.workspaces) {
649
653
  }
650
654
 
651
655
  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);
656
+ const srcPrefix = detectFrontendSrcDir(projectRoot);
657
+ console.log(`🔍 Framework tespit edildi: ${framework}`);
658
+ if (srcPrefix !== "src") console.log(`📂 Fullstack proje algılandı: kaynak dizin → ${srcPrefix}`);
659
+ console.log("");
656
660
 
657
661
  // ADIM 1
658
662
  if (needsStorybook(projectRoot, framework)) {
@@ -662,7 +666,7 @@ if (needsStorybook(projectRoot, framework)) {
662
666
  }
663
667
 
664
668
  // ADIM 2
665
- ensureStorybook(projectRoot, framework);
669
+ ensureStorybook(projectRoot, framework, srcPrefix);
666
670
 
667
671
  // ADIM 3
668
672
  ensureVdsCore(projectRoot);
@@ -674,10 +678,10 @@ addScripts(projectRoot);
674
678
  ensureCursorrules(projectRoot);
675
679
 
676
680
  // ADIM 6
677
- ensureStoriesDir(projectRoot);
681
+ ensureStoriesDir(projectRoot, srcPrefix);
678
682
 
679
683
  // ADIM 9 (örnek dosyaları taramadan önce silebiliriz; scan src/components ve src/pages tarar, src/stories değil)
680
- removeStorybookExamples(projectRoot);
684
+ removeStorybookExamples(projectRoot, srcPrefix);
681
685
 
682
686
  // ADIM 9b
683
687
  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.41",
4
4
  "description": "Auto-generate design systems for vibe coding projects",
5
5
  "homepage": "https://vibedesign.tech",
6
6
  "repository": {