vibe-stocks
Version:
Terminal-based stock market viewer with real-time data streaming
103 lines (86 loc) โข 3.31 kB
JavaScript
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'));
}
});
});