@expressots/cli
Version:
Expressots CLI - modern, fast, lightweight nodejs web framework (@cli)
74 lines (73 loc) • 2.85 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BUNDLE_VERSION = void 0;
const chalk_1 = __importDefault(require("chalk"));
const process_1 = require("process");
const yargs_1 = __importDefault(require("yargs"));
const helpers_1 = require("yargs/helpers");
const project_commands_1 = require("./commands/project.commands");
const generate_1 = require("./generate");
const cli_1 = require("./help/cli");
const info_1 = require("./info");
const new_1 = require("./new");
const providers_1 = require("./providers");
const cli_2 = require("./providers/create/cli");
const cli_ui_1 = require("./utils/cli-ui");
const scripts_1 = require("./scripts");
/**
* The current version of the ExpressoTS Bundle.
* core, adapters, and cli.
*/
exports.BUNDLE_VERSION = "3.0.0";
process_1.stdout.write(`\n${[chalk_1.default.bold.green("🐎 Expressots")]}\n\n`);
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
.scriptName("expressots")
.command((0, new_1.createProject)())
.command(project_commands_1.devCommand)
.command(project_commands_1.buildCommand)
.command(project_commands_1.prodCommand)
.command((0, cli_2.createExternalProviderCMD)())
.command((0, providers_1.addProviderCMD)())
.command((0, providers_1.removeProviderCMD)())
.command((0, generate_1.generateProject)())
.command((0, scripts_1.scriptsCommand)())
.command((0, info_1.infoProject)())
.command((0, cli_1.helpCommand)())
.demandCommand(1, "You need at least one command before moving on")
.strict()
.fail((msg, err, yargs) => {
if (msg) {
if (msg.includes("Unknown argument")) {
const command = process.argv[2];
if (command === "run") {
(0, cli_ui_1.printError)(`The "run" command has been removed. Use "dev", "prod" or "build" instead.`, "expressots help");
}
else {
(0, cli_ui_1.printError)(`Unknown command [${command}]. For help type`, "expressots help");
}
}
else {
(0, cli_ui_1.printError)(msg, "expressots help");
}
}
else if (err) {
(0, cli_ui_1.printError)(err.stack, "command-validator");
}
else {
(0, cli_ui_1.printError)("Command invalid. Consider updating the CLI.", "command-validator");
yargs.showHelp();
}
process.exit(1);
})
.epilog(`${chalk_1.default.bold.green("For more information:")} \n\n` +
"🌐 visit:\t https://expresso-ts.com\n" +
"💖 Sponsor:\t https://github.com/sponsors/expressots")
.help("help", "Show command help")
.alias("h", "help")
.version(false)
.wrap(140)
.parse();