create-wdio 7.2.0 → 8.0.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 +37 -0
- package/LICENSE +17 -18
- package/README.md +3 -2
- package/__mocks__/commander.ts +18 -0
- package/bin/wdio.js +3 -1
- package/build/constants.js +10 -13
- package/build/index.js +60 -98
- package/build/types.js +1 -2
- package/build/utils.js +20 -61
- package/package.json +21 -21
- package/vitest.config.ts +23 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
plugins: ['@typescript-eslint', 'unicorn'],
|
|
5
|
+
extends: [
|
|
6
|
+
'eslint:recommended',
|
|
7
|
+
'plugin:import/errors',
|
|
8
|
+
'plugin:import/warnings'
|
|
9
|
+
],
|
|
10
|
+
env: {
|
|
11
|
+
node: true,
|
|
12
|
+
es6: true,
|
|
13
|
+
jest: true
|
|
14
|
+
},
|
|
15
|
+
parserOptions: {
|
|
16
|
+
ecmaVersion: 2019,
|
|
17
|
+
sourceType: 'module'
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
semi: ['error', 'never'],
|
|
21
|
+
quotes: ['error', 'single'],
|
|
22
|
+
indent: [2, 4],
|
|
23
|
+
|
|
24
|
+
'no-constant-condition': 0,
|
|
25
|
+
// see https://stackoverflow.com/questions/55280555/typescript-eslint-eslint-plugin-error-route-is-defined-but-never-used-no-un
|
|
26
|
+
'no-unused-vars': 'off',
|
|
27
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
|
28
|
+
|
|
29
|
+
'import/no-unresolved': 0,
|
|
30
|
+
'import/named': 2,
|
|
31
|
+
'import/namespace': 2,
|
|
32
|
+
'import/default': 2,
|
|
33
|
+
'import/export': 2,
|
|
34
|
+
|
|
35
|
+
'unicorn/prefer-node-protocol': ['error']
|
|
36
|
+
}
|
|
37
|
+
}
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright (c) OpenJS Foundation and other contributors
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
4
10
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -45,10 +45,10 @@ yarn create wdio ./e2e
|
|
|
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
|
-
It will create a directory called `e2e` inside the current folder.
|
|
48
|
+
It will create a directory called `e2e` inside the current folder.
|
|
49
49
|
Then it will run the configuration wizard that will help you setup your framework.
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
## Supported Options
|
|
53
53
|
|
|
54
54
|
You can pass the following command line flags to modify the bootstrap mechanism:
|
|
@@ -56,6 +56,7 @@ You can pass the following command line flags to modify the bootstrap mechanism:
|
|
|
56
56
|
* `--dev` - Install all packages as `devDependencies` (default: `true`)
|
|
57
57
|
* `--yes` - Will fill in all config defaults without prompting (default: `false`)
|
|
58
58
|
* `--use-yarn` - yes, we support yarn too! (default: `true`)
|
|
59
|
+
* `--npm-tag` - use a specific NPM tag for `@wdio/cli` package (default: `latest`)
|
|
59
60
|
* `--verbose` - print additional logs (default: `false`)
|
|
60
61
|
|
|
61
62
|
----
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
const command: any = {}
|
|
4
|
+
command.name = vi.fn().mockReturnValue(command)
|
|
5
|
+
command.version = vi.fn().mockReturnValue(command)
|
|
6
|
+
command.usage = vi.fn().mockReturnValue(command)
|
|
7
|
+
command.arguments = vi.fn().mockReturnValue(command)
|
|
8
|
+
command.action = vi.fn((cb) => {
|
|
9
|
+
cb('someProjectName')
|
|
10
|
+
return command
|
|
11
|
+
})
|
|
12
|
+
command.option = vi.fn().mockReturnValue(command)
|
|
13
|
+
command.allowUnknownOption = vi.fn().mockReturnValue(command)
|
|
14
|
+
command.on = vi.fn().mockReturnValue(command)
|
|
15
|
+
command.parse = vi.fn().mockReturnValue(command)
|
|
16
|
+
command.opts = vi.fn().mockReturnValue('foobar')
|
|
17
|
+
|
|
18
|
+
export const Command = vi.fn().mockReturnValue(command)
|
package/bin/wdio.js
CHANGED
package/build/constants.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UNSUPPORTED_NODE_VERSION = exports.PROGRAM_TITLE = exports.ASCII_ROBOT = exports.DEFAULT_NPM_TAG = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
exports.DEFAULT_NPM_TAG = 'latest';
|
|
9
|
-
const colorItBold = chalk_1.default.bold.rgb(234, 89, 6);
|
|
10
|
-
const colorIt = chalk_1.default.rgb(234, 89, 6);
|
|
11
|
-
exports.ASCII_ROBOT = `
|
|
1
|
+
import { colorItBold, colorIt } from './utils.js';
|
|
2
|
+
export const DEFAULT_NPM_TAG = 'latest';
|
|
3
|
+
export const ASCII_ROBOT = `
|
|
12
4
|
-:...........................-:.
|
|
13
5
|
+ +
|
|
14
6
|
\`\` + \`...\` \`...\` + \`
|
|
@@ -49,10 +41,15 @@ oooooooo+\`-oooo\`-- \`/\` .:+ -/-\`/\` .:::::::::: .oooo-.+oooooooo
|
|
|
49
41
|
-/::::::::://:/+ \`+/:+::::::::::+.
|
|
50
42
|
:oooooooooooo++/ +++oooooooooooo-
|
|
51
43
|
`;
|
|
52
|
-
|
|
44
|
+
export const PROGRAM_TITLE = `
|
|
53
45
|
${colorItBold('Webdriver.IO')}
|
|
54
46
|
${colorIt('Next-gen browser and mobile automation')}
|
|
55
47
|
${colorIt('test framework for Node.js')}
|
|
56
48
|
`;
|
|
57
|
-
|
|
49
|
+
export const UNSUPPORTED_NODE_VERSION = (`You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
|
|
58
50
|
'Please update to Node 12 or higher for a better, fully supported experience.\n');
|
|
51
|
+
export const COMMUNITY_DISCLAIMER = ('Join our Gitter community and instantly find answers to your issues or queries. Or just join and say hi 👋!\n' +
|
|
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');
|
package/build/index.js
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
const constants_1 = require("./constants");
|
|
14
|
-
let pkg = { version: 'unknown' };
|
|
15
|
-
try {
|
|
16
|
-
pkg = JSON.parse(fs_1.default.readFileSync(__dirname + '/../package.json').toString());
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
/* ignore */
|
|
20
|
-
}
|
|
21
|
-
let projectName;
|
|
22
|
-
let useYarn;
|
|
23
|
-
function run(operation = createWebdriverIO) {
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { exists, runProgram, shouldUseYarn, getPackageVersion } from './utils.js';
|
|
7
|
+
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG, COMMUNITY_DISCLAIMER } from './constants.js';
|
|
8
|
+
const WDIO_COMMAND = 'wdio';
|
|
9
|
+
let projectDir;
|
|
10
|
+
export async function run(operation = createWebdriverIO) {
|
|
11
|
+
const version = await getPackageVersion();
|
|
24
12
|
/**
|
|
25
13
|
* print program ASCII art
|
|
26
14
|
*/
|
|
27
15
|
if (!(process.argv.includes('--version') || process.argv.includes('-v'))) {
|
|
28
|
-
console.log(
|
|
16
|
+
console.log(ASCII_ROBOT, PROGRAM_TITLE);
|
|
29
17
|
}
|
|
30
|
-
const program = new
|
|
31
|
-
.version(
|
|
32
|
-
.arguments('[project]')
|
|
33
|
-
.usage(`${
|
|
34
|
-
.action(name => (
|
|
35
|
-
.option('-t, --npm-tag <tag>', 'Which NPM version you like to install, e.g. @next',
|
|
18
|
+
const program = new Command(WDIO_COMMAND)
|
|
19
|
+
.version(version, '-v, --version')
|
|
20
|
+
.arguments('[project-path]')
|
|
21
|
+
.usage(`${chalk.green('[project-path]')} [options]`)
|
|
22
|
+
.action(name => (projectDir = name))
|
|
23
|
+
.option('-t, --npm-tag <tag>', 'Which NPM version you like to install, e.g. @next', DEFAULT_NPM_TAG)
|
|
36
24
|
.option('-u, --use-yarn', 'Use Yarn package manager to install packages', false)
|
|
37
25
|
.option('-v, --verbose', 'print additional logs')
|
|
38
26
|
.option('-y, --yes', 'will fill in all config defaults without prompting', false)
|
|
@@ -40,88 +28,62 @@ function run(operation = createWebdriverIO) {
|
|
|
40
28
|
.allowUnknownOption()
|
|
41
29
|
.on('--help', () => console.log())
|
|
42
30
|
.parse(process.argv);
|
|
43
|
-
|
|
44
|
-
console.error('There is no package.json in current directory!\n');
|
|
45
|
-
console.log('To create WebdriverIO in a new project pass in a directory name:\n' +
|
|
46
|
-
` npm init ${chalk_1.default.cyan(program.name())} ${chalk_1.default.green('/path/to/project/directory')}\n` +
|
|
47
|
-
'\n' +
|
|
48
|
-
'For example:\n' +
|
|
49
|
-
` npm init ${chalk_1.default.cyan(program.name())} ${chalk_1.default.green('./tests')}\n` +
|
|
50
|
-
'\n' +
|
|
51
|
-
'To update current project to include WebdriverIO packages, run this script in a directory with package.json\n' +
|
|
52
|
-
`Run ${chalk_1.default.cyan(`${program.name()} --help`)} to see all options.`);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
return operation(program.opts()).then(() => console.log(`To start the test, run: ${chalk_1.default.cyan('$ npm run')} ${chalk_1.default.green(program.name())}`));
|
|
31
|
+
return operation(program.opts());
|
|
56
32
|
}
|
|
57
|
-
exports.run = run;
|
|
58
33
|
async function createWebdriverIO(opts) {
|
|
59
34
|
const cwd = process.cwd();
|
|
35
|
+
const useYarn = opts.useYarn && await shouldUseYarn();
|
|
60
36
|
const npmTag = opts.npmTag.startsWith('@') ? opts.npmTag : `@${opts.npmTag}`;
|
|
61
|
-
const unsupportedNodeVersion = !
|
|
37
|
+
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=12');
|
|
62
38
|
if (unsupportedNodeVersion) {
|
|
63
|
-
console.log(
|
|
39
|
+
console.log(chalk.yellow(UNSUPPORTED_NODE_VERSION));
|
|
64
40
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
await fs_1.default.promises.mkdir(root, { recursive: true });
|
|
41
|
+
const root = path.resolve(process.cwd(), projectDir || '');
|
|
42
|
+
if (!await exists(root)) {
|
|
43
|
+
await fs.mkdir(root, { recursive: true });
|
|
69
44
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!useYarn && !(0, utils_1.checkThatNpmCanReadCwd)()) {
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
console.log(`\nCreating WebdriverIO project in ${chalk_1.default.bold(root)}\n`);
|
|
78
|
-
if (!await (0, utils_1.exists)(pkgJsonPath)) {
|
|
79
|
-
console.log('package.json file does not exist in current dir, creating it...');
|
|
45
|
+
const pkgJsonPath = path.join(root, 'package.json');
|
|
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.`);
|
|
80
49
|
const pkgJson = {
|
|
81
50
|
name: 'webdriverio-tests',
|
|
82
51
|
version: '0.1.0',
|
|
83
|
-
|
|
52
|
+
description: '',
|
|
53
|
+
private: true,
|
|
54
|
+
keywords: [],
|
|
55
|
+
author: '',
|
|
56
|
+
license: 'ISC'
|
|
84
57
|
};
|
|
85
|
-
await
|
|
58
|
+
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 4));
|
|
59
|
+
console.log(chalk.green.bold('✔ Success!'));
|
|
86
60
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
61
|
+
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project.`);
|
|
62
|
+
const logLevel = opts.verbose ? 'trace' : 'error';
|
|
63
|
+
const command = useYarn ? 'yarnpkg' : 'npm';
|
|
64
|
+
const args = useYarn
|
|
65
|
+
? ['add', ...(opts.dev ? ['-D'] : []), '--exact', '--cwd', root, `@wdio/cli${npmTag}`]
|
|
66
|
+
: ['install', opts.dev ? '--save-dev' : '--save', '--loglevel', logLevel, `@wdio/cli${npmTag}`];
|
|
67
|
+
await runProgram(command, args, { cwd: root, stdio: 'ignore' });
|
|
68
|
+
console.log(chalk.green.bold('✔ Success!'));
|
|
90
69
|
console.log('\nRunning WDIO CLI Wizard...');
|
|
91
|
-
await
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
70
|
+
await runProgram('npx', [
|
|
71
|
+
WDIO_COMMAND,
|
|
72
|
+
'config',
|
|
73
|
+
...(useYarn ? ['--yarn'] : []),
|
|
74
|
+
...(opts.yes ? ['--yes'] : [])
|
|
75
|
+
], { 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!'));
|
|
101
82
|
}
|
|
102
|
-
console.log(`\n🤖 Successfully setup project at ${root}
|
|
83
|
+
console.log(`\n🤖 Successfully setup project at ${root} 🎉\n`);
|
|
84
|
+
console.log(COMMUNITY_DISCLAIMER);
|
|
103
85
|
if (root != cwd) {
|
|
104
|
-
console.log(
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function install(dependencies, root, opts) {
|
|
108
|
-
const logLevel = opts.verbose ? 'trace' : 'error';
|
|
109
|
-
let command;
|
|
110
|
-
let args;
|
|
111
|
-
console.log('Installing packages: ', chalk_1.default.green(dependencies.join(', ')), '\n');
|
|
112
|
-
if (useYarn) {
|
|
113
|
-
command = 'yarnpkg';
|
|
114
|
-
args = ['add', ...(opts.dev ? ['-D'] : []), '--exact', ...dependencies];
|
|
115
|
-
// Explicitly set cwd() to work around issues like
|
|
116
|
-
// https://github.com/facebook/create-react-app/issues/3326.
|
|
117
|
-
// Unfortunately we can only do this for Yarn because npm support for
|
|
118
|
-
// equivalent --prefix flag doesn't help with this issue.
|
|
119
|
-
// This is why for npm, we run checkThatNpmCanReadCwd() early instead.
|
|
120
|
-
args.push('--cwd', root);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
command = 'npm';
|
|
124
|
-
args = ['install', opts.dev ? '--save-dev' : '--save', '--loglevel', logLevel, ...dependencies];
|
|
86
|
+
console.log(`${chalk.bold.yellow('⚠')} First, change the directory via: ${chalk.cyan('$ cd')} ${chalk.green(root)}`);
|
|
125
87
|
}
|
|
126
|
-
|
|
88
|
+
console.log(`To start the test, run: ${chalk.cyan('$ npm run')} ${chalk.green(WDIO_COMMAND)}`);
|
|
127
89
|
}
|
package/build/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/build/utils.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return fs_1.default.promises.access(path).then(() => true, () => false);
|
|
1
|
+
import url from 'node:url';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import spawn from 'cross-spawn';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
7
|
+
export const colorItBold = chalk.bold.rgb(234, 89, 6);
|
|
8
|
+
export const colorIt = chalk.rgb(234, 89, 6);
|
|
9
|
+
export function exists(path) {
|
|
10
|
+
return fs.access(path).then(() => true, () => false);
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const child = (0, cross_spawn_1.default)(command, args, options);
|
|
12
|
+
export function runProgram(command, args, options) {
|
|
13
|
+
const child = spawn(command, args, { stdio: 'inherit', ...options });
|
|
16
14
|
return new Promise((resolve, reject) => {
|
|
17
15
|
let error;
|
|
18
16
|
child.on('error', (e) => (error = e));
|
|
@@ -25,56 +23,17 @@ function runProgram(command, args, options = { stdio: 'inherit' }) {
|
|
|
25
23
|
});
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
function shouldUseYarn() {
|
|
26
|
+
export function shouldUseYarn() {
|
|
30
27
|
return runProgram('yarnpkg', ['--version'], { stdio: 'ignore' }).then(() => true, () => false);
|
|
31
28
|
}
|
|
32
|
-
|
|
33
|
-
function checkThatNpmCanReadCwd() {
|
|
34
|
-
const cwd = process.cwd();
|
|
35
|
-
let childOutput = null;
|
|
29
|
+
export async function getPackageVersion() {
|
|
36
30
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// to reproduce the wrong path. Just printing process.cwd()
|
|
41
|
-
// in a Node process was not enough.
|
|
42
|
-
childOutput = cross_spawn_1.default.sync('npm', ['config', 'list']).output.join('');
|
|
31
|
+
const pkgJsonPath = path.join(__dirname, '..', 'package.json');
|
|
32
|
+
const pkg = JSON.parse((await fs.readFile(pkgJsonPath)).toString());
|
|
33
|
+
return `v${pkg.version}`;
|
|
43
34
|
}
|
|
44
|
-
catch (
|
|
45
|
-
|
|
46
|
-
// Not great, but it means we can't do this check.
|
|
47
|
-
// We might fail later on, but let's continue.
|
|
48
|
-
return true;
|
|
35
|
+
catch (e) {
|
|
36
|
+
/* ignore */
|
|
49
37
|
}
|
|
50
|
-
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
const lines = childOutput.split('\n');
|
|
54
|
-
// `npm config list` output includes the following line:
|
|
55
|
-
// "; cwd = C:\path\to\current\dir" (unquoted)
|
|
56
|
-
// I couldn't find an easier way to get it.
|
|
57
|
-
const prefix = '; cwd = ';
|
|
58
|
-
const line = lines.find(line => line.indexOf(prefix) === 0);
|
|
59
|
-
if (typeof line !== 'string') {
|
|
60
|
-
// Fail gracefully. They could remove it.
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
const npmCWD = line.substring(prefix.length);
|
|
64
|
-
if (npmCWD === cwd) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
console.error(chalk_1.default.red('Could not start an npm process in the right directory.\n\n' +
|
|
68
|
-
`The current directory is: ${chalk_1.default.bold(cwd)}\n` +
|
|
69
|
-
`However, a newly started npm process runs in: ${chalk_1.default.bold(npmCWD)}\n\n` +
|
|
70
|
-
'This is probably caused by a misconfigured system terminal shell.'));
|
|
71
|
-
if (process.platform === 'win32') {
|
|
72
|
-
console.error(chalk_1.default.red('On Windows, this can usually be fixed by running:\n\n') +
|
|
73
|
-
` ${chalk_1.default.cyan('reg')} delete "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n` +
|
|
74
|
-
` ${chalk_1.default.cyan('reg')} delete "HKLM\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n\n` +
|
|
75
|
-
chalk_1.default.red('Try to run the above two lines in the terminal.\n') +
|
|
76
|
-
chalk_1.default.red('To learn more about this problem, read: https://blogs.msdn.microsoft.com/oldnewthing/20071121-00/?p=24433/'));
|
|
77
|
-
}
|
|
78
|
-
return false;
|
|
38
|
+
return 'unknown';
|
|
79
39
|
}
|
|
80
|
-
exports.checkThatNpmCanReadCwd = checkThatNpmCanReadCwd;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-wdio",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Install WebdriverIO with all its dependencies in a single run",
|
|
5
|
-
"author": "Christian Bromann <
|
|
3
|
+
"version": "8.0.0",
|
|
4
|
+
"description": "Install and setup a WebdriverIO project with all its dependencies in a single run",
|
|
5
|
+
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/webdriverio/create-wdio#readme",
|
|
8
8
|
"repository": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"bin": {
|
|
23
23
|
"create-wdio": "./bin/wdio.js"
|
|
24
24
|
},
|
|
25
|
+
"type": "module",
|
|
25
26
|
"scripts": {
|
|
26
27
|
"build": "run-s clean compile",
|
|
27
28
|
"clean": "rimraf tsconfig.tsbuildinfo ./build ./coverage",
|
|
@@ -32,31 +33,30 @@
|
|
|
32
33
|
"release:minor": "npm run release -- minor",
|
|
33
34
|
"release:major": "npm run release -- major",
|
|
34
35
|
"test": "run-s build test:*",
|
|
35
|
-
"test:eslint": "eslint -c ./.eslintrc.
|
|
36
|
-
"test:unit": "
|
|
36
|
+
"test:eslint": "eslint -c ./.eslintrc.cjs ./src/**/*.ts ./tests/**/*.ts",
|
|
37
|
+
"test:unit": "vitest",
|
|
37
38
|
"watch": "npm run compile -- --watch"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@schemastore/package": "^0.0.6",
|
|
41
41
|
"@types/cross-spawn": "^6.0.2",
|
|
42
|
-
"@types/
|
|
43
|
-
"@types/
|
|
44
|
-
"@
|
|
45
|
-
"@typescript-eslint/
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
48
|
-
"eslint
|
|
49
|
-
"
|
|
42
|
+
"@types/node": "^18.7.23",
|
|
43
|
+
"@types/semver": "^7.3.12",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
45
|
+
"@typescript-eslint/parser": "^5.38.1",
|
|
46
|
+
"@vitest/coverage-c8": "^0.23.4",
|
|
47
|
+
"c8": "^7.12.0",
|
|
48
|
+
"eslint": "^8.24.0",
|
|
49
|
+
"eslint-plugin-import": "^2.26.0",
|
|
50
|
+
"eslint-plugin-unicorn": "^43.0.2",
|
|
50
51
|
"npm-run-all": "^4.1.5",
|
|
51
|
-
"release-it": "^15.
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"typescript": "^4.6.2"
|
|
52
|
+
"release-it": "^15.4.2",
|
|
53
|
+
"typescript": "^4.8.4",
|
|
54
|
+
"vitest": "^0.23.4"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"chalk": "^
|
|
58
|
-
"commander": "^9.
|
|
57
|
+
"chalk": "^5.0.1",
|
|
58
|
+
"commander": "^9.4.0",
|
|
59
59
|
"cross-spawn": "^7.0.3",
|
|
60
|
-
"semver": "^7.3.
|
|
60
|
+
"semver": "^7.3.7"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import { defineConfig } from 'vite'
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
include: ['tests/**/*.test.ts'],
|
|
7
|
+
/**
|
|
8
|
+
* not to ESM ported packages
|
|
9
|
+
*/
|
|
10
|
+
exclude: [
|
|
11
|
+
'build', '.idea', '.git', '.cache',
|
|
12
|
+
'**/node_modules/**', '__mocks__'
|
|
13
|
+
],
|
|
14
|
+
coverage: {
|
|
15
|
+
enabled: true,
|
|
16
|
+
exclude: ['**/build/**', '__mocks__', '**/*.test.ts'],
|
|
17
|
+
lines: 95,
|
|
18
|
+
functions: 75,
|
|
19
|
+
branches: 95,
|
|
20
|
+
statements: 95
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})
|