UNPKG

vibe-stocks

Version:

Terminal-based stock market viewer with real-time data streaming

103 lines (86 loc) โ€ข 3.31 kB
#!/usr/bin/env node const fs = require('fs'); const path = require('path'); const { exec } = require('child_process'); const chalk = require('chalk'); console.log(chalk.cyan.bold('๐Ÿš€ Pre-publish Check for vibe-stocks\n')); // Check 1: Package.json validation console.log(chalk.blue('๐Ÿ“ฆ Checking package.json...')); const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); const requiredFields = ['name', 'version', 'description', 'main', 'bin', 'author', 'license']; const missingFields = requiredFields.filter(field => !pkg[field]); if (missingFields.length > 0) { console.log(chalk.red(`โŒ Missing required fields: ${missingFields.join(', ')}`)); process.exit(1); } else { console.log(chalk.green('โœ… All required fields present')); } // Check 2: Binary executable console.log(chalk.blue('\n๐Ÿ”ง Checking binary executable...')); if (!fs.existsSync(pkg.bin['vibe-stocks'])) { console.log(chalk.red('โŒ Binary file not found')); process.exit(1); } if (!(fs.statSync(pkg.bin['vibe-stocks']).mode & parseInt('0001', 8))) { console.log(chalk.yellow('โš ๏ธ Binary not executable, fixing...')); fs.chmodSync(pkg.bin['vibe-stocks'], '755'); } console.log(chalk.green('โœ… Binary executable check passed')); // Check 3: Dependencies console.log(chalk.blue('\n๐Ÿ“š Checking dependencies...')); const deps = Object.keys(pkg.dependencies || {}); if (deps.length === 0) { console.log(chalk.yellow('โš ๏ธ No dependencies listed')); } else { console.log(chalk.green(`โœ… ${deps.length} dependencies listed`)); } // Check 4: File structure console.log(chalk.blue('\n๐Ÿ“ Checking file structure...')); const requiredFiles = [ 'README.md', 'package.json', 'index.js', 'bin/vibe-stocks.js', 'lib/config.js', 'lib/stream.js', 'lib/market.js', 'lib/quote.js', 'lib/chart.js' ]; const missingFiles = requiredFiles.filter(file => !fs.existsSync(file)); if (missingFiles.length > 0) { console.log(chalk.red(`โŒ Missing files: ${missingFiles.join(', ')}`)); process.exit(1); } else { console.log(chalk.green('โœ… All required files present')); } // Check 5: Test CLI commands console.log(chalk.blue('\n๐Ÿงช Testing CLI commands...')); const testCommands = [ 'node bin/vibe-stocks.js --version', 'node bin/vibe-stocks.js --help' ]; let testsCompleted = 0; const totalTests = testCommands.length; testCommands.forEach((cmd, index) => { exec(cmd, { timeout: 5000 }, (error, stdout, stderr) => { testsCompleted++; if (error && !error.killed) { console.log(chalk.red(`โŒ Command failed: ${cmd}`)); console.log(chalk.red(error.message)); } else { console.log(chalk.green(`โœ… Command passed: ${cmd.split(' ').slice(-1)}`)); } if (testsCompleted === totalTests) { console.log(chalk.blue('\n๐Ÿ“‹ Summary:')); console.log(`Package: ${chalk.bold(pkg.name)}@${chalk.bold(pkg.version)}`); console.log(`Description: ${pkg.description}`); console.log(`Author: ${pkg.author}`); console.log(`License: ${pkg.license}`); console.log(chalk.green.bold('\nโœ… All checks passed! Ready to publish.')); console.log(chalk.yellow('\nTo publish, run:')); console.log(chalk.gray(' npm login')); console.log(chalk.gray(' npm publish --access public')); } }); });