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 8.3.4 to 8.4.0

77

build/index.js
import fs from 'node:fs/promises';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import chalk from 'chalk';
import semver from 'semver';
import { detect } from 'detect-package-manager';
import { readPackageUp } from 'read-pkg-up';
import { Command } from 'commander';
import { resolve } from 'import-meta-resolve';
import { runProgram, getPackageVersion } from './utils.js';
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG, INSTALL_COMMAND, DEV_FLAG, PMs } from './constants.js';
import { execSync } from 'node:child_process';
const WDIO_COMMAND = 'wdio';

@@ -45,41 +46,33 @@ let projectDir;

/**
* check if a package.json exists and if not create one
* find package manager that was used to create project
*/
const project = await readPackageUp({ cwd: root });
if (!project) {
const pm = PMs.find((pm) => (
// for pnpm check for "~/Library/pnpm/store/v3/..."
process.argv[1].includes(`${path.sep}${pm}${path.sep}`) ||
// for NPM and Yarn check for "~/.npm/npx/..." or "~/.yarn/bin/create-wdio"
process.argv[1].includes(`${path.sep}.${pm}${path.sep}`))) || 'npm';
const hasPackageJson = await fs.access(path.resolve(root, 'package.json')).then(() => true).catch(() => false);
if (!hasPackageJson) {
await fs.mkdir(root, { recursive: true });
await fs.writeFile(path.resolve(root, 'package.json'), JSON.stringify({
name: 'my-new-project',
name: root.replace(/\/$/, '').split('/').pop(),
type: 'module'
}, null, 2));
/**
* find package manager that was used to create project
*/
const pm = PMs.find((pm) => (
// for pnpm check for "~/Library/pnpm/store/v3/..."
process.argv[1].includes(`${path.sep}${pm}${path.sep}`) ||
// for NPM and Yarn check for "~/.npm/npx/..." or "~/.yarn/bin/create-wdio"
process.argv[1].includes(`${path.sep}.${pm}${path.sep}`))) || 'npm';
/**
* create a package-lock.json, yarn.lock or pnpm-lock.yaml so
* that `detect-package-manager` doesn't mark it as a default
* Yarn project
* @see https://github.com/egoist/detect-package-manager/issues/11
*/
await runProgram(pm, ['install'], { cwd: root, stdio: 'ignore' });
}
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project...`);
const pm = await detect({ cwd: root });
const args = [INSTALL_COMMAND[pm]];
if (pm === 'yarn') {
args.push('--exact', '--cwd', root);
const cliInstalled = await isCLIInstalled(root);
if (!cliInstalled) {
console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project...`);
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!'));
}
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!'));
return runProgram('npx', [
WDIO_COMMAND,
return runProgram(pm === 'npm' ? 'npx' : pm, [
`${pm === 'npm' ? '' : 'run '}${WDIO_COMMAND}`,
'config',

@@ -89,1 +82,17 @@ ...(opts.yes ? ['--yes'] : [])

}
async function isCLIInstalled(path) {
try {
// can be replaced with import.meta.resolve('@wdio/cli', new URL(`file:///${root}`).href) in the future
// check if the cli is installed in the project
resolve('@wdio/cli', pathToFileURL(path).href);
return true;
}
catch (error) {
// check of the cli is installed globally
const output = execSync('npm ls -g', { encoding: 'utf-8' });
if (output.includes('@wdio/cli')) {
return true;
}
return false;
}
}
{
"name": "create-wdio",
"version": "8.3.4",
"version": "8.4.0",
"description": "Install and setup a WebdriverIO project with all its dependencies in a single run",

@@ -49,5 +49,5 @@ "author": "Christian Bromann <mail@bromann.dev>",

"eslint-plugin-import": "^2.27.5",
"eslint-plugin-unicorn": "^48.0.0",
"eslint-plugin-unicorn": "^49.0.0",
"npm-run-all": "^4.1.5",
"release-it": "^16.1.2",
"release-it": "^17.0.0",
"typescript": "^5.1.6",

@@ -60,6 +60,5 @@ "vitest": "^0.34.1"

"cross-spawn": "^7.0.3",
"detect-package-manager": "^3.0.1",
"read-pkg-up": "^10.0.0",
"import-meta-resolve": "^4.0.0",
"semver": "^7.5.4"
}
}
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