create-wdio 8.4.0 → 8.4.2

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.
@@ -1,4 +1,5 @@
1
1
  import { vi } from 'vitest'
2
+ import * as path from 'node:path'
2
3
 
3
4
  const command: any = {}
4
5
  command.name = vi.fn().mockReturnValue(command)
@@ -6,7 +7,7 @@ command.version = vi.fn().mockReturnValue(command)
6
7
  command.usage = vi.fn().mockReturnValue(command)
7
8
  command.arguments = vi.fn().mockReturnValue(command)
8
9
  command.action = vi.fn((cb) => {
9
- cb('someProjectName')
10
+ cb(`${path.sep}foo${path.sep}bar${path.sep}someProjectName`)
10
11
  return command
11
12
  })
12
13
  command.option = vi.fn().mockReturnValue(command)
@@ -55,6 +55,18 @@ export const INSTALL_COMMAND = {
55
55
  yarn: 'add',
56
56
  bun: 'install'
57
57
  };
58
+ export const EXECUTER = {
59
+ npm: 'npx',
60
+ pnpm: 'pnpm',
61
+ yarn: 'yarn',
62
+ bun: 'bunx'
63
+ };
64
+ export const EXECUTE_COMMAND = {
65
+ npm: '',
66
+ pnpm: 'exec',
67
+ yarn: 'exec',
68
+ bun: ''
69
+ };
58
70
  export const DEV_FLAG = {
59
71
  npm: '--save-dev',
60
72
  pnpm: '--save-dev',
package/build/index.js CHANGED
@@ -6,7 +6,7 @@ import semver from 'semver';
6
6
  import { Command } from 'commander';
7
7
  import { resolve } from 'import-meta-resolve';
8
8
  import { runProgram, getPackageVersion } from './utils.js';
9
- import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG, INSTALL_COMMAND, DEV_FLAG, PMs } from './constants.js';
9
+ import { ASCII_ROBOT, PROGRAM_TITLE, UNSUPPORTED_NODE_VERSION, DEFAULT_NPM_TAG, INSTALL_COMMAND, DEV_FLAG, PMs, EXECUTER, EXECUTE_COMMAND } from './constants.js';
10
10
  import { execSync } from 'node:child_process';
11
11
  const WDIO_COMMAND = 'wdio';
12
12
  let projectDir;
@@ -46,15 +46,17 @@ export async function createWebdriverIO(opts) {
46
46
  * find package manager that was used to create project
47
47
  */
48
48
  const pm = PMs.find((pm) => (
49
- // for pnpm check for "~/Library/pnpm/store/v3/..."
49
+ // for pnpm check "~/Library/pnpm/store/v3/..."
50
+ // for NPM check "~/.npm/npx/..."
51
+ // for Yarn check "~/.yarn/bin/create-wdio"
52
+ // for Bun check "~/.bun/bin/create-wdio"
50
53
  process.argv[1].includes(`${path.sep}${pm}${path.sep}`) ||
51
- // for NPM and Yarn check for "~/.npm/npx/..." or "~/.yarn/bin/create-wdio"
52
54
  process.argv[1].includes(`${path.sep}.${pm}${path.sep}`))) || 'npm';
53
55
  const hasPackageJson = await fs.access(path.resolve(root, 'package.json')).then(() => true).catch(() => false);
54
56
  if (!hasPackageJson) {
55
57
  await fs.mkdir(root, { recursive: true });
56
58
  await fs.writeFile(path.resolve(root, 'package.json'), JSON.stringify({
57
- name: root.replace(/\/$/, '').split('/').pop(),
59
+ name: root.substring(root.lastIndexOf(path.sep) + 1),
58
60
  type: 'module'
59
61
  }, null, 2));
60
62
  }
@@ -72,11 +74,12 @@ export async function createWebdriverIO(opts) {
72
74
  await runProgram(pm, args, { cwd: root, stdio: 'ignore' });
73
75
  console.log(chalk.green.bold('✔ Success!'));
74
76
  }
75
- return runProgram(pm === 'npm' ? 'npx' : pm, [
76
- `${pm === 'npm' ? '' : 'run '}${WDIO_COMMAND}`,
77
+ return runProgram(EXECUTER[pm], [
78
+ EXECUTE_COMMAND[pm],
79
+ WDIO_COMMAND,
77
80
  'config',
78
81
  ...(opts.yes ? ['--yes'] : [])
79
- ], { cwd: root });
82
+ ].filter(i => !!i), { cwd: root });
80
83
  }
81
84
  async function isCLIInstalled(path) {
82
85
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-wdio",
3
- "version": "8.4.0",
3
+ "version": "8.4.2",
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",