text: #!/usr/bin/env node
  const path = require('path');
  const fse = require('fs-extra');
  const componentsManifest = require('../src/components-manifest.json');
  const { generateComponentsMapTS } = require('./generate-components-map');
  
  const projectDir = path.join(__dirname, '..');
  
  generateComponentsMapTS();
  generateDynamicComponents();
  copyModelsToStorybookAddon();
  
  function generateDynamicComponents() {
      console.log('⏳ generating dynamic components for storybook...');
  
      const staticMap = Object.entries(componentsManifest)
          .filter(([_, component]) => !component.isDynamic)
          .map(([componentName, componentManifest]) => `'${componentName}': ${componentManifest.path.split('/')[0]}.${componentName},`);
  
      const dynamicComponentsString = Object.entries(componentsManifest)
          .filter(([_, component]) => component.isDynamic)
          .map(([componentName, componentManifest]) => `'${componentManifest.modelName}': ${componentManifest.path.split('/')[0]}.${componentName},`);
  
      const data = `// ⚠️ This file is autogenerated by 'scripts/generate-storybook-dynamic.js'
  // To update this file, change 'src/components-manifest.json' and re-run 'npm run build'
  
  import * as components from '../src/components';
  import * as layouts from '../src/layouts';
  
  const dynamicComponents = {
      ${staticMap.join('\n    ')}
      ${dynamicComponentsString.join('\n    ')}
  };
  
  export default dynamicComponents;
  `;
  
      fse.writeFileSync(path.join(projectDir, '.storybook/storybook-dynamic.js'), data, 'utf8');
  
      console.log('✔ generated .storybook/storybook-dynamic.js');
  }
  
  function copyModelsToStorybookAddon() {
      fse.copy(path.join(projectDir, 'models'), path.join(projectDir, 'public/models'));
  }
  