create-wdio
Advanced tools
Comparing version 8.1.0 to 8.2.0
@@ -5,4 +5,6 @@ import fs from 'node:fs/promises'; | ||
import semver from 'semver'; | ||
import hasYarn from 'has-yarn'; | ||
import { readPackageUp } from 'read-pkg-up'; | ||
import { Command } from 'commander'; | ||
import { runProgram, shouldUseYarn, getPackageVersion } from './utils.js'; | ||
import { runProgram, getPackageVersion } from './utils.js'; | ||
import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG } from './constants.js'; | ||
@@ -43,5 +45,2 @@ const WDIO_COMMAND = 'wdio'; | ||
export async function createWebdriverIO(opts) { | ||
const useYarn = typeof opts.useYarn === 'boolean' | ||
? opts.useYarn | ||
: await shouldUseYarn(); | ||
const npmTag = opts.npmTag.startsWith('@') ? opts.npmTag : `@${opts.npmTag}`; | ||
@@ -53,3 +52,16 @@ const root = path.resolve(process.cwd(), projectDir || ''); | ||
} | ||
/** | ||
* check if a package.json exists and if not create one | ||
*/ | ||
const project = await readPackageUp({ cwd: root }); | ||
if (!project) { | ||
await fs.writeFile(path.resolve(root, 'package.json'), JSON.stringify({ | ||
name: 'my-new-project', | ||
type: 'module' | ||
}, null, 2)); | ||
} | ||
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'; | ||
@@ -56,0 +68,0 @@ const command = useYarn ? 'yarnpkg' : 'npm'; |
@@ -9,11 +9,13 @@ import url from 'node:url'; | ||
export const colorIt = chalk.rgb(234, 89, 6); | ||
process.on('SIGINT', () => printAndExit(undefined, 'SIGINT')); | ||
export function runProgram(command, args, options) { | ||
const child = spawn(command, args, { stdio: 'inherit', ...options }); | ||
return new Promise((resolve, reject) => { | ||
return new Promise((resolve, rejects) => { | ||
let error; | ||
child.on('error', (e) => (error = e)); | ||
child.on('close', code => { | ||
child.on('close', (code, signal) => { | ||
if (code !== 0) { | ||
return reject(new Error((error && error.message) || | ||
`Error calling: ${command} ${args.join(' ')}`)); | ||
const errorMessage = (error && error.message) || `Error calling: ${command} ${args.join(' ')}`; | ||
printAndExit(errorMessage, signal); | ||
return rejects(errorMessage); | ||
} | ||
@@ -24,7 +26,2 @@ resolve(); | ||
} | ||
/* c8 ignore start */ | ||
export function shouldUseYarn() { | ||
return runProgram('yarnpkg', ['--version'], { stdio: 'ignore' }).then(() => true, () => false); | ||
} | ||
/* c8 ignore end */ | ||
export async function getPackageVersion() { | ||
@@ -41,1 +38,10 @@ try { | ||
} | ||
function printAndExit(error, signal) { | ||
if (signal === 'SIGINT') { | ||
console.log('\n\nGoodbye 👋'); | ||
} | ||
else { | ||
console.log(`\n\n⚠️ Ups, something went wrong${error ? `: ${error}` : ''}!`); | ||
} | ||
process.exit(1); | ||
} |
{ | ||
"name": "create-wdio", | ||
"version": "8.1.0", | ||
"version": "8.2.0", | ||
"description": "Install and setup a WebdriverIO project with all its dependencies in a single run", | ||
@@ -42,22 +42,24 @@ "author": "Christian Bromann <mail@bromann.dev>", | ||
"@types/cross-spawn": "^6.0.2", | ||
"@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.25.0", | ||
"@types/node": "^18.11.13", | ||
"@types/semver": "^7.3.13", | ||
"@typescript-eslint/eslint-plugin": "^5.46.0", | ||
"@typescript-eslint/parser": "^5.46.0", | ||
"@vitest/coverage-c8": "^0.25.7", | ||
"c8": "^7.12.0", | ||
"eslint": "^8.24.0", | ||
"eslint": "^8.29.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-unicorn": "^45.0.0", | ||
"eslint-plugin-unicorn": "^45.0.1", | ||
"npm-run-all": "^4.1.5", | ||
"release-it": "^15.4.2", | ||
"typescript": "^4.8.4", | ||
"vitest": "^0.25.0" | ||
"release-it": "^15.5.1", | ||
"typescript": "^4.9.4", | ||
"vitest": "^0.25.7" | ||
}, | ||
"dependencies": { | ||
"chalk": "^5.0.1", | ||
"commander": "^9.4.0", | ||
"chalk": "^5.2.0", | ||
"commander": "^9.4.1", | ||
"cross-spawn": "^7.0.3", | ||
"semver": "^7.3.7" | ||
"has-yarn": "^3.0.0", | ||
"read-pkg-up": "^9.1.0", | ||
"semver": "^7.3.8" | ||
} | ||
} |
@@ -17,8 +17,8 @@ /// <reference types="vitest" /> | ||
exclude: ['**/build/**', '__mocks__', '**/*.test.ts'], | ||
lines: 100, | ||
functions: 82, | ||
branches: 84, | ||
statements: 100 | ||
lines: 98, | ||
functions: 80, | ||
branches: 77, | ||
statements: 98 | ||
} | ||
} | ||
}) |
Sorry, the diff of this file is not supported yet
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
16104
260
6
+ Addedhas-yarn@^3.0.0
+ Addedread-pkg-up@^9.1.0
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@types/normalize-package-data@2.4.4(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedfind-up@6.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedhas-yarn@3.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhosted-git-info@4.1.0(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addedlines-and-columns@1.2.4(transitive)
+ Addedlocate-path@7.2.0(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addednormalize-package-data@3.0.3(transitive)
+ Addedp-limit@4.0.0(transitive)
+ Addedp-locate@6.0.0(transitive)
+ Addedparse-json@5.2.0(transitive)
+ Addedpath-exists@5.0.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedread-pkg@7.1.0(transitive)
+ Addedread-pkg-up@9.1.0(transitive)
+ Addedspdx-correct@3.2.0(transitive)
+ Addedspdx-exceptions@2.5.0(transitive)
+ Addedspdx-expression-parse@3.0.1(transitive)
+ Addedspdx-license-ids@3.0.20(transitive)
+ Addedtype-fest@2.19.0(transitive)
+ Addedvalidate-npm-package-license@3.0.4(transitive)
+ Addedyallist@4.0.0(transitive)
+ Addedyocto-queue@1.1.1(transitive)
Updatedchalk@^5.2.0
Updatedcommander@^9.4.1
Updatedsemver@^7.3.8