create-wdio
Advanced tools
Comparing version 8.0.0 to 8.1.0
@@ -49,8 +49,4 @@ import { colorItBold, colorIt } from './utils.js'; | ||
`; | ||
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` + | ||
'Please update to Node 12 or higher for a better, fully supported experience.\n'); | ||
export const COMMUNITY_DISCLAIMER = ('Join our Gitter community and instantly find answers to your issues or queries. Or just join and say hi 👋!\n' + | ||
' 🔗 https://gitter.im/webdriverio/webdriverio\n' + | ||
'\n' + | ||
'Visit the project on GitHub to report bugs 🐛 or raise feature requests 💡:\n' + | ||
' 🔗 https://github.com/webdriverio/webdriverio\n'); | ||
export const UNSUPPORTED_NODE_VERSION = ('⚠️ Unsupported Node.js Version Error ⚠️\n' + | ||
`You are using Node.js ${process.version} which is to old to be used with WebdriverIO.\n` + | ||
'Please update to Node.js v16 to continue.\n'); |
@@ -6,4 +6,4 @@ import fs from 'node:fs/promises'; | ||
import { Command } from 'commander'; | ||
import { exists, runProgram, shouldUseYarn, getPackageVersion } from './utils.js'; | ||
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG, COMMUNITY_DISCLAIMER } from './constants.js'; | ||
import { runProgram, shouldUseYarn, getPackageVersion } from './utils.js'; | ||
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG } from './constants.js'; | ||
const WDIO_COMMAND = 'wdio'; | ||
@@ -19,2 +19,10 @@ let projectDir; | ||
} | ||
/** | ||
* ensure right Node.js version is used | ||
*/ | ||
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=16'); | ||
if (unsupportedNodeVersion) { | ||
console.log(chalk.yellow(UNSUPPORTED_NODE_VERSION)); | ||
return; | ||
} | ||
const program = new Command(WDIO_COMMAND) | ||
@@ -35,31 +43,13 @@ .version(version, '-v, --version') | ||
} | ||
async function createWebdriverIO(opts) { | ||
const cwd = process.cwd(); | ||
const useYarn = opts.useYarn && await shouldUseYarn(); | ||
export async function createWebdriverIO(opts) { | ||
const useYarn = typeof opts.useYarn === 'boolean' | ||
? opts.useYarn | ||
: await shouldUseYarn(); | ||
const npmTag = opts.npmTag.startsWith('@') ? opts.npmTag : `@${opts.npmTag}`; | ||
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=12'); | ||
if (unsupportedNodeVersion) { | ||
console.log(chalk.yellow(UNSUPPORTED_NODE_VERSION)); | ||
} | ||
const root = path.resolve(process.cwd(), projectDir || ''); | ||
if (!await exists(root)) { | ||
const rootDirExists = await fs.access(root).then(() => true, () => false); | ||
if (!rootDirExists) { | ||
await fs.mkdir(root, { recursive: true }); | ||
} | ||
const pkgJsonPath = path.join(root, 'package.json'); | ||
console.log(`\nCreating WebdriverIO project in ${chalk.bold(root)}\n`); | ||
if (!await exists(pkgJsonPath)) { | ||
console.log(`Creating a ${chalk.bold('package.json')} for the directory.`); | ||
const pkgJson = { | ||
name: 'webdriverio-tests', | ||
version: '0.1.0', | ||
description: '', | ||
private: true, | ||
keywords: [], | ||
author: '', | ||
license: 'ISC' | ||
}; | ||
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 4)); | ||
console.log(chalk.green.bold('✔ Success!')); | ||
} | ||
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project.`); | ||
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project...`); | ||
const logLevel = opts.verbose ? 'trace' : 'error'; | ||
@@ -72,4 +62,3 @@ const command = useYarn ? 'yarnpkg' : 'npm'; | ||
console.log(chalk.green.bold('✔ Success!')); | ||
console.log('\nRunning WDIO CLI Wizard...'); | ||
await runProgram('npx', [ | ||
return runProgram('npx', [ | ||
WDIO_COMMAND, | ||
@@ -80,15 +69,2 @@ 'config', | ||
], { cwd: root }); | ||
if (await exists(pkgJsonPath)) { | ||
console.log(`Adding ${chalk.bold(`"${WDIO_COMMAND}"`)} script to package.json.`); | ||
const isUsingTypescript = await exists('test/wdio.conf.ts'); | ||
const script = `wdio run ${isUsingTypescript ? 'test/wdio.conf.ts' : 'wdio.conf.js'}`; | ||
await runProgram('npm', ['set-script', WDIO_COMMAND, script], { cwd: root }); | ||
console.log(chalk.green.bold('✔ Success!')); | ||
} | ||
console.log(`\n🤖 Successfully setup project at ${root} 🎉\n`); | ||
console.log(COMMUNITY_DISCLAIMER); | ||
if (root != cwd) { | ||
console.log(`${chalk.bold.yellow('⚠')} First, change the directory via: ${chalk.cyan('$ cd')} ${chalk.green(root)}`); | ||
} | ||
console.log(`To start the test, run: ${chalk.cyan('$ npm run')} ${chalk.green(WDIO_COMMAND)}`); | ||
} |
@@ -9,5 +9,2 @@ import url from 'node:url'; | ||
export const colorIt = chalk.rgb(234, 89, 6); | ||
export function exists(path) { | ||
return fs.access(path).then(() => true, () => false); | ||
} | ||
export function runProgram(command, args, options) { | ||
@@ -27,5 +24,7 @@ const child = spawn(command, args, { stdio: 'inherit', ...options }); | ||
} | ||
/* c8 ignore start */ | ||
export function shouldUseYarn() { | ||
return runProgram('yarnpkg', ['--version'], { stdio: 'ignore' }).then(() => true, () => false); | ||
} | ||
/* c8 ignore end */ | ||
export async function getPackageVersion() { | ||
@@ -32,0 +31,0 @@ try { |
{ | ||
"name": "create-wdio", | ||
"version": "8.0.0", | ||
"version": "8.1.0", | ||
"description": "Install and setup a WebdriverIO project with all its dependencies in a single run", | ||
@@ -46,11 +46,11 @@ "author": "Christian Bromann <mail@bromann.dev>", | ||
"@typescript-eslint/parser": "^5.38.1", | ||
"@vitest/coverage-c8": "^0.23.4", | ||
"@vitest/coverage-c8": "^0.25.0", | ||
"c8": "^7.12.0", | ||
"eslint": "^8.24.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-unicorn": "^43.0.2", | ||
"eslint-plugin-unicorn": "^45.0.0", | ||
"npm-run-all": "^4.1.5", | ||
"release-it": "^15.4.2", | ||
"typescript": "^4.8.4", | ||
"vitest": "^0.23.4" | ||
"vitest": "^0.25.0" | ||
}, | ||
@@ -57,0 +57,0 @@ "dependencies": { |
@@ -26,3 +26,3 @@ WebdriverIO Starter Toolkit [![Test Changes](https://github.com/webdriverio/create-wdio/actions/workflows/test.yml/badge.svg?branch=main&event=push)](https://github.com/webdriverio/create-wdio/actions/workflows/test.yml) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/webdriverio/create-wdio/blob/main/CONTRIBUTING.md) | ||
```sh | ||
npx create-wdio ./e2e | ||
npx create-wdio@latest ./e2e | ||
``` | ||
@@ -35,3 +35,3 @@ | ||
```sh | ||
npm init wdio ./e2e | ||
npm init wdio@latest ./e2e | ||
``` | ||
@@ -44,3 +44,3 @@ | ||
```sh | ||
yarn create wdio ./e2e | ||
yarn create wdio@latest ./e2e | ||
``` | ||
@@ -52,3 +52,3 @@ | ||
It will create a directory called `e2e` inside the current folder. | ||
Then it will run the configuration wizard that will help you setup your framework. | ||
Then it will run the configuration wizard that will help you set-up your framework. | ||
@@ -55,0 +55,0 @@ |
@@ -17,8 +17,8 @@ /// <reference types="vitest" /> | ||
exclude: ['**/build/**', '__mocks__', '**/*.test.ts'], | ||
lines: 95, | ||
functions: 75, | ||
branches: 95, | ||
statements: 95 | ||
lines: 100, | ||
functions: 82, | ||
branches: 84, | ||
statements: 100 | ||
} | ||
} | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
15308
234