cvm-cli
Version:
A unified CLI tool for managing PHP, Node.js, and Python versions with virtual environment and dependency management support.
53 lines (41 loc) • 1.48 kB
JavaScript
const fs = require('fs-extra');
const path = require('path');
const os = require('os');
const chalk = require('chalk');
const CVM_HOME = path.join(os.homedir(), '.cvm');
async function postInstall() {
try {
console.log(chalk.blue('Setting up CVM...'));
// Create CVM home directory
await fs.ensureDir(CVM_HOME);
// Create directories for each language
await fs.ensureDir(path.join(CVM_HOME, 'php'));
await fs.ensureDir(path.join(CVM_HOME, 'node'));
await fs.ensureDir(path.join(CVM_HOME, 'python'));
await fs.ensureDir(path.join(CVM_HOME, 'environments'));
// Create config directory
await fs.ensureDir(path.join(CVM_HOME, 'config'));
// Create default config
const defaultConfig = {
currentVersions: {
php: null,
node: null,
python: null
},
environments: {},
activeEnvironment: null
};
const configPath = path.join(CVM_HOME, 'config', 'config.json');
if (!await fs.pathExists(configPath)) {
await fs.writeJson(configPath, defaultConfig, { spaces: 2 });
}
console.log(chalk.green('✓ CVM setup complete!'));
console.log(chalk.yellow(`CVM home directory: ${CVM_HOME}`));
console.log(chalk.cyan('You can now use cvm, cpvm, cnvm, cpyvm, and cenv commands.'));
} catch (error) {
console.error(chalk.red('Error during setup:'), error.message);
process.exit(1);
}
}
postInstall();