UNPKG

@microsoft.azure/autorest.testserver

Version:
62 lines 2.47 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 }); exports.DEFAULT_PORT = void 0; // eslint-disable-next-line @typescript-eslint/no-var-requires require("source-map-support").install(); const path_1 = require("path"); const yargs_1 = __importDefault(require("yargs")); const helpers_1 = require("yargs/helpers"); const logger_1 = require("../logger"); const commands_1 = require("./commands"); exports.DEFAULT_PORT = 3000; const run = async () => { await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)) .help() .strict() .env("AUTOREST_TESTSERVER") .option("verbose", { alias: "v", type: "boolean", description: "Run with verbose logging level.", }) .option("debug", { type: "boolean", description: "Run with debug logging level.", }) .option("level", { type: "string", description: "Run with given logging level.", }) .option("port", { alias: "p", type: "number", description: "Port where to host the server", default: exports.DEFAULT_PORT, }) .option("coverageDirectory", { type: "string", description: "Path of the directory where the coverage reports should be saved.", default: (0, path_1.join)(process.cwd(), "coverage"), }) .middleware((args) => { (0, logger_1.setLoggingLevelFromConfig)(args); }) .command(["$0", "run"], "Run the autorest test server.", (cmd) => cmd.option("appendCoverage", { type: "boolean", description: "Load the existing coverage reports and append to it instead of starting fresh.", }), (args) => (0, commands_1.runCommand)(args)) .command("stop", "Stop the autorest test server running at the provided port.", () => null, (args) => (0, commands_1.stopCommand)(args)) .command("validate-spec-coverage", "Validate there is a mock api for all the path defined in the specs", (cmd) => cmd.option("maxErrorCount", { description: "Maximum number of errors allowed", default: 0, }), (args) => (0, commands_1.validateSpecCoverageCommand)(args)).argv; }; run().catch((e) => { logger_1.logger.error("Error", e); process.exit(1); }); //# sourceMappingURL=cli.js.map