create-wdio 8.1.0 ā 8.2.1
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/build/index.js +16 -4
- package/build/utils.js +15 -9
- package/package.json +17 -15
- package/vitest.config.ts +4 -4
package/.eslintrc.cjs
CHANGED
package/build/index.js
CHANGED
|
@@ -2,8 +2,10 @@ 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 { runProgram,
|
|
8
|
+
import { runProgram, getPackageVersion } from './utils.js';
|
|
7
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;
|
|
@@ -39,16 +41,26 @@ export async function run(operation = createWebdriverIO) {
|
|
|
39
41
|
return operation(program.opts());
|
|
40
42
|
}
|
|
41
43
|
export async function createWebdriverIO(opts) {
|
|
42
|
-
const useYarn = typeof opts.useYarn === 'boolean'
|
|
43
|
-
? opts.useYarn
|
|
44
|
-
: await shouldUseYarn();
|
|
45
44
|
const npmTag = opts.npmTag.startsWith('@') ? opts.npmTag : `@${opts.npmTag}`;
|
|
46
45
|
const root = path.resolve(process.cwd(), projectDir || '');
|
|
47
46
|
const rootDirExists = await fs.access(root).then(() => true, () => false);
|
|
48
47
|
if (!rootDirExists) {
|
|
49
48
|
await fs.mkdir(root, { recursive: true });
|
|
50
49
|
}
|
|
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));
|
|
59
|
+
}
|
|
51
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);
|
|
52
64
|
const logLevel = opts.verbose ? 'trace' : 'error';
|
|
53
65
|
const command = useYarn ? 'yarnpkg' : 'npm';
|
|
54
66
|
const args = useYarn
|
package/build/utils.js
CHANGED
|
@@ -6,25 +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
|
+
process.on('SIGINT', () => printAndExit(undefined, 'SIGINT'));
|
|
9
10
|
export function runProgram(command, args, options) {
|
|
10
11
|
const child = spawn(command, args, { stdio: 'inherit', ...options });
|
|
11
|
-
return new Promise((resolve,
|
|
12
|
+
return new Promise((resolve, rejects) => {
|
|
12
13
|
let error;
|
|
13
14
|
child.on('error', (e) => (error = e));
|
|
14
|
-
child.on('close', code => {
|
|
15
|
+
child.on('close', (code, signal) => {
|
|
15
16
|
if (code !== 0) {
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
const errorMessage = (error && error.message) || `Error calling: ${command} ${args.join(' ')}`;
|
|
18
|
+
printAndExit(errorMessage, signal);
|
|
19
|
+
return rejects(errorMessage);
|
|
18
20
|
}
|
|
19
21
|
resolve();
|
|
20
22
|
});
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
|
-
/* c8 ignore start */
|
|
24
|
-
export function shouldUseYarn() {
|
|
25
|
-
return runProgram('yarnpkg', ['--version'], { stdio: 'ignore' }).then(() => true, () => false);
|
|
26
|
-
}
|
|
27
|
-
/* c8 ignore end */
|
|
28
25
|
export async function getPackageVersion() {
|
|
29
26
|
try {
|
|
30
27
|
const pkgJsonPath = path.join(__dirname, '..', 'package.json');
|
|
@@ -36,3 +33,12 @@ export async function getPackageVersion() {
|
|
|
36
33
|
}
|
|
37
34
|
return 'unknown';
|
|
38
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.1
|
|
3
|
+
"version": "8.2.1",
|
|
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.18",
|
|
43
|
+
"@types/semver": "^7.3.13",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
|
45
|
+
"@typescript-eslint/parser": "^5.48.2",
|
|
46
|
+
"@vitest/coverage-c8": "^0.28.1",
|
|
47
47
|
"c8": "^7.12.0",
|
|
48
|
-
"eslint": "^8.
|
|
49
|
-
"eslint-plugin-import": "^2.
|
|
50
|
-
"eslint-plugin-unicorn": "^45.0.
|
|
48
|
+
"eslint": "^8.32.0",
|
|
49
|
+
"eslint-plugin-import": "^2.27.5",
|
|
50
|
+
"eslint-plugin-unicorn": "^45.0.2",
|
|
51
51
|
"npm-run-all": "^4.1.5",
|
|
52
|
-
"release-it": "^15.
|
|
53
|
-
"typescript": "^4.
|
|
54
|
-
"vitest": "^0.
|
|
52
|
+
"release-it": "^15.6.0",
|
|
53
|
+
"typescript": "^4.9.4",
|
|
54
|
+
"vitest": "^0.28.1"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"chalk": "^5.0
|
|
58
|
-
"commander": "^
|
|
57
|
+
"chalk": "^5.2.0",
|
|
58
|
+
"commander": "^10.0.0",
|
|
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
|
})
|