vibe-design-system 2.8.39 → 2.8.40
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 +6 -0
- package/package.json +1 -1
- package/vds-core-template/storybook-adapt.mjs +48 -0
package/bin/init.js
CHANGED
|
@@ -316,6 +316,12 @@ function buildStorybookPreviewTs(framework, projectRoot) {
|
|
|
316
316
|
["src/globals.css", "../src/globals.css"],
|
|
317
317
|
["src/styles/globals.css", "../src/styles/globals.css"],
|
|
318
318
|
["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"],
|
|
319
325
|
];
|
|
320
326
|
let cssImport = '// CSS bulunamadı — projenizin global CSS dosyasını buraya ekleyin';
|
|
321
327
|
for (const [rel, importPath] of cssCandidates) {
|
package/package.json
CHANGED
|
@@ -206,6 +206,52 @@ function injectAliases(projectRoot, specifiers) {
|
|
|
206
206
|
|
|
207
207
|
/** Inject resolve.dedupe into .storybook/main.* viteFinal to prevent multiple React instances.
|
|
208
208
|
* Multiple React instances cause "Cannot read properties of null (reading 'useRef')" at MemoryRouter. */
|
|
209
|
+
/** Read vite.config.ts/js and extract path.resolve alias entries.
|
|
210
|
+
* Injects any missing aliases into .storybook/main.ts viteFinal. */
|
|
211
|
+
function injectViteConfigAliases(projectRoot) {
|
|
212
|
+
const mainPath = getMainPath(projectRoot);
|
|
213
|
+
if (!mainPath) return;
|
|
214
|
+
|
|
215
|
+
// Find the project's vite config
|
|
216
|
+
const viteConfigCandidates = ["vite.config.ts", "vite.config.js", "vite.config.mts", "vite.config.mjs"];
|
|
217
|
+
let viteConfigContent = null;
|
|
218
|
+
for (const name of viteConfigCandidates) {
|
|
219
|
+
const p = path.join(projectRoot, name);
|
|
220
|
+
if (fs.existsSync(p)) { viteConfigContent = fs.readFileSync(p, "utf-8"); break; }
|
|
221
|
+
}
|
|
222
|
+
if (!viteConfigContent) return;
|
|
223
|
+
|
|
224
|
+
// Extract alias entries like: "@shared": path.resolve(..., "shared")
|
|
225
|
+
const aliasRe = /["'](@[^"']+)["']\s*:\s*path\.resolve\([^)]*,\s*["']([^"']+)["']\s*\)/g;
|
|
226
|
+
const viteAliases = {};
|
|
227
|
+
let m;
|
|
228
|
+
while ((m = aliasRe.exec(viteConfigContent)) !== null) {
|
|
229
|
+
viteAliases[m[1]] = m[2]; // e.g. "@shared" -> "shared"
|
|
230
|
+
}
|
|
231
|
+
if (Object.keys(viteAliases).length === 0) return;
|
|
232
|
+
|
|
233
|
+
// Read current main.ts
|
|
234
|
+
let mainContent = fs.readFileSync(mainPath, "utf-8");
|
|
235
|
+
|
|
236
|
+
// Find which aliases are missing
|
|
237
|
+
const missingAliases = Object.entries(viteAliases).filter(([key]) => !mainContent.includes(`"${key}"`));
|
|
238
|
+
if (missingAliases.length === 0) return;
|
|
239
|
+
|
|
240
|
+
// Inject missing aliases into the existing alias block
|
|
241
|
+
const aliasBlockRe = /(\balias\s*:\s*\{)([^}]*)(\})/;
|
|
242
|
+
if (!aliasBlockRe.test(mainContent)) return;
|
|
243
|
+
|
|
244
|
+
const additions = missingAliases
|
|
245
|
+
.map(([key, dir]) => `\n "${key}": path.resolve(process.cwd(), "${dir}"),`)
|
|
246
|
+
.join("");
|
|
247
|
+
|
|
248
|
+
mainContent = mainContent.replace(aliasBlockRe, (_, open, body, close) =>
|
|
249
|
+
`${open}${body}${additions}\n ${close}`
|
|
250
|
+
);
|
|
251
|
+
fs.writeFileSync(mainPath, mainContent, "utf-8");
|
|
252
|
+
console.log(`[VDS] Storybook adapt: injected vite aliases: ${missingAliases.map(([k]) => k).join(", ")}`);
|
|
253
|
+
}
|
|
254
|
+
|
|
209
255
|
function injectDedupe(projectRoot) {
|
|
210
256
|
const mainPath = getMainPath(projectRoot);
|
|
211
257
|
if (!mainPath) return;
|
|
@@ -231,6 +277,8 @@ function main() {
|
|
|
231
277
|
}
|
|
232
278
|
// Always inject dedupe — prevents "useRef null" crashes from multiple React instances
|
|
233
279
|
injectDedupe(projectRoot);
|
|
280
|
+
// Propagate aliases from project's vite.config.ts to Storybook
|
|
281
|
+
injectViteConfigAliases(projectRoot);
|
|
234
282
|
reportUnresolvedImports(projectRoot);
|
|
235
283
|
const problematic = collectProblematicImports(projectRoot);
|
|
236
284
|
if (problematic.size === 0) return;
|