From c6bb79a67d2f69442da3d5fb50893d2de0a3a47f Mon Sep 17 00:00:00 2001 From: AgentEnder Date: Wed, 7 Aug 2024 13:05:25 -0400 Subject: [PATCH 1/2] fix(misc): avoid terminal popups when checking package manager version --- packages/nx/src/utils/package-manager.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/nx/src/utils/package-manager.ts b/packages/nx/src/utils/package-manager.ts index 371a50083fe39..557d42eff5ed7 100644 --- a/packages/nx/src/utils/package-manager.ts +++ b/packages/nx/src/utils/package-manager.ts @@ -203,6 +203,7 @@ export function getPackageManagerVersion( version = execSync(`${packageManager} --version`, { cwd, encoding: 'utf-8', + windowsHide: true, }).trim(); } catch { if (existsSync(join(cwd, 'package.json'))) { @@ -411,7 +412,10 @@ export async function resolvePackageVersionUsingInstallation( try { const pmc = getPackageManagerCommand(); - await execAsync(`${pmc.add} ${packageName}@${version}`, { cwd: dir }); + await execAsync(`${pmc.add} ${packageName}@${version}`, { + cwd: dir, + windowsHide: true, + }); const { packageJson } = readModulePackageJson(packageName, [dir]); @@ -441,7 +445,9 @@ export async function packageRegistryView( pm = 'npm'; } - const { stdout } = await execAsync(`${pm} view ${pkg}@${version} ${args}`); + const { stdout } = await execAsync(`${pm} view ${pkg}@${version} ${args}`, { + windowsHide: true, + }); return stdout.toString().trim(); } @@ -464,7 +470,10 @@ export async function packageRegistryPack( pm = 'npm'; } - const { stdout } = await execAsync(`${pm} pack ${pkg}@${version}`, { cwd }); + const { stdout } = await execAsync(`${pm} pack ${pkg}@${version}`, { + cwd, + windowsHide: true, + }); const tarballPath = stdout.trim(); return { tarballPath }; From bed40291ebe03c24febb3eb8ac504ddcc59f3487 Mon Sep 17 00:00:00 2001 From: AgentEnder Date: Wed, 7 Aug 2024 13:14:03 -0400 Subject: [PATCH 2/2] fix(misc): avoid terminal popups during create-nx-workspace --- packages/create-nx-workspace/src/utils/git/default-base.ts | 5 +++-- packages/create-nx-workspace/src/utils/git/git.ts | 4 +++- packages/create-nx-workspace/src/utils/nx/ab-testing.ts | 5 ++++- packages/create-nx-workspace/src/utils/nx/show-nx-warning.ts | 1 + packages/create-nx-workspace/src/utils/package-manager.ts | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/create-nx-workspace/src/utils/git/default-base.ts b/packages/create-nx-workspace/src/utils/git/default-base.ts index 30ba50f22aa1a..16cefb9c77f5d 100644 --- a/packages/create-nx-workspace/src/utils/git/default-base.ts +++ b/packages/create-nx-workspace/src/utils/git/default-base.ts @@ -8,8 +8,9 @@ export function deduceDefaultBase(): string { const nxDefaultBase = 'main'; try { return ( - execSync('git config --get init.defaultBranch').toString().trim() || - nxDefaultBase + execSync('git config --get init.defaultBranch', { windowsHide: true }) + .toString() + .trim() || nxDefaultBase ); } catch { return nxDefaultBase; diff --git a/packages/create-nx-workspace/src/utils/git/git.ts b/packages/create-nx-workspace/src/utils/git/git.ts index ad05496ac3eb9..c1b913743f3a9 100644 --- a/packages/create-nx-workspace/src/utils/git/git.ts +++ b/packages/create-nx-workspace/src/utils/git/git.ts @@ -4,7 +4,9 @@ import { output } from '../output'; export function checkGitVersion(): string | null | undefined { try { - let gitVersionOutput = execSync('git --version').toString().trim(); + let gitVersionOutput = execSync('git --version', { windowsHide: true }) + .toString() + .trim(); return gitVersionOutput.match(/[0-9]+\.[0-9]+\.+[0-9]+/)?.[0]; } catch { return null; diff --git a/packages/create-nx-workspace/src/utils/nx/ab-testing.ts b/packages/create-nx-workspace/src/utils/nx/ab-testing.ts index 9b1e8bee7cb11..8ed999de2881d 100644 --- a/packages/create-nx-workspace/src/utils/nx/ab-testing.ts +++ b/packages/create-nx-workspace/src/utils/nx/ab-testing.ts @@ -137,7 +137,10 @@ function shouldRecordStats(): boolean { return true; } try { - const stdout = execSync(pmc.getRegistryUrl, { encoding: 'utf-8' }); + const stdout = execSync(pmc.getRegistryUrl, { + encoding: 'utf-8', + windowsHide: true, + }); const url = new URL(stdout.trim()); // don't record stats when testing locally diff --git a/packages/create-nx-workspace/src/utils/nx/show-nx-warning.ts b/packages/create-nx-workspace/src/utils/nx/show-nx-warning.ts index 039e1dc44795d..7ad3d9cffa022 100644 --- a/packages/create-nx-workspace/src/utils/nx/show-nx-warning.ts +++ b/packages/create-nx-workspace/src/utils/nx/show-nx-warning.ts @@ -9,6 +9,7 @@ export function showNxWarning(workspaceName: string) { execSync('nx --version', { cwd: pathToRunNxCommand, stdio: ['ignore', 'ignore', 'ignore'], + windowsHide: true, }); } catch (e) { // no nx found diff --git a/packages/create-nx-workspace/src/utils/package-manager.ts b/packages/create-nx-workspace/src/utils/package-manager.ts index bb8394d26f6bb..da2fef162aaea 100644 --- a/packages/create-nx-workspace/src/utils/package-manager.ts +++ b/packages/create-nx-workspace/src/utils/package-manager.ts @@ -123,6 +123,7 @@ export function getPackageManagerVersion( const version = execSync(`${packageManager} --version`, { cwd, encoding: 'utf-8', + windowsHide: true, }).trim(); pmVersionCache.set(packageManager, version); return version;