UNPKG

flagpole

Version:

Simple and fast DOM integration, headless or headful browser, and REST API testing framework.

78 lines 3.12 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const fs = require("fs"); const path_1 = require("path"); const cli_helper_1 = require("./cli-helper"); const cli_1 = require("./cli"); const pkg = require("../../package.json"); const FLAGPOLE_VERSION = pkg.version; const program = new commander_1.Command("flagpole").passCommandToAction(false); const setVolume = (value = 50, defaultValue = 50) => { if (typeof value === "string") { if (value.startsWith("-") || value.startsWith("+")) { value = 50 + parseInt(value); } else if (value == "verbose" || value == "debug" || value == "loud") { value = 100; } else if (value == "normal" || value == "default") { value = 50; } else if (value == "quiet") { value = 30; } else if (value == "silent") { value = 0; } else { value = parseInt(value); } } return String(!isNaN(value) ? Math.max(0, Math.min(100, value)) : defaultValue); }; program.version(FLAGPOLE_VERSION, "-V, --version", "Output the current version of Flagpole CLI"); program .option("-c, --config <file>", "override the default file name of the config file", "flagpole.json") .option("-p, --project <path>", "override the default project folder", process.cwd()) .option("-e, --env <name>", "set the environment") .option("-b, --base <domain>", "override base domain") .option("-v, --volume <level>", "set volume (verbosity) level beteen 0 and 100", (value) => { return setVolume(value); }, process.env.VOLUME || "50") .option("-x, --exitOnDone", "exit process after suites finish runs") .option("-z, --isChildProcess"); program.usage("[command] [arguments]"); const files = fs.readdirSync(path_1.join(__dirname, "commands")); files.forEach((file) => { if (file.endsWith(".js")) { const CliCommand = require(path_1.join(__dirname, "commands", file)).default; const command = new CliCommand(); command.init(program); } }); program.action(() => { cli_helper_1.printHeader(true); cli_1.Cli.log(` about credits add [type] add a new suite, scenario, environment or tag audit find problems in Flagpole configuration, such as suites whose files do not exist build transpile tests from TypeScript to JavaScript debug give some debug information import find files in the tests folder that are not in Flagpole config and import them init initialize Flagpole in this project list [type] list out the suites, environments or tags in this project rm [type] remove a suite or environment run [options] run test suites `); cli_1.Cli.exit(0); }); program.on("--help", () => { cli_helper_1.printHeader(true); }); program.parseAsync(process.argv); //# sourceMappingURL=main.js.map