1 | #!/usr/bin/env node
|
2 | "use strict";
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | const cli_1 = require("./cli");
|
5 | const util_1 = require("../util");
|
6 | const flagpoleexecutionoptions_1 = require("../flagpoleexecutionoptions");
|
7 | const path = require("path");
|
8 | let commands = [
|
9 | "run",
|
10 | "list",
|
11 | "init",
|
12 | "add",
|
13 | "rm",
|
14 | "import",
|
15 | "pack",
|
16 | "login",
|
17 | "logout",
|
18 | "deploy",
|
19 | "about",
|
20 | "serve",
|
21 | "watch",
|
22 | "build",
|
23 | "debug"
|
24 | ];
|
25 | let yargs = require("yargs");
|
26 | let argv = require("yargs")
|
27 | .usage("Usage: $0 <command> [options]")
|
28 | .help(false)
|
29 | .alias("v", "version")
|
30 | .version()
|
31 | .demandCommand(1, "You must specify a command: " + commands.join(", "))
|
32 | .alias({
|
33 | s: "suite",
|
34 | t: "tag",
|
35 | e: "env",
|
36 | c: "config",
|
37 | d: "debug",
|
38 | h: "hide_banner",
|
39 | o: "output",
|
40 | q: "quiet"
|
41 | })
|
42 | .describe({
|
43 | s: "Specify one or more suites to run",
|
44 | t: "Specify a tag for suites to run",
|
45 | e: "Environment like: dev, staging, prod",
|
46 | c: "Specify path to config file",
|
47 | d: "Show extra debug info",
|
48 | h: "Hide the output banner",
|
49 | o: "Output: console, text, html, json, csv, browser",
|
50 | q: "Quiet Mode: Silence all output"
|
51 | })
|
52 | .array("s")
|
53 | .string("t")
|
54 | .string("e")
|
55 | .boolean("a")
|
56 | .boolean("d")
|
57 | .boolean("h")
|
58 | .boolean("q")
|
59 | .string("o")
|
60 | .string("base")
|
61 | .default("o", "console")
|
62 | .default("s", [])
|
63 | .default("t", "")
|
64 | .default("h", false)
|
65 | .default("q", false)
|
66 | .default("l", false)
|
67 | .example("flagpole list", "To show a list of test suites")
|
68 | .example("flagpole run", "To run all test suites")
|
69 | .example("flagpole run -s smoke", "To run just the suite called smoke")
|
70 | .example("flagpole run -s smoke api", "Or you can run multiple suites (smoke and api)")
|
71 | .example("flagpole run -t basic", 'To run all suites with tag "basic"')
|
72 | .example("flagpole init", "Initialize a new Flagpole project")
|
73 | .example("flagpole add suite", "Add a new test suite")
|
74 | .example("flagpole add scenario", "Add a new scenario to a test suite")
|
75 | .example("flagpole login", "Login to your FlagpoleJS.com account")
|
76 | .example("flagpole logout", "Logout of your FlagpoleJS.com account")
|
77 | .example("flagpole deploy", "Send your test project to your FlagpoleJS.com account")
|
78 | .example("flagpole build", "Transpile TypeScript source tests to JavaScript output")
|
79 | .epilogue("For more information, go to https://github.com/flocasts/flagpole")
|
80 | .wrap(Math.min(100, yargs.terminalWidth()))
|
81 | .fail(function (msg, err, yargs) {
|
82 | cli_1.Cli.log(yargs.help());
|
83 | cli_1.Cli.log(msg);
|
84 | cli_1.Cli.exit(1);
|
85 | }).argv;
|
86 | cli_1.Cli.command = argv._[0];
|
87 | cli_1.Cli.commandArg = argv._[1];
|
88 | cli_1.Cli.commandArg2 = argv._[2];
|
89 | if (commands.indexOf(String(cli_1.Cli.command)) < 0) {
|
90 | cli_1.Cli.log("Command must be either: " + commands.join(", ") + "\n");
|
91 | cli_1.Cli.log("Example: flagpole run\n");
|
92 | cli_1.Cli.exit(1);
|
93 | }
|
94 | flagpoleexecutionoptions_1.FlagpoleExecution.opts.setOutputFromString(argv.o);
|
95 | flagpoleexecutionoptions_1.FlagpoleExecution.opts.automaticallyPrintToConsole = true;
|
96 | flagpoleexecutionoptions_1.FlagpoleExecution.opts.automaticallyPrintToConsole = !argv.q;
|
97 | flagpoleexecutionoptions_1.FlagpoleExecution.opts.quietMode = !!argv.q;
|
98 | flagpoleexecutionoptions_1.FlagpoleExecution.opts.asyncExecution = !!argv.a;
|
99 | cli_1.Cli.hideBanner = !!argv.h || argv.q || argv.o !== "console";
|
100 | cli_1.Cli.projectPath = util_1.normalizePath(typeof argv.p !== "undefined" ? argv.p : process.cwd());
|
101 | cli_1.Cli.configPath = argv.c || path.join(cli_1.Cli.projectPath, "flagpole.json");
|
102 | cli_1.parseConfigFile(cli_1.Cli.configPath);
|
103 | if (argv.c && !cli_1.Cli.config.isValid()) {
|
104 | cli_1.Cli.log("The config file you specified did not exist.\n");
|
105 | cli_1.Cli.exit(1);
|
106 | }
|
107 | flagpoleexecutionoptions_1.FlagpoleExecution.opts.environment = (() => {
|
108 | if (argv.e) {
|
109 | return argv.e;
|
110 | }
|
111 | const envs = Object.keys(cli_1.Cli.config.environments);
|
112 | if (envs.length > 0) {
|
113 | return envs[0];
|
114 | }
|
115 | return "dev";
|
116 | })();
|
117 | flagpoleexecutionoptions_1.FlagpoleExecution.opts.configPath = cli_1.Cli.configPath;
|
118 | flagpoleexecutionoptions_1.FlagpoleExecution.opts.baseDomain = (() => {
|
119 | if (argv.base) {
|
120 | return argv.base;
|
121 | }
|
122 | if (cli_1.Cli.config.environments[flagpoleexecutionoptions_1.FlagpoleExecution.opts.environment]) {
|
123 | return cli_1.Cli.config.environments[flagpoleexecutionoptions_1.FlagpoleExecution.opts.environment]
|
124 | .defaultDomain;
|
125 | }
|
126 | return "";
|
127 | })();
|
128 | if (argv.d || cli_1.Cli.command == "debug") {
|
129 | require("./debug").debug(argv);
|
130 | }
|
131 | if (cli_1.Cli.command == "list") {
|
132 | require("./list").list();
|
133 | }
|
134 | else if (cli_1.Cli.command == "run") {
|
135 | const cacheFolder = cli_1.Cli.config.getCacheFolder();
|
136 | util_1.emptyFolder(cacheFolder)
|
137 | .then(() => {
|
138 | require("./run").run(argv.s, argv.t);
|
139 | })
|
140 | .catch(err => {
|
141 | console.log(err);
|
142 | });
|
143 | }
|
144 | else if (cli_1.Cli.command == "login") {
|
145 | require("./login").login();
|
146 | }
|
147 | else if (cli_1.Cli.command == "logout") {
|
148 | require("./logout").logout();
|
149 | }
|
150 | else if (cli_1.Cli.command == "init") {
|
151 | require("./init").init();
|
152 | }
|
153 | else if (cli_1.Cli.command == "pack") {
|
154 | require("./pack").pack();
|
155 | }
|
156 | else if (cli_1.Cli.command == "add") {
|
157 | require("./add").add();
|
158 | }
|
159 | else if (cli_1.Cli.command == "rm") {
|
160 | require("./rm").rm();
|
161 | }
|
162 | else if (cli_1.Cli.command == "deploy") {
|
163 | require("./deploy").deploy();
|
164 | }
|
165 | else if (cli_1.Cli.command == "about") {
|
166 | require("./about").about();
|
167 | }
|
168 | else if (cli_1.Cli.command == "import") {
|
169 | if (cli_1.Cli.commandArg == "suite") {
|
170 | }
|
171 | require("./import").importSuite();
|
172 | }
|
173 | else if (cli_1.Cli.command == "serve") {
|
174 | require("./serve").serve();
|
175 | }
|
176 | else if (cli_1.Cli.command == "watch") {
|
177 | require("./watch").watch(argv.s, argv.t);
|
178 | }
|
179 | else if (cli_1.Cli.command == "build") {
|
180 | require("./build").build();
|
181 | }
|
182 |
|
\ | No newline at end of file |