UNPKG

testify-universal-cli

Version:

Universal interactive CLI tool for scanning and executing tests across multiple programming languages

141 lines (120 loc) 3.6 kB
#!/usr/bin/env node import chalk from 'chalk'; import { execa } from 'execa'; import fs from 'node:fs/promises'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const CDN_CONFIG_PATH = path.join(__dirname, '..', '..', '.cdn-config.json'); // Skip postinstall script in CI environments if (process.env.CI || process.env.SKIP_POSTINSTALL) { process.exit(0); } async function checkAndConfigureCDN() { try { console.log(chalk.cyan('🔍 Configuring testify-universal-cli for optimal performance...')); // Create CDN configuration if it doesn't exist try { await fs.access(CDN_CONFIG_PATH); } catch (error) { // Create default CDN config const cdnConfig = { enabled: true, region: 'auto', cacheTime: 86400, // 24 hours preferredEndpoints: [] }; await fs.writeFile(CDN_CONFIG_PATH, JSON.stringify(cdnConfig, null, 2)); console.log(chalk.green('✓ Created CDN configuration for faster updates')); } // Check for language-specific test runners await checkLanguageSupport(); console.log(chalk.green('✓ testify-universal-cli is ready to use!')); console.log(chalk.cyan('Run `testify` to start testing your project\n')); } catch (error) { // Don't fail installation if post-install fails console.log(chalk.yellow('⚠️ Non-critical error during setup: ' + error.message)); } } async function checkLanguageSupport() { const supportedLanguages = []; // Check for Python/pytest try { await execa('python', ['--version']); try { await execa('pytest', ['--version']); supportedLanguages.push('python/pytest'); } catch { // pytest not available } } catch { // Python not available } // Check for Node.js test frameworks try { const hasNpm = await execa('npm', ['--version']); if (hasNpm) { supportedLanguages.push('node.js'); } } catch { // npm not available } // Check for Ruby/RSpec try { await execa('ruby', ['--version']); try { await execa('gem', ['list', 'rspec', '-i']); supportedLanguages.push('ruby/rspec'); } catch { // RSpec not available } } catch { // Ruby not available } // Check for Go try { await execa('go', ['version']); supportedLanguages.push('go'); } catch { // Go not available } // Check for Java try { await execa('java', ['--version']); supportedLanguages.push('java'); // Check for Maven try { await execa('mvn', ['--version']); supportedLanguages.push('java/maven'); } catch { // Maven not available } // Check for Gradle try { await execa('gradle', ['--version']); supportedLanguages.push('java/gradle'); } catch { // Gradle not available } } catch { // Java not available } // Check for Rust try { await execa('cargo', ['--version']); supportedLanguages.push('rust/cargo'); } catch { // Rust not available } // Save detected languages to config await fs.writeFile( path.join(__dirname, '..', '..', '.language-support.json'), JSON.stringify({ supportedLanguages }, null, 2) ); if (supportedLanguages.length > 0) { console.log(chalk.green(`✓ Detected test frameworks: ${supportedLanguages.join(', ')}`)); } else { console.log(chalk.yellow('⚠️ No testing frameworks detected. Install language-specific test runners for full functionality.')); } } checkAndConfigureCDN();