UNPKG

@jin7942/ray

Version:

Lightweight CI/CD deployment tool powered by Docker and Git

105 lines (104 loc) 3.56 kB
#!/usr/bin/env node "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const initWizard_1 = require("../wizard/initWizard"); const configLoader_1 = require("../config/configLoader"); const main_1 = require("../main"); const promises_1 = __importDefault(require("fs/promises")); const path_1 = __importDefault(require("path")); const args = process.argv.slice(2); const [command, sub] = args; async function main() { try { switch (command) { case 'init': if (sub === 'wizard') { // run: ray init wizard → interactive config wizard await (0, initWizard_1.initConfigWizard)(); } else { // run: ray init → create default ray.config.json await createDefaultConfig(); } break; case 'run': if (sub) { // run: ray run <project> → specific project const config = await (0, configLoader_1.loadProjectConfig)(sub); await (0, main_1.runRayPipeline)(config); } else { // run: ray run → all projects const configs = await (0, configLoader_1.loadAllProjects)(); await (0, main_1.runAllPipelines)(configs); } break; case 'help': case undefined: printHelp(); break; default: console.error(`Unknown command: ${command}`); printHelp(); process.exit(1); } } catch (err) { console.error('Error:', err instanceof Error ? err.message : String(err)); process.exit(1); } } /** * Create a default ray.config.json with example project */ async function createDefaultConfig() { const defaultJson = { projects: [ { name: 'my-project', repo: 'https://github.com/your/repo.git', branch: 'main', // buildCommand: 'npm run build', docker: { type: 'docker', image: 'your-image', containername: 'your-container', path: { dockerfile: './Dockerfile', }, network: '', volumes: '', }, internal: { logdir: './logs', maxLogDirSize: 5242880, logLevel: 'info', envFilePath: './.env', }, env: { NODE_ENV: 'production', }, }, ], }; const filePath = path_1.default.resolve('ray.config.json'); await promises_1.default.writeFile(filePath, JSON.stringify(defaultJson, null, 2), 'utf-8'); console.log(`Default config created at: ${filePath}`); } /** * Print usage instructions for CLI */ function printHelp() { console.log(` Usage: ray init # Create default ray.config.json ray init wizard # Launch interactive wizard ray run # Run all projects ray run <project> # Run a specific project ray help # Show this help `); } main();