@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
JavaScript
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();