create-wdio 8.0.0 ā 8.2.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/.eslintrc.cjs +9 -1
- package/README.md +4 -4
- package/build/constants.js +3 -7
- package/build/index.js +29 -41
- package/build/utils.js +15 -10
- package/package.json +16 -14
- package/vitest.config.ts +4 -4
package/.eslintrc.cjs
CHANGED
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
|
@@ -2,9 +2,11 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import semver from 'semver';
|
|
5
|
+
import hasYarn from 'has-yarn';
|
|
6
|
+
import { readPackageUp } from 'read-pkg-up';
|
|
5
7
|
import { Command } from 'commander';
|
|
6
|
-
import {
|
|
7
|
-
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG
|
|
8
|
+
import { runProgram, getPackageVersion } from './utils.js';
|
|
9
|
+
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG } from './constants.js';
|
|
8
10
|
const WDIO_COMMAND = 'wdio';
|
|
9
11
|
let projectDir;
|
|
10
12
|
export async function run(operation = createWebdriverIO) {
|
|
@@ -15,6 +17,14 @@ export async function run(operation = createWebdriverIO) {
|
|
|
15
17
|
if (!(process.argv.includes('--version') || process.argv.includes('-v'))) {
|
|
16
18
|
console.log(ASCII_ROBOT, PROGRAM_TITLE);
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* ensure right Node.js version is used
|
|
22
|
+
*/
|
|
23
|
+
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=16');
|
|
24
|
+
if (unsupportedNodeVersion) {
|
|
25
|
+
console.log(chalk.yellow(UNSUPPORTED_NODE_VERSION));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
18
28
|
const program = new Command(WDIO_COMMAND)
|
|
19
29
|
.version(version, '-v, --version')
|
|
20
30
|
.arguments('[project-path]')
|
|
@@ -30,35 +40,27 @@ export async function run(operation = createWebdriverIO) {
|
|
|
30
40
|
.parse(process.argv);
|
|
31
41
|
return operation(program.opts());
|
|
32
42
|
}
|
|
33
|
-
async function createWebdriverIO(opts) {
|
|
34
|
-
const cwd = process.cwd();
|
|
35
|
-
const useYarn = opts.useYarn && await shouldUseYarn();
|
|
43
|
+
export async function createWebdriverIO(opts) {
|
|
36
44
|
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
45
|
const root = path.resolve(process.cwd(), projectDir || '');
|
|
42
|
-
|
|
46
|
+
const rootDirExists = await fs.access(root).then(() => true, () => false);
|
|
47
|
+
if (!rootDirExists) {
|
|
43
48
|
await fs.mkdir(root, { recursive: true });
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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!'));
|
|
50
|
+
/**
|
|
51
|
+
* check if a package.json exists and if not create one
|
|
52
|
+
*/
|
|
53
|
+
const project = await readPackageUp({ cwd: root });
|
|
54
|
+
if (!project) {
|
|
55
|
+
await fs.writeFile(path.resolve(root, 'package.json'), JSON.stringify({
|
|
56
|
+
name: 'my-new-project',
|
|
57
|
+
type: 'module'
|
|
58
|
+
}, null, 2));
|
|
60
59
|
}
|
|
61
|
-
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project
|
|
60
|
+
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project...`);
|
|
61
|
+
const useYarn = typeof opts.useYarn === 'boolean'
|
|
62
|
+
? opts.useYarn
|
|
63
|
+
: await hasYarn(root);
|
|
62
64
|
const logLevel = opts.verbose ? 'trace' : 'error';
|
|
63
65
|
const command = useYarn ? 'yarnpkg' : 'npm';
|
|
64
66
|
const args = useYarn
|
|
@@ -66,24 +68,10 @@ async function createWebdriverIO(opts) {
|
|
|
66
68
|
: ['install', opts.dev ? '--save-dev' : '--save', '--loglevel', logLevel, `@wdio/cli${npmTag}`];
|
|
67
69
|
await runProgram(command, args, { cwd: root, stdio: 'ignore' });
|
|
68
70
|
console.log(chalk.green.bold('ā Success!'));
|
|
69
|
-
|
|
70
|
-
await runProgram('npx', [
|
|
71
|
+
return runProgram('npx', [
|
|
71
72
|
WDIO_COMMAND,
|
|
72
73
|
'config',
|
|
73
74
|
...(useYarn ? ['--yarn'] : []),
|
|
74
75
|
...(opts.yes ? ['--yes'] : [])
|
|
75
76
|
], { 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
77
|
}
|
package/build/utils.js
CHANGED
|
@@ -6,26 +6,22 @@ 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
|
-
|
|
10
|
-
return fs.access(path).then(() => true, () => false);
|
|
11
|
-
}
|
|
9
|
+
process.on('SIGINT', () => printAndExit(undefined, 'SIGINT'));
|
|
12
10
|
export function runProgram(command, args, options) {
|
|
13
11
|
const child = spawn(command, args, { stdio: 'inherit', ...options });
|
|
14
|
-
return new Promise((resolve,
|
|
12
|
+
return new Promise((resolve, rejects) => {
|
|
15
13
|
let error;
|
|
16
14
|
child.on('error', (e) => (error = e));
|
|
17
|
-
child.on('close', code => {
|
|
15
|
+
child.on('close', (code, signal) => {
|
|
18
16
|
if (code !== 0) {
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const errorMessage = (error && error.message) || `Error calling: ${command} ${args.join(' ')}`;
|
|
18
|
+
printAndExit(errorMessage, signal);
|
|
19
|
+
return rejects(errorMessage);
|
|
21
20
|
}
|
|
22
21
|
resolve();
|
|
23
22
|
});
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
|
-
export function shouldUseYarn() {
|
|
27
|
-
return runProgram('yarnpkg', ['--version'], { stdio: 'ignore' }).then(() => true, () => false);
|
|
28
|
-
}
|
|
29
25
|
export async function getPackageVersion() {
|
|
30
26
|
try {
|
|
31
27
|
const pkgJsonPath = path.join(__dirname, '..', 'package.json');
|
|
@@ -37,3 +33,12 @@ export async function getPackageVersion() {
|
|
|
37
33
|
}
|
|
38
34
|
return 'unknown';
|
|
39
35
|
}
|
|
36
|
+
function printAndExit(error, signal) {
|
|
37
|
+
if (signal === 'SIGINT') {
|
|
38
|
+
console.log('\n\nGoodbye š');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.log(`\n\nā ļø Ups, something went wrong${error ? `: ${error}` : ''}!`);
|
|
42
|
+
}
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-wdio",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.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",
|
|
@@ -39,24 +39,26 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/cross-spawn": "^6.0.2",
|
|
42
|
-
"@types/node": "^18.
|
|
43
|
-
"@types/semver": "^7.3.
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
45
|
-
"@typescript-eslint/parser": "^5.
|
|
46
|
-
"@vitest/coverage-c8": "^0.
|
|
42
|
+
"@types/node": "^18.11.13",
|
|
43
|
+
"@types/semver": "^7.3.13",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^5.46.0",
|
|
45
|
+
"@typescript-eslint/parser": "^5.46.0",
|
|
46
|
+
"@vitest/coverage-c8": "^0.25.7",
|
|
47
47
|
"c8": "^7.12.0",
|
|
48
|
-
"eslint": "^8.
|
|
48
|
+
"eslint": "^8.29.0",
|
|
49
49
|
"eslint-plugin-import": "^2.26.0",
|
|
50
|
-
"eslint-plugin-unicorn": "^
|
|
50
|
+
"eslint-plugin-unicorn": "^45.0.1",
|
|
51
51
|
"npm-run-all": "^4.1.5",
|
|
52
|
-
"release-it": "^15.
|
|
53
|
-
"typescript": "^4.
|
|
54
|
-
"vitest": "^0.
|
|
52
|
+
"release-it": "^15.5.1",
|
|
53
|
+
"typescript": "^4.9.4",
|
|
54
|
+
"vitest": "^0.25.7"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"chalk": "^5.0
|
|
58
|
-
"commander": "^9.4.
|
|
57
|
+
"chalk": "^5.2.0",
|
|
58
|
+
"commander": "^9.4.1",
|
|
59
59
|
"cross-spawn": "^7.0.3",
|
|
60
|
-
"
|
|
60
|
+
"has-yarn": "^3.0.0",
|
|
61
|
+
"read-pkg-up": "^9.1.0",
|
|
62
|
+
"semver": "^7.3.8"
|
|
61
63
|
}
|
|
62
64
|
}
|
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: 98,
|
|
18
|
+
functions: 80,
|
|
19
|
+
branches: 77,
|
|
20
|
+
statements: 98
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
})
|