UNPKG

flagpole

Version:

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

186 lines 6.05 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const cli_1 = require("./cli"); const util_1 = require("../util"); const flagpoleexecutionoptions_1 = require("../flagpoleexecutionoptions"); const path = require("path"); let commands = [ "run", "list", "init", "add", "rm", "import", "pack", "login", "logout", "deploy", "about", "serve", "watch", "build", "debug", "audit", ]; let yargs = require("yargs"); let argv = require("yargs") .usage("Usage: $0 <command> [options]") .help(false) .alias("v", "version") .version() .demandCommand(1, "You must specify a command: " + commands.join(", ")) .alias({ s: "suite", t: "tag", e: "env", c: "config", d: "debug", h: "hide_banner", o: "output", q: "quiet", }) .describe({ s: "Specify one or more suites to run", t: "Specify a tag for suites to run", e: "Environment like: dev, staging, prod", c: "Specify path to config file", d: "Show extra debug info", h: "Hide the output banner", o: "Output: console, text, html, json, csv, browser", q: "Quiet Mode: Silence all output", }) .array("s") .string("t") .string("e") .boolean("a") .boolean("d") .boolean("h") .boolean("q") .string("o") .string("base") .default("o", "console") .default("s", []) .default("t", "") .default("h", false) .default("q", false) .default("l", false) .example("flagpole list", "To show a list of test suites") .example("flagpole run", "To run all test suites") .example("flagpole run -s smoke", "To run just the suite called smoke") .example("flagpole run -s smoke api", "Or you can run multiple suites (smoke and api)") .example("flagpole run -t basic", 'To run all suites with tag "basic"') .example("flagpole init", "Initialize a new Flagpole project") .example("flagpole add suite", "Add a new test suite") .example("flagpole add scenario", "Add a new scenario to a test suite") .example("flagpole login", "Login to your FlagpoleJS.com account") .example("flagpole logout", "Logout of your FlagpoleJS.com account") .example("flagpole deploy", "Send your test project to your FlagpoleJS.com account") .example("flagpole build", "Transpile TypeScript source tests to JavaScript output") .epilogue("For more information, go to https://github.com/flocasts/flagpole") .wrap(Math.min(100, yargs.terminalWidth())) .fail(function (msg, err, yargs) { cli_1.Cli.log(yargs.help()); cli_1.Cli.log(msg); cli_1.Cli.exit(1); }).argv; cli_1.Cli.command = argv._[0]; cli_1.Cli.commandArg = argv._[1]; cli_1.Cli.commandArg2 = argv._[2]; if (commands.indexOf(String(cli_1.Cli.command)) < 0) { cli_1.Cli.log("Command must be either: " + commands.join(", ") + "\n"); cli_1.Cli.log("Example: flagpole run\n"); cli_1.Cli.exit(1); } flagpoleexecutionoptions_1.FlagpoleExecution.opts.setOutputFromString(argv.o); flagpoleexecutionoptions_1.FlagpoleExecution.opts.automaticallyPrintToConsole = true; flagpoleexecutionoptions_1.FlagpoleExecution.opts.automaticallyPrintToConsole = !argv.q; flagpoleexecutionoptions_1.FlagpoleExecution.opts.quietMode = !!argv.q; flagpoleexecutionoptions_1.FlagpoleExecution.opts.asyncExecution = !!argv.a; cli_1.Cli.hideBanner = !!argv.h || argv.q || argv.o !== "console"; cli_1.Cli.projectPath = util_1.normalizePath(typeof argv.p !== "undefined" ? argv.p : process.cwd()); cli_1.Cli.configPath = argv.c || path.join(cli_1.Cli.projectPath, "flagpole.json"); cli_1.parseConfigFile(cli_1.Cli.configPath); if (argv.c && !cli_1.Cli.config.isValid()) { cli_1.Cli.log("The config file you specified did not exist.\n"); cli_1.Cli.exit(1); } flagpoleexecutionoptions_1.FlagpoleExecution.opts.environment = (() => { if (argv.e) { return argv.e; } const envs = Object.keys(cli_1.Cli.config.environments); if (envs.length > 0) { return envs[0]; } return "dev"; })(); flagpoleexecutionoptions_1.FlagpoleExecution.opts.configPath = cli_1.Cli.configPath; flagpoleexecutionoptions_1.FlagpoleExecution.opts.baseDomain = (() => { if (argv.base) { return argv.base; } if (cli_1.Cli.config.environments[flagpoleexecutionoptions_1.FlagpoleExecution.opts.environment]) { return cli_1.Cli.config.environments[flagpoleexecutionoptions_1.FlagpoleExecution.opts.environment] .defaultDomain; } return ""; })(); if (argv.d || cli_1.Cli.command == "debug") { require("./debug").debug(argv); } if (cli_1.Cli.command == "list") { require("./list").list(); } else if (cli_1.Cli.command == "audit") { require("./audit").audit(); } else if (cli_1.Cli.command == "run") { const cacheFolder = cli_1.Cli.config.getCacheFolder(); util_1.emptyFolder(cacheFolder) .then(() => { require("./run").run(argv.s, argv.t); }) .catch((err) => { console.log(err); }); } else if (cli_1.Cli.command == "login") { require("./login").login(); } else if (cli_1.Cli.command == "logout") { require("./logout").logout(); } else if (cli_1.Cli.command == "init") { require("./init").init(); } else if (cli_1.Cli.command == "pack") { require("./pack").pack(); } else if (cli_1.Cli.command == "add") { require("./add").add(); } else if (cli_1.Cli.command == "rm") { require("./rm").rm(); } else if (cli_1.Cli.command == "deploy") { require("./deploy").deploy(); } else if (cli_1.Cli.command == "about") { require("./about").about(); } else if (cli_1.Cli.command == "import") { if (cli_1.Cli.commandArg == "suite") { } require("./import").importSuite(); } else if (cli_1.Cli.command == "serve") { require("./serve").serve(); } else if (cli_1.Cli.command == "watch") { require("./watch").watch(argv.s, argv.t); } else if (cli_1.Cli.command == "build") { require("./build").build(); } //# sourceMappingURL=main.js.map