create-wdio 8.2.4 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -44,6 +44,13 @@ yarn create wdio@latest ./e2e
44
44
 
45
45
  _[`yarn create <starter-kit-package>`](https://yarnpkg.com/lang/en/docs/cli/create/) is available in Yarn 0.25+_
46
46
 
47
+ #### pnpm
48
+
49
+ ```sh
50
+ pnpm create wdio ./e2e
51
+ ```
52
+
53
+ _[`pnpm create <starter-kit-package>`](https://pnpm.io/cli/create) is available in pnpm v7+_
47
54
 
48
55
  It will create a directory called `e2e` inside the current folder.
49
56
  Then it will run the configuration wizard that will help you set-up your framework.
@@ -55,9 +62,7 @@ You can pass the following command line flags to modify the bootstrap mechanism:
55
62
 
56
63
  * `--dev` - Install all packages as `devDependencies` (default: `true`)
57
64
  * `--yes` - Will fill in all config defaults without prompting (default: `false`)
58
- * `--use-yarn` - yes, we support yarn too! (default: `true`)
59
65
  * `--npm-tag` - use a specific NPM tag for `@wdio/cli` package (default: `latest`)
60
- * `--verbose` - print additional logs (default: `false`)
61
66
 
62
67
  ----
63
68
 
@@ -49,3 +49,15 @@ export const PROGRAM_TITLE = `
49
49
  export const UNSUPPORTED_NODE_VERSION = ('⚠️ Unsupported Node.js Version Error ⚠️\n' +
50
50
  `You are using Node.js ${process.version} which is to old to be used with WebdriverIO.\n` +
51
51
  'Please update to Node.js v16 to continue.\n');
52
+ export const INSTALL_COMMAND = {
53
+ npm: 'install',
54
+ pnpm: 'add',
55
+ yarn: 'add',
56
+ bun: 'install'
57
+ };
58
+ export const DEV_FLAG = {
59
+ npm: '--save-dev',
60
+ pnpm: '--save-dev',
61
+ yarn: '--dev',
62
+ bun: '--dev'
63
+ };
package/build/index.js CHANGED
@@ -2,11 +2,11 @@ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import chalk from 'chalk';
4
4
  import semver from 'semver';
5
- import hasYarn from 'has-yarn';
5
+ import { detect } from 'detect-package-manager';
6
6
  import { readPackageUp } from 'read-pkg-up';
7
7
  import { Command } from 'commander';
8
8
  import { runProgram, getPackageVersion } from './utils.js';
9
- import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG } from './constants.js';
9
+ import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG, INSTALL_COMMAND, DEV_FLAG } from './constants.js';
10
10
  const WDIO_COMMAND = 'wdio';
11
11
  let projectDir;
12
12
  export async function run(operation = createWebdriverIO) {
@@ -31,8 +31,6 @@ export async function run(operation = createWebdriverIO) {
31
31
  .usage(`${chalk.green('[project-path]')} [options]`)
32
32
  .action(name => (projectDir = name))
33
33
  .option('-t, --npm-tag <tag>', 'Which NPM version you like to install, e.g. @next', DEFAULT_NPM_TAG)
34
- .option('-u, --use-yarn', 'Use Yarn package manager to install packages', false)
35
- .option('-v, --verbose', 'print additional logs')
36
34
  .option('-y, --yes', 'will fill in all config defaults without prompting', false)
37
35
  .option('-d, --dev', 'Install all packages as into devDependencies', true)
38
36
  .allowUnknownOption()
@@ -43,35 +41,38 @@ export async function run(operation = createWebdriverIO) {
43
41
  export async function createWebdriverIO(opts) {
44
42
  const npmTag = opts.npmTag.startsWith('@') ? opts.npmTag : `@${opts.npmTag}`;
45
43
  const root = path.resolve(process.cwd(), projectDir || '');
46
- const rootDirExists = await fs.access(root).then(() => true, () => false);
47
- if (!rootDirExists) {
48
- await fs.mkdir(root, { recursive: true });
49
- }
50
44
  /**
51
45
  * check if a package.json exists and if not create one
52
46
  */
53
47
  const project = await readPackageUp({ cwd: root });
54
48
  if (!project) {
49
+ await fs.mkdir(root, { recursive: true });
55
50
  await fs.writeFile(path.resolve(root, 'package.json'), JSON.stringify({
56
51
  name: 'my-new-project',
57
52
  type: 'module'
58
53
  }, null, 2));
54
+ /**
55
+ * create a package-lock.json so that `detect-package-manager`
56
+ * doesn't mark it as a Yarn project
57
+ * @see https://github.com/egoist/detect-package-manager/issues/11
58
+ */
59
+ await runProgram('npm', ['install'], { cwd: root, stdio: 'ignore' });
59
60
  }
60
61
  console.log(`\nInstalling ${chalk.bold('@wdio/cli')} to initialize project...`);
61
- const useYarn = typeof opts.useYarn === 'boolean'
62
- ? opts.useYarn
63
- : await hasYarn(root);
64
- const logLevel = opts.verbose ? 'trace' : 'error';
65
- const command = useYarn ? 'yarnpkg' : 'npm';
66
- const args = useYarn
67
- ? ['add', ...(opts.dev ? ['-D'] : []), '--exact', '--cwd', root, `@wdio/cli${npmTag}`]
68
- : ['install', opts.dev ? '--save-dev' : '--save', '--loglevel', logLevel, `@wdio/cli${npmTag}`];
69
- await runProgram(command, args, { cwd: root, stdio: 'ignore' });
62
+ const pm = await detect({ cwd: root });
63
+ const args = [INSTALL_COMMAND[pm]];
64
+ if (pm === 'yarn') {
65
+ args.push('--exact', '--cwd', root);
66
+ }
67
+ if (opts.dev) {
68
+ args.push(DEV_FLAG[pm]);
69
+ }
70
+ args.push(`@wdio/cli${npmTag}`);
71
+ await runProgram(pm, args, { cwd: root, stdio: 'ignore' });
70
72
  console.log(chalk.green.bold('✔ Success!'));
71
73
  return runProgram('npx', [
72
74
  WDIO_COMMAND,
73
75
  'config',
74
- ...(useYarn ? ['--yarn'] : []),
75
76
  ...(opts.yes ? ['--yes'] : [])
76
77
  ], { cwd: root });
77
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-wdio",
3
- "version": "8.2.4",
3
+ "version": "8.3.0",
4
4
  "description": "Install and setup a WebdriverIO project with all its dependencies in a single run",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "license": "MIT",
@@ -39,25 +39,25 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/cross-spawn": "^6.0.2",
42
- "@types/node": "^20.3.1",
42
+ "@types/node": "^20.4.2",
43
43
  "@types/semver": "^7.5.0",
44
- "@typescript-eslint/eslint-plugin": "^5.59.11",
45
- "@typescript-eslint/parser": "^5.59.11",
46
- "@vitest/coverage-v8": "^0.32.0",
47
- "eslint": "^8.42.0",
44
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
45
+ "@typescript-eslint/parser": "^6.0.0",
46
+ "@vitest/coverage-v8": "^0.34.1",
47
+ "eslint": "^8.45.0",
48
48
  "eslint-plugin-import": "^2.27.5",
49
- "eslint-plugin-unicorn": "^47.0.0",
49
+ "eslint-plugin-unicorn": "^48.0.0",
50
50
  "npm-run-all": "^4.1.5",
51
- "release-it": "^15.11.0",
52
- "typescript": "^5.1.3",
53
- "vitest": "^0.32.0"
51
+ "release-it": "^16.1.2",
52
+ "typescript": "^5.1.6",
53
+ "vitest": "^0.34.1"
54
54
  },
55
55
  "dependencies": {
56
- "chalk": "^5.2.0",
57
- "commander": "^10.0.1",
56
+ "chalk": "^5.3.0",
57
+ "commander": "^11.0.0",
58
58
  "cross-spawn": "^7.0.3",
59
- "has-yarn": "^3.0.0",
60
- "read-pkg-up": "^9.1.0",
61
- "semver": "^7.5.1"
59
+ "detect-package-manager": "^3.0.1",
60
+ "read-pkg-up": "^10.0.0",
61
+ "semver": "^7.5.4"
62
62
  }
63
63
  }