@tpitre/story-ui 2.1.1 → 2.1.2

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/dist/cli/setup.js +23 -4
  2. package/package.json +1 -1
package/dist/cli/setup.js CHANGED
@@ -86,6 +86,23 @@ function setupStorybookPreview(designSystem) {
86
86
  console.log(chalk.yellow('⚠️ .storybook directory not found. Please run storybook init first.'));
87
87
  return;
88
88
  }
89
+ // Verify required packages are installed before creating preview
90
+ if (['antd', 'mantine', 'chakra'].includes(designSystem)) {
91
+ const packageJsonPath = path.join(process.cwd(), 'package.json');
92
+ if (fs.existsSync(packageJsonPath)) {
93
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
94
+ const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies };
95
+ const config = DESIGN_SYSTEM_CONFIGS[designSystem];
96
+ if (config) {
97
+ const missingDeps = config.packages.filter(pkg => !allDeps[pkg]);
98
+ if (missingDeps.length > 0) {
99
+ console.log(chalk.red(`❌ Cannot create preview.tsx - missing dependencies: ${missingDeps.join(', ')}`));
100
+ console.log(chalk.yellow(`Please install them first: npm install ${missingDeps.join(' ')}`));
101
+ return;
102
+ }
103
+ }
104
+ }
105
+ }
89
106
  const designSystemConfigs = {
90
107
  chakra: {
91
108
  imports: [
@@ -402,6 +419,8 @@ export async function setupCommand() {
402
419
  console.log(chalk.cyan(`npm install ${config.packages.join(' ')}`));
403
420
  process.exit(1);
404
421
  }
422
+ // Set up Storybook preview file after successful installation
423
+ setupStorybookPreview(answers.designSystem);
405
424
  }
406
425
  else if (['antd', 'mantine', 'chakra'].includes(answers.designSystem)) {
407
426
  // User declined installation - verify dependencies exist
@@ -417,6 +436,10 @@ export async function setupCommand() {
417
436
  console.log(chalk.cyan(`npm install ${missingDeps.join(' ')}`));
418
437
  process.exit(1);
419
438
  }
439
+ else {
440
+ // Dependencies exist, set up Storybook preview
441
+ setupStorybookPreview(answers.designSystem);
442
+ }
420
443
  }
421
444
  }
422
445
  // Generate configuration
@@ -648,10 +671,6 @@ export async function setupCommand() {
648
671
  }
649
672
  // Clean up default Storybook template components to prevent conflicts
650
673
  cleanupDefaultStorybookComponents();
651
- // Set up Storybook preview file for design systems that require JSX
652
- if (['chakra', 'antd', 'mantine'].includes(answers.designSystem)) {
653
- setupStorybookPreview(answers.designSystem);
654
- }
655
674
  // Update package.json with convenience scripts
656
675
  if (packageJson) {
657
676
  const scripts = packageJson.scripts || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpitre/story-ui",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "AI-powered Storybook story generator with dynamic component discovery",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",