Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(@wdio/cli): use proper package manager when asking if to install #12089

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/wdio-cli/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getDefaultFiles,
convertPackageHashToObject,
getProjectRoot,
detectPackageManager,
} from './utils.js'
import type { Questionnair } from './types.js'

Expand All @@ -23,6 +24,7 @@ export const CONFIG_HELPER_INTRO = `
===============================
`

export const PMs = ['npm', 'yarn', 'pnpm', 'bun'] as const
export const SUPPORTED_CONFIG_FILE_EXTENSION = ['js', 'ts', 'mjs', 'mts', 'cjs', 'cts']
export const configHelperSuccessMessage = ({ projectRootDir, runScript, extraInfo = '' }: { projectRootDir: string, runScript: string, extraInfo: string }) => `
🤖 Successfully setup project at ${ projectRootDir } 🎉
Expand Down Expand Up @@ -667,7 +669,7 @@ export const QUESTIONNAIRE = [{
}, {
type: 'confirm',
name: 'npmInstall',
message: 'Do you want me to run `npm install`',
message: () => `Do you want me to run \`${detectPackageManager()} install\``,
default: true
}]

Expand Down
3 changes: 2 additions & 1 deletion packages/wdio-cli/src/install.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { execa } from 'execa'
import { detectPackageManager, type PM } from './utils.js'
import { detectPackageManager } from './utils.js'
import type { PM } from './types.js'

const installCommand: Record<PM, string> = {
npm: 'install',
Expand Down
4 changes: 3 additions & 1 deletion packages/wdio-cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Options, Reporters } from '@wdio/types'
import type { NormalizedPackageJson } from 'read-pkg-up'
import type { BackendChoice, RegionOptions, CompilerOptions, ElectronBuildToolChoice } from './constants.js'
import type { BackendChoice, RegionOptions, CompilerOptions, ElectronBuildToolChoice, PMs } from './constants.js'

export type PM = typeof PMs[number]

export interface Questionnair {
runner: string
Expand Down
3 changes: 1 addition & 2 deletions packages/wdio-cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
TESTING_LIBRARY_PACKAGES,
COMMUNITY_PACKAGES_WITH_TS_SUPPORT,
usesSerenity,
PMs,
} from './constants.js'
import type {
OnCompleteResult,
Expand Down Expand Up @@ -815,8 +816,6 @@ export async function npmInstall(parsedAnswers: ParsedAnswers, npmTag: string) {
}
}

export const PMs = ['npm', 'yarn', 'pnpm', 'bun'] as const
export type PM = typeof PMs[number]
/**
* detect the package manager that was used
*/
Expand Down