UNPKG

neex

Version:

Neex - Modern Fullstack Framework Built on Express and Next.js. Fast to Start, Easy to Build, Ready to Deploy

94 lines (93 loc) 4.09 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.addRunCommands = addRunCommands; const index_js_1 = require("../index.js"); const chalk_1 = __importDefault(require("chalk")); const figures_1 = __importDefault(require("figures")); function addRunCommands(program) { let cleanupRunner = null; // Main command for sequential execution (similar to run-s) program .command("s <commands...>") .alias("seq") .alias("sequential") .description("Run commands sequentially") .option("-c, --no-color", "Disable colored output") .option("-t, --no-timing", "Hide timing information") .option("-p, --no-prefix", "Hide command prefix") .option("-s, --stop-on-error", "Stop on first error") .option("-o, --no-output", "Hide command output") .option("-m, --minimal", "Use minimal output format") .action(async (commands, options) => { try { await (0, index_js_1.run)(commands, { parallel: false, color: options.color, showTiming: options.timing, prefix: options.prefix, stopOnError: options.stopOnError, printOutput: options.output, minimalOutput: options.minimal, registerCleanup: (cleanup) => { cleanupRunner = cleanup; }, }); } catch (error) { if (error instanceof Error) { console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`)); } else { console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`)); } process.exit(1); } }); // runx command: parallel execution by default (with alias 'p'), can run sequentially with -q program .command("p <commands...>", { isDefault: true }) .alias("par") .alias("parallel") .description("Run commands in parallel (default) or sequentially with -q. This is the default command.") .option("-c, --no-color", "Disable colored output") .option("-t, --no-timing", "Hide timing information") .option("-p, --no-prefix", "Hide command prefix") .option("-s, --stop-on-error", "Stop on first error") .option("-o, --no-output", "Hide command output") .option("-m, --minimal", "Use minimal output format") .option("-x, --max-parallel <number>", "Maximum number of parallel processes", parseInt) .option("-q, --sequential", "Run commands sequentially instead of in parallel") .option("--retry <count>", "Number of times to retry a failed command", parseInt) .option("--retry-delay <ms>", "Delay in milliseconds between retries", parseInt) .action(async (commands, options) => { try { await (0, index_js_1.run)(commands, { parallel: !options.sequential, maxParallel: options.maxParallel, color: options.color, showTiming: options.timing, prefix: options.prefix, stopOnError: options.stopOnError, printOutput: options.output, minimalOutput: options.minimal, retry: options.retry, retryDelay: options.retryDelay, registerCleanup: (cleanup) => { cleanupRunner = cleanup; }, }); } catch (error) { if (error instanceof Error) { console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`)); } else { console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`)); } process.exit(1); } }); }