@wdio/cli 7.20.8 → 8.0.0-alpha.214
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.
- package/bin/wdio.js +7 -1
- package/build/commands/config.d.ts +3 -3
- package/build/commands/config.d.ts.map +1 -1
- package/build/commands/config.js +56 -61
- package/build/commands/index.d.ts +2 -0
- package/build/commands/index.d.ts.map +1 -0
- package/build/commands/index.js +5 -0
- package/build/commands/install.d.ts +3 -3
- package/build/commands/install.d.ts.map +1 -1
- package/build/commands/install.js +27 -35
- package/build/commands/repl.d.ts +5 -5
- package/build/commands/repl.d.ts.map +1 -1
- package/build/commands/repl.js +15 -29
- package/build/commands/run.d.ts +3 -3
- package/build/commands/run.d.ts.map +1 -1
- package/build/commands/run.js +24 -33
- package/build/constants.d.ts +2 -1
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +45 -46
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +24 -41
- package/build/interface.d.ts +2 -2
- package/build/interface.d.ts.map +1 -1
- package/build/interface.js +27 -34
- package/build/launcher.d.ts +4 -4
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +59 -52
- package/build/types.d.ts +2 -2
- package/build/types.d.ts.map +1 -1
- package/build/types.js +1 -2
- package/build/utils.d.ts +1 -1
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +71 -92
- package/build/watcher.d.ts +1 -1
- package/build/watcher.d.ts.map +1 -1
- package/build/watcher.js +21 -24
- package/package.json +28 -22
package/bin/wdio.js
CHANGED
|
@@ -8,4 +8,10 @@ if (process.env.NODE_ENV == null) {
|
|
|
8
8
|
process.env.NODE_ENV = 'test'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* use IIFE to allow running this within CJS and ESM context
|
|
13
|
+
*/
|
|
14
|
+
(async () => {
|
|
15
|
+
const cli = await import('../build/index.js')
|
|
16
|
+
cli.run()
|
|
17
|
+
})()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Argv } from 'yargs';
|
|
2
|
+
import type { ConfigCommandArguments, ParsedAnswers } from '../types';
|
|
3
3
|
export declare const command = "config";
|
|
4
4
|
export declare const desc = "Initialize WebdriverIO and setup configuration in your current project.";
|
|
5
5
|
export declare const cmdArgs: {
|
|
@@ -15,7 +15,7 @@ export declare const cmdArgs: {
|
|
|
15
15
|
readonly default: false;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
export declare const builder: (yargs:
|
|
18
|
+
export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, "yarn" | "yes"> & import("yargs").InferredOptionTypes<{
|
|
19
19
|
readonly yarn: {
|
|
20
20
|
readonly type: "boolean";
|
|
21
21
|
readonly desc: "Install packages via yarn package manager.";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAcjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAErE,eAAO,MAAM,OAAO,WAAW,CAAA;AAC/B,eAAO,MAAM,IAAI,4EAA4E,CAAA;AAE7F,eAAO,MAAM,OAAO;;;;;;;;;;;;CAYV,CAAA;AAEV,eAAO,MAAM,OAAO,UAAW,IAAI;;;;;;;;;;;;GAKlC,CAAA;AA0MD,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;;;;;;;;GA4B3H"}
|
package/build/commands/config.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
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 = {
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import util from 'node:util';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import yarnInstall from 'yarn-install';
|
|
6
|
+
import { CONFIG_HELPER_INTRO, CLI_EPILOGUE, COMPILER_OPTIONS, TS_COMPILER_INSTRUCTIONS, SUPPORTED_PACKAGES, CONFIG_HELPER_SUCCESS_MESSAGE, DEPENDENCIES_INSTALLATION_MESSAGE, pkg } from '../constants.js';
|
|
7
|
+
import { addServiceDeps, convertPackageHashToObject, renderConfigurationFile, hasFile, generateTestFiles, getAnswers, getPathForFileGeneration, hasPackage } from '../utils.js';
|
|
8
|
+
export const command = 'config';
|
|
9
|
+
export const desc = 'Initialize WebdriverIO and setup configuration in your current project.';
|
|
10
|
+
export const cmdArgs = {
|
|
18
11
|
yarn: {
|
|
19
12
|
type: 'boolean',
|
|
20
13
|
desc: 'Install packages via yarn package manager.',
|
|
21
|
-
default:
|
|
14
|
+
default: hasFile('yarn.lock')
|
|
22
15
|
},
|
|
23
16
|
yes: {
|
|
24
17
|
alias: 'y',
|
|
@@ -27,21 +20,20 @@ exports.cmdArgs = {
|
|
|
27
20
|
default: false
|
|
28
21
|
}
|
|
29
22
|
};
|
|
30
|
-
const builder = (yargs) => {
|
|
23
|
+
export const builder = (yargs) => {
|
|
31
24
|
return yargs
|
|
32
|
-
.options(
|
|
33
|
-
.epilogue(
|
|
25
|
+
.options(cmdArgs)
|
|
26
|
+
.epilogue(CLI_EPILOGUE)
|
|
34
27
|
.help();
|
|
35
28
|
};
|
|
36
|
-
exports.builder = builder;
|
|
37
29
|
const runConfig = async function (useYarn, yes, exit = false) {
|
|
38
|
-
console.log(
|
|
39
|
-
const answers = await
|
|
40
|
-
const frameworkPackage =
|
|
41
|
-
const runnerPackage =
|
|
42
|
-
const servicePackages = answers.services.map((service) =>
|
|
43
|
-
const pluginPackages = answers.plugins.map((plugin) =>
|
|
44
|
-
const reporterPackages = answers.reporters.map((reporter) =>
|
|
30
|
+
console.log(CONFIG_HELPER_INTRO);
|
|
31
|
+
const answers = await getAnswers(yes);
|
|
32
|
+
const frameworkPackage = convertPackageHashToObject(answers.framework);
|
|
33
|
+
const runnerPackage = convertPackageHashToObject(answers.runner || SUPPORTED_PACKAGES.runner[0].value);
|
|
34
|
+
const servicePackages = answers.services.map((service) => convertPackageHashToObject(service));
|
|
35
|
+
const pluginPackages = answers.plugins.map((plugin) => convertPackageHashToObject(plugin));
|
|
36
|
+
const reporterPackages = answers.reporters.map((reporter) => convertPackageHashToObject(reporter));
|
|
45
37
|
let packagesToInstall = [
|
|
46
38
|
runnerPackage.package,
|
|
47
39
|
frameworkPackage.package,
|
|
@@ -52,7 +44,7 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
52
44
|
/**
|
|
53
45
|
* find relative paths between tests and pages
|
|
54
46
|
*/
|
|
55
|
-
const parsedPaths =
|
|
47
|
+
const parsedPaths = getPathForFileGeneration(answers);
|
|
56
48
|
const parsedAnswers = {
|
|
57
49
|
...answers,
|
|
58
50
|
runner: runnerPackage.short,
|
|
@@ -61,21 +53,21 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
61
53
|
plugins: pluginPackages.map(({ short }) => short),
|
|
62
54
|
services: servicePackages.map(({ short }) => short),
|
|
63
55
|
packagesToInstall,
|
|
64
|
-
isUsingTypeScript: answers.isUsingCompiler ===
|
|
65
|
-
isUsingBabel: answers.isUsingCompiler ===
|
|
56
|
+
isUsingTypeScript: answers.isUsingCompiler === COMPILER_OPTIONS.ts,
|
|
57
|
+
isUsingBabel: answers.isUsingCompiler === COMPILER_OPTIONS.babel,
|
|
66
58
|
isSync: false,
|
|
67
59
|
_async: 'async ',
|
|
68
60
|
_await: 'await ',
|
|
69
61
|
destSpecRootPath: parsedPaths.destSpecRootPath,
|
|
70
62
|
destPageObjectRootPath: parsedPaths.destPageObjectRootPath,
|
|
71
63
|
relativePath: parsedPaths.relativePath,
|
|
72
|
-
tsConfigFilePath:
|
|
64
|
+
tsConfigFilePath: path.join(process.cwd(), 'test', 'tsconfig.json')
|
|
73
65
|
};
|
|
74
66
|
/**
|
|
75
67
|
* add ts-node if TypeScript is desired but not installed
|
|
76
68
|
*/
|
|
77
69
|
if (parsedAnswers.isUsingTypeScript) {
|
|
78
|
-
if (!
|
|
70
|
+
if (!hasPackage('ts-node')) {
|
|
79
71
|
packagesToInstall.push('ts-node', 'typescript');
|
|
80
72
|
}
|
|
81
73
|
const config = {
|
|
@@ -83,34 +75,34 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
83
75
|
moduleResolution: 'node',
|
|
84
76
|
types: [
|
|
85
77
|
'node',
|
|
86
|
-
'
|
|
78
|
+
'@wdio/globals/types',
|
|
87
79
|
frameworkPackage.package,
|
|
88
80
|
'expect-webdriverio'
|
|
89
81
|
],
|
|
90
82
|
target: 'es2019',
|
|
91
83
|
}
|
|
92
84
|
};
|
|
93
|
-
|
|
94
|
-
await
|
|
85
|
+
fs.ensureDirSync(path.join(process.cwd(), 'test'));
|
|
86
|
+
await fs.promises.writeFile(parsedAnswers.tsConfigFilePath, JSON.stringify(config, null, 4));
|
|
95
87
|
}
|
|
96
88
|
/**
|
|
97
89
|
* add @babel/register package if not installed
|
|
98
90
|
*/
|
|
99
91
|
if (parsedAnswers.isUsingBabel) {
|
|
100
|
-
if (!
|
|
92
|
+
if (!hasPackage('@babel/register')) {
|
|
101
93
|
packagesToInstall.push('@babel/register');
|
|
102
94
|
}
|
|
103
95
|
/**
|
|
104
96
|
* setup Babel if no config file exists
|
|
105
97
|
*/
|
|
106
|
-
if (!
|
|
107
|
-
if (!
|
|
98
|
+
if (!hasFile('babel.config.js')) {
|
|
99
|
+
if (!hasPackage('@babel/core')) {
|
|
108
100
|
packagesToInstall.push('@babel/core');
|
|
109
101
|
}
|
|
110
|
-
if (!
|
|
102
|
+
if (!hasPackage('@babel/preset-env')) {
|
|
111
103
|
packagesToInstall.push('@babel/preset-env');
|
|
112
104
|
}
|
|
113
|
-
await
|
|
105
|
+
await fs.promises.writeFile(path.join(process.cwd(), 'babel.config.js'), `module.exports = ${JSON.stringify({
|
|
114
106
|
presets: [
|
|
115
107
|
['@babel/preset-env', {
|
|
116
108
|
targets: {
|
|
@@ -124,7 +116,7 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
124
116
|
/**
|
|
125
117
|
* add packages that are required by services
|
|
126
118
|
*/
|
|
127
|
-
|
|
119
|
+
addServiceDeps(servicePackages, packagesToInstall);
|
|
128
120
|
/**
|
|
129
121
|
* ensure wdio packages have the same dist tag as cli
|
|
130
122
|
*/
|
|
@@ -140,7 +132,7 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
140
132
|
*/
|
|
141
133
|
if (parsedAnswers.npmInstall) {
|
|
142
134
|
console.log('\nInstalling wdio packages:\n-', packagesToInstall.join('\n- '));
|
|
143
|
-
const result = (
|
|
135
|
+
const result = yarnInstall({ deps: packagesToInstall, dev: true, respectNpm5: !useYarn });
|
|
144
136
|
if (result.status !== 0) {
|
|
145
137
|
const customError = 'An unknown error happened! Please retry ' +
|
|
146
138
|
`installing dependencies via "${useYarn ? 'yarn add --dev' : 'npm i --save-dev'} ` +
|
|
@@ -149,7 +141,7 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
149
141
|
/**
|
|
150
142
|
* don't exit if running unit tests
|
|
151
143
|
*/
|
|
152
|
-
if (exit /* istanbul ignore next */ && !process.env.
|
|
144
|
+
if (exit /* istanbul ignore next */ && !process.env.VITEST_WORKER_ID) {
|
|
153
145
|
/* istanbul ignore next */
|
|
154
146
|
process.exit(1);
|
|
155
147
|
}
|
|
@@ -159,13 +151,13 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
159
151
|
}
|
|
160
152
|
else {
|
|
161
153
|
const installationCommand = `${useYarn ? 'yarn add --dev' : 'npm i --save-dev'} ${packagesToInstall.join(' ')}`;
|
|
162
|
-
console.log(
|
|
154
|
+
console.log(util.format(DEPENDENCIES_INSTALLATION_MESSAGE, installationCommand));
|
|
163
155
|
}
|
|
164
156
|
try {
|
|
165
|
-
await
|
|
157
|
+
await renderConfigurationFile(parsedAnswers);
|
|
166
158
|
if (answers.generateTestFiles) {
|
|
167
159
|
console.log('\nConfig file installed successfully, creating test files...');
|
|
168
|
-
await
|
|
160
|
+
await generateTestFiles(parsedAnswers);
|
|
169
161
|
}
|
|
170
162
|
}
|
|
171
163
|
catch (err) {
|
|
@@ -174,9 +166,9 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
174
166
|
/**
|
|
175
167
|
* print TypeScript configuration message
|
|
176
168
|
*/
|
|
177
|
-
if (answers.isUsingCompiler ===
|
|
169
|
+
if (answers.isUsingCompiler === COMPILER_OPTIONS.ts) {
|
|
178
170
|
const tsPkgs = `"${[
|
|
179
|
-
'
|
|
171
|
+
'@wdio/globals/types',
|
|
180
172
|
frameworkPackage.package,
|
|
181
173
|
'expect-webdriverio',
|
|
182
174
|
...servicePackages
|
|
@@ -187,13 +179,13 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
187
179
|
*/
|
|
188
180
|
.filter(service => service.startsWith('@wdio'))
|
|
189
181
|
].join('", "')}"`;
|
|
190
|
-
console.log(
|
|
182
|
+
console.log(util.format(TS_COMPILER_INSTRUCTIONS, tsPkgs));
|
|
191
183
|
}
|
|
192
|
-
console.log(
|
|
184
|
+
console.log(util.format(CONFIG_HELPER_SUCCESS_MESSAGE, parsedAnswers.isUsingTypeScript ? 'test/' : '', parsedAnswers.isUsingTypeScript ? 'ts' : 'js'));
|
|
193
185
|
/**
|
|
194
186
|
* don't exit if running unit tests
|
|
195
187
|
*/
|
|
196
|
-
if (exit /* istanbul ignore next */ && !process.env.
|
|
188
|
+
if (exit /* istanbul ignore next */ && !process.env.VITEST_WORKER_ID) {
|
|
197
189
|
/* istanbul ignore next */
|
|
198
190
|
process.exit(0);
|
|
199
191
|
}
|
|
@@ -203,10 +195,9 @@ const runConfig = async function (useYarn, yes, exit = false) {
|
|
|
203
195
|
installedPackages: packagesToInstall.map((pkg) => pkg.split('--')[0])
|
|
204
196
|
};
|
|
205
197
|
};
|
|
206
|
-
function handler(argv) {
|
|
198
|
+
export function handler(argv) {
|
|
207
199
|
return runConfig(argv.yarn, argv.yes);
|
|
208
200
|
}
|
|
209
|
-
exports.handler = handler;
|
|
210
201
|
/**
|
|
211
202
|
* Helper utility used in `run` and `install` command to create config if none exist
|
|
212
203
|
* @param {string} command to be executed by user
|
|
@@ -214,24 +205,28 @@ exports.handler = handler;
|
|
|
214
205
|
* @param {boolean} useYarn parameter set to true if yarn is used
|
|
215
206
|
* @param {Function} runConfigCmd runConfig method to be replaceable for unit testing
|
|
216
207
|
*/
|
|
217
|
-
async function missingConfigurationPrompt(command, message, useYarn = false, runConfigCmd = runConfig) {
|
|
218
|
-
const
|
|
208
|
+
export async function missingConfigurationPrompt(command, message, useYarn = false, runConfigCmd = runConfig) {
|
|
209
|
+
const configMessage = command === 'run'
|
|
210
|
+
? `Error: Could not execute "run" due to missing configuration, file "${message}" not found! Would you like to create one?`
|
|
211
|
+
: `Error: Could not execute "${command}" due to missing configuration. Would you like to create one?`;
|
|
212
|
+
const { config } = await inquirer.prompt([
|
|
219
213
|
{
|
|
220
214
|
type: 'confirm',
|
|
221
215
|
name: 'config',
|
|
222
|
-
message:
|
|
216
|
+
message: configMessage,
|
|
223
217
|
default: false
|
|
224
218
|
}
|
|
225
219
|
]);
|
|
226
220
|
/**
|
|
227
221
|
* don't exit if running unit tests
|
|
228
222
|
*/
|
|
229
|
-
if (!config && !process.env.
|
|
223
|
+
if (!config && !process.env.VITEST_WORKER_ID) {
|
|
230
224
|
/* istanbul ignore next */
|
|
231
|
-
console.log(
|
|
225
|
+
console.log(command === 'run'
|
|
226
|
+
? `No WebdriverIO configuration found in "${process.cwd()}"`
|
|
227
|
+
: message);
|
|
232
228
|
/* istanbul ignore next */
|
|
233
229
|
return process.exit(0);
|
|
234
230
|
}
|
|
235
231
|
return await runConfigCmd(useYarn, false, true);
|
|
236
232
|
}
|
|
237
|
-
exports.missingConfigurationPrompt = missingConfigurationPrompt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,EAAE,GAAkC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Argv } from 'yargs';
|
|
2
|
+
import type { InstallCommandArguments } from '../types';
|
|
3
3
|
export declare const command = "install <type> <name>";
|
|
4
4
|
export declare const desc: string;
|
|
5
5
|
export declare const cmdArgs: {
|
|
@@ -13,6 +13,6 @@ export declare const cmdArgs: {
|
|
|
13
13
|
readonly default: "./wdio.conf.js";
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
export declare const builder: (yargs:
|
|
16
|
+
export declare const builder: (yargs: Argv) => Argv<{}>;
|
|
17
17
|
export declare function handler(argv: InstallCommandArguments): Promise<void>;
|
|
18
18
|
//# sourceMappingURL=install.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAUjC,OAAO,KAAK,EAAE,uBAAuB,EAAoB,MAAM,UAAU,CAAA;AASzE,eAAO,MAAM,OAAO,0BAA0B,CAAA;AAC9C,eAAO,MAAM,IAAI,QAIN,CAAA;AAEX,eAAO,MAAM,OAAO;;;;;;;;;;CAUV,CAAA;AAEV,eAAO,MAAM,OAAO,UAAW,IAAI,aAalC,CAAA;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,uBAAuB,iBAyE1D"}
|
|
@@ -1,29 +1,23 @@
|
|
|
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
1
|
/* eslint-disable no-console */
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import yarnInstall from 'yarn-install';
|
|
5
|
+
import { replaceConfig, findInConfig, addServiceDeps, convertPackageHashToObject } from '../utils.js';
|
|
6
|
+
import { missingConfigurationPrompt } from './config.js';
|
|
7
|
+
import { SUPPORTED_PACKAGES, CLI_EPILOGUE } from '../constants.js';
|
|
14
8
|
const supportedInstallations = {
|
|
15
|
-
plugin:
|
|
16
|
-
service:
|
|
17
|
-
reporter:
|
|
18
|
-
framework:
|
|
9
|
+
plugin: SUPPORTED_PACKAGES.plugin.map(({ value }) => convertPackageHashToObject(value)),
|
|
10
|
+
service: SUPPORTED_PACKAGES.service.map(({ value }) => convertPackageHashToObject(value)),
|
|
11
|
+
reporter: SUPPORTED_PACKAGES.reporter.map(({ value }) => convertPackageHashToObject(value)),
|
|
12
|
+
framework: SUPPORTED_PACKAGES.framework.map(({ value }) => convertPackageHashToObject(value))
|
|
19
13
|
};
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
export const command = 'install <type> <name>';
|
|
15
|
+
export const desc = [
|
|
22
16
|
'Add a `reporter`, `service`, or `framework` to your WebdriverIO project.',
|
|
23
17
|
'The command installs the package from NPM, adds it to your package.json',
|
|
24
18
|
'and modifies the wdio.conf.js accordingly.'
|
|
25
19
|
].join(' ');
|
|
26
|
-
|
|
20
|
+
export const cmdArgs = {
|
|
27
21
|
yarn: {
|
|
28
22
|
desc: 'Install packages using yarn',
|
|
29
23
|
type: 'boolean',
|
|
@@ -34,10 +28,10 @@ exports.cmdArgs = {
|
|
|
34
28
|
default: './wdio.conf.js',
|
|
35
29
|
},
|
|
36
30
|
};
|
|
37
|
-
const builder = (yargs) => {
|
|
31
|
+
export const builder = (yargs) => {
|
|
38
32
|
yargs
|
|
39
|
-
.options(
|
|
40
|
-
.epilogue(
|
|
33
|
+
.options(cmdArgs)
|
|
34
|
+
.epilogue(CLI_EPILOGUE)
|
|
41
35
|
.help();
|
|
42
36
|
for (const [type, plugins] of Object.entries(supportedInstallations)) {
|
|
43
37
|
for (const plugin of plugins) {
|
|
@@ -46,8 +40,7 @@ const builder = (yargs) => {
|
|
|
46
40
|
}
|
|
47
41
|
return yargs;
|
|
48
42
|
};
|
|
49
|
-
|
|
50
|
-
async function handler(argv) {
|
|
43
|
+
export async function handler(argv) {
|
|
51
44
|
/**
|
|
52
45
|
* type = service | reporter | framework
|
|
53
46
|
* name = names for the supported service or reporter
|
|
@@ -70,20 +63,20 @@ async function handler(argv) {
|
|
|
70
63
|
process.exit(0);
|
|
71
64
|
return;
|
|
72
65
|
}
|
|
73
|
-
const localConfPath =
|
|
74
|
-
if (!
|
|
66
|
+
const localConfPath = path.join(process.cwd(), config);
|
|
67
|
+
if (!fs.existsSync(localConfPath)) {
|
|
75
68
|
try {
|
|
76
69
|
const promptMessage = `Cannot install packages without a WebdriverIO configuration.
|
|
77
70
|
You can create one by running 'wdio config'`;
|
|
78
|
-
await
|
|
71
|
+
await missingConfigurationPrompt('install', promptMessage, yarn);
|
|
79
72
|
}
|
|
80
73
|
catch {
|
|
81
74
|
process.exit(1);
|
|
82
75
|
return;
|
|
83
76
|
}
|
|
84
77
|
}
|
|
85
|
-
const configFile =
|
|
86
|
-
const match =
|
|
78
|
+
const configFile = fs.readFileSync(localConfPath, { encoding: 'utf-8' });
|
|
79
|
+
const match = findInConfig(configFile, type);
|
|
87
80
|
if (match && match[0].includes(name)) {
|
|
88
81
|
console.log(`The ${type} ${name} is already part of your configuration.`);
|
|
89
82
|
process.exit(0);
|
|
@@ -91,22 +84,21 @@ You can create one by running 'wdio config'`;
|
|
|
91
84
|
}
|
|
92
85
|
const selectedPackage = supportedInstallations[type].find(({ short }) => short === name);
|
|
93
86
|
const pkgsToInstall = selectedPackage ? [selectedPackage.package] : [];
|
|
94
|
-
|
|
87
|
+
addServiceDeps(selectedPackage ? [selectedPackage] : [], pkgsToInstall, true);
|
|
95
88
|
console.log(`Installing "${selectedPackage.package}"${yarn ? ' using yarn.' : '.'}`);
|
|
96
|
-
const install = (
|
|
89
|
+
const install = yarnInstall({ deps: pkgsToInstall, dev: true, respectNpm5: !yarn }); // use !yarn so the package forces npm install
|
|
97
90
|
if (install.status !== 0) {
|
|
98
91
|
console.error('Error installing packages', install.stderr);
|
|
99
92
|
process.exit(1);
|
|
100
93
|
return;
|
|
101
94
|
}
|
|
102
95
|
console.log(`Package "${selectedPackage.package}" installed successfully.`);
|
|
103
|
-
const newConfig =
|
|
96
|
+
const newConfig = replaceConfig(configFile, type, name);
|
|
104
97
|
if (!newConfig) {
|
|
105
|
-
throw new Error(`Couldn't find "${type}" property in ${
|
|
98
|
+
throw new Error(`Couldn't find "${type}" property in ${path.basename(localConfPath)}`);
|
|
106
99
|
}
|
|
107
|
-
|
|
100
|
+
fs.writeFileSync(localConfPath, newConfig, { encoding: 'utf-8' });
|
|
108
101
|
console.log('Your wdio.conf.js file has been updated.');
|
|
109
102
|
process.exit(0);
|
|
110
103
|
}
|
|
111
|
-
exports.handler = handler;
|
|
112
104
|
/* eslint-enable no-console */
|
package/build/commands/repl.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Argv, Options } from 'yargs';
|
|
2
|
+
import type { ReplCommandArguments } from '../types';
|
|
3
3
|
export declare const command = "repl <option> [capabilities]";
|
|
4
4
|
export declare const desc = "Run WebDriver session in command line";
|
|
5
5
|
export declare const cmdArgs: {
|
|
6
|
-
[k in keyof ReplCommandArguments]?:
|
|
6
|
+
[k in keyof ReplCommandArguments]?: Options;
|
|
7
7
|
};
|
|
8
|
-
export declare const builder: (yargs:
|
|
8
|
+
export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, string | number> & import("yargs").InferredOptionTypes<import("lodash").Dictionary<Options | {
|
|
9
9
|
readonly desc: "Run WebdriverIO in watch mode";
|
|
10
10
|
readonly type: "boolean";
|
|
11
11
|
} | {
|
|
@@ -67,5 +67,5 @@ export declare const builder: (yargs: yargs.Argv<{}>) => yargs.Argv<yargs.Omit<{
|
|
|
67
67
|
} | {
|
|
68
68
|
readonly desc: "Auto compilation options";
|
|
69
69
|
}>>>;
|
|
70
|
-
export declare const handler: (argv: ReplCommandArguments) => Promise<
|
|
70
|
+
export declare const handler: (argv: ReplCommandArguments) => Promise<void>;
|
|
71
71
|
//# sourceMappingURL=repl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/commands/repl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/commands/repl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAK1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAOpD,eAAO,MAAM,OAAO,iCAAiC,CAAA;AACrD,eAAO,MAAM,IAAI,0CAA0C,CAAA;AAC3D,eAAO,MAAM,OAAO,EAAE;KAAG,CAAC,IAAI,MAAM,oBAAoB,CAAC,CAAC,EAAE,OAAO;CAgBzD,CAAA;AAEV,eAAO,MAAM,OAAO,UAAW,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAYlC,CAAA;AAED,eAAO,MAAM,OAAO,SAAgB,oBAAoB,kBAWvD,CAAA"}
|
package/build/commands/repl.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
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 run_1 = require("./run");
|
|
11
|
-
const utils_2 = require("../utils");
|
|
12
|
-
const constants_1 = require("../constants");
|
|
1
|
+
import pickBy from 'lodash.pickby';
|
|
2
|
+
import { remote } from 'webdriverio';
|
|
3
|
+
import { cmdArgs as runCmdArgs } from './run.js';
|
|
4
|
+
import { getCapabilities } from '../utils.js';
|
|
5
|
+
import { CLI_EPILOGUE } from '../constants.js';
|
|
13
6
|
const IGNORED_ARGS = [
|
|
14
7
|
'bail', 'framework', 'reporters', 'suite', 'spec', 'exclude',
|
|
15
8
|
'mochaOpts', 'jasmineOpts', 'cucumberOpts', 'autoCompileOpts'
|
|
16
9
|
];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
export const command = 'repl <option> [capabilities]';
|
|
11
|
+
export const desc = 'Run WebDriver session in command line';
|
|
12
|
+
export const cmdArgs = {
|
|
20
13
|
platformVersion: {
|
|
21
14
|
alias: 'v',
|
|
22
15
|
desc: 'Version of OS for mobile devices',
|
|
@@ -33,9 +26,9 @@ exports.cmdArgs = {
|
|
|
33
26
|
type: 'string',
|
|
34
27
|
}
|
|
35
28
|
};
|
|
36
|
-
const builder = (yargs) => {
|
|
29
|
+
export const builder = (yargs) => {
|
|
37
30
|
return yargs
|
|
38
|
-
.options((
|
|
31
|
+
.options(pickBy({ ...cmdArgs, ...runCmdArgs }, (_, key) => !IGNORED_ARGS.includes(key)))
|
|
39
32
|
.example('$0 repl firefox --path /', 'Run repl locally')
|
|
40
33
|
.example('$0 repl chrome -u <SAUCE_USERNAME> -k <SAUCE_ACCESS_KEY>', 'Run repl in Sauce Labs cloud')
|
|
41
34
|
.example('$0 repl android', 'Run repl browser on launched Android device')
|
|
@@ -43,23 +36,16 @@ const builder = (yargs) => {
|
|
|
43
36
|
.example('$0 repl ios -v 11.3 -d "iPhone 7" -u 123432abc', 'Run repl browser on iOS device with capabilities')
|
|
44
37
|
.example('$0 repl "./path/to/wdio.config.js" 0 -p 9515', 'Run repl using the first capability from the capabilty array in wdio.config.js')
|
|
45
38
|
.example('$0 repl "./path/to/wdio.config.js" "myChromeBrowser" -p 9515', 'Run repl using a named multiremote capabilities in wdio.config.js')
|
|
46
|
-
.epilogue(
|
|
39
|
+
.epilogue(CLI_EPILOGUE)
|
|
47
40
|
.help();
|
|
48
41
|
};
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
/**
|
|
53
|
-
* runner option required to wrap commands within Fibers context
|
|
54
|
-
*/
|
|
55
|
-
const execMode = utils_1.hasWdioSyncSupport ? { runner: 'local' } : {};
|
|
56
|
-
const client = await (0, webdriverio_1.remote)({ ...argv, ...caps, ...execMode });
|
|
57
|
-
// @ts-ignore
|
|
42
|
+
export const handler = async (argv) => {
|
|
43
|
+
const caps = await getCapabilities(argv);
|
|
44
|
+
const client = await remote({ ...argv, ...caps });
|
|
58
45
|
global.$ = client.$.bind(client);
|
|
59
|
-
// @ts-ignore
|
|
60
46
|
global.$$ = client.$$.bind(client);
|
|
47
|
+
// @ts-expect-error global browser is for some reason not detected
|
|
61
48
|
global.browser = client;
|
|
62
49
|
await client.debug();
|
|
63
50
|
return client.deleteSession();
|
|
64
51
|
};
|
|
65
|
-
exports.handler = handler;
|
package/build/commands/run.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Argv } from 'yargs';
|
|
2
|
+
import type { RunCommandArguments } from '../types';
|
|
3
3
|
export declare const command = "run <configPath>";
|
|
4
4
|
export declare const desc = "Run your WDIO configuration file to initialize your tests. (default)";
|
|
5
5
|
export declare const cmdArgs: {
|
|
@@ -84,7 +84,7 @@ export declare const cmdArgs: {
|
|
|
84
84
|
readonly desc: "Auto compilation options";
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
|
-
export declare const builder: (yargs:
|
|
87
|
+
export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, "framework" | "reporters" | "hostname" | "port" | "path" | "baseUrl" | "exclude" | "user" | "key" | "logLevel" | "spec" | "waitforTimeout" | "watch" | "bail" | "suite" | "mochaOpts" | "jasmineOpts" | "cucumberOpts" | "autoCompileOpts"> & import("yargs").InferredOptionTypes<{
|
|
88
88
|
readonly watch: {
|
|
89
89
|
readonly desc: "Run WebdriverIO in watch mode";
|
|
90
90
|
readonly type: "boolean";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAMjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,eAAO,MAAM,OAAO,qBAAqB,CAAA;AAEzC,eAAO,MAAM,IAAI,yEAAyE,CAAA;AAE1F,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiFV,CAAA;AAEV,eAAO,MAAM,OAAO,UAAW,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUlC,CAAA;AAED,wBAAgB,eAAe,CAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAc1F;AAED,wBAAgB,MAAM,CAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,iBAgBjF;AAED,wBAAsB,OAAO,CAAE,IAAI,EAAE,mBAAmB,iBAmCvD"}
|