UNPKG

seb-cli-tool

Version:

SEB CLI - Smart Embedded Board Configuration Tool - Cloud-First MCU Management

123 lines (109 loc) โ€ข 4.27 kB
#!/usr/bin/env node const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); console.log('๐Ÿงช Testing SEB CLI Installation...\n'); // Test 1: Check if binary exists console.log('1. Checking binary file...'); const binaryPath = path.join(__dirname, '..', 'dist', 'seb'); if (fs.existsSync(binaryPath)) { console.log('โœ… Binary file exists'); } else { console.log('โŒ Binary file not found'); process.exit(1); } // Test 2: Check binary permissions console.log('2. Checking binary permissions...'); try { const stats = fs.statSync(binaryPath); if (stats.mode & 0o111) { console.log('โœ… Binary is executable'); } else { console.log('โš ๏ธ Binary is not executable, fixing...'); fs.chmodSync(binaryPath, 0o755); console.log('โœ… Fixed binary permissions'); } } catch (error) { console.log('โŒ Error checking binary permissions:', error.message); process.exit(1); } // Test 3: Test binary execution console.log('3. Testing binary execution...'); try { const output = execSync(`"${binaryPath}" --help`, { encoding: 'utf8' }); if (output.includes('SEB: Cloud-First Firmware CLI Compiler')) { console.log('โœ… Binary executes correctly'); } else { console.log('โŒ Binary output unexpected'); process.exit(1); } } catch (error) { console.log('โŒ Error executing binary:', error.message); process.exit(1); } // Test 4: Test registry connection console.log('4. Testing registry connection...'); try { const output = execSync(`"${binaryPath}" registry boards`, { encoding: 'utf8' }); if (output.includes('Found 5 board configuration(s)')) { console.log('โœ… Registry connection works'); } else { console.log('โš ๏ธ Registry connection may have issues'); } } catch (error) { console.log('โš ๏ธ Registry connection failed (may be expected in test environment)'); } // Test 5: Check package.json configuration console.log('5. Checking package.json configuration...'); const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')); const requiredFields = ['name', 'version', 'bin', 'files', 'publishConfig']; let allFieldsPresent = true; requiredFields.forEach(field => { if (!packageJson[field]) { console.log(`โŒ Missing required field: ${field}`); allFieldsPresent = false; } }); if (allFieldsPresent) { console.log('โœ… Package.json configuration is correct'); } else { console.log('โŒ Package.json configuration has issues'); process.exit(1); } // Test 6: Check npm package contents console.log('6. Checking npm package contents...'); try { const output = execSync('npm pack --dry-run', { encoding: 'utf8' }); const expectedFiles = ['README.md', 'bin/seb.js', 'dist/seb', 'package.json']; let allFilesPresent = true; // Simple check - just verify the files are mentioned in the output expectedFiles.forEach(file => { // Remove emoji and extra whitespace for comparison const cleanOutput = output.replace(/๐Ÿ“ฆ/g, '').replace(/\s+/g, ' '); console.log(`๐Ÿ” Looking for: "${file}"`); console.log(`๐Ÿ” Clean output contains: ${cleanOutput.includes(file)}`); if (cleanOutput.includes(file)) { console.log(`โœ… Found file in package: ${file}`); } else { console.log(`โŒ Missing file in package: ${file}`); allFilesPresent = false; } }); if (allFilesPresent) { console.log('โœ… All required files are included in package'); } else { console.log('โŒ Some required files are missing'); process.exit(1); } } catch (error) { console.log('โŒ Error checking package contents:', error.message); process.exit(1); } console.log('\n๐ŸŽ‰ All tests passed! SEB CLI is ready for distribution.'); console.log('\n๐Ÿ“ฆ To publish to GitHub Packages:'); console.log(' 1. Create a GitHub Personal Access Token with package write permissions'); console.log(' 2. Set GITHUB_TOKEN environment variable'); console.log(' 3. Run: npm publish'); console.log('\n๐Ÿ“‹ To test installation:'); console.log(' 1. Run: npm link'); console.log(' 2. Test: seb --help');