@tpitre/story-ui 2.1.0 ā 2.1.1
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/dist/cli/setup.js +49 -3
- package/package.json +1 -1
package/dist/cli/setup.js
CHANGED
|
@@ -115,6 +115,7 @@ function setupStorybookPreview(designSystem) {
|
|
|
115
115
|
imports: [
|
|
116
116
|
"import type { Preview } from '@storybook/react-vite'",
|
|
117
117
|
"import { MantineProvider } from '@mantine/core'",
|
|
118
|
+
"import '@mantine/core/styles.css'",
|
|
118
119
|
"import React from 'react'"
|
|
119
120
|
],
|
|
120
121
|
decorator: `(Story) => (
|
|
@@ -201,11 +202,56 @@ async function installDesignSystem(systemKey) {
|
|
|
201
202
|
try {
|
|
202
203
|
console.log(chalk.gray(`Running: ${installCommand}`));
|
|
203
204
|
execSync(installCommand, { stdio: 'inherit' });
|
|
205
|
+
// Verify installation was successful by re-checking package.json
|
|
206
|
+
const updatedPackageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'));
|
|
207
|
+
const updatedDeps = { ...updatedPackageJson.dependencies, ...updatedPackageJson.devDependencies };
|
|
208
|
+
const stillMissingPackages = config.packages.filter(pkg => !updatedDeps[pkg]);
|
|
209
|
+
if (stillMissingPackages.length > 0) {
|
|
210
|
+
throw new Error(`Installation failed: packages still missing: ${stillMissingPackages.join(', ')}`);
|
|
211
|
+
}
|
|
204
212
|
console.log(chalk.green(`ā
${config.name} installed successfully!`));
|
|
205
213
|
if (config.additionalSetup) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
214
|
+
// Try to automatically add CSS import for Mantine
|
|
215
|
+
if (systemKey === 'mantine') {
|
|
216
|
+
const cssFiles = [
|
|
217
|
+
path.join(process.cwd(), 'src', 'index.css'),
|
|
218
|
+
path.join(process.cwd(), 'src', 'main.css'),
|
|
219
|
+
path.join(process.cwd(), 'src', 'App.css')
|
|
220
|
+
];
|
|
221
|
+
let cssAdded = false;
|
|
222
|
+
for (const cssFile of cssFiles) {
|
|
223
|
+
if (fs.existsSync(cssFile)) {
|
|
224
|
+
try {
|
|
225
|
+
const cssContent = fs.readFileSync(cssFile, 'utf-8');
|
|
226
|
+
if (!cssContent.includes('@mantine/core/styles.css')) {
|
|
227
|
+
const newContent = `@import "@mantine/core/styles.css";\n\n${cssContent}`;
|
|
228
|
+
fs.writeFileSync(cssFile, newContent);
|
|
229
|
+
console.log(chalk.green(`ā
Added Mantine CSS import to ${path.relative(process.cwd(), cssFile)}`));
|
|
230
|
+
cssAdded = true;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
console.log(chalk.blue(`ā¹ļø Mantine CSS already imported in ${path.relative(process.cwd(), cssFile)}`));
|
|
235
|
+
cssAdded = true;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
console.warn(chalk.yellow(`ā ļø Could not modify ${cssFile}:`, error));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (!cssAdded) {
|
|
245
|
+
console.log(chalk.blue('\nš Manual setup required:'));
|
|
246
|
+
console.log(chalk.gray(`Add this import to your main CSS file:`));
|
|
247
|
+
console.log(chalk.cyan(`${config.additionalSetup}`));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
console.log(chalk.blue('\nš Additional setup required:'));
|
|
252
|
+
console.log(chalk.gray(`Add this import to your main CSS/index file:`));
|
|
253
|
+
console.log(chalk.cyan(`${config.additionalSetup}`));
|
|
254
|
+
}
|
|
209
255
|
}
|
|
210
256
|
return true;
|
|
211
257
|
}
|