can-algorithm
Version:
Cortex Algorithm Numeral - Intelligent development automation tool
65 lines (52 loc) • 2.08 kB
JavaScript
import chalk from 'chalk';
import { promises as fs } from 'fs';
import { exec } from 'child_process';
import { promisify } from 'util';
const execAsync = promisify(exec);
async function testES6() {
console.log(chalk.cyan.bold('\n🧪 Testing ES6 Modules\n'));
try {
console.log(chalk.yellow('1️⃣ Testing imports...'));
const modules = [
'commander',
'chalk',
'ora',
'axios',
'inquirer',
'crypto-js'
];
for (const mod of modules) {
try {
await import(mod);
console.log(chalk.green(`✅ ${mod} imported successfully`));
} catch (error) {
console.log(chalk.red(`❌ Failed to import ${mod}`));
}
}
console.log(chalk.yellow('\n2️⃣ Testing Can modules...'));
const canModules = [
'./core/can-core.js',
'./core/license.js',
'./core/protection.js',
'./core/config-manager.js',
'./lib/encryption.js'
];
for (const mod of canModules) {
try {
await import(mod);
console.log(chalk.green(`✅ ${mod} loaded`));
} catch (error) {
console.log(chalk.red(`❌ Failed to load ${mod}: ${error.message}`));
}
}
console.log(chalk.yellow('\n3️⃣ Testing CLI...'));
const { stdout: versionOutput } = await execAsync('node can.js --version');
console.log(chalk.green('✅ Version check:'), versionOutput.trim());
const { stdout: helpOutput } = await execAsync('node can.js --help');
console.log(chalk.green('✅ Help command works'));
console.log(chalk.green.bold('\n✨ ES6 modules working correctly!'));
} catch (error) {
console.error(chalk.red('Test failed:'), error);
}
}
testES6();