UNPKG

@budytalk/activity-server

Version:

Complete social media content management server with built-in PostgreSQL database, real-time features, and zero-configuration setup

121 lines (95 loc) • 3.94 kB
#!/usr/bin/env node const fs = require('fs'); const path = require('path'); console.log('šŸ“¦ Validating package exports...\n'); function validateExports() { try { // Check if dist files exist const distPath = path.join(__dirname, '..', 'dist'); if (!fs.existsSync(distPath)) { throw new Error('dist/ directory not found. Run npm run build first.'); } // Check main entry point const mainEntry = path.join(distPath, 'index.js'); if (!fs.existsSync(mainEntry)) { throw new Error('Main entry point dist/index.js not found'); } // Check TypeScript definitions const typesEntry = path.join(distPath, 'index.d.ts'); if (!fs.existsSync(typesEntry)) { throw new Error('TypeScript definitions dist/index.d.ts not found'); } // Check CLI entry point const cliEntry = path.join(distPath, 'cli', 'index.js'); if (!fs.existsSync(cliEntry)) { throw new Error('CLI entry point dist/cli/index.js not found'); } console.log('āœ… All entry points exist'); // Validate main exports console.log('šŸ“‹ Validating main exports...'); const mainExports = require(mainEntry); const expectedExports = [ 'createServer', 'connect', 'ActivityServer', 'Logger' ]; for (const exportName of expectedExports) { if (!mainExports[exportName]) { throw new Error(`Expected export '${exportName}' not found`); } console.log(`āœ… ${exportName} exported`); } // Validate TypeScript definitions console.log('šŸ“‹ Validating TypeScript definitions...'); const typesContent = fs.readFileSync(typesEntry, 'utf8'); const expectedTypes = [ 'export interface User', 'export interface Activity', 'export interface Feed', 'export interface Message', 'export interface Notification' ]; for (const expectedType of expectedTypes) { if (!typesContent.includes(expectedType)) { console.warn(`āš ļø Expected type definition '${expectedType}' not found`); } else { console.log(`āœ… ${expectedType.split(' ')[2]} type exported`); } } // Check package.json consistency console.log('šŸ“‹ Validating package.json consistency...'); const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')); if (packageJson.main !== 'dist/index.js') { throw new Error(`package.json main field should be 'dist/index.js', got '${packageJson.main}'`); } if (packageJson.types !== 'dist/index.d.ts') { throw new Error(`package.json types field should be 'dist/index.d.ts', got '${packageJson.types}'`); } if (!packageJson.bin || packageJson.bin.budytalk !== 'dist/cli/index.js') { throw new Error(`package.json bin.budytalk should be 'dist/cli/index.js'`); } console.log('āœ… package.json fields are consistent'); // Validate files array console.log('šŸ“‹ Validating files array...'); const files = packageJson.files || []; const requiredFiles = ['dist/**/*', 'README.md', 'LICENSE']; for (const requiredFile of requiredFiles) { if (!files.includes(requiredFile)) { throw new Error(`Required file pattern '${requiredFile}' not in files array`); } } console.log('āœ… Files array is complete'); console.log('\nšŸŽ‰ EXPORT VALIDATION COMPLETE!'); console.log('āœ… All entry points exist'); console.log('āœ… Main exports are correct'); console.log('āœ… TypeScript definitions are present'); console.log('āœ… package.json is consistent'); console.log('āœ… Files array is complete'); console.log('\nšŸ“¦ Package exports are valid!'); } catch (error) { console.error('āŒ Export validation failed:', error.message); process.exit(1); } } validateExports();