@wdio/cli 7.16.16 → 7.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +4 -4
  2. package/build/@types/yarn-install.d.ts +0 -16
  3. package/build/@types/yarn-install.d.ts.map +0 -1
  4. package/build/@types/yarn-install.js +0 -1
  5. package/build/commands/config.d.ts +0 -64
  6. package/build/commands/config.d.ts.map +0 -1
  7. package/build/commands/config.js +0 -236
  8. package/build/commands/install.d.ts +0 -18
  9. package/build/commands/install.d.ts.map +0 -1
  10. package/build/commands/install.js +0 -112
  11. package/build/commands/repl.d.ts +0 -36
  12. package/build/commands/repl.d.ts.map +0 -1
  13. package/build/commands/repl.js +0 -62
  14. package/build/commands/run.d.ts +0 -172
  15. package/build/commands/run.d.ts.map +0 -1
  16. package/build/commands/run.js +0 -172
  17. package/build/constants.d.ts +0 -485
  18. package/build/constants.d.ts.map +0 -1
  19. package/build/constants.js +0 -370
  20. package/build/index.d.ts +0 -5
  21. package/build/index.d.ts.map +0 -1
  22. package/build/index.js +0 -84
  23. package/build/interface.d.ts +0 -75
  24. package/build/interface.d.ts.map +0 -1
  25. package/build/interface.js +0 -245
  26. package/build/launcher.d.ts +0 -95
  27. package/build/launcher.d.ts.map +0 -1
  28. package/build/launcher.js +0 -418
  29. package/build/templates/afterTest.ejs +0 -20
  30. package/build/templates/exampleFiles/cucumber/features/login.feature +0 -12
  31. package/build/templates/exampleFiles/cucumber/step_definitions/steps.js.ejs +0 -52
  32. package/build/templates/exampleFiles/jasmine/example.e2e.js.ejs +0 -42
  33. package/build/templates/exampleFiles/mocha/example.e2e.js.ejs +0 -42
  34. package/build/templates/exampleFiles/pageobjects/login.page.js.ejs +0 -44
  35. package/build/templates/exampleFiles/pageobjects/page.js.ejs +0 -13
  36. package/build/templates/exampleFiles/pageobjects/secure.page.js.ejs +0 -19
  37. package/build/templates/reporters.ejs +0 -14
  38. package/build/templates/wdio.conf.tpl.ejs +0 -448
  39. package/build/types.d.ts +0 -110
  40. package/build/types.d.ts.map +0 -1
  41. package/build/types.js +0 -2
  42. package/build/utils.d.ts +0 -82
  43. package/build/utils.d.ts.map +0 -1
  44. package/build/utils.js +0 -345
  45. package/build/watcher.d.ts +0 -34
  46. package/build/watcher.d.ts.map +0 -1
  47. package/build/watcher.js +0 -150
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/cli",
3
- "version": "7.16.16",
3
+ "version": "7.17.0",
4
4
  "description": "WebdriverIO testrunner command line interface",
5
5
  "author": "Christian Bromann <christian@saucelabs.com>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-cli",
@@ -40,7 +40,7 @@
40
40
  "@wdio/config": "7.16.16",
41
41
  "@wdio/logger": "7.16.0",
42
42
  "@wdio/types": "7.16.14",
43
- "@wdio/utils": "7.16.14",
43
+ "@wdio/utils": "7.17.0",
44
44
  "async-exit-hook": "^2.0.1",
45
45
  "chalk": "^4.0.0",
46
46
  "chokidar": "^3.0.0",
@@ -53,7 +53,7 @@
53
53
  "lodash.union": "^4.6.0",
54
54
  "mkdirp": "^1.0.4",
55
55
  "recursive-readdir": "^2.2.2",
56
- "webdriverio": "7.16.16",
56
+ "webdriverio": "7.17.0",
57
57
  "yargs": "^17.0.0",
58
58
  "yarn-install": "^1.0.0"
59
59
  },
@@ -61,5 +61,5 @@
61
61
  "access": "public"
62
62
  },
63
63
  "types": "./build/index.d.ts",
64
- "gitHead": "10597a2afe43b2f64ed9bf0ddae3f3f77d280047"
64
+ "gitHead": "e18d2cde6ff979758830bdff4c3bc82ca9818b24"
65
65
  }
@@ -1,16 +0,0 @@
1
- declare module 'yarn-install' {
2
- export default function yarnInstall(params: {
3
- deps: string[];
4
- cwd?: string;
5
- registry?: string;
6
- dev?: boolean;
7
- global?: boolean;
8
- remove?: boolean;
9
- production?: boolean;
10
- respectNpm5?: boolean;
11
- }): {
12
- stderr: string;
13
- status: number;
14
- };
15
- }
16
- //# sourceMappingURL=yarn-install.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"yarn-install.d.ts","sourceRoot":"","sources":["../../src/@types/yarn-install.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC1B,MAAM,CAAC,OAAO,UAAU,WAAW,CAC/B,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,EAAE,CAAA;QACd,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,GAAG,CAAC,EAAE,OAAO,CAAA;QACb,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,WAAW,CAAC,EAAE,OAAO,CAAA;KACxB,GACF;QACC,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;CACJ"}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,64 +0,0 @@
1
- import { ConfigCommandArguments, ParsedAnswers } from '../types';
2
- import yargs from 'yargs';
3
- export declare const command = "config";
4
- export declare const desc = "Initialize WebdriverIO and setup configuration in your current project.";
5
- export declare const cmdArgs: {
6
- readonly yarn: {
7
- readonly type: "boolean";
8
- readonly desc: "Install packages via yarn package manager.";
9
- readonly default: boolean;
10
- };
11
- readonly yes: {
12
- readonly alias: "y";
13
- readonly desc: "will fill in all config defaults without prompting";
14
- readonly type: "boolean";
15
- readonly default: false;
16
- };
17
- };
18
- export declare const builder: (yargs: yargs.Argv<{}>) => yargs.Argv<yargs.Omit<{}, "yarn" | "yes"> & yargs.InferredOptionTypes<{
19
- readonly yarn: {
20
- readonly type: "boolean";
21
- readonly desc: "Install packages via yarn package manager.";
22
- readonly default: boolean;
23
- };
24
- readonly yes: {
25
- readonly alias: "y";
26
- readonly desc: "will fill in all config defaults without prompting";
27
- readonly type: "boolean";
28
- readonly default: false;
29
- };
30
- }>>;
31
- export declare function handler(argv: ConfigCommandArguments): Promise<{
32
- success: boolean;
33
- parsedAnswers?: undefined;
34
- installedPackages?: undefined;
35
- } | {
36
- success: boolean;
37
- parsedAnswers: ParsedAnswers;
38
- installedPackages: string[];
39
- }>;
40
- /**
41
- * Helper utility used in `run` and `install` command to create config if none exist
42
- * @param {string} command to be executed by user
43
- * @param {string} message to show when no config is suppose to be created
44
- * @param {boolean} useYarn parameter set to true if yarn is used
45
- * @param {Function} runConfigCmd runConfig method to be replaceable for unit testing
46
- */
47
- export declare function missingConfigurationPrompt(command: string, message: string, useYarn?: boolean, runConfigCmd?: (useYarn: boolean, yes: boolean, exit?: boolean) => Promise<{
48
- success: boolean;
49
- parsedAnswers?: undefined;
50
- installedPackages?: undefined;
51
- } | {
52
- success: boolean;
53
- parsedAnswers: ParsedAnswers;
54
- installedPackages: string[];
55
- }>): Promise<{
56
- success: boolean;
57
- parsedAnswers?: undefined;
58
- installedPackages?: undefined;
59
- } | {
60
- success: boolean;
61
- parsedAnswers: ParsedAnswers;
62
- installedPackages: string[];
63
- }>;
64
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,OAAO,WAAW,CAAA;AAC/B,eAAO,MAAM,IAAI,4EAA4E,CAAA;AAE7F,eAAO,MAAM,OAAO;;;;;;;;;;;;CAYV,CAAA;AAEV,eAAO,MAAM,OAAO;;;;;;;;;;;;GAKnB,CAAA;AA2MD,wBAAgB,OAAO,CAAC,IAAI,EAAE,sBAAsB;;;;;;;;GAEnD;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,UAAQ,EAAE,YAAY;;;;;;;;EAAY;;;;;;;;GAqB3H"}
@@ -1,236 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.missingConfigurationPrompt = exports.handler = exports.builder = exports.cmdArgs = exports.desc = exports.command = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const util_1 = __importDefault(require("util"));
10
- const inquirer_1 = __importDefault(require("inquirer"));
11
- const yarn_install_1 = __importDefault(require("yarn-install"));
12
- const constants_1 = require("../constants");
13
- const utils_1 = require("../utils");
14
- const pkg = require('../../package.json');
15
- exports.command = 'config';
16
- exports.desc = 'Initialize WebdriverIO and setup configuration in your current project.';
17
- exports.cmdArgs = {
18
- yarn: {
19
- type: 'boolean',
20
- desc: 'Install packages via yarn package manager.',
21
- default: (0, utils_1.hasFile)('yarn.lock')
22
- },
23
- yes: {
24
- alias: 'y',
25
- desc: 'will fill in all config defaults without prompting',
26
- type: 'boolean',
27
- default: false
28
- }
29
- };
30
- const builder = (yargs) => {
31
- return yargs
32
- .options(exports.cmdArgs)
33
- .epilogue(constants_1.CLI_EPILOGUE)
34
- .help();
35
- };
36
- exports.builder = builder;
37
- const runConfig = async function (useYarn, yes, exit = false) {
38
- console.log(constants_1.CONFIG_HELPER_INTRO);
39
- const answers = await (0, utils_1.getAnswers)(yes);
40
- const frameworkPackage = (0, utils_1.convertPackageHashToObject)(answers.framework);
41
- const runnerPackage = (0, utils_1.convertPackageHashToObject)(answers.runner || constants_1.SUPPORTED_PACKAGES.runner[0].value);
42
- const servicePackages = answers.services.map((service) => (0, utils_1.convertPackageHashToObject)(service));
43
- const pluginPackages = answers.plugins.map((plugin) => (0, utils_1.convertPackageHashToObject)(plugin));
44
- const reporterPackages = answers.reporters.map((reporter) => (0, utils_1.convertPackageHashToObject)(reporter));
45
- let packagesToInstall = [
46
- runnerPackage.package,
47
- frameworkPackage.package,
48
- ...reporterPackages.map(reporter => reporter.package),
49
- ...pluginPackages.map(plugin => plugin.package),
50
- ...servicePackages.map(service => service.package)
51
- ];
52
- /**
53
- * find relative paths between tests and pages
54
- */
55
- const parsedPaths = (0, utils_1.getPathForFileGeneration)(answers);
56
- const parsedAnswers = {
57
- ...answers,
58
- runner: runnerPackage.short,
59
- framework: frameworkPackage.short,
60
- reporters: reporterPackages.map(({ short }) => short),
61
- plugins: pluginPackages.map(({ short }) => short),
62
- services: servicePackages.map(({ short }) => short),
63
- packagesToInstall,
64
- isUsingTypeScript: answers.isUsingCompiler === constants_1.COMPILER_OPTIONS.ts,
65
- isUsingBabel: answers.isUsingCompiler === constants_1.COMPILER_OPTIONS.babel,
66
- isSync: false,
67
- _async: 'async ',
68
- _await: 'await ',
69
- destSpecRootPath: parsedPaths.destSpecRootPath,
70
- destPageObjectRootPath: parsedPaths.destPageObjectRootPath,
71
- relativePath: parsedPaths.relativePath,
72
- tsConfigFilePath: path_1.default.join(process.cwd(), 'test', 'tsconfig.json')
73
- };
74
- /**
75
- * add ts-node if TypeScript is desired but not installed
76
- */
77
- if (parsedAnswers.isUsingTypeScript) {
78
- if (!(0, utils_1.hasPackage)('ts-node')) {
79
- packagesToInstall.push('ts-node', 'typescript');
80
- }
81
- const config = {
82
- compilerOptions: {
83
- types: [
84
- 'node',
85
- 'webdriverio/async',
86
- frameworkPackage.package,
87
- 'expect-webdriverio'
88
- ],
89
- target: 'ES5',
90
- }
91
- };
92
- fs_extra_1.default.ensureDirSync(path_1.default.join(process.cwd(), 'test'));
93
- await fs_extra_1.default.promises.writeFile(parsedAnswers.tsConfigFilePath, JSON.stringify(config, null, 4));
94
- }
95
- /**
96
- * add @babel/register package if not installed
97
- */
98
- if (parsedAnswers.isUsingBabel) {
99
- if (!(0, utils_1.hasPackage)('@babel/register')) {
100
- packagesToInstall.push('@babel/register');
101
- }
102
- /**
103
- * setup Babel if no config file exists
104
- */
105
- if (!(0, utils_1.hasFile)('babel.config.js')) {
106
- if (!(0, utils_1.hasPackage)('@babel/core')) {
107
- packagesToInstall.push('@babel/core');
108
- }
109
- if (!(0, utils_1.hasPackage)('@babel/preset-env')) {
110
- packagesToInstall.push('@babel/preset-env');
111
- }
112
- await fs_extra_1.default.promises.writeFile(path_1.default.join(process.cwd(), 'babel.config.js'), `module.exports = ${JSON.stringify({
113
- presets: [
114
- ['@babel/preset-env', {
115
- targets: {
116
- node: '14'
117
- }
118
- }]
119
- ]
120
- }, null, 4)}`);
121
- }
122
- }
123
- /**
124
- * add packages that are required by services
125
- */
126
- (0, utils_1.addServiceDeps)(servicePackages, packagesToInstall);
127
- /**
128
- * ensure wdio packages have the same dist tag as cli
129
- */
130
- if (pkg._requested && pkg._requested.fetchSpec) {
131
- const { fetchSpec } = pkg._requested;
132
- packagesToInstall = packagesToInstall.map((p) => (p.startsWith('@wdio') || ['devtools', 'webdriver', 'webdriverio'].includes(p)) &&
133
- (fetchSpec.match(/(v)?\d+\.\d+\.\d+/) === null)
134
- ? `${p}@${fetchSpec}`
135
- : p);
136
- }
137
- /**
138
- * run npm install only if required by the user
139
- */
140
- if (parsedAnswers.npmInstall) {
141
- console.log('\nInstalling wdio packages:\n-', packagesToInstall.join('\n- '));
142
- const result = (0, yarn_install_1.default)({ deps: packagesToInstall, dev: true, respectNpm5: !useYarn });
143
- if (result.status !== 0) {
144
- const customError = 'An unknown error happened! Please retry ' +
145
- `installing dependencies via "${useYarn ? 'yarn add --dev' : 'npm i --save-dev'} ` +
146
- `${packagesToInstall.join(' ')}"\n\nError: ${result.stderr || 'unknown'}`;
147
- console.log(customError);
148
- /**
149
- * don't exit if running unit tests
150
- */
151
- if (exit /* istanbul ignore next */ && !process.env.JEST_WORKER_ID) {
152
- /* istanbul ignore next */
153
- process.exit(1);
154
- }
155
- return { success: false };
156
- }
157
- console.log('\nPackages installed successfully, creating configuration file...');
158
- }
159
- else {
160
- const installationCommand = `${useYarn ? 'yarn add --dev' : 'npm i --save-dev'} ${packagesToInstall.join(' ')}`;
161
- console.log(util_1.default.format(constants_1.DEPENDENCIES_INSTALLATION_MESSAGE, installationCommand));
162
- }
163
- try {
164
- await (0, utils_1.renderConfigurationFile)(parsedAnswers);
165
- if (answers.generateTestFiles) {
166
- console.log('\nConfig file installed successfully, creating test files...');
167
- await (0, utils_1.generateTestFiles)(parsedAnswers);
168
- }
169
- }
170
- catch (err) {
171
- throw new Error(`Couldn't write config file: ${err.stack}`);
172
- }
173
- /**
174
- * print TypeScript configuration message
175
- */
176
- if (answers.isUsingCompiler === constants_1.COMPILER_OPTIONS.ts) {
177
- const tsPkgs = `"${[
178
- 'webdriverio/async',
179
- frameworkPackage.package,
180
- 'expect-webdriverio',
181
- ...servicePackages
182
- .map(service => service.package)
183
- /**
184
- * given that we know that all "offical" services have
185
- * typescript support we only include them
186
- */
187
- .filter(service => service.startsWith('@wdio'))
188
- ].join('", "')}"`;
189
- console.log(util_1.default.format(constants_1.TS_COMPILER_INSTRUCTIONS, tsPkgs));
190
- }
191
- console.log(util_1.default.format(constants_1.CONFIG_HELPER_SUCCESS_MESSAGE, parsedAnswers.isUsingTypeScript ? 'test/' : '', parsedAnswers.isUsingTypeScript ? 'ts' : 'js'));
192
- /**
193
- * don't exit if running unit tests
194
- */
195
- if (exit /* istanbul ignore next */ && !process.env.JEST_WORKER_ID) {
196
- /* istanbul ignore next */
197
- process.exit(0);
198
- }
199
- return {
200
- success: true,
201
- parsedAnswers,
202
- installedPackages: packagesToInstall.map((pkg) => pkg.split('--')[0])
203
- };
204
- };
205
- function handler(argv) {
206
- return runConfig(argv.yarn, argv.yes);
207
- }
208
- exports.handler = handler;
209
- /**
210
- * Helper utility used in `run` and `install` command to create config if none exist
211
- * @param {string} command to be executed by user
212
- * @param {string} message to show when no config is suppose to be created
213
- * @param {boolean} useYarn parameter set to true if yarn is used
214
- * @param {Function} runConfigCmd runConfig method to be replaceable for unit testing
215
- */
216
- async function missingConfigurationPrompt(command, message, useYarn = false, runConfigCmd = runConfig) {
217
- const { config } = await inquirer_1.default.prompt([
218
- {
219
- type: 'confirm',
220
- name: 'config',
221
- message: `Error: Could not execute "${command}" due to missing configuration. Would you like to create one?`,
222
- default: false
223
- }
224
- ]);
225
- /**
226
- * don't exit if running unit tests
227
- */
228
- if (!config && !process.env.JEST_WORKER_ID) {
229
- /* istanbul ignore next */
230
- console.log(message);
231
- /* istanbul ignore next */
232
- return process.exit(0);
233
- }
234
- return await runConfigCmd(useYarn, false, true);
235
- }
236
- exports.missingConfigurationPrompt = missingConfigurationPrompt;
@@ -1,18 +0,0 @@
1
- import { InstallCommandArguments } from '../types';
2
- import yargs from 'yargs';
3
- export declare const command = "install <type> <name>";
4
- export declare const desc: string;
5
- export declare const cmdArgs: {
6
- readonly yarn: {
7
- readonly desc: "Install packages using yarn";
8
- readonly type: "boolean";
9
- readonly default: false;
10
- };
11
- readonly config: {
12
- readonly desc: "Location of your WDIO configuration";
13
- readonly default: "./wdio.conf.js";
14
- };
15
- };
16
- export declare const builder: (yargs: yargs.Argv<{}>) => yargs.Argv<{}>;
17
- export declare function handler(argv: InstallCommandArguments): Promise<void>;
18
- //# sourceMappingURL=install.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,uBAAuB,EAAoB,MAAM,UAAU,CAAA;AAEpE,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,eAAO,MAAM,OAAO,0BAA0B,CAAA;AAC9C,eAAO,MAAM,IAAI,QAIN,CAAA;AAEX,eAAO,MAAM,OAAO;;;;;;;;;;CAUV,CAAA;AAEV,eAAO,MAAM,OAAO,2CAanB,CAAA;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,uBAAuB,iBAyE1D"}
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.handler = exports.builder = exports.cmdArgs = exports.desc = exports.command = void 0;
7
- /* eslint-disable no-console */
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const path_1 = __importDefault(require("path"));
10
- const yarn_install_1 = __importDefault(require("yarn-install"));
11
- const utils_1 = require("../utils");
12
- const config_1 = require("./config");
13
- const constants_1 = require("../constants");
14
- const supportedInstallations = {
15
- plugin: constants_1.SUPPORTED_PACKAGES.plugin.map(({ value }) => (0, utils_1.convertPackageHashToObject)(value)),
16
- service: constants_1.SUPPORTED_PACKAGES.service.map(({ value }) => (0, utils_1.convertPackageHashToObject)(value)),
17
- reporter: constants_1.SUPPORTED_PACKAGES.reporter.map(({ value }) => (0, utils_1.convertPackageHashToObject)(value)),
18
- framework: constants_1.SUPPORTED_PACKAGES.framework.map(({ value }) => (0, utils_1.convertPackageHashToObject)(value))
19
- };
20
- exports.command = 'install <type> <name>';
21
- exports.desc = [
22
- 'Add a `reporter`, `service`, or `framework` to your WebdriverIO project.',
23
- 'The command installs the package from NPM, adds it to your package.json',
24
- 'and modifies the wdio.conf.js accordingly.'
25
- ].join(' ');
26
- exports.cmdArgs = {
27
- yarn: {
28
- desc: 'Install packages using yarn',
29
- type: 'boolean',
30
- default: false
31
- },
32
- config: {
33
- desc: 'Location of your WDIO configuration',
34
- default: './wdio.conf.js',
35
- },
36
- };
37
- const builder = (yargs) => {
38
- yargs
39
- .options(exports.cmdArgs)
40
- .epilogue(constants_1.CLI_EPILOGUE)
41
- .help();
42
- for (const [type, plugins] of Object.entries(supportedInstallations)) {
43
- for (const plugin of plugins) {
44
- yargs.example(`$0 install ${type} ${plugin.short}`, `Install ${plugin.package}`);
45
- }
46
- }
47
- return yargs;
48
- };
49
- exports.builder = builder;
50
- async function handler(argv) {
51
- /**
52
- * type = service | reporter | framework
53
- * name = names for the supported service or reporter
54
- * yarn = optional flag to install package using yarn instead of default yarn
55
- */
56
- const { type, name, yarn, config } = argv;
57
- /**
58
- * verify for supported types via `supportedInstallations` keys
59
- */
60
- if (!Object.keys(supportedInstallations).includes(type)) {
61
- console.log(`Type ${type} is not supported.`);
62
- process.exit(0);
63
- return;
64
- }
65
- /**
66
- * verify if the name of the `type` is valid
67
- */
68
- if (!supportedInstallations[type].find(pkg => pkg.short === name)) {
69
- console.log(`${name} is not a supported ${type}.`);
70
- process.exit(0);
71
- return;
72
- }
73
- const localConfPath = path_1.default.join(process.cwd(), config);
74
- if (!fs_extra_1.default.existsSync(localConfPath)) {
75
- try {
76
- const promptMessage = `Cannot install packages without a WebdriverIO configuration.
77
- You can create one by running 'wdio config'`;
78
- await (0, config_1.missingConfigurationPrompt)('install', promptMessage, yarn);
79
- }
80
- catch {
81
- process.exit(1);
82
- return;
83
- }
84
- }
85
- const configFile = fs_extra_1.default.readFileSync(localConfPath, { encoding: 'utf-8' });
86
- const match = (0, utils_1.findInConfig)(configFile, type);
87
- if (match && match[0].includes(name)) {
88
- console.log(`The ${type} ${name} is already part of your configuration.`);
89
- process.exit(0);
90
- return;
91
- }
92
- const selectedPackage = supportedInstallations[type].find(({ short }) => short === name);
93
- const pkgsToInstall = selectedPackage ? [selectedPackage.package] : [];
94
- (0, utils_1.addServiceDeps)(selectedPackage ? [selectedPackage] : [], pkgsToInstall, true);
95
- console.log(`Installing "${selectedPackage.package}"${yarn ? ' using yarn.' : '.'}`);
96
- const install = (0, yarn_install_1.default)({ deps: pkgsToInstall, dev: true, respectNpm5: !yarn }); // use !yarn so the package forces npm install
97
- if (install.status !== 0) {
98
- console.error('Error installing packages', install.stderr);
99
- process.exit(1);
100
- return;
101
- }
102
- console.log(`Package "${selectedPackage.package}" installed successfully.`);
103
- const newConfig = (0, utils_1.replaceConfig)(configFile, type, name);
104
- if (!newConfig) {
105
- throw new Error(`Couldn't find "${type}" property in ${path_1.default.basename(localConfPath)}`);
106
- }
107
- fs_extra_1.default.writeFileSync(localConfPath, newConfig, { encoding: 'utf-8' });
108
- console.log('Your wdio.conf.js file has been updated.');
109
- process.exit(0);
110
- }
111
- exports.handler = handler;
112
- /* eslint-enable no-console */
@@ -1,36 +0,0 @@
1
- import { ReplCommandArguments } from '../types';
2
- import yargs from 'yargs';
3
- export declare const command = "repl <option> [capabilities]";
4
- export declare const desc = "Run WebDriver session in command line";
5
- export declare const cmdArgs: {
6
- readonly platformVersion: {
7
- readonly alias: "v";
8
- readonly desc: "Version of OS for mobile devices";
9
- readonly type: "string";
10
- };
11
- readonly deviceName: {
12
- readonly alias: "d";
13
- readonly desc: "Device name for mobile devices";
14
- readonly type: "string";
15
- };
16
- readonly udid: {
17
- readonly alias: "u";
18
- readonly desc: "UDID of real mobile devices";
19
- readonly type: "string";
20
- };
21
- };
22
- export declare const builder: (yargs: yargs.Argv<{}>) => yargs.Argv<yargs.Omit<{}, string | number> & yargs.InferredOptionTypes<import("lodash").Dictionary<{
23
- readonly alias: "v";
24
- readonly desc: "Version of OS for mobile devices";
25
- readonly type: "string";
26
- } | {
27
- readonly alias: "d";
28
- readonly desc: "Device name for mobile devices";
29
- readonly type: "string";
30
- } | {
31
- readonly alias: "u";
32
- readonly desc: "UDID of real mobile devices";
33
- readonly type: "string";
34
- }>>>;
35
- export declare const handler: (argv: ReplCommandArguments) => Promise<any>;
36
- //# sourceMappingURL=repl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/commands/repl.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,eAAO,MAAM,OAAO,iCAAiC,CAAA;AACrD,eAAO,MAAM,IAAI,0CAA0C,CAAA;AAC3D,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;CAgBV,CAAA;AAEV,eAAO,MAAM,OAAO;;;;;;;;;;;;IAUnB,CAAA;AAED,eAAO,MAAM,OAAO,SAAgB,oBAAoB,iBAiBvD,CAAA"}
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.handler = exports.builder = exports.cmdArgs = exports.desc = exports.command = void 0;
7
- const lodash_pickby_1 = __importDefault(require("lodash.pickby"));
8
- const webdriverio_1 = require("webdriverio");
9
- const utils_1 = require("@wdio/utils");
10
- const utils_2 = require("../utils");
11
- const constants_1 = require("../constants");
12
- const IGNORED_ARGS = [
13
- 'bail', 'framework', 'reporters', 'suite', 'spec', 'exclude',
14
- 'mochaOpts', 'jasmineOpts', 'cucumberOpts', 'autoCompileOpts'
15
- ];
16
- exports.command = 'repl <option> [capabilities]';
17
- exports.desc = 'Run WebDriver session in command line';
18
- exports.cmdArgs = {
19
- platformVersion: {
20
- alias: 'v',
21
- desc: 'Version of OS for mobile devices',
22
- type: 'string',
23
- },
24
- deviceName: {
25
- alias: 'd',
26
- desc: 'Device name for mobile devices',
27
- type: 'string',
28
- },
29
- udid: {
30
- alias: 'u',
31
- desc: 'UDID of real mobile devices',
32
- type: 'string',
33
- }
34
- };
35
- const builder = (yargs) => {
36
- return yargs
37
- .options((0, lodash_pickby_1.default)(exports.cmdArgs, (_, key) => !IGNORED_ARGS.includes(key)))
38
- .example('$0 repl firefox --path /', 'Run repl locally')
39
- .example('$0 repl chrome -u <SAUCE_USERNAME> -k <SAUCE_ACCESS_KEY>', 'Run repl in Sauce Labs cloud')
40
- .example('$0 repl android', 'Run repl browser on launched Android device')
41
- .example('$0 repl "./path/to/your_app.app"', 'Run repl native app on iOS simulator')
42
- .example('$0 repl ios -v 11.3 -d "iPhone 7" -u 123432abc', 'Run repl browser on iOS device with capabilities')
43
- .epilogue(constants_1.CLI_EPILOGUE)
44
- .help();
45
- };
46
- exports.builder = builder;
47
- const handler = async (argv) => {
48
- const caps = (0, utils_2.getCapabilities)(argv);
49
- /**
50
- * runner option required to wrap commands within Fibers context
51
- */
52
- const execMode = utils_1.hasWdioSyncSupport ? { runner: 'local' } : {};
53
- const client = await (0, webdriverio_1.remote)({ ...argv, ...caps, ...execMode });
54
- // @ts-ignore
55
- global.$ = client.$.bind(client);
56
- // @ts-ignore
57
- global.$$ = client.$$.bind(client);
58
- global.browser = client;
59
- await client.debug();
60
- return client.deleteSession();
61
- };
62
- exports.handler = handler;