create-wdio
Advanced tools
Comparing version 8.2.5 to 8.3.0
@@ -52,1 +52,13 @@ import { colorItBold, colorIt } from './utils.js'; | ||
'Please update to Node.js v16 to continue.\n'); | ||
export const INSTALL_COMMAND = { | ||
npm: 'install', | ||
pnpm: 'add', | ||
yarn: 'add', | ||
bun: 'install' | ||
}; | ||
export const DEV_FLAG = { | ||
npm: '--save-dev', | ||
pnpm: '--save-dev', | ||
yarn: '--dev', | ||
bun: '--dev' | ||
}; |
@@ -5,7 +5,7 @@ import fs from 'node:fs/promises'; | ||
import semver from 'semver'; | ||
import hasYarn from 'has-yarn'; | ||
import { detect } from 'detect-package-manager'; | ||
import { readPackageUp } from 'read-pkg-up'; | ||
import { Command } from 'commander'; | ||
import { runProgram, getPackageVersion } from './utils.js'; | ||
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG } from './constants.js'; | ||
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG, INSTALL_COMMAND, DEV_FLAG } from './constants.js'; | ||
const WDIO_COMMAND = 'wdio'; | ||
@@ -35,4 +35,2 @@ let projectDir; | ||
.option('-t, --npm-tag <tag>', 'Which NPM version you like to install, e.g. @next', DEFAULT_NPM_TAG) | ||
.option('-u, --use-yarn', 'Use Yarn package manager to install packages', false) | ||
.option('-v, --verbose', 'print additional logs') | ||
.option('-y, --yes', 'will fill in all config defaults without prompting', false) | ||
@@ -48,6 +46,2 @@ .option('-d, --dev', 'Install all packages as into devDependencies', true) | ||
const root = path.resolve(process.cwd(), projectDir || ''); | ||
const rootDirExists = await fs.access(root).then(() => true, () => false); | ||
if (!rootDirExists) { | ||
await fs.mkdir(root, { recursive: true }); | ||
} | ||
/** | ||
@@ -58,2 +52,3 @@ * check if a package.json exists and if not create one | ||
if (!project) { | ||
await fs.mkdir(root, { recursive: true }); | ||
await fs.writeFile(path.resolve(root, 'package.json'), JSON.stringify({ | ||
@@ -63,13 +58,20 @@ name: 'my-new-project', | ||
}, null, 2)); | ||
/** | ||
* create a package-lock.json so that `detect-package-manager` | ||
* doesn't mark it as a Yarn project | ||
* @see https://github.com/egoist/detect-package-manager/issues/11 | ||
*/ | ||
await runProgram('npm', ['install'], { cwd: root, stdio: 'ignore' }); | ||
} | ||
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project...`); | ||
const useYarn = typeof opts.useYarn === 'boolean' | ||
? opts.useYarn | ||
: await hasYarn(root); | ||
const logLevel = opts.verbose ? 'trace' : 'error'; | ||
const command = useYarn ? 'yarnpkg' : 'npm'; | ||
const args = useYarn | ||
? ['add', ...(opts.dev ? ['-D'] : []), '--exact', '--cwd', root, `@wdio/cli${npmTag}`] | ||
: ['install', opts.dev ? '--save-dev' : '--save', '--loglevel', logLevel, `@wdio/cli${npmTag}`]; | ||
await runProgram(command, args, { cwd: root, stdio: 'ignore' }); | ||
const pm = await detect({ cwd: root }); | ||
const args = [INSTALL_COMMAND[pm]]; | ||
if (pm === 'yarn') { | ||
args.push('--exact', '--cwd', root); | ||
} | ||
if (opts.dev) { | ||
args.push(DEV_FLAG[pm]); | ||
} | ||
args.push(`@wdio/cli${npmTag}`); | ||
await runProgram(pm, args, { cwd: root, stdio: 'ignore' }); | ||
console.log(chalk.green.bold('✔ Success!')); | ||
@@ -79,5 +81,4 @@ return runProgram('npx', [ | ||
'config', | ||
...(useYarn ? ['--yarn'] : []), | ||
...(opts.yes ? ['--yes'] : []) | ||
], { cwd: root }); | ||
} |
{ | ||
"name": "create-wdio", | ||
"version": "8.2.5", | ||
"version": "8.3.0", | ||
"description": "Install and setup a WebdriverIO project with all its dependencies in a single run", | ||
@@ -42,23 +42,23 @@ "author": "Christian Bromann <mail@bromann.dev>", | ||
"@types/cross-spawn": "^6.0.2", | ||
"@types/node": "^20.3.1", | ||
"@types/node": "^20.4.2", | ||
"@types/semver": "^7.5.0", | ||
"@typescript-eslint/eslint-plugin": "^5.59.11", | ||
"@typescript-eslint/parser": "^5.59.11", | ||
"@vitest/coverage-v8": "^0.33.0", | ||
"eslint": "^8.42.0", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"@vitest/coverage-v8": "^0.34.1", | ||
"eslint": "^8.45.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-unicorn": "^47.0.0", | ||
"eslint-plugin-unicorn": "^48.0.0", | ||
"npm-run-all": "^4.1.5", | ||
"release-it": "^16.1.0", | ||
"typescript": "^5.1.3", | ||
"vitest": "^0.33.0" | ||
"release-it": "^16.1.2", | ||
"typescript": "^5.1.6", | ||
"vitest": "^0.34.1" | ||
}, | ||
"dependencies": { | ||
"chalk": "^5.2.0", | ||
"chalk": "^5.3.0", | ||
"commander": "^11.0.0", | ||
"cross-spawn": "^7.0.3", | ||
"has-yarn": "^3.0.0", | ||
"detect-package-manager": "^3.0.1", | ||
"read-pkg-up": "^10.0.0", | ||
"semver": "^7.5.1" | ||
"semver": "^7.5.4" | ||
} | ||
} |
@@ -47,3 +47,10 @@ 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) | ||
#### pnpm | ||
```sh | ||
pnpm create wdio ./e2e | ||
``` | ||
_[`pnpm create <starter-kit-package>`](https://pnpm.io/cli/create) is available in pnpm v7+_ | ||
It will create a directory called `e2e` inside the current folder. | ||
@@ -59,5 +66,3 @@ Then it will run the configuration wizard that will help you set-up your framework. | ||
* `--yes` - Will fill in all config defaults without prompting (default: `false`) | ||
* `--use-yarn` - yes, we support yarn too! (default: `true`) | ||
* `--npm-tag` - use a specific NPM tag for `@wdio/cli` package (default: `latest`) | ||
* `--verbose` - print additional logs (default: `false`) | ||
@@ -64,0 +69,0 @@ ---- |
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
16194
273
70
+ Addeddetect-package-manager@3.0.2(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
- Removedhas-yarn@^3.0.0
- Removedhas-yarn@3.0.0(transitive)
Updatedchalk@^5.3.0
Updatedsemver@^7.5.4