vibe-design-system 2.5.48 → 2.5.50
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 +24 -12
- package/package.json +1 -1
package/bin/init.js
CHANGED
|
@@ -48,18 +48,9 @@ export default config;
|
|
|
48
48
|
|
|
49
49
|
const STORYBOOK_PREVIEW_TS = `import type { Preview } from "@storybook/react";
|
|
50
50
|
import React from "react";
|
|
51
|
-
import { MemoryRouter } from "react-router-dom";
|
|
52
51
|
// Uygulamanızla aynı stiller için: index.css + kullandığınız diğer global CSS dosyalarını ekleyin (örn. "../src/App.css").
|
|
53
52
|
import "../src/index.css";
|
|
54
53
|
|
|
55
|
-
const withRouter = (Story: any) => {
|
|
56
|
-
try {
|
|
57
|
-
return React.createElement(MemoryRouter, null, React.createElement(Story));
|
|
58
|
-
} catch {
|
|
59
|
-
return React.createElement(Story);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
54
|
const preview: Preview = {
|
|
64
55
|
parameters: {
|
|
65
56
|
layout: "fullscreen",
|
|
@@ -77,7 +68,6 @@ const preview: Preview = {
|
|
|
77
68
|
},
|
|
78
69
|
},
|
|
79
70
|
},
|
|
80
|
-
decorators: [withRouter],
|
|
81
71
|
};
|
|
82
72
|
|
|
83
73
|
export default preview;
|
|
@@ -204,12 +194,34 @@ function ensureStorybook(projectRoot) {
|
|
|
204
194
|
fs.writeFileSync(mainPath, STORYBOOK_MAIN_TS, "utf-8");
|
|
205
195
|
console.log("📝 .storybook/main.ts yazıldı.");
|
|
206
196
|
|
|
207
|
-
|
|
197
|
+
// preview.ts / preview.tsx — eski VDS template'lerini otomatik olarak yeni router'sız template'e migrate et.
|
|
198
|
+
const previewCandidates = ["preview.tsx", "preview.ts", "preview.jsx", "preview.js"];
|
|
199
|
+
const existingPreview = previewCandidates.find((name) =>
|
|
208
200
|
fs.existsSync(path.join(storybookDir, name))
|
|
209
201
|
);
|
|
210
|
-
|
|
202
|
+
const previewPath = existingPreview ? path.join(storybookDir, existingPreview) : null;
|
|
203
|
+
|
|
204
|
+
if (!previewPath) {
|
|
205
|
+
// Daha önce hiç preview yoksa, yeni template'i yaz.
|
|
211
206
|
fs.writeFileSync(path.join(storybookDir, "preview.ts"), STORYBOOK_PREVIEW_TS, "utf-8");
|
|
212
207
|
console.log("📝 .storybook/preview.ts yazıldı.");
|
|
208
|
+
} else {
|
|
209
|
+
// Eski VDS preview'lerini tespit edip otomatik migrate et; kullanıcıya ait preview'lere dokunma.
|
|
210
|
+
try {
|
|
211
|
+
const content = fs.readFileSync(previewPath, "utf-8");
|
|
212
|
+
const looksLikeOldVdsPreview =
|
|
213
|
+
content.includes('MemoryRouter from "react-router-dom"') ||
|
|
214
|
+
content.includes("const withRouter") ||
|
|
215
|
+
content.includes("decorators: [withRouter");
|
|
216
|
+
if (looksLikeOldVdsPreview) {
|
|
217
|
+
fs.writeFileSync(previewPath, STORYBOOK_PREVIEW_TS, "utf-8");
|
|
218
|
+
console.log("📝 .storybook/preview.* eski VDS şablonundan yeni router'sız şablona güncellendi.");
|
|
219
|
+
} else {
|
|
220
|
+
console.log("ℹ️ .storybook/preview.* bulundu, kullanıcıya ait görünüyor; değiştirilmedi.");
|
|
221
|
+
}
|
|
222
|
+
} catch {
|
|
223
|
+
console.log("⚠️ .storybook/preview.* okunamadı; değiştirilmedi.");
|
|
224
|
+
}
|
|
213
225
|
}
|
|
214
226
|
}
|
|
215
227
|
|