vibe-design-system 2.8.36 → 2.8.38

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/bin/init.js +40 -4
  2. package/package.json +1 -1
package/bin/init.js CHANGED
@@ -223,14 +223,45 @@ function detectFramework(pkg) {
223
223
  return "vite";
224
224
  }
225
225
 
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
+
226
242
  /** Framework'e göre Storybook framework paket adı */
227
243
  function storybookFrameworkPackage(framework) {
228
244
  if (framework === "nextjs") return "@storybook/nextjs";
229
245
  return "@storybook/react-vite"; // vite & remix
230
246
  }
231
247
 
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
+
232
263
  /** Framework'e göre .storybook/main.ts içeriği */
233
- function buildStorybookMainTs(framework) {
264
+ function buildStorybookMainTs(framework, projectRoot) {
234
265
  if (framework === "nextjs") {
235
266
  return `import type { StorybookConfig } from "@storybook/nextjs";
236
267
 
@@ -250,6 +281,7 @@ export default config;
250
281
  `;
251
282
  }
252
283
  // vite (default) & remix
284
+ const srcDir = detectFrontendSrcDir(projectRoot || process.cwd());
253
285
  return `import type { StorybookConfig } from "@storybook/react-vite";
254
286
  import { mergeConfig } from "vite";
255
287
  import path from "path";
@@ -265,7 +297,7 @@ const config: StorybookConfig = {
265
297
  return mergeConfig(config, {
266
298
  resolve: {
267
299
  alias: {
268
- "@": path.resolve(process.cwd(), "src"),
300
+ "@": path.resolve(process.cwd(), "${srcDir}"),
269
301
  },
270
302
  },
271
303
  });
@@ -365,10 +397,11 @@ function ensureStorybook(projectRoot, framework) {
365
397
  console.log("📁 .storybook/ oluşturuldu.");
366
398
  }
367
399
 
368
- const mainTs = buildStorybookMainTs(framework);
400
+ const mainTs = buildStorybookMainTs(framework, projectRoot);
369
401
  const mainPath = path.join(storybookDir, "main.ts");
370
402
  fs.writeFileSync(mainPath, mainTs, "utf-8");
371
- console.log(`📝 .storybook/main.ts yazıldı (framework: ${framework}).`);
403
+ const detectedSrc = detectFrontendSrcDir(projectRoot);
404
+ console.log(`📝 .storybook/main.ts yazıldı (framework: ${framework}, @ alias: ${detectedSrc}).`);
372
405
 
373
406
  const previewTs = buildStorybookPreviewTs(framework, projectRoot);
374
407
 
@@ -612,6 +645,9 @@ if (monorepoPackages.length > 0 && pkg.workspaces) {
612
645
  const framework = detectFramework(pkg);
613
646
  console.log(`🔍 Framework tespit edildi: ${framework}\n`);
614
647
 
648
+ // Vite 7+ projelerinde Storybook 8 peer dep çakışmasını önle
649
+ ensureLegacyPeerDepsIfNeeded(projectRoot, pkg);
650
+
615
651
  // ADIM 1
616
652
  if (needsStorybook(projectRoot, framework)) {
617
653
  installStorybook(projectRoot, framework);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-design-system",
3
- "version": "2.8.36",
3
+ "version": "2.8.38",
4
4
  "description": "Auto-generate design systems for vibe coding projects",
5
5
  "homepage": "https://vibedesign.tech",
6
6
  "repository": {