UNPKG

@tamyla/ui-components-react

Version:

React-based UI component library with Factory Bridge pattern - integrates seamlessly with @tamyla/ui-components. Enhanced AI agent discoverability with structured component registry, comprehensive Storybook (8 components), and detailed guides.

223 lines (185 loc) • 7.67 kB
#!/usr/bin/env node /** * Comprehensive Certification Script for UI Components React * Mirrors the certification system from ui-components with React-specific validation */ import fs from 'fs'; import path from 'path'; import { execSync } from 'child_process'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const projectRoot = path.join(__dirname, '..'); const startTime = Date.now(); console.log('šŸš€ UI COMPONENTS REACT CERTIFICATION'); console.log('======================================================================'); console.log('This script validates your React UI components for production readiness!'); // Phase 1: Repository Validation console.log('\nšŸ“ PHASE 1: Repository Validation'); console.log('========================================'); let gitExists = false; try { execSync('git status', { cwd: projectRoot, stdio: 'ignore' }); gitExists = true; console.log('āœ“ Git repository exists'); } catch (e) { console.log('⚠ Git repository not found'); } // Phase 2: TypeScript and Build System Validation console.log('\nšŸ”Ø PHASE 2: Build System Validation'); console.log('========================================'); let buildPassed = false; try { console.log('Testing TypeScript compilation...'); execSync('npm run type-check', { cwd: projectRoot, stdio: 'ignore' }); console.log('āœ“ TypeScript compilation successful'); console.log('Testing main build system...'); execSync('npm run build', { cwd: projectRoot, stdio: 'pipe' }); console.log('āœ“ Main build successful'); // Check build outputs const distPath = path.join(projectRoot, 'dist'); if (fs.existsSync(distPath)) { const files = fs.readdirSync(distPath); const jsFiles = files.filter(f => f.endsWith('.js')); const dtsFiles = files.filter(f => f.endsWith('.d.ts')); console.log(`āœ“ Build outputs: ${jsFiles.length} JS files, ${dtsFiles.length} type definitions`); // Check file sizes jsFiles.forEach(file => { const filePath = path.join(distPath, file); const stats = fs.statSync(filePath); const sizeKB = (stats.size / 1024).toFixed(1); console.log(`āœ“ ${file}: ${sizeKB}KB`); }); } buildPassed = true; } catch (e) { console.log('āŒ Build system validation failed'); console.log(e.message); } // Phase 3: React Component Certification console.log('\n🧩 PHASE 3: React Component Certification'); console.log('========================================'); const componentDirs = { 'src/components/atoms': 'atoms', 'src/components/molecules': 'molecules', 'src/components/organisms': 'organisms', 'src/components/applications': 'applications' }; const componentCounts = {}; let totalComponents = 0; for (const [dir, category] of Object.entries(componentDirs)) { const fullPath = path.join(projectRoot, dir); if (fs.existsSync(fullPath)) { const items = fs.readdirSync(fullPath).filter(item => { const itemPath = path.join(fullPath, item); return (fs.statSync(itemPath).isFile() && item.endsWith('.tsx')) || (fs.statSync(itemPath).isDirectory() && item !== '__tests__'); }); componentCounts[category] = items.length; totalComponents += items.length; console.log(`āœ“ ${category}: ${items.length} components`); if (items.length > 0) { console.log(` ${items.slice(0, 10).join(', ')}${items.length > 10 ? '...' : ''}`); } } else { componentCounts[category] = 0; console.log(`⚠ ${category}: directory not found`); } } // Phase 4: Redux Store Validation console.log('\nšŸŖ PHASE 4: Redux Store Validation'); console.log('========================================'); const storeFiles = [ 'src/store/store.ts', 'src/store/hooks.ts', 'src/store/slices' ]; let storeValid = true; for (const file of storeFiles) { const filePath = path.join(projectRoot, file); if (fs.existsSync(filePath)) { console.log(`āœ“ ${file} exists`); } else { console.log(`⚠ ${file} missing`); storeValid = false; } } // Phase 5: Package Configuration Validation console.log('\nšŸ“¦ PHASE 5: Package Configuration'); console.log('========================================'); const packageJsonPath = path.join(projectRoot, 'package.json'); const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); console.log(`āœ“ Package: ${packageJson.name}@${packageJson.version}`); console.log(`āœ“ Description: ${packageJson.description}`); console.log(`āœ“ Main entry: ${packageJson.main}`); console.log(`āœ“ Module entry: ${packageJson.module}`); console.log(`āœ“ Types: ${packageJson.types}`); // Check peer dependencies const requiredPeerDeps = ['react', 'react-dom']; const peerDeps = packageJson.peerDependencies || {}; const missingPeerDeps = requiredPeerDeps.filter(dep => !peerDeps[dep]); if (missingPeerDeps.length === 0) { console.log('āœ“ Peer dependencies configured'); } else { console.log(`⚠ Missing peer dependencies: ${missingPeerDeps.join(', ')}`); } // Phase 6: Generate Certification Report console.log('\nšŸ“‹ PHASE 6: Certification Report'); console.log('========================================'); const duration = ((Date.now() - startTime) / 1000).toFixed(2); const status = buildPassed && totalComponents >= 3 && storeValid ? 'READY_FOR_REUSE' : 'NEEDS_WORK'; const certification = { timestamp: new Date().toISOString(), version: packageJson.version, duration: `${duration}s`, status, checks: { repository: gitExists, buildSystem: buildPassed, packageConfig: true, typescriptSupport: true, reduxStore: storeValid }, components: { total: totalComponents, breakdown: componentCounts }, capabilities: [ 'React 18+ compatibility', 'TypeScript support with full type definitions', 'Redux Toolkit state management', 'Styled-components theming', 'Factory Bridge pattern for ui-components integration', 'ESM module system with tree-shaking', 'Rollup bundling with optimized outputs' ], nextSteps: [ 'Run: npm run dev (start development server)', 'Run: npm run storybook (component documentation)', 'Run: npm run test (run component tests)', 'Integrate with @tamyla/ui-components factory bridge', 'Publish to NPM for team distribution' ] }; // Write certification file const certificationPath = path.join(projectRoot, 'COMPONENT_CERTIFICATION.json'); fs.writeFileSync(certificationPath, JSON.stringify(certification, null, 2)); console.log('āœ“ Certification report generated'); // Phase 7: Final Results console.log('\nšŸŽÆ CERTIFICATION RESULTS'); console.log('=============================='); console.log(`Duration: ${duration}s`); console.log(`Repository: ${gitExists ? 'āœ…' : 'āš ļø'}`); console.log(`Build System: ${buildPassed ? 'āœ…' : 'āŒ'}`); console.log(`Components: ${totalComponents} (${totalComponents >= 3 ? 'āœ…' : 'āŒ'})`); console.log(`Redux Store: ${storeValid ? 'āœ…' : 'āš ļø'}`); console.log('TypeScript: āœ…'); console.log(`\nšŸ“Š STATUS: ${status}`); if (status === 'READY_FOR_REUSE') { console.log('\nšŸŽ‰ CERTIFICATION SUCCESS!'); console.log('Your React UI components are ready for production use!'); } else { console.log('\nāš ļø CERTIFICATION INCOMPLETE'); console.log('Please address the issues above before proceeding.'); } console.log(`\nšŸ“ Certification details saved to: ${certificationPath}`);