Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

create-wdio

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-wdio - npm Package Compare versions

Comparing version 7.2.0 to 8.0.0

__mocks__/commander.ts

4

bin/wdio.js

@@ -7,2 +7,4 @@ #!/usr/bin/env node

*/
require('../build').run()
import { run } from '../build/index.js'
run()

@@ -1,12 +0,4 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UNSUPPORTED_NODE_VERSION = exports.PROGRAM_TITLE = exports.ASCII_ROBOT = exports.DEFAULT_NPM_TAG = void 0;
const chalk_1 = __importDefault(require("chalk"));
exports.DEFAULT_NPM_TAG = 'latest';
const colorItBold = chalk_1.default.bold.rgb(234, 89, 6);
const colorIt = chalk_1.default.rgb(234, 89, 6);
exports.ASCII_ROBOT = `
import { colorItBold, colorIt } from './utils.js';
export const DEFAULT_NPM_TAG = 'latest';
export const ASCII_ROBOT = `
-:...........................-:.

@@ -52,3 +44,3 @@ + +

`;
exports.PROGRAM_TITLE = `
export const PROGRAM_TITLE = `
${colorItBold('Webdriver.IO')}

@@ -58,3 +50,8 @@ ${colorIt('Next-gen browser and mobile automation')}

`;
exports.UNSUPPORTED_NODE_VERSION = (`You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
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');

@@ -1,24 +0,12 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const chalk_1 = __importDefault(require("chalk"));
const commander_1 = require("commander");
const semver_1 = __importDefault(require("semver"));
const utils_1 = require("./utils");
const constants_1 = require("./constants");
let pkg = { version: 'unknown' };
try {
pkg = JSON.parse(fs_1.default.readFileSync(__dirname + '/../package.json').toString());
}
catch (e) {
/* ignore */
}
let projectName;
let useYarn;
function run(operation = createWebdriverIO) {
import fs from 'node:fs/promises';
import path from 'node:path';
import chalk from 'chalk';
import semver from 'semver';
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';
const WDIO_COMMAND = 'wdio';
let projectDir;
export async function run(operation = createWebdriverIO) {
const version = await getPackageVersion();
/**

@@ -28,10 +16,10 @@ * print program ASCII art

if (!(process.argv.includes('--version') || process.argv.includes('-v'))) {
console.log(constants_1.ASCII_ROBOT, constants_1.PROGRAM_TITLE);
console.log(ASCII_ROBOT, PROGRAM_TITLE);
}
const program = new commander_1.Command('wdio')
.version(`v${pkg.version}`, '-v, --version')
.arguments('[project]')
.usage(`${chalk_1.default.green('[project]')} [options]`)
.action(name => (projectName = name))
.option('-t, --npm-tag <tag>', 'Which NPM version you like to install, e.g. @next', constants_1.DEFAULT_NPM_TAG)
const program = new Command(WDIO_COMMAND)
.version(version, '-v, --version')
.arguments('[project-path]')
.usage(`${chalk.green('[project-path]')} [options]`)
.action(name => (projectDir = name))
.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)

@@ -44,86 +32,60 @@ .option('-v, --verbose', 'print additional logs')

.parse(process.argv);
if (typeof projectName === 'undefined' && !fs_1.default.existsSync('package.json')) {
console.error('There is no package.json in current directory!\n');
console.log('To create WebdriverIO in a new project pass in a directory name:\n' +
` npm init ${chalk_1.default.cyan(program.name())} ${chalk_1.default.green('/path/to/project/directory')}\n` +
'\n' +
'For example:\n' +
` npm init ${chalk_1.default.cyan(program.name())} ${chalk_1.default.green('./tests')}\n` +
'\n' +
'To update current project to include WebdriverIO packages, run this script in a directory with package.json\n' +
`Run ${chalk_1.default.cyan(`${program.name()} --help`)} to see all options.`);
process.exit(1);
}
return operation(program.opts()).then(() => console.log(`To start the test, run: ${chalk_1.default.cyan('$ npm run')} ${chalk_1.default.green(program.name())}`));
return operation(program.opts());
}
exports.run = run;
async function createWebdriverIO(opts) {
const cwd = process.cwd();
const useYarn = opts.useYarn && await shouldUseYarn();
const npmTag = opts.npmTag.startsWith('@') ? opts.npmTag : `@${opts.npmTag}`;
const unsupportedNodeVersion = !semver_1.default.satisfies(process.version, '>=12');
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=12');
if (unsupportedNodeVersion) {
console.log(chalk_1.default.yellow(constants_1.UNSUPPORTED_NODE_VERSION));
console.log(chalk.yellow(UNSUPPORTED_NODE_VERSION));
}
useYarn = opts.useYarn && await (0, utils_1.shouldUseYarn)();
let root = path_1.default.join(process.cwd(), projectName || '');
if (!await (0, utils_1.exists)(root)) {
await fs_1.default.promises.mkdir(root, { recursive: true });
const root = path.resolve(process.cwd(), projectDir || '');
if (!await exists(root)) {
await fs.mkdir(root, { recursive: true });
}
process.chdir(root);
root = process.cwd();
const currentDir = process.cwd();
const pkgJsonPath = path_1.default.join(currentDir, 'package.json');
if (!useYarn && !(0, utils_1.checkThatNpmCanReadCwd)()) {
process.exit(1);
}
console.log(`\nCreating WebdriverIO project in ${chalk_1.default.bold(root)}\n`);
if (!await (0, utils_1.exists)(pkgJsonPath)) {
console.log('package.json file does not exist in current dir, creating it...');
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',
private: true
description: '',
private: true,
keywords: [],
author: '',
license: 'ISC'
};
await fs_1.default.promises.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 4));
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 4));
console.log(chalk.green.bold('βœ” Success!'));
}
const deps = [`@wdio/cli${npmTag}`];
await install(deps.flat(), root, opts);
console.log('\nFinished installing packages.');
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project.`);
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' });
console.log(chalk.green.bold('βœ” Success!'));
console.log('\nRunning WDIO CLI Wizard...');
await (0, utils_1.runProgram)('npx', ['wdio', 'config', ...(useYarn ? ['--yarn'] : []), ...(opts.yes ? ['--yes'] : [])]);
if (await (0, utils_1.exists)(pkgJsonPath)) {
console.log('Adding scripts to package.json');
const pkgJson = require(pkgJsonPath);
const isUsingTypescript = await (0, utils_1.exists)('test/wdio.conf.ts');
if (!pkgJson.scripts) {
pkgJson.scripts = {};
}
pkgJson.scripts['wdio'] = `wdio run ${isUsingTypescript ? 'test/wdio.conf.ts' : 'wdio.conf.js'}`;
await fs_1.default.promises.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 4));
await runProgram('npx', [
WDIO_COMMAND,
'config',
...(useYarn ? ['--yarn'] : []),
...(opts.yes ? ['--yes'] : [])
], { 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} πŸŽ‰`);
console.log(`\nπŸ€– Successfully setup project at ${root} πŸŽ‰\n`);
console.log(COMMUNITY_DISCLAIMER);
if (root != cwd) {
console.log(`\n${chalk_1.default.yellow('⚠')} First, change the directory via: ${chalk_1.default.cyan('$ cd')} ${chalk_1.default.green(root)}`);
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)}`);
}
function install(dependencies, root, opts) {
const logLevel = opts.verbose ? 'trace' : 'error';
let command;
let args;
console.log('Installing packages: ', chalk_1.default.green(dependencies.join(', ')), '\n');
if (useYarn) {
command = 'yarnpkg';
args = ['add', ...(opts.dev ? ['-D'] : []), '--exact', ...dependencies];
// Explicitly set cwd() to work around issues like
// https://github.com/facebook/create-react-app/issues/3326.
// Unfortunately we can only do this for Yarn because npm support for
// equivalent --prefix flag doesn't help with this issue.
// This is why for npm, we run checkThatNpmCanReadCwd() early instead.
args.push('--cwd', root);
}
else {
command = 'npm';
args = ['install', opts.dev ? '--save-dev' : '--save', '--loglevel', logLevel, ...dependencies];
}
return (0, utils_1.runProgram)(command, args);
}

@@ -1,2 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};

@@ -1,16 +0,14 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkThatNpmCanReadCwd = exports.shouldUseYarn = exports.runProgram = exports.exists = void 0;
const fs_1 = __importDefault(require("fs"));
const chalk_1 = __importDefault(require("chalk"));
const cross_spawn_1 = __importDefault(require("cross-spawn"));
function exists(path) {
return fs_1.default.promises.access(path).then(() => true, () => false);
import url from 'node:url';
import path from 'node:path';
import fs from 'node:fs/promises';
import spawn from 'cross-spawn';
import chalk from 'chalk';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
export const colorItBold = chalk.bold.rgb(234, 89, 6);
export const colorIt = chalk.rgb(234, 89, 6);
export function exists(path) {
return fs.access(path).then(() => true, () => false);
}
exports.exists = exists;
function runProgram(command, args, options = { stdio: 'inherit' }) {
const child = (0, cross_spawn_1.default)(command, args, options);
export function runProgram(command, args, options) {
const child = spawn(command, args, { stdio: 'inherit', ...options });
return new Promise((resolve, reject) => {

@@ -28,54 +26,15 @@ let error;

}
exports.runProgram = runProgram;
function shouldUseYarn() {
export function shouldUseYarn() {
return runProgram('yarnpkg', ['--version'], { stdio: 'ignore' }).then(() => true, () => false);
}
exports.shouldUseYarn = shouldUseYarn;
function checkThatNpmCanReadCwd() {
const cwd = process.cwd();
let childOutput = null;
export async function getPackageVersion() {
try {
// Note: intentionally using spawn over exec since
// the problem doesn't reproduce otherwise.
// `npm config list` is the only reliable way I could find
// to reproduce the wrong path. Just printing process.cwd()
// in a Node process was not enough.
childOutput = cross_spawn_1.default.sync('npm', ['config', 'list']).output.join('');
const pkgJsonPath = path.join(__dirname, '..', 'package.json');
const pkg = JSON.parse((await fs.readFile(pkgJsonPath)).toString());
return `v${pkg.version}`;
}
catch (err) {
// Something went wrong spawning node.
// Not great, but it means we can't do this check.
// We might fail later on, but let's continue.
return true;
catch (e) {
/* ignore */
}
if (typeof childOutput !== 'string') {
return true;
}
const lines = childOutput.split('\n');
// `npm config list` output includes the following line:
// "; cwd = C:\path\to\current\dir" (unquoted)
// I couldn't find an easier way to get it.
const prefix = '; cwd = ';
const line = lines.find(line => line.indexOf(prefix) === 0);
if (typeof line !== 'string') {
// Fail gracefully. They could remove it.
return true;
}
const npmCWD = line.substring(prefix.length);
if (npmCWD === cwd) {
return true;
}
console.error(chalk_1.default.red('Could not start an npm process in the right directory.\n\n' +
`The current directory is: ${chalk_1.default.bold(cwd)}\n` +
`However, a newly started npm process runs in: ${chalk_1.default.bold(npmCWD)}\n\n` +
'This is probably caused by a misconfigured system terminal shell.'));
if (process.platform === 'win32') {
console.error(chalk_1.default.red('On Windows, this can usually be fixed by running:\n\n') +
` ${chalk_1.default.cyan('reg')} delete "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n` +
` ${chalk_1.default.cyan('reg')} delete "HKLM\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n\n` +
chalk_1.default.red('Try to run the above two lines in the terminal.\n') +
chalk_1.default.red('To learn more about this problem, read: https://blogs.msdn.microsoft.com/oldnewthing/20071121-00/?p=24433/'));
}
return false;
return 'unknown';
}
exports.checkThatNpmCanReadCwd = checkThatNpmCanReadCwd;
{
"name": "create-wdio",
"version": "7.2.0",
"description": "Install WebdriverIO with all its dependencies in a single run",
"author": "Christian Bromann <christian@saucelabs.com>",
"version": "8.0.0",
"description": "Install and setup a WebdriverIO project with all its dependencies in a single run",
"author": "Christian Bromann <mail@bromann.dev>",
"license": "MIT",

@@ -25,2 +25,3 @@ "homepage": "https://github.com/webdriverio/create-wdio#readme",

},
"type": "module",
"scripts": {

@@ -36,29 +37,28 @@ "build": "run-s clean compile",

"test": "run-s build test:*",
"test:eslint": "eslint -c ./.eslintrc.js ./src/**/*.ts ./tests/**/*.ts",
"test:unit": "npx jest",
"test:eslint": "eslint -c ./.eslintrc.cjs ./src/**/*.ts ./tests/**/*.ts",
"test:unit": "vitest",
"watch": "npm run compile -- --watch"
},
"devDependencies": {
"@schemastore/package": "^0.0.6",
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^27.4.1",
"@types/node": "^18.0.0",
"@types/semver": "^7.3.9",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"eslint": "^8.10.0",
"eslint-plugin-import": "^2.25.4",
"jest": "^27.5.1",
"@types/node": "^18.7.23",
"@types/semver": "^7.3.12",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"@vitest/coverage-c8": "^0.23.4",
"c8": "^7.12.0",
"eslint": "^8.24.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-unicorn": "^43.0.2",
"npm-run-all": "^4.1.5",
"release-it": "^15.0.0",
"ts-jest": "^27.1.3",
"ts-node": "^10.7.0",
"typescript": "^4.6.2"
"release-it": "^15.4.2",
"typescript": "^4.8.4",
"vitest": "^0.23.4"
},
"dependencies": {
"chalk": "^4.1.2",
"commander": "^9.0.0",
"chalk": "^5.0.1",
"commander": "^9.4.0",
"cross-spawn": "^7.0.3",
"semver": "^7.3.5"
"semver": "^7.3.7"
}
}

@@ -48,6 +48,6 @@ 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)

It will create a directory called `e2e` inside the current folder.
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.
## Supported Options

@@ -60,2 +60,3 @@

* `--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`)

@@ -62,0 +63,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc