neex
Version:
Neex - Modern Fullstack Framework Built on Express and Next.js. Fast to Start, Easy to Build, Ready to Deploy
50 lines (49 loc) • 2.22 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addServerCommands = addServerCommands;
const index_js_1 = require("../index.js");
const chalk_1 = __importDefault(require("chalk"));
const figures_1 = __importDefault(require("figures"));
function addServerCommands(program) {
let cleanupRunner = null;
// Servers command specifically optimized for running web servers
program
.command('servers <commands...>')
.alias('srv')
.description('Run multiple servers with optimized output for API, frontend, etc.')
.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 when any server crashes')
.option('-x, --max-parallel <number>', 'Maximum number of parallel servers', parseInt)
.option('-g, --group-output', 'Group outputs by server')
.action(async (commands, options) => {
try {
console.log(chalk_1.default.blue(`${figures_1.default.info} Starting servers in parallel mode...`));
await (0, index_js_1.run)(commands, {
parallel: true,
maxParallel: options.maxParallel,
color: options.color,
showTiming: options.timing,
prefix: options.prefix,
stopOnError: options.stopOnError,
printOutput: true,
registerCleanup: (cleanup) => { cleanupRunner = cleanup; },
groupOutput: options.groupOutput,
isServerMode: true
});
}
catch (error) {
if (error instanceof Error) {
console.error(chalk_1.default.red(`${figures_1.default.cross} Server Error: ${error.message}`));
}
else {
console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown server error occurred`));
}
process.exit(1);
}
});
}