create-wdio 8.0.0 ā 8.1.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.
- package/README.md +4 -4
- package/build/constants.js +3 -7
- package/build/index.js +18 -42
- package/build/utils.js +2 -3
- package/package.json +4 -4
- package/vitest.config.ts +4 -4
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ To install a WebdriverIO project, you may choose one of the following methods:
|
|
|
23
23
|
#### npx
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
|
-
npx create-wdio ./e2e
|
|
26
|
+
npx create-wdio@latest ./e2e
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
_[`npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) is a package runner tool that comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f)_
|
|
@@ -31,7 +31,7 @@ _[`npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f
|
|
|
31
31
|
#### npm
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
|
-
npm init wdio ./e2e
|
|
34
|
+
npm init wdio@latest ./e2e
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
_[`npm init <initializer>`](https://docs.npmjs.com/cli/v7/commands/npm-init) is available in npm 6+_
|
|
@@ -39,14 +39,14 @@ _[`npm init <initializer>`](https://docs.npmjs.com/cli/v7/commands/npm-init) is
|
|
|
39
39
|
#### yarn
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
yarn create wdio ./e2e
|
|
42
|
+
yarn create wdio@latest ./e2e
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
_[`yarn create <starter-kit-package>`](https://yarnpkg.com/lang/en/docs/cli/create/) is available in Yarn 0.25+_
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
It will create a directory called `e2e` inside the current folder.
|
|
49
|
-
Then it will run the configuration wizard that will help you
|
|
49
|
+
Then it will run the configuration wizard that will help you set-up your framework.
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
## Supported Options
|
package/build/constants.js
CHANGED
|
@@ -46,10 +46,6 @@ export const PROGRAM_TITLE = `
|
|
|
46
46
|
${colorIt('Next-gen browser and mobile automation')}
|
|
47
47
|
${colorIt('test framework for Node.js')}
|
|
48
48
|
`;
|
|
49
|
-
export const UNSUPPORTED_NODE_VERSION = (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
' š https://gitter.im/webdriverio/webdriverio\n' +
|
|
53
|
-
'\n' +
|
|
54
|
-
'Visit the project on GitHub to report bugs š or raise feature requests š”:\n' +
|
|
55
|
-
' š https://github.com/webdriverio/webdriverio\n');
|
|
49
|
+
export const UNSUPPORTED_NODE_VERSION = ('ā ļø Unsupported Node.js Version Error ā ļø\n' +
|
|
50
|
+
`You are using Node.js ${process.version} which is to old to be used with WebdriverIO.\n` +
|
|
51
|
+
'Please update to Node.js v16 to continue.\n');
|
package/build/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import path from 'node:path';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import semver from 'semver';
|
|
5
5
|
import { Command } from 'commander';
|
|
6
|
-
import {
|
|
7
|
-
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG
|
|
6
|
+
import { runProgram, shouldUseYarn, getPackageVersion } from './utils.js';
|
|
7
|
+
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG } from './constants.js';
|
|
8
8
|
const WDIO_COMMAND = 'wdio';
|
|
9
9
|
let projectDir;
|
|
10
10
|
export async function run(operation = createWebdriverIO) {
|
|
@@ -15,6 +15,14 @@ export async function run(operation = createWebdriverIO) {
|
|
|
15
15
|
if (!(process.argv.includes('--version') || process.argv.includes('-v'))) {
|
|
16
16
|
console.log(ASCII_ROBOT, PROGRAM_TITLE);
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* ensure right Node.js version is used
|
|
20
|
+
*/
|
|
21
|
+
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=16');
|
|
22
|
+
if (unsupportedNodeVersion) {
|
|
23
|
+
console.log(chalk.yellow(UNSUPPORTED_NODE_VERSION));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
18
26
|
const program = new Command(WDIO_COMMAND)
|
|
19
27
|
.version(version, '-v, --version')
|
|
20
28
|
.arguments('[project-path]')
|
|
@@ -30,35 +38,17 @@ export async function run(operation = createWebdriverIO) {
|
|
|
30
38
|
.parse(process.argv);
|
|
31
39
|
return operation(program.opts());
|
|
32
40
|
}
|
|
33
|
-
async function createWebdriverIO(opts) {
|
|
34
|
-
const
|
|
35
|
-
|
|
41
|
+
export async function createWebdriverIO(opts) {
|
|
42
|
+
const useYarn = typeof opts.useYarn === 'boolean'
|
|
43
|
+
? opts.useYarn
|
|
44
|
+
: await shouldUseYarn();
|
|
36
45
|
const npmTag = opts.npmTag.startsWith('@') ? opts.npmTag : `@${opts.npmTag}`;
|
|
37
|
-
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=12');
|
|
38
|
-
if (unsupportedNodeVersion) {
|
|
39
|
-
console.log(chalk.yellow(UNSUPPORTED_NODE_VERSION));
|
|
40
|
-
}
|
|
41
46
|
const root = path.resolve(process.cwd(), projectDir || '');
|
|
42
|
-
|
|
47
|
+
const rootDirExists = await fs.access(root).then(() => true, () => false);
|
|
48
|
+
if (!rootDirExists) {
|
|
43
49
|
await fs.mkdir(root, { recursive: true });
|
|
44
50
|
}
|
|
45
|
-
|
|
46
|
-
console.log(`\nCreating WebdriverIO project in ${chalk.bold(root)}\n`);
|
|
47
|
-
if (!await exists(pkgJsonPath)) {
|
|
48
|
-
console.log(`Creating a ${chalk.bold('package.json')} for the directory.`);
|
|
49
|
-
const pkgJson = {
|
|
50
|
-
name: 'webdriverio-tests',
|
|
51
|
-
version: '0.1.0',
|
|
52
|
-
description: '',
|
|
53
|
-
private: true,
|
|
54
|
-
keywords: [],
|
|
55
|
-
author: '',
|
|
56
|
-
license: 'ISC'
|
|
57
|
-
};
|
|
58
|
-
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 4));
|
|
59
|
-
console.log(chalk.green.bold('ā Success!'));
|
|
60
|
-
}
|
|
61
|
-
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project.`);
|
|
51
|
+
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project...`);
|
|
62
52
|
const logLevel = opts.verbose ? 'trace' : 'error';
|
|
63
53
|
const command = useYarn ? 'yarnpkg' : 'npm';
|
|
64
54
|
const args = useYarn
|
|
@@ -66,24 +56,10 @@ async function createWebdriverIO(opts) {
|
|
|
66
56
|
: ['install', opts.dev ? '--save-dev' : '--save', '--loglevel', logLevel, `@wdio/cli${npmTag}`];
|
|
67
57
|
await runProgram(command, args, { cwd: root, stdio: 'ignore' });
|
|
68
58
|
console.log(chalk.green.bold('ā Success!'));
|
|
69
|
-
|
|
70
|
-
await runProgram('npx', [
|
|
59
|
+
return runProgram('npx', [
|
|
71
60
|
WDIO_COMMAND,
|
|
72
61
|
'config',
|
|
73
62
|
...(useYarn ? ['--yarn'] : []),
|
|
74
63
|
...(opts.yes ? ['--yes'] : [])
|
|
75
64
|
], { cwd: root });
|
|
76
|
-
if (await exists(pkgJsonPath)) {
|
|
77
|
-
console.log(`Adding ${chalk.bold(`"${WDIO_COMMAND}"`)} script to package.json.`);
|
|
78
|
-
const isUsingTypescript = await exists('test/wdio.conf.ts');
|
|
79
|
-
const script = `wdio run ${isUsingTypescript ? 'test/wdio.conf.ts' : 'wdio.conf.js'}`;
|
|
80
|
-
await runProgram('npm', ['set-script', WDIO_COMMAND, script], { cwd: root });
|
|
81
|
-
console.log(chalk.green.bold('ā Success!'));
|
|
82
|
-
}
|
|
83
|
-
console.log(`\nš¤ Successfully setup project at ${root} š\n`);
|
|
84
|
-
console.log(COMMUNITY_DISCLAIMER);
|
|
85
|
-
if (root != cwd) {
|
|
86
|
-
console.log(`${chalk.bold.yellow('ā ')} First, change the directory via: ${chalk.cyan('$ cd')} ${chalk.green(root)}`);
|
|
87
|
-
}
|
|
88
|
-
console.log(`To start the test, run: ${chalk.cyan('$ npm run')} ${chalk.green(WDIO_COMMAND)}`);
|
|
89
65
|
}
|
package/build/utils.js
CHANGED
|
@@ -6,9 +6,6 @@ import chalk from 'chalk';
|
|
|
6
6
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
7
7
|
export const colorItBold = chalk.bold.rgb(234, 89, 6);
|
|
8
8
|
export const colorIt = chalk.rgb(234, 89, 6);
|
|
9
|
-
export function exists(path) {
|
|
10
|
-
return fs.access(path).then(() => true, () => false);
|
|
11
|
-
}
|
|
12
9
|
export function runProgram(command, args, options) {
|
|
13
10
|
const child = spawn(command, args, { stdio: 'inherit', ...options });
|
|
14
11
|
return new Promise((resolve, reject) => {
|
|
@@ -23,9 +20,11 @@ export function runProgram(command, args, options) {
|
|
|
23
20
|
});
|
|
24
21
|
});
|
|
25
22
|
}
|
|
23
|
+
/* c8 ignore start */
|
|
26
24
|
export function shouldUseYarn() {
|
|
27
25
|
return runProgram('yarnpkg', ['--version'], { stdio: 'ignore' }).then(() => true, () => false);
|
|
28
26
|
}
|
|
27
|
+
/* c8 ignore end */
|
|
29
28
|
export async function getPackageVersion() {
|
|
30
29
|
try {
|
|
31
30
|
const pkgJsonPath = path.join(__dirname, '..', 'package.json');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-wdio",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Install and setup a WebdriverIO project with all its dependencies in a single run",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"@types/semver": "^7.3.12",
|
|
44
44
|
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
45
45
|
"@typescript-eslint/parser": "^5.38.1",
|
|
46
|
-
"@vitest/coverage-c8": "^0.
|
|
46
|
+
"@vitest/coverage-c8": "^0.25.0",
|
|
47
47
|
"c8": "^7.12.0",
|
|
48
48
|
"eslint": "^8.24.0",
|
|
49
49
|
"eslint-plugin-import": "^2.26.0",
|
|
50
|
-
"eslint-plugin-unicorn": "^
|
|
50
|
+
"eslint-plugin-unicorn": "^45.0.0",
|
|
51
51
|
"npm-run-all": "^4.1.5",
|
|
52
52
|
"release-it": "^15.4.2",
|
|
53
53
|
"typescript": "^4.8.4",
|
|
54
|
-
"vitest": "^0.
|
|
54
|
+
"vitest": "^0.25.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"chalk": "^5.0.1",
|
package/vitest.config.ts
CHANGED
|
@@ -14,10 +14,10 @@ export default defineConfig({
|
|
|
14
14
|
coverage: {
|
|
15
15
|
enabled: true,
|
|
16
16
|
exclude: ['**/build/**', '__mocks__', '**/*.test.ts'],
|
|
17
|
-
lines:
|
|
18
|
-
functions:
|
|
19
|
-
branches:
|
|
20
|
-
statements:
|
|
17
|
+
lines: 100,
|
|
18
|
+
functions: 82,
|
|
19
|
+
branches: 84,
|
|
20
|
+
statements: 100
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
})
|