From c6be2b6ebc68c9951845c1d36916651e2ec6f08d Mon Sep 17 00:00:00 2001 From: gurisko Date: Sun, 24 Mar 2024 14:48:33 +0100 Subject: [PATCH] fix: do not hardcode npx in shadcn-ui:add executor (fixes #245) --- packages/core/src/utils/exec-package-manager-command.ts | 6 +++--- packages/e2e-runner/src/executors/run/utils/nx-target.ts | 4 ++-- packages/shadcn-ui/src/executors/add/add.impl.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/src/utils/exec-package-manager-command.ts b/packages/core/src/utils/exec-package-manager-command.ts index 9cbf143c..029a27f1 100644 --- a/packages/core/src/utils/exec-package-manager-command.ts +++ b/packages/core/src/utils/exec-package-manager-command.ts @@ -3,13 +3,13 @@ import { detectPackageManager, getPackageManagerCommand } from 'nx/src/utils/pac import { buildCommand } from './build-command' import { execCommand, Options } from './exec' -export function getPackageManagerExecCommand() { - return getPackageManagerCommand(detectPackageManager()).exec +export function getPackageManagerDlxCommand() { + return getPackageManagerCommand(detectPackageManager()).dlx } export function execPackageManagerCommand(command: string, options?: Options) { return execCommand(buildCommand([ - process.env.NX_EXTEND_COMMAND_USE_NPX ? 'npx' : getPackageManagerExecCommand(), + process.env.NX_EXTEND_COMMAND_USE_NPX ? 'npx' : getPackageManagerDlxCommand(), command ]), options) } diff --git a/packages/e2e-runner/src/executors/run/utils/nx-target.ts b/packages/e2e-runner/src/executors/run/utils/nx-target.ts index 096a5ee1..793f2850 100644 --- a/packages/e2e-runner/src/executors/run/utils/nx-target.ts +++ b/packages/e2e-runner/src/executors/run/utils/nx-target.ts @@ -1,6 +1,6 @@ import { logger, parseTargetString } from '@nx/devkit' import { readCachedProjectGraph } from '@nx/workspace/src/core/project-graph' -import { getPackageManagerExecCommand, USE_VERBOSE_LOGGING } from '@nx-extend/core' +import { getPackageManagerDlxCommand, USE_VERBOSE_LOGGING } from '@nx-extend/core' import * as childProcess from 'child_process' import { isApiLive } from './is-api-live' @@ -172,7 +172,7 @@ function launchProcess( const shouldLog = options.logging ?? USE_VERBOSE_LOGGING const spawnedProcess = childProcess.spawn( - `${getPackageManagerExecCommand()} nx ${target} ${project} ${ + `${getPackageManagerDlxCommand()} nx ${target} ${project} ${ configuration ? `--configuration=${configuration}` : '' }`, [], diff --git a/packages/shadcn-ui/src/executors/add/add.impl.ts b/packages/shadcn-ui/src/executors/add/add.impl.ts index 97fb1619..c3f7014d 100644 --- a/packages/shadcn-ui/src/executors/add/add.impl.ts +++ b/packages/shadcn-ui/src/executors/add/add.impl.ts @@ -1,5 +1,5 @@ import { ExecutorContext } from '@nx/devkit' -import { buildCommand, execCommand } from '@nx-extend/core' +import { buildCommand, execPackageManagerCommand } from '@nx-extend/core' export interface ExecutorSchema { component: string @@ -12,8 +12,8 @@ export async function addExecutor( ): Promise<{ success: boolean }> { const { root } = context.workspace.projects[context.projectName] - return execCommand(buildCommand([ - 'npx shadcn-ui@latest add', + return execPackageManagerCommand(buildCommand([ + 'shadcn-ui@latest add', options.component, options.overwrite && '--overwrite', '--path=src',