From b73f1e0e0002c55fc0bacaa1557140adb9eec8de Mon Sep 17 00:00:00 2001 From: MaxKless <34165455+MaxKless@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:31:22 +0200 Subject: [PATCH] fix(core): set windowsHide: true wherever possible (#28073) ## Current Behavior ## Expected Behavior ## Related Issue(s) Fixes # --- e2e/utils/command-utils.ts | 1 + e2e/utils/global-setup.ts | 16 ++++--- .../src/utils/child-process-utils.ts | 2 +- .../create-nx-workspace/src/utils/git/git.ts | 1 + packages/cypress/plugins/cypress-preset.ts | 5 ++- .../devkit/src/tasks/install-packages-task.ts | 1 + packages/devkit/src/utils/package-json.ts | 2 + packages/expo/src/utils/pod-install-task.ts | 2 + packages/expo/src/utils/resolve-eas.ts | 4 +- .../js/src/executors/node/lib/kill-tree.ts | 34 ++++++++------ .../release-publish/release-publish.impl.ts | 3 ++ .../src/executors/verdaccio/verdaccio.impl.ts | 37 ++++++++++------ .../release-version/release-version.ts | 3 ++ .../release-version/utils/update-lock-file.ts | 1 + .../generators/setup-verdaccio/generator.ts | 7 ++- .../src/plugins/jest/start-local-registry.ts | 9 +++- packages/js/src/utils/npm-config.ts | 2 +- packages/js/src/utils/swc/compile-swc.ts | 2 + .../src/generators/application/application.ts | 6 ++- packages/nx/bin/nx.ts | 12 ++++- .../activate-powerpack/activate-powerpack.ts | 5 ++- packages/nx/src/command-line/add/add.ts | 30 ++++++++----- .../nx/src/command-line/connect/view-logs.ts | 1 + packages/nx/src/command-line/exec/exec.ts | 8 +++- packages/nx/src/command-line/format/format.ts | 4 +- packages/nx/src/command-line/graph/graph.ts | 1 + .../angular/integrated-workspace.ts | 6 ++- .../angular/legacy-angular-versions.ts | 7 ++- .../implementation/dot-nx/add-nx-scripts.ts | 4 +- .../init/implementation/dot-nx/nxw.ts | 1 + .../react/check-for-uncommitted-changes.ts | 4 +- .../init/implementation/react/index.ts | 22 +++++++--- .../command-line/init/implementation/utils.ts | 6 ++- packages/nx/src/command-line/init/init-v1.ts | 1 + packages/nx/src/command-line/init/init-v2.ts | 1 + .../command-line/migrate/command-object.ts | 4 ++ .../nx/src/command-line/migrate/migrate.ts | 2 +- .../release/config/version-plans.ts | 3 ++ .../release/utils/exec-command.ts | 1 + .../src/command-line/release/utils/github.ts | 1 + .../release/utils/launch-editor.ts | 7 ++- .../nx/src/command-line/release/version.ts | 1 + packages/nx/src/command-line/run/run.ts | 1 + packages/nx/src/command-line/watch/watch.ts | 1 + .../src/daemon/client/generate-help-output.ts | 1 + .../run-commands/run-commands.impl.spec.ts | 6 +++ .../run-commands/run-commands.impl.ts | 1 + .../executors/run-script/run-script.impl.ts | 1 + .../connect-to-nx-cloud.ts | 2 +- packages/nx/src/project-graph/file-utils.ts | 1 + packages/nx/src/tasks-runner/cache.ts | 1 + packages/nx/src/utils/ab-testing.ts | 5 ++- packages/nx/src/utils/child-process.ts | 2 + packages/nx/src/utils/command-line-utils.ts | 8 +++- packages/nx/src/utils/default-base.ts | 7 ++- .../nx/src/utils/git-utils.index-filter.ts | 3 +- packages/nx/src/utils/git-utils.spec.ts | 30 ++++++++++--- .../nx/src/utils/git-utils.tree-filter.ts | 4 +- packages/nx/src/utils/git-utils.ts | 4 ++ .../executors/playwright/playwright.impl.ts | 1 + .../generators/configuration/configuration.ts | 5 ++- .../src/utils/testing-utils/async-commands.ts | 1 + .../src/utils/testing-utils/commands.ts | 1 + .../src/utils/testing-utils/nx-project.ts | 2 + .../src/utils/pod-install-task.ts | 2 + .../migrate-7/calling-storybook-cli.ts | 2 + .../migrate-8/calling-storybook-cli.ts | 2 + .../nx-vite-build-coordination.plugin.ts | 4 +- packages/vite/src/utils/executor-utils.ts | 1 + .../webpack-nx-build-coordination-plugin.ts | 4 +- .../src/generators/new/generate-preset.ts | 1 + packages/workspace/src/generators/new/new.ts | 1 + .../utils/get-npm-package-version.ts | 6 ++- .../workspace/src/utilities/default-base.ts | 7 ++- .../angular-support-upgrades/init-upgrade.ts | 13 +++++- .../generate-devkit-documentation.ts | 1 + scripts/documentation/generators/main.ts | 9 +++- scripts/generate-graph-environment.ts | 4 +- scripts/generate-graph.ts | 2 +- scripts/nx-release.ts | 44 ++++++++++++++++--- scripts/release-docs.ts | 12 +++-- 81 files changed, 366 insertions(+), 107 deletions(-) diff --git a/e2e/utils/command-utils.ts b/e2e/utils/command-utils.ts index 1d2cb61822742..59bb78f298549 100644 --- a/e2e/utils/command-utils.ts +++ b/e2e/utils/command-utils.ts @@ -273,6 +273,7 @@ export function runCommandUntil( ...opts.env, FORCE_COLOR: 'false', }, + windowsHide: true, }); return new Promise((res, rej) => { let output = ''; diff --git a/e2e/utils/global-setup.ts b/e2e/utils/global-setup.ts index d95882dafb315..f88b62f13a9a7 100644 --- a/e2e/utils/global-setup.ts +++ b/e2e/utils/global-setup.ts @@ -62,11 +62,17 @@ export default async function (globalConfig: Config.ConfigGlobals) { function getPublishedVersion(): Promise { return new Promise((resolve) => { // Resolve the published nx version from verdaccio - exec('npm view nx@latest version', (error, stdout, stderr) => { - if (error) { - return resolve(undefined); + exec( + 'npm view nx@latest version', + { + windowsHide: true, + }, + (error, stdout, stderr) => { + if (error) { + return resolve(undefined); + } + return resolve(stdout.trim()); } - return resolve(stdout.trim()); - }); + ); }); } diff --git a/packages/create-nx-workspace/src/utils/child-process-utils.ts b/packages/create-nx-workspace/src/utils/child-process-utils.ts index bd09075c934c3..3dcf4b1cbfdcd 100644 --- a/packages/create-nx-workspace/src/utils/child-process-utils.ts +++ b/packages/create-nx-workspace/src/utils/child-process-utils.ts @@ -36,7 +36,7 @@ export function execAndWait(command: string, cwd: string) { return new Promise<{ code: number; stdout: string }>((res, rej) => { exec( command, - { cwd, env: { ...process.env, NX_DAEMON: 'false' } }, + { cwd, env: { ...process.env, NX_DAEMON: 'false' }, windowsHide: true }, (error, stdout, stderr) => { if (error) { const logFile = join(cwd, 'error.log'); diff --git a/packages/create-nx-workspace/src/utils/git/git.ts b/packages/create-nx-workspace/src/utils/git/git.ts index c1b913743f3a9..4138dc72aced8 100644 --- a/packages/create-nx-workspace/src/utils/git/git.ts +++ b/packages/create-nx-workspace/src/utils/git/git.ts @@ -43,6 +43,7 @@ export async function initializeGitRepo( } : {}), }, + windowsHide: true, }; return new Promise((resolve, reject) => { spawn('git', args, spawnOptions).on('close', (code) => { diff --git a/packages/cypress/plugins/cypress-preset.ts b/packages/cypress/plugins/cypress-preset.ts index ea763eaa48152..aec9a651b8941 100644 --- a/packages/cypress/plugins/cypress-preset.ts +++ b/packages/cypress/plugins/cypress-preset.ts @@ -78,12 +78,15 @@ function startWebServer(webServerCommand: string) { // Windows is fine so we leave it attached to this process detached: process.platform !== 'win32', stdio: 'inherit', + windowsHide: true, }); return () => { if (process.platform === 'win32') { try { - execSync('taskkill /pid ' + serverProcess.pid + ' /T /F'); + execSync('taskkill /pid ' + serverProcess.pid + ' /T /F', { + windowsHide: true, + }); } catch (e) { if (process.env.NX_VERBOSE_LOGGING === 'true') { console.error(e); diff --git a/packages/devkit/src/tasks/install-packages-task.ts b/packages/devkit/src/tasks/install-packages-task.ts index b43726b7db4af..93d8921d84a2d 100644 --- a/packages/devkit/src/tasks/install-packages-task.ts +++ b/packages/devkit/src/tasks/install-packages-task.ts @@ -43,6 +43,7 @@ export function installPackagesTask( const execSyncOptions: ExecSyncOptions = { cwd: join(tree.root, cwd), stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit', + windowsHide: true, }; // ensure local registry from process is not interfering with the install // when we start the process from temp folder the local registry would override the custom registry diff --git a/packages/devkit/src/utils/package-json.ts b/packages/devkit/src/utils/package-json.ts index ac0fee718b477..896c3f2c995cc 100644 --- a/packages/devkit/src/utils/package-json.ts +++ b/packages/devkit/src/utils/package-json.ts @@ -497,6 +497,7 @@ export function ensurePackage( execSync(preInstallCommand, { cwd: tempDir, stdio: isVerbose ? 'inherit' : 'ignore', + windowsHide: true, }); } let addCommand = getPackageManagerCommand(packageManager).addDev; @@ -507,6 +508,7 @@ export function ensurePackage( execSync(`${addCommand} ${pkg}@${requiredVersion}`, { cwd: tempDir, stdio: isVerbose ? 'inherit' : 'ignore', + windowsHide: true, }); addToNodePath(join(workspaceRoot, 'node_modules')); diff --git a/packages/expo/src/utils/pod-install-task.ts b/packages/expo/src/utils/pod-install-task.ts index 3612c66562d32..7f36566b3d7b0 100644 --- a/packages/expo/src/utils/pod-install-task.ts +++ b/packages/expo/src/utils/pod-install-task.ts @@ -68,6 +68,7 @@ export function podInstall( execSync('touch .xcode.env', { cwd: iosDirectory, stdio: 'inherit', + windowsHide: true, }); } execSync( @@ -77,6 +78,7 @@ export function podInstall( { cwd: iosDirectory, stdio: 'inherit', + windowsHide: true, } ); } catch (e) { diff --git a/packages/expo/src/utils/resolve-eas.ts b/packages/expo/src/utils/resolve-eas.ts index 7058d875ffac6..81164d7a2f4c1 100644 --- a/packages/expo/src/utils/resolve-eas.ts +++ b/packages/expo/src/utils/resolve-eas.ts @@ -11,13 +11,13 @@ export function resolveEas(workspaceRoot: string): string { let npmGlobalPath: string, yarnGlobalPath: string; try { - npmGlobalPath = execSync('npm root -g') + npmGlobalPath = execSync('npm root -g', { windowsHide: true }) ?.toString() ?.trim() ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes } catch {} try { - yarnGlobalPath = execSync('yarn global dir') + yarnGlobalPath = execSync('yarn global dir', { windowsHide: true }) ?.toString() ?.trim() ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes diff --git a/packages/js/src/executors/node/lib/kill-tree.ts b/packages/js/src/executors/node/lib/kill-tree.ts index 2a28254e6c13d..adeb74e8021d5 100644 --- a/packages/js/src/executors/node/lib/kill-tree.ts +++ b/packages/js/src/executors/node/lib/kill-tree.ts @@ -18,11 +18,17 @@ export async function killTree(pid: number, signal: NodeJS.Signals) { switch (process.platform) { case 'win32': - exec('taskkill /pid ' + pid + ' /T /F', (error) => { - // Ignore Fatal errors (128) because it might be due to the process already being killed. - // On Linux/Mac we can check ESRCH (no such process), but on Windows we can't. - callback(error?.code !== 128 ? error : null); - }); + exec( + 'taskkill /pid ' + pid + ' /T /F', + { + windowsHide: true, + }, + (error) => { + // Ignore Fatal errors (128) because it might be due to the process already being killed. + // On Linux/Mac we can check ESRCH (no such process), but on Windows we can't. + callback(error?.code !== 128 ? error : null); + } + ); break; case 'darwin': buildProcessTree( @@ -30,7 +36,9 @@ export async function killTree(pid: number, signal: NodeJS.Signals) { tree, pidsToProcess, function (parentPid) { - return spawn('pgrep', ['-P', parentPid]); + return spawn('pgrep', ['-P', parentPid], { + windowsHide: true, + }); }, function () { killAll(tree, signal, callback); @@ -43,13 +51,13 @@ export async function killTree(pid: number, signal: NodeJS.Signals) { tree, pidsToProcess, function (parentPid) { - return spawn('ps', [ - '-o', - 'pid', - '--no-headers', - '--ppid', - parentPid, - ]); + return spawn( + 'ps', + ['-o', 'pid', '--no-headers', '--ppid', parentPid], + { + windowsHide: true, + } + ); }, function () { killAll(tree, signal, callback); diff --git a/packages/js/src/executors/release-publish/release-publish.impl.ts b/packages/js/src/executors/release-publish/release-publish.impl.ts index b19a5ae70fd00..d510fe0fb1108 100644 --- a/packages/js/src/executors/release-publish/release-publish.impl.ts +++ b/packages/js/src/executors/release-publish/release-publish.impl.ts @@ -128,6 +128,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio env: processEnv(true), cwd: context.root, stdio: ['ignore', 'pipe', 'pipe'], + windowsHide: true, }); const resultJson = JSON.parse(result.toString()); @@ -153,6 +154,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio env: processEnv(true), cwd: context.root, stdio: 'ignore', + windowsHide: true, }); console.log( `Added the dist-tag ${tag} to v${currentVersion} for registry ${registry}.\n` @@ -267,6 +269,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio env: processEnv(true), cwd: context.root, stdio: ['ignore', 'pipe', 'pipe'], + windowsHide: true, }); /** diff --git a/packages/js/src/executors/verdaccio/verdaccio.impl.ts b/packages/js/src/executors/verdaccio/verdaccio.impl.ts index 9f1d4b6b8f744..1af6e7887b3dc 100644 --- a/packages/js/src/executors/verdaccio/verdaccio.impl.ts +++ b/packages/js/src/executors/verdaccio/verdaccio.impl.ts @@ -136,7 +136,7 @@ function createVerdaccioOptions( function setupNpm(options: VerdaccioExecutorSchema) { try { - execSync('npm --version', { env }); + execSync('npm --version', { env, windowsHide: true }); } catch (e) { return () => {}; } @@ -151,7 +151,7 @@ function setupNpm(options: VerdaccioExecutorSchema) { npmRegistryPaths.push( execSync( `npm config get ${registryName} --location ${options.location}`, - { env } + { env, windowsHide: true } ) ?.toString() ?.trim() @@ -159,12 +159,12 @@ function setupNpm(options: VerdaccioExecutorSchema) { ); execSync( `npm config set ${registryName} http://localhost:${options.port}/ --location ${options.location}`, - { env } + { env, windowsHide: true } ); execSync( `npm config set //localhost:${options.port}/:_authToken="secretVerdaccioToken" --location ${options.location}`, - { env } + { env, windowsHide: true } ); logger.info( @@ -181,7 +181,7 @@ function setupNpm(options: VerdaccioExecutorSchema) { try { const currentNpmRegistryPath = execSync( `npm config get registry --location ${options.location}`, - { env } + { env, windowsHide: true } ) ?.toString() ?.trim() @@ -194,7 +194,7 @@ function setupNpm(options: VerdaccioExecutorSchema) { ) { execSync( `npm config set ${registryName} ${npmRegistryPaths[index]} --location ${options.location}`, - { env } + { env, windowsHide: true } ); logger.info( `Reset npm ${registryName} to ${npmRegistryPaths[index]}` @@ -204,6 +204,7 @@ function setupNpm(options: VerdaccioExecutorSchema) { `npm config delete ${registryName} --location ${options.location}`, { env, + windowsHide: true, } ); logger.info('Cleared custom npm registry'); @@ -211,7 +212,7 @@ function setupNpm(options: VerdaccioExecutorSchema) { }); execSync( `npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`, - { env } + { env, windowsHide: true } ); } catch (e) { throw new Error(`Failed to reset npm registry: ${e.message}`); @@ -230,6 +231,7 @@ function getYarnUnsafeHttpWhitelist(isYarnV1: boolean) { JSON.parse( execSync(`yarn config get unsafeHttpWhitelist --json`, { env, + windowsHide: true, }).toString() ) ) @@ -245,13 +247,13 @@ function setYarnUnsafeHttpWhitelist( `yarn config set unsafeHttpWhitelist --json '${JSON.stringify( Array.from(currentWhitelist) )}'` + (options.location === 'user' ? ' --home' : ''), - { env } + { env, windowsHide: true } ); } else { execSync( `yarn config unset unsafeHttpWhitelist` + (options.location === 'user' ? ' --home' : ''), - { env } + { env, windowsHide: true } ); } } @@ -263,7 +265,9 @@ function setupYarn(options: VerdaccioExecutorSchema) { try { isYarnV1 = - major(execSync('yarn --version', { env }).toString().trim()) === 1; + major( + execSync('yarn --version', { env, windowsHide: true }).toString().trim() + ) === 1; } catch { // This would fail if yarn is not installed which is okay return () => {}; @@ -277,6 +281,7 @@ function setupYarn(options: VerdaccioExecutorSchema) { yarnRegistryPaths.push( execSync(`yarn config get ${scopeName}${registryConfigName}`, { env, + windowsHide: true, }) ?.toString() ?.trim() @@ -286,7 +291,7 @@ function setupYarn(options: VerdaccioExecutorSchema) { execSync( `yarn config set ${scopeName}${registryConfigName} http://localhost:${options.port}/` + (options.location === 'user' ? ' --home' : ''), - { env } + { env, windowsHide: true } ); logger.info( @@ -313,7 +318,7 @@ function setupYarn(options: VerdaccioExecutorSchema) { try { const currentYarnRegistryPath = execSync( `yarn config get ${registryConfigName}`, - { env } + { env, windowsHide: true } ) ?.toString() ?.trim() @@ -331,7 +336,11 @@ function setupYarn(options: VerdaccioExecutorSchema) { execSync( `yarn config set ${registryName} ${yarnRegistryPaths[index]}` + (options.location === 'user' ? ' --home' : ''), - { env } + { + env, + + windowsHide: true, + } ); logger.info( `Reset yarn ${registryName} to ${yarnRegistryPaths[index]}` @@ -340,7 +349,7 @@ function setupYarn(options: VerdaccioExecutorSchema) { execSync( `yarn config ${isYarnV1 ? 'delete' : 'unset'} ${registryName}` + (options.location === 'user' ? ' --home' : ''), - { env } + { env, windowsHide: true } ); logger.info(`Cleared custom yarn ${registryConfigName}`); } diff --git a/packages/js/src/generators/release-version/release-version.ts b/packages/js/src/generators/release-version/release-version.ts index a870bf4df2f6b..4e3b366cf378c 100644 --- a/packages/js/src/generators/release-version/release-version.ts +++ b/packages/js/src/generators/release-version/release-version.ts @@ -211,6 +211,9 @@ To fix this you will either need to add a package.json file at that location, or currentVersion = await new Promise((resolve, reject) => { exec( `npm view ${packageName} version --"${registryConfigKey}=${registry}" --tag=${tag}`, + { + windowsHide: true, + }, (error, stdout, stderr) => { if (error) { return reject(error); diff --git a/packages/js/src/generators/release-version/utils/update-lock-file.ts b/packages/js/src/generators/release-version/utils/update-lock-file.ts index 86f6a055dbccf..e9296f05c1cf6 100644 --- a/packages/js/src/generators/release-version/utils/update-lock-file.ts +++ b/packages/js/src/generators/release-version/utils/update-lock-file.ts @@ -133,6 +133,7 @@ function execLockFileUpdate( ...process.env, ...env, }, + windowsHide: true, }); } catch (e) { output.error({ diff --git a/packages/js/src/generators/setup-verdaccio/generator.ts b/packages/js/src/generators/setup-verdaccio/generator.ts index 735c556fd7dbe..a1dcd44967b6c 100644 --- a/packages/js/src/generators/setup-verdaccio/generator.ts +++ b/packages/js/src/generators/setup-verdaccio/generator.ts @@ -21,8 +21,11 @@ export async function setupVerdaccio( if (!tree.exists('.verdaccio/config.yml')) { generateFiles(tree, path.join(__dirname, 'files'), '.verdaccio', { npmUplinkRegistry: - execSync('npm config get registry')?.toString()?.trim() ?? - 'https://registry.npmjs.org', + execSync('npm config get registry', { + windowsHide: true, + }) + ?.toString() + ?.trim() ?? 'https://registry.npmjs.org', }); } diff --git a/packages/js/src/plugins/jest/start-local-registry.ts b/packages/js/src/plugins/jest/start-local-registry.ts index 04e14a5acb9e8..b5f49f9fb9d2d 100644 --- a/packages/js/src/plugins/jest/start-local-registry.ts +++ b/packages/js/src/plugins/jest/start-local-registry.ts @@ -46,7 +46,10 @@ export function startLocalRegistry({ const registry = `http://localhost:${port}`; process.env.npm_config_registry = registry; execSync( - `npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"` + `npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`, + { + windowsHide: true, + } ); // yarnv1 @@ -59,7 +62,9 @@ export function startLocalRegistry({ resolve(() => { childProcess.kill(); - execSync(`npm config delete //localhost:${port}/:_authToken`); + execSync(`npm config delete //localhost:${port}/:_authToken`, { + windowsHide: true, + }); }); childProcess?.stdout?.off('data', listener); } diff --git a/packages/js/src/utils/npm-config.ts b/packages/js/src/utils/npm-config.ts index 61c6113c434b2..616bc4fddf961 100644 --- a/packages/js/src/utils/npm-config.ts +++ b/packages/js/src/utils/npm-config.ts @@ -108,7 +108,7 @@ async function getNpmConfigValue(key: string, cwd: string): Promise { async function execAsync(command: string, cwd: string): Promise { // Must be non-blocking async to allow spinner to render return new Promise((resolve, reject) => { - exec(command, { cwd }, (error, stdout, stderr) => { + exec(command, { cwd, windowsHide: true }, (error, stdout, stderr) => { if (error) { return reject(error); } diff --git a/packages/js/src/utils/swc/compile-swc.ts b/packages/js/src/utils/swc/compile-swc.ts index 3ae235d0adde3..9f48864ee8149 100644 --- a/packages/js/src/utils/swc/compile-swc.ts +++ b/packages/js/src/utils/swc/compile-swc.ts @@ -85,6 +85,7 @@ export async function compileSwc( const swcCmdLog = execSync(getSwcCmd(normalizedOptions), { encoding: 'utf8', cwd: normalizedOptions.swcCliOptions.swcCwd, + windowsHide: true, }); logger.log(swcCmdLog.replace(/\n/, '')); const isCompileSuccess = swcCmdLog.includes('Successfully compiled'); @@ -137,6 +138,7 @@ export async function* compileSwcWatch( const swcWatcher = exec(getSwcCmd(normalizedOptions, true), { cwd: normalizedOptions.swcCliOptions.swcCwd, + windowsHide: true, }); processOnExit = () => { diff --git a/packages/nuxt/src/generators/application/application.ts b/packages/nuxt/src/generators/application/application.ts index fe50e6147af6b..0a0b7e4edf06f 100644 --- a/packages/nuxt/src/generators/application/application.ts +++ b/packages/nuxt/src/generators/application/application.ts @@ -153,7 +153,11 @@ export async function applicationGenerator(tree: Tree, schema: Schema) { tasks.push(() => { try { - execSync(`npx -y nuxi prepare`, { cwd: options.appProjectRoot }); + execSync(`npx -y nuxi prepare`, { + cwd: options.appProjectRoot, + + windowsHide: true, + }); } catch (e) { console.error( `Failed to run \`nuxi prepare\` in "${options.appProjectRoot}". Please run the command manually.` diff --git a/packages/nx/bin/nx.ts b/packages/nx/bin/nx.ts index f141f6d17608f..400ed4720914d 100644 --- a/packages/nx/bin/nx.ts +++ b/packages/nx/bin/nx.ts @@ -260,10 +260,18 @@ function getLocalNxVersion(workspace: WorkspaceTypeAndRoot): string | null { function _getLatestVersionOfNx(): string { try { - return execSync('npm view nx@latest version').toString().trim(); + return execSync('npm view nx@latest version', { + windowsHide: true, + }) + .toString() + .trim(); } catch { try { - return execSync('pnpm view nx@latest version').toString().trim(); + return execSync('pnpm view nx@latest version', { + windowsHide: true, + }) + .toString() + .trim(); } catch { return null; } diff --git a/packages/nx/src/command-line/activate-powerpack/activate-powerpack.ts b/packages/nx/src/command-line/activate-powerpack/activate-powerpack.ts index 856091d0f7352..1658dadd1e2d1 100644 --- a/packages/nx/src/command-line/activate-powerpack/activate-powerpack.ts +++ b/packages/nx/src/command-line/activate-powerpack/activate-powerpack.ts @@ -24,7 +24,10 @@ async function requirePowerpack(): Promise { if ('code' in e && e.code === 'MODULE_NOT_FOUND') { try { execSync( - `${getPackageManagerCommand().addDev} @nx/powerpack-license@latest` + `${getPackageManagerCommand().addDev} @nx/powerpack-license@latest`, + { + windowsHide: true, + } ); // @ts-ignore diff --git a/packages/nx/src/command-line/add/add.ts b/packages/nx/src/command-line/add/add.ts index 9cf31c4d35ab1..3f80de1567905 100644 --- a/packages/nx/src/command-line/add/add.ts +++ b/packages/nx/src/command-line/add/add.ts @@ -43,19 +43,25 @@ async function installPackage( if (existsSync('package.json')) { const pmc = getPackageManagerCommand(); await new Promise((resolve) => - exec(`${pmc.addDev} ${pkgName}@${version}`, (error, stdout) => { - if (error) { - spinner.fail(); - output.addNewline(); - logger.error(stdout); - output.error({ - title: `Failed to install ${pkgName}. Please check the error above for more details.`, - }); - process.exit(1); + exec( + `${pmc.addDev} ${pkgName}@${version}`, + { + windowsHide: true, + }, + (error, stdout) => { + if (error) { + spinner.fail(); + output.addNewline(); + logger.error(stdout); + output.error({ + title: `Failed to install ${pkgName}. Please check the error above for more details.`, + }); + process.exit(1); + } + + return resolve(); } - - return resolve(); - }) + ) ); } else { nxJson.installation.plugins ??= {}; diff --git a/packages/nx/src/command-line/connect/view-logs.ts b/packages/nx/src/command-line/connect/view-logs.ts index 97cbc236e73c2..bca8feb1fa130 100644 --- a/packages/nx/src/command-line/connect/view-logs.ts +++ b/packages/nx/src/command-line/connect/view-logs.ts @@ -50,6 +50,7 @@ export async function viewLogs(): Promise { const pmc = getPackageManagerCommand(); execSync(`${pmc.exec} nx-cloud upload-and-show-run-details`, { stdio: [0, 1, 2], + windowsHide: true, }); if (!cloudUsed) { diff --git a/packages/nx/src/command-line/exec/exec.ts b/packages/nx/src/command-line/exec/exec.ts index ef53c844b24b7..e95c691c04255 100644 --- a/packages/nx/src/command-line/exec/exec.ts +++ b/packages/nx/src/command-line/exec/exec.ts @@ -54,6 +54,7 @@ export async function nxExecCommand( NX_PROJECT_ROOT_PATH: projectGraph.nodes?.[process.env.NX_TASK_TARGET_PROJECT]?.data?.root, }, + windowsHide: true, }); } else { // nx exec is being ran inside of Nx's context @@ -104,6 +105,7 @@ async function runScriptAsNxTarget( projectGraph.nodes?.[projectName]?.data?.root ) : workspaceRoot, + windowsHide: true, }); }); } @@ -127,7 +129,11 @@ function runTargetOnProject( const command = `${ pm.exec } nx run ${projectName}:\\\"${targetName}\\\" ${extraArgs.join(' ')}`; - execSync(command, { stdio: 'inherit' }); + execSync(command, { + stdio: 'inherit', + + windowsHide: true, + }); } function readScriptArgV( diff --git a/packages/nx/src/command-line/format/format.ts b/packages/nx/src/command-line/format/format.ts index 8bf1dd2a84e76..42755b0fdc472 100644 --- a/packages/nx/src/command-line/format/format.ts +++ b/packages/nx/src/command-line/format/format.ts @@ -211,6 +211,7 @@ function write(patterns: string[]) { )}`, { stdio: [0, 1, 2], + windowsHide: true, } ); @@ -221,6 +222,7 @@ function write(patterns: string[]) { )} --parser json`, { stdio: [0, 1, 2], + windowsHide: true, } ); } @@ -237,7 +239,7 @@ async function check(patterns: string[]): Promise { return new Promise((resolve) => { exec( `node "${prettierPath}" --list-different ${patterns.join(' ')}`, - { encoding: 'utf-8' }, + { encoding: 'utf-8', windowsHide: true }, (error, stdout) => { if (error) { // The command failed so there are files with different formatting. Prettier writes them to stdout, newline separated. diff --git a/packages/nx/src/command-line/graph/graph.ts b/packages/nx/src/command-line/graph/graph.ts index 90fdbeefb310e..24a6b38d21d85 100644 --- a/packages/nx/src/command-line/graph/graph.ts +++ b/packages/nx/src/command-line/graph/graph.ts @@ -1263,5 +1263,6 @@ function getHelpTextFromTarget( return execSync(command, { cwd: target.options?.cwd ?? workspaceRoot, + windowsHide: true, }).toString(); } diff --git a/packages/nx/src/command-line/init/implementation/angular/integrated-workspace.ts b/packages/nx/src/command-line/init/implementation/angular/integrated-workspace.ts index 0ca59a6bccbdd..2682503740d68 100644 --- a/packages/nx/src/command-line/init/implementation/angular/integrated-workspace.ts +++ b/packages/nx/src/command-line/init/implementation/angular/integrated-workspace.ts @@ -3,5 +3,9 @@ import { getPackageManagerCommand } from '../../../../utils/package-manager'; export function setupIntegratedWorkspace(): void { const pmc = getPackageManagerCommand(); - execSync(`${pmc.exec} nx g @nx/angular:ng-add`, { stdio: [0, 1, 2] }); + execSync(`${pmc.exec} nx g @nx/angular:ng-add`, { + stdio: [0, 1, 2], + + windowsHide: true, + }); } diff --git a/packages/nx/src/command-line/init/implementation/angular/legacy-angular-versions.ts b/packages/nx/src/command-line/init/implementation/angular/legacy-angular-versions.ts index 6b9177d948eb8..30871353e84f5 100644 --- a/packages/nx/src/command-line/init/implementation/angular/legacy-angular-versions.ts +++ b/packages/nx/src/command-line/init/implementation/angular/legacy-angular-versions.ts @@ -106,7 +106,10 @@ export async function getLegacyMigrationFunctionIfApplicable( ); output.log({ title: '๐Ÿ“ Setting up workspace' }); - execSync(`${pmc.exec} ${legacyMigrationCommand}`, { stdio: [0, 1, 2] }); + execSync(`${pmc.exec} ${legacyMigrationCommand}`, { + stdio: [0, 1, 2], + windowsHide: true, + }); if (useNxCloud) { output.log({ title: '๐Ÿ› ๏ธ Setting up Nx Cloud' }); @@ -146,7 +149,7 @@ async function installDependencies( } writeJsonFile(`package.json`, json); - execSync(pmc.install, { stdio: [0, 1, 2] }); + execSync(pmc.install, { stdio: [0, 1, 2], windowsHide: true }); } async function resolvePackageVersion( diff --git a/packages/nx/src/command-line/init/implementation/dot-nx/add-nx-scripts.ts b/packages/nx/src/command-line/init/implementation/dot-nx/add-nx-scripts.ts index 425c2d9b26bec..ad2548d52d0be 100644 --- a/packages/nx/src/command-line/init/implementation/dot-nx/add-nx-scripts.ts +++ b/packages/nx/src/command-line/init/implementation/dot-nx/add-nx-scripts.ts @@ -67,7 +67,9 @@ export function generateDotNxSetup(version?: string) { export function normalizeVersionForNxJson(pkg: string, version: string) { if (!valid(version)) { - version = execSync(`npm view ${pkg}@${version} version`).toString(); + version = execSync(`npm view ${pkg}@${version} version`, { + windowsHide: true, + }).toString(); } return version.trimEnd(); } diff --git a/packages/nx/src/command-line/init/implementation/dot-nx/nxw.ts b/packages/nx/src/command-line/init/implementation/dot-nx/nxw.ts index 12fca08acf84a..f62bc0fd2bc45 100644 --- a/packages/nx/src/command-line/init/implementation/dot-nx/nxw.ts +++ b/packages/nx/src/command-line/init/implementation/dot-nx/nxw.ts @@ -90,6 +90,7 @@ function performInstallation( cp.execSync('npm i', { cwd: path.dirname(installationPath), stdio: 'inherit', + windowsHide: true, }); } catch (e) { // revert possible changes to the current installation diff --git a/packages/nx/src/command-line/init/implementation/react/check-for-uncommitted-changes.ts b/packages/nx/src/command-line/init/implementation/react/check-for-uncommitted-changes.ts index 170b146ba2bce..2299eb706ee55 100644 --- a/packages/nx/src/command-line/init/implementation/react/check-for-uncommitted-changes.ts +++ b/packages/nx/src/command-line/init/implementation/react/check-for-uncommitted-changes.ts @@ -1,7 +1,9 @@ import { execSync } from 'child_process'; export function checkForUncommittedChanges() { - const gitResult = execSync('git status --porcelain').toString(); + const gitResult = execSync('git status --porcelain', { + windowsHide: true, + }).toString(); const filteredResults = gitResult .split('\n') diff --git a/packages/nx/src/command-line/init/implementation/react/index.ts b/packages/nx/src/command-line/init/implementation/react/index.ts index a62a3e146528e..7138083048b6e 100644 --- a/packages/nx/src/command-line/init/implementation/react/index.ts +++ b/packages/nx/src/command-line/init/implementation/react/index.ts @@ -70,6 +70,7 @@ function installDependencies(options: NormalizedOptions) { execSync(`${options.pmc.addDev} ${dependencies.join(' ')}`, { stdio: [0, 1, 2], + windowsHide: true, }); } @@ -86,7 +87,9 @@ async function normalizeOptions(options: Options): Promise { ...packageJson.devDependencies, }; const isCRA5 = /^[^~]?5/.test(deps['react-scripts']); - const npmVersion = execSync('npm -v').toString(); + const npmVersion = execSync('npm -v', { + windowsHide: true, + }).toString(); // Should remove this check 04/2023 once Node 14 & npm 6 reach EOL const npxYesFlagNeeded = !npmVersion.startsWith('6'); // npm 7 added -y flag to npx const isVite = options.vite; @@ -126,8 +129,14 @@ async function reorgnizeWorkspaceStructure(options: NormalizedOptions) { output.log({ title: '๐Ÿงถ Updating .gitignore file' }); - execSync(`echo "node_modules" >> .gitignore`, { stdio: [0, 1, 2] }); - execSync(`echo "dist" >> .gitignore`, { stdio: [0, 1, 2] }); + execSync(`echo "node_modules" >> .gitignore`, { + stdio: [0, 1, 2], + windowsHide: true, + }); + execSync(`echo "dist" >> .gitignore`, { + stdio: [0, 1, 2], + windowsHide: true, + }); process.chdir('..'); @@ -168,7 +177,7 @@ function createTempWorkspace(options: NormalizedOptions) { } ${ options.addE2e ? '--e2eTestRunner=playwright' : '--e2eTestRunner=none' }`, - { stdio: [0, 1, 2] } + { stdio: [0, 1, 2], windowsHide: true } ); output.log({ title: '๐Ÿ‘‹ Welcome to Nx!' }); @@ -311,7 +320,10 @@ async function addBundler(options: NormalizedOptions) { title: '๐Ÿ›ฌ Skip CRA preflight check since Nx manages the monorepo', }); - execSync(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, { stdio: [0, 1, 2] }); + execSync(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, { + stdio: [0, 1, 2], + windowsHide: true, + }); } } diff --git a/packages/nx/src/command-line/init/implementation/utils.ts b/packages/nx/src/command-line/init/implementation/utils.ts index cd2e1d44148cd..c249188780d58 100644 --- a/packages/nx/src/command-line/init/implementation/utils.ts +++ b/packages/nx/src/command-line/init/implementation/utils.ts @@ -68,24 +68,28 @@ function deduceDefaultBase() { try { execSync(`git rev-parse --verify main`, { stdio: ['ignore', 'ignore', 'ignore'], + windowsHide: true, }); return 'main'; } catch { try { execSync(`git rev-parse --verify dev`, { stdio: ['ignore', 'ignore', 'ignore'], + windowsHide: true, }); return 'dev'; } catch { try { execSync(`git rev-parse --verify develop`, { stdio: ['ignore', 'ignore', 'ignore'], + windowsHide: true, }); return 'develop'; } catch { try { execSync(`git rev-parse --verify next`, { stdio: ['ignore', 'ignore', 'ignore'], + windowsHide: true, }); return 'next'; } catch { @@ -140,7 +144,7 @@ export function runInstall( repoRoot: string, pmc: PackageManagerCommands = getPackageManagerCommand() ) { - execSync(pmc.install, { stdio: [0, 1, 2], cwd: repoRoot }); + execSync(pmc.install, { stdio: [0, 1, 2], cwd: repoRoot, windowsHide: true }); } export async function initCloud( diff --git a/packages/nx/src/command-line/init/init-v1.ts b/packages/nx/src/command-line/init/init-v1.ts index 8eb114e278ff4..5d63363c35a0d 100644 --- a/packages/nx/src/command-line/init/init-v1.ts +++ b/packages/nx/src/command-line/init/init-v1.ts @@ -95,6 +95,7 @@ export async function initHandler(options: InitArgs) { } else { execSync(`npx --yes create-nx-workspace@${version} ${args}`, { stdio: [0, 1, 2], + windowsHide: true, }); } } diff --git a/packages/nx/src/command-line/init/init-v2.ts b/packages/nx/src/command-line/init/init-v2.ts index 4058f2d40ff87..02f991ad4e373 100644 --- a/packages/nx/src/command-line/init/init-v2.ts +++ b/packages/nx/src/command-line/init/init-v2.ts @@ -59,6 +59,7 @@ export function installPlugins( { stdio: [0, 1, 2], cwd: repoRoot, + windowsHide: true, } ); } diff --git a/packages/nx/src/command-line/migrate/command-object.ts b/packages/nx/src/command-line/migrate/command-object.ts index dfad06fd9a71d..38dc58a266cd7 100644 --- a/packages/nx/src/command-line/migrate/command-object.ts +++ b/packages/nx/src/command-line/migrate/command-object.ts @@ -128,6 +128,7 @@ function runMigration() { } execSync(`${p} _migrate ${process.argv.slice(3).join(' ')}`, { stdio: ['inherit', 'inherit', 'inherit'], + windowsHide: true, }); } } else { @@ -155,12 +156,14 @@ function nxCliPath() { execSync(pmc.preInstall, { cwd: tmpDir, stdio: ['ignore', 'ignore', 'ignore'], + windowsHide: true, }); // if it's berry ensure we set the node_linker to node-modules if (packageManager === 'yarn' && pmc.ciInstall.includes('immutable')) { execSync('yarn config set nodeLinker node-modules', { cwd: tmpDir, stdio: ['ignore', 'ignore', 'ignore'], + windowsHide: true, }); } } @@ -168,6 +171,7 @@ function nxCliPath() { execSync(pmc.install, { cwd: tmpDir, stdio: ['ignore', 'ignore', 'ignore'], + windowsHide: true, }); // Set NODE_PATH so that these modules can be used for module resolution diff --git a/packages/nx/src/command-line/migrate/migrate.ts b/packages/nx/src/command-line/migrate/migrate.ts index c365c1d9f75b5..081845f9bee27 100644 --- a/packages/nx/src/command-line/migrate/migrate.ts +++ b/packages/nx/src/command-line/migrate/migrate.ts @@ -1387,7 +1387,7 @@ function runInstall() { output.log({ title: `Running '${pmCommands.install}' to make sure necessary packages are installed`, }); - execSync(pmCommands.install, { stdio: [0, 1, 2] }); + execSync(pmCommands.install, { stdio: [0, 1, 2], windowsHide: true }); } export async function executeMigrations( diff --git a/packages/nx/src/command-line/release/config/version-plans.ts b/packages/nx/src/command-line/release/config/version-plans.ts index 633f7e3c785e9..a00c6718cc9d0 100644 --- a/packages/nx/src/command-line/release/config/version-plans.ts +++ b/packages/nx/src/command-line/release/config/version-plans.ts @@ -323,6 +323,9 @@ async function getCommitForVersionPlanFile( return new Promise((resolve) => { exec( `git log --diff-filter=A --pretty=format:"%s|%h|%an|%ae|%b" -n 1 -- ${rawVersionPlan.absolutePath}`, + { + windowsHide: true, + }, (error, stdout, stderr) => { if (error) { if (isVerbose) { diff --git a/packages/nx/src/command-line/release/utils/exec-command.ts b/packages/nx/src/command-line/release/utils/exec-command.ts index aa262eedb6765..ebe5f2ae230ca 100644 --- a/packages/nx/src/command-line/release/utils/exec-command.ts +++ b/packages/nx/src/command-line/release/utils/exec-command.ts @@ -10,6 +10,7 @@ export async function execCommand( ...options, stdio: ['pipe', 'pipe', 'pipe'], // stdin, stdout, stderr encoding: 'utf-8', + windowsHide: true, }); let stdout = ''; diff --git a/packages/nx/src/command-line/release/utils/github.ts b/packages/nx/src/command-line/release/utils/github.ts index 284a1ef57b919..021217a56f3b1 100644 --- a/packages/nx/src/command-line/release/utils/github.ts +++ b/packages/nx/src/command-line/release/utils/github.ts @@ -367,6 +367,7 @@ async function resolveGithubToken(hostname: string): Promise { return execSync(`gh auth token`, { encoding: 'utf8', stdio: 'pipe', + windowsHide: true, }).trim(); } } diff --git a/packages/nx/src/command-line/release/utils/launch-editor.ts b/packages/nx/src/command-line/release/utils/launch-editor.ts index 9ecc90baff863..a01b17f70a79c 100644 --- a/packages/nx/src/command-line/release/utils/launch-editor.ts +++ b/packages/nx/src/command-line/release/utils/launch-editor.ts @@ -14,6 +14,7 @@ export async function launchEditor(filePath: string) { return new Promise((resolve, reject) => { const editorProcess = spawn(cmd, [...args, filePath], { stdio: 'inherit', // This will ensure the editor uses the current terminal + windowsHide: true, }); editorProcess.on('exit', (code) => { @@ -28,7 +29,11 @@ export async function launchEditor(filePath: string) { function getGitConfig(key): string | null { try { - return execSync(`git config --get ${key}`).toString().trim(); + return execSync(`git config --get ${key}`, { + windowsHide: true, + }) + .toString() + .trim(); } catch { return null; } diff --git a/packages/nx/src/command-line/release/version.ts b/packages/nx/src/command-line/release/version.ts index 9c2f2e1b6d8ad..8aac3764b3778 100644 --- a/packages/nx/src/command-line/release/version.ts +++ b/packages/nx/src/command-line/release/version.ts @@ -753,6 +753,7 @@ function runPreVersionCommand( maxBuffer: LARGE_BUFFER, stdio, env, + windowsHide: true, }); } catch (e) { const title = verbose diff --git a/packages/nx/src/command-line/run/run.ts b/packages/nx/src/command-line/run/run.ts index d7679ebe63cde..4aa0213430807 100644 --- a/packages/nx/src/command-line/run/run.ts +++ b/packages/nx/src/command-line/run/run.ts @@ -134,6 +134,7 @@ async function printTargetRunHelpInternal( } else { const cp = exec(helpCommand, { env, + windowsHide: true, }); cp.on('exit', (code) => { process.exit(code); diff --git a/packages/nx/src/command-line/watch/watch.ts b/packages/nx/src/command-line/watch/watch.ts index 518f0729999ac..98928e5db1211 100644 --- a/packages/nx/src/command-line/watch/watch.ts +++ b/packages/nx/src/command-line/watch/watch.ts @@ -132,6 +132,7 @@ class BatchCommandRunner extends BatchFunctionRunner { [this.projectNameEnv]: env[this.projectNameEnv], [this.fileChangesEnv]: env[this.fileChangesEnv], }, + windowsHide: true, }); commandExec.on('close', () => { resolve(); diff --git a/packages/nx/src/daemon/client/generate-help-output.ts b/packages/nx/src/daemon/client/generate-help-output.ts index da427f905c6a7..215a3f7bd2960 100644 --- a/packages/nx/src/daemon/client/generate-help-output.ts +++ b/packages/nx/src/daemon/client/generate-help-output.ts @@ -9,6 +9,7 @@ export function generateDaemonHelpOutput(): string { */ const res = spawnSync(process.execPath, ['./exec-is-server-available.js'], { cwd: __dirname, + windowsHide: true, }); const isServerAvailable = res?.stdout?.toString().trim().indexOf('true') > -1; diff --git a/packages/nx/src/executors/run-commands/run-commands.impl.spec.ts b/packages/nx/src/executors/run-commands/run-commands.impl.spec.ts index 95bfb5ab4d198..a5e5715455515 100644 --- a/packages/nx/src/executors/run-commands/run-commands.impl.spec.ts +++ b/packages/nx/src/executors/run-commands/run-commands.impl.spec.ts @@ -572,6 +572,7 @@ describe('Run Commands', () => { ...process.env, ...env(), }, + windowsHide: true, }); expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, { maxBuffer: LARGE_BUFFER, @@ -579,6 +580,7 @@ describe('Run Commands', () => { ...process.env, ...env(), }, + windowsHide: true, }); }); @@ -601,6 +603,7 @@ describe('Run Commands', () => { ...process.env, ...env(), }, + windowsHide: true, }); expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, { maxBuffer: LARGE_BUFFER, @@ -608,6 +611,7 @@ describe('Run Commands', () => { ...process.env, ...env(), }, + windowsHide: true, }); }); @@ -627,10 +631,12 @@ describe('Run Commands', () => { expect(exec).toHaveBeenNthCalledWith(1, `echo 'Hello World'`, { maxBuffer: LARGE_BUFFER, env: { ...process.env, FORCE_COLOR: `true`, ...env() }, + windowsHide: true, }); expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, { maxBuffer: LARGE_BUFFER, env: { ...process.env, FORCE_COLOR: `true`, ...env() }, + windowsHide: true, }); }); }); diff --git a/packages/nx/src/executors/run-commands/run-commands.impl.ts b/packages/nx/src/executors/run-commands/run-commands.impl.ts index 0656a10a6d1ab..414c7a8d942e1 100644 --- a/packages/nx/src/executors/run-commands/run-commands.impl.ts +++ b/packages/nx/src/executors/run-commands/run-commands.impl.ts @@ -402,6 +402,7 @@ function nodeProcess( maxBuffer: LARGE_BUFFER, env, cwd, + windowsHide: true, }); childProcesses.add(childProcess); diff --git a/packages/nx/src/executors/run-script/run-script.impl.ts b/packages/nx/src/executors/run-script/run-script.impl.ts index 1ef3e8cb6cf48..130489b2af8e5 100644 --- a/packages/nx/src/executors/run-script/run-script.impl.ts +++ b/packages/nx/src/executors/run-script/run-script.impl.ts @@ -54,6 +54,7 @@ function nodeProcess( stdio: ['inherit', 'inherit', 'inherit'], cwd, env, + windowsHide: true, }); } diff --git a/packages/nx/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.ts b/packages/nx/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.ts index acf9da15f635a..5083c4767a975 100644 --- a/packages/nx/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.ts +++ b/packages/nx/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.ts @@ -37,7 +37,7 @@ function getNxInitDate(): string | null { try { const nxInitIso = execSync( 'git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1', - { stdio: 'pipe' } + { stdio: 'pipe', windowsHide: true } ) .toString() .trim(); diff --git a/packages/nx/src/project-graph/file-utils.ts b/packages/nx/src/project-graph/file-utils.ts index d0db3a6f5767f..6f609ae6f22e7 100644 --- a/packages/nx/src/project-graph/file-utils.ts +++ b/packages/nx/src/project-graph/file-utils.ts @@ -125,6 +125,7 @@ function defaultReadFileAtRevision( : execSync(`git show ${revision}:${filePathInGitRepository}`, { maxBuffer: TEN_MEGABYTES, stdio: ['pipe', 'pipe', 'ignore'], + windowsHide: true, }) .toString() .trim(); diff --git a/packages/nx/src/tasks-runner/cache.ts b/packages/nx/src/tasks-runner/cache.ts index bbddf348b7d8d..be98d31eddb51 100644 --- a/packages/nx/src/tasks-runner/cache.ts +++ b/packages/nx/src/tasks-runner/cache.ts @@ -230,6 +230,7 @@ export class Cache { stdio: 'ignore', detached: true, shell: false, + windowsHide: true, }); p.unref(); } catch (e) { diff --git a/packages/nx/src/utils/ab-testing.ts b/packages/nx/src/utils/ab-testing.ts index e3f82e551df21..4847a112b74d2 100644 --- a/packages/nx/src/utils/ab-testing.ts +++ b/packages/nx/src/utils/ab-testing.ts @@ -108,7 +108,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/nx/src/utils/child-process.ts b/packages/nx/src/utils/child-process.ts index 2f9ae1d4dbbe7..31c2c85ea6907 100644 --- a/packages/nx/src/utils/child-process.ts +++ b/packages/nx/src/utils/child-process.ts @@ -20,6 +20,7 @@ export function runNxSync( } else { options ??= {}; options.cwd ??= process.cwd(); + options.windowsHide ??= true; const offsetFromRoot = relative( options.cwd, workspaceRootInner(options.cwd, null) @@ -43,6 +44,7 @@ export async function runNxAsync( } else { options ??= {}; options.cwd ??= process.cwd(); + options.windowsHide ??= true; const offsetFromRoot = relative( options.cwd, workspaceRootInner(options.cwd, null) diff --git a/packages/nx/src/utils/command-line-utils.ts b/packages/nx/src/utils/command-line-utils.ts index 688f511fb5541..4689468824867 100644 --- a/packages/nx/src/utils/command-line-utils.ts +++ b/packages/nx/src/utils/command-line-utils.ts @@ -306,6 +306,7 @@ function getMergeBase(base: string, head: string = 'HEAD') { maxBuffer: TEN_MEGABYTES, cwd: workspaceRoot, stdio: 'pipe', + windowsHide: true, }) .toString() .trim(); @@ -315,6 +316,7 @@ function getMergeBase(base: string, head: string = 'HEAD') { maxBuffer: TEN_MEGABYTES, cwd: workspaceRoot, stdio: 'pipe', + windowsHide: true, }) .toString() .trim(); @@ -331,7 +333,11 @@ function getFilesUsingBaseAndHead(base: string, head: string): string[] { } function parseGitOutput(command: string): string[] { - return execSync(command, { maxBuffer: TEN_MEGABYTES, cwd: workspaceRoot }) + return execSync(command, { + maxBuffer: TEN_MEGABYTES, + cwd: workspaceRoot, + windowsHide: true, + }) .toString('utf-8') .split('\n') .map((a) => a.trim()) diff --git a/packages/nx/src/utils/default-base.ts b/packages/nx/src/utils/default-base.ts index 42a410f41bb19..98376433df527 100644 --- a/packages/nx/src/utils/default-base.ts +++ b/packages/nx/src/utils/default-base.ts @@ -4,8 +4,11 @@ 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/nx/src/utils/git-utils.index-filter.ts b/packages/nx/src/utils/git-utils.index-filter.ts index 09004da1ef0f8..0ba27298428b4 100644 --- a/packages/nx/src/utils/git-utils.index-filter.ts +++ b/packages/nx/src/utils/git-utils.index-filter.ts @@ -9,9 +9,10 @@ try { const { execSync } = require('child_process'); // NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped. const src = process.env.NX_IMPORT_SOURCE; - execSync('git read-tree --empty', { stdio: 'inherit' }); + execSync('git read-tree --empty', { stdio: 'inherit', windowsHide: true }); execSync(`git reset ${process.env.GIT_COMMIT} -- "${src}"`, { stdio: 'inherit', + windowsHide: true, }); } catch (error) { console.error(`Error executing Git commands: ${error}`); diff --git a/packages/nx/src/utils/git-utils.spec.ts b/packages/nx/src/utils/git-utils.spec.ts index 67bc43ad2b2fd..3ff74484e292e 100644 --- a/packages/nx/src/utils/git-utils.spec.ts +++ b/packages/nx/src/utils/git-utils.spec.ts @@ -21,7 +21,10 @@ describe('git utils tests', () => { const result = getGithubSlugOrNull(); expect(result).toBe('origin-user/repo-name'); - expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' }); + expect(execSync).toHaveBeenCalledWith('git remote -v', { + stdio: 'pipe', + windowsHide: true, + }); }); it('should return "github" if there are no remotes', () => { @@ -30,7 +33,10 @@ describe('git utils tests', () => { const result = getGithubSlugOrNull(); expect(result).toBe('github'); - expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' }); + expect(execSync).toHaveBeenCalledWith('git remote -v', { + stdio: 'pipe', + windowsHide: true, + }); }); it('should return "github" if execSync throws an error', () => { @@ -41,7 +47,10 @@ describe('git utils tests', () => { const result = getGithubSlugOrNull(); expect(result).toBe('github'); - expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' }); + expect(execSync).toHaveBeenCalledWith('git remote -v', { + stdio: 'pipe', + windowsHide: true, + }); }); it('should return the first github remote slug if no origin is present', () => { @@ -53,7 +62,10 @@ describe('git utils tests', () => { const result = getGithubSlugOrNull(); expect(result).toBe('upstream-user/repo-name'); - expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' }); + expect(execSync).toHaveBeenCalledWith('git remote -v', { + stdio: 'pipe', + windowsHide: true, + }); }); it('should return null if remote is set up but not github', () => { @@ -65,7 +77,10 @@ describe('git utils tests', () => { const result = getGithubSlugOrNull(); expect(result).toBeNull(); - expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' }); + expect(execSync).toHaveBeenCalledWith('git remote -v', { + stdio: 'pipe', + windowsHide: true, + }); }); it('should return the first github remote slug for HTTPS URLs', () => { @@ -77,7 +92,10 @@ describe('git utils tests', () => { const result = getGithubSlugOrNull(); expect(result).toBe('origin-user/repo-name'); - expect(execSync).toHaveBeenCalledWith('git remote -v', { stdio: 'pipe' }); + expect(execSync).toHaveBeenCalledWith('git remote -v', { + stdio: 'pipe', + windowsHide: true, + }); }); }); diff --git a/packages/nx/src/utils/git-utils.tree-filter.ts b/packages/nx/src/utils/git-utils.tree-filter.ts index 81ff865006f49..0d505d302df20 100644 --- a/packages/nx/src/utils/git-utils.tree-filter.ts +++ b/packages/nx/src/utils/git-utils.tree-filter.ts @@ -14,7 +14,9 @@ try { // NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped. const src = process.env.NX_IMPORT_SOURCE; const dest = process.env.NX_IMPORT_DESTINATION; - const files = execSync(`git ls-files -z ${src}`) + const files = execSync(`git ls-files -z ${src}`, { + windowsHide: true, + }) .toString() .trim() .split('\x00') diff --git a/packages/nx/src/utils/git-utils.ts b/packages/nx/src/utils/git-utils.ts index 74f5d72131078..fe457e939f33c 100644 --- a/packages/nx/src/utils/git-utils.ts +++ b/packages/nx/src/utils/git-utils.ts @@ -40,6 +40,7 @@ export class GitRepository { getGitRootPath(cwd: string) { return execSync('git rev-parse --show-toplevel', { cwd, + windowsHide: true, }) .toString() .trim(); @@ -237,6 +238,7 @@ export function getGithubSlugOrNull(): string | null { try { const gitRemote = execSync('git remote -v', { stdio: 'pipe', + windowsHide: true, }).toString(); // If there are no remotes, we default to github if (!gitRemote || gitRemote.length === 0) { @@ -302,6 +304,7 @@ export function commitChanges( stdio: 'pipe', input: commitMessage, cwd: directory, + windowsHide: true, }); } catch (err) { if (directory) { @@ -323,6 +326,7 @@ export function getLatestCommitSha(): string | null { return execSync('git rev-parse HEAD', { encoding: 'utf8', stdio: 'pipe', + windowsHide: true, }).trim(); } catch { return null; diff --git a/packages/playwright/src/executors/playwright/playwright.impl.ts b/packages/playwright/src/executors/playwright/playwright.impl.ts index f395f1d371c0b..5ea711aba536f 100644 --- a/packages/playwright/src/executors/playwright/playwright.impl.ts +++ b/packages/playwright/src/executors/playwright/playwright.impl.ts @@ -80,6 +80,7 @@ export async function playwrightExecutor( execSync(`${pmc.exec} playwright install`, { cwd: workspaceRoot, stdio: 'inherit', + windowsHide: true, }); } diff --git a/packages/playwright/src/generators/configuration/configuration.ts b/packages/playwright/src/generators/configuration/configuration.ts index 2bf2ba29f29fd..d884e0606714e 100644 --- a/packages/playwright/src/generators/configuration/configuration.ts +++ b/packages/playwright/src/generators/configuration/configuration.ts @@ -161,7 +161,10 @@ function getBrowsersInstallTask() { bodyLines: ['use --skipInstall to skip installation.'], }); const pmc = getPackageManagerCommand(); - execSync(`${pmc.exec} playwright install`, { cwd: workspaceRoot }); + execSync(`${pmc.exec} playwright install`, { + cwd: workspaceRoot, + windowsHide: true, + }); }; } diff --git a/packages/plugin/src/utils/testing-utils/async-commands.ts b/packages/plugin/src/utils/testing-utils/async-commands.ts index ae69d347e1c57..baf6f34da4b2d 100644 --- a/packages/plugin/src/utils/testing-utils/async-commands.ts +++ b/packages/plugin/src/utils/testing-utils/async-commands.ts @@ -21,6 +21,7 @@ export function runCommandAsync( { cwd: opts.cwd ?? tmpProjPath(), env: { ...process.env, ...opts.env }, + windowsHide: true, }, (err, stdout, stderr) => { if (!opts.silenceError && err) { diff --git a/packages/plugin/src/utils/testing-utils/commands.ts b/packages/plugin/src/utils/testing-utils/commands.ts index d5b0cd58d6464..e5a6277dd96a3 100644 --- a/packages/plugin/src/utils/testing-utils/commands.ts +++ b/packages/plugin/src/utils/testing-utils/commands.ts @@ -21,6 +21,7 @@ export function runNxCommand( const execSyncOptions: ExecOptions = { cwd, env: { ...process.env, ...opts.env }, + windowsHide: true, }; if (fileExists(tmpProjPath('package.json'))) { const pmc = getPackageManagerCommand(detectPackageManager(cwd)); diff --git a/packages/plugin/src/utils/testing-utils/nx-project.ts b/packages/plugin/src/utils/testing-utils/nx-project.ts index af70eaa65e06a..6f432da98fe98 100644 --- a/packages/plugin/src/utils/testing-utils/nx-project.ts +++ b/packages/plugin/src/utils/testing-utils/nx-project.ts @@ -21,6 +21,7 @@ function runNxNewCommand(args?: string, silent?: boolean) { { cwd: localTmpDir, ...(silent && false ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}), + windowsHide: true, } ); } @@ -55,6 +56,7 @@ export function runPackageManagerInstall(silent: boolean = true) { const install = execSync(pmc.install, { cwd, ...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}), + windowsHide: true, }); return install ? install.toString() : ''; } diff --git a/packages/react-native/src/utils/pod-install-task.ts b/packages/react-native/src/utils/pod-install-task.ts index 48dc2f39b46b2..840e126e1fbbc 100644 --- a/packages/react-native/src/utils/pod-install-task.ts +++ b/packages/react-native/src/utils/pod-install-task.ts @@ -72,6 +72,7 @@ export function podInstall( execSync('touch .xcode.env', { cwd: iosDirectory, stdio: 'inherit', + windowsHide: true, }); } const podCommand = [ @@ -82,6 +83,7 @@ export function podInstall( execSync(podCommand, { cwd: iosDirectory, stdio: 'inherit', + windowsHide: true, }); } catch (e) { logger.error(podInstallErrorMessage); diff --git a/packages/storybook/src/generators/migrate-7/calling-storybook-cli.ts b/packages/storybook/src/generators/migrate-7/calling-storybook-cli.ts index 70003cb0369be..deac07f7385fb 100644 --- a/packages/storybook/src/generators/migrate-7/calling-storybook-cli.ts +++ b/packages/storybook/src/generators/migrate-7/calling-storybook-cli.ts @@ -20,6 +20,7 @@ export function callUpgrade(schema: Schema): 1 | Buffer { }`, { stdio: [0, 1, 2], + windowsHide: true, } ); @@ -85,6 +86,7 @@ export function callAutomigrate( `${commandToRun} ${schema.autoAcceptAllPrompts ? '--yes' : ''}`, { stdio: 'inherit', + windowsHide: true, } ); diff --git a/packages/storybook/src/generators/migrate-8/calling-storybook-cli.ts b/packages/storybook/src/generators/migrate-8/calling-storybook-cli.ts index 4d6d5769d6779..a65c0e63d209e 100644 --- a/packages/storybook/src/generators/migrate-8/calling-storybook-cli.ts +++ b/packages/storybook/src/generators/migrate-8/calling-storybook-cli.ts @@ -20,6 +20,7 @@ export function callUpgrade(schema: Schema): 1 | Buffer { }`, { stdio: [0, 1, 2], + windowsHide: true, } ); @@ -83,6 +84,7 @@ export function callAutomigrate( `${commandToRun} ${schema.autoAcceptAllPrompts ? '--yes' : ''}`, { stdio: 'inherit', + windowsHide: true, } ); diff --git a/packages/vite/plugins/nx-vite-build-coordination.plugin.ts b/packages/vite/plugins/nx-vite-build-coordination.plugin.ts index 445cd5ff21187..3f62ad440aa62 100644 --- a/packages/vite/plugins/nx-vite-build-coordination.plugin.ts +++ b/packages/vite/plugins/nx-vite-build-coordination.plugin.ts @@ -18,7 +18,9 @@ export function nxViteBuildCoordinationPlugin( async function buildChangedProjects() { await new Promise((res) => { - activeBuildProcess = exec(options.buildCommand); + activeBuildProcess = exec(options.buildCommand, { + windowsHide: true, + }); activeBuildProcess.stdout.pipe(process.stdout); activeBuildProcess.stderr.pipe(process.stderr); activeBuildProcess.on('exit', () => { diff --git a/packages/vite/src/utils/executor-utils.ts b/packages/vite/src/utils/executor-utils.ts index 1dd10df173eae..d99b9ebab4752 100644 --- a/packages/vite/src/utils/executor-utils.ts +++ b/packages/vite/src/utils/executor-utils.ts @@ -36,6 +36,7 @@ export async function validateTypes(opts: { { cwd: opts.workspaceRoot, stdio: 'inherit', + windowsHide: true, } ); } diff --git a/packages/webpack/src/plugins/webpack-nx-build-coordination-plugin.ts b/packages/webpack/src/plugins/webpack-nx-build-coordination-plugin.ts index 5b2273aae7754..9f86943bc61a6 100644 --- a/packages/webpack/src/plugins/webpack-nx-build-coordination-plugin.ts +++ b/packages/webpack/src/plugins/webpack-nx-build-coordination-plugin.ts @@ -52,7 +52,9 @@ export class WebpackNxBuildCoordinationPlugin { this.currentlyRunning = 'nx-build'; try { return await new Promise((res) => { - this.buildCmdProcess = exec(this.buildCmd); + this.buildCmdProcess = exec(this.buildCmd, { + windowsHide: true, + }); this.buildCmdProcess.stdout.pipe(process.stdout); this.buildCmdProcess.stderr.pipe(process.stderr); diff --git a/packages/workspace/src/generators/new/generate-preset.ts b/packages/workspace/src/generators/new/generate-preset.ts index 125cbe43a4b64..731fdd0239a22 100644 --- a/packages/workspace/src/generators/new/generate-preset.ts +++ b/packages/workspace/src/generators/new/generate-preset.ts @@ -36,6 +36,7 @@ export function generatePreset(host: Tree, opts: NormalizedSchema) { stdio: 'inherit', shell: true, cwd: join(host.root, opts.directory), + windowsHide: true, }; const pmc = getPackageManagerCommand(); const executable = `${pmc.exec} nx`; diff --git a/packages/workspace/src/generators/new/new.ts b/packages/workspace/src/generators/new/new.ts index 0184e650cdabb..706175c86a960 100644 --- a/packages/workspace/src/generators/new/new.ts +++ b/packages/workspace/src/generators/new/new.ts @@ -63,6 +63,7 @@ export async function newGenerator(tree: Tree, opts: Schema) { cwd: joinPathFragments(tree.root, options.directory), stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit', + windowsHide: true, }); } installPackagesTask( diff --git a/packages/workspace/src/generators/utils/get-npm-package-version.ts b/packages/workspace/src/generators/utils/get-npm-package-version.ts index 1cf17d87a871a..20db178e61b53 100644 --- a/packages/workspace/src/generators/utils/get-npm-package-version.ts +++ b/packages/workspace/src/generators/utils/get-npm-package-version.ts @@ -7,7 +7,11 @@ export function getNpmPackageVersion( `npm view ${packageName}${ packageVersion ? '@' + packageVersion : '' } version --json`, - { stdio: ['pipe', 'pipe', 'ignore'] } + { + stdio: ['pipe', 'pipe', 'ignore'], + + windowsHide: true, + } ); if (version) { diff --git a/packages/workspace/src/utilities/default-base.ts b/packages/workspace/src/utilities/default-base.ts index 42a410f41bb19..98376433df527 100644 --- a/packages/workspace/src/utilities/default-base.ts +++ b/packages/workspace/src/utilities/default-base.ts @@ -4,8 +4,11 @@ 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/scripts/angular-support-upgrades/init-upgrade.ts b/scripts/angular-support-upgrades/init-upgrade.ts index bcd4dad8aa921..5a8c1c113b49e 100644 --- a/scripts/angular-support-upgrades/init-upgrade.ts +++ b/scripts/angular-support-upgrades/init-upgrade.ts @@ -42,11 +42,20 @@ async function run() { updateVersionUtils(packageVersionMap); console.log('โณ - Installing packages...'); - execSync('pnpm install', { stdio: 'inherit', encoding: 'utf8' }); + execSync('pnpm install', { + stdio: 'inherit', + encoding: 'utf8', + + windowsHide: true, + }); console.log('โœ… - Finished installing packages!'); console.log('โณ - Formatting files...'); - execSync('pnpm nx format', { stdio: 'inherit', encoding: 'utf8' }); + execSync('pnpm nx format', { + stdio: 'inherit', + encoding: 'utf8', + windowsHide: true, + }); console.log('โœ… - Finished creating migrations!'); } diff --git a/scripts/documentation/generators/generate-devkit-documentation.ts b/scripts/documentation/generators/generate-devkit-documentation.ts index 37888e7bac4a8..de3ec565bc72c 100644 --- a/scripts/documentation/generators/generate-devkit-documentation.ts +++ b/scripts/documentation/generators/generate-devkit-documentation.ts @@ -10,6 +10,7 @@ export async function generateDevkitDocumentation() { const execSyncOptions: ExecSyncOptions = { stdio: 'true' === 'true' ? 'inherit' : 'ignore', // stdio: process.env.CI === 'true' ? 'inherit' : 'ignore', + windowsHide: true, }; execSync('nx run-many -t build -p devkit,typedoc-theme', execSyncOptions); diff --git a/scripts/documentation/generators/main.ts b/scripts/documentation/generators/main.ts index 8ea465e689354..7f8348ebdccac 100644 --- a/scripts/documentation/generators/main.ts +++ b/scripts/documentation/generators/main.ts @@ -38,7 +38,9 @@ async function generate() { } function checkDocumentation() { - const output = execSync('git status --porcelain ./docs').toString('utf-8'); + const output = execSync('git status --porcelain ./docs', { + windowsHide: true, + }).toString('utf-8'); if (output) { console.log( @@ -50,7 +52,10 @@ function checkDocumentation() { ); console.log('\nChanged Docs:'); - execSync('git status --porcelain ./docs', { stdio: 'inherit' }); + execSync('git status --porcelain ./docs', { + stdio: 'inherit', + windowsHide: true, + }); process.exit(1); } else { diff --git a/scripts/generate-graph-environment.ts b/scripts/generate-graph-environment.ts index e05157e5e17aa..28bd01e07dc6c 100644 --- a/scripts/generate-graph-environment.ts +++ b/scripts/generate-graph-environment.ts @@ -62,7 +62,9 @@ function writeFile() { // if no generated projects are found, generate one for nx and try this again if (generatedGraphs.length === 0) { - execSync('nx run graph-client:generate-graph --directory ./ --name nx'); + execSync('nx run graph-client:generate-graph --directory ./ --name nx', { + windowsHide: true, + }); writeFile(); return; } diff --git a/scripts/generate-graph.ts b/scripts/generate-graph.ts index ca35cb53d33a5..e006d89450560 100644 --- a/scripts/generate-graph.ts +++ b/scripts/generate-graph.ts @@ -13,7 +13,7 @@ async function generateGraph(directory: string, name: string) { try { execSync( 'npx nx graph --file ./node_modules/.cache/nx-graph-gen/graph.html', - { cwd: directory, stdio: 'ignore' } + { cwd: directory, stdio: 'ignore', windowsHide: true } ); } catch { console.error(`Could not run graph command in directory ${directory}`); diff --git a/scripts/nx-release.ts b/scripts/nx-release.ts index 71728df240055..de7fc6004b8e7 100755 --- a/scripts/nx-release.ts +++ b/scripts/nx-release.ts @@ -35,6 +35,7 @@ const VALID_AUTHORS_FOR_LATEST = [ execSync(`pnpm nx copy-native-package-directories nx`, { stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', maxBuffer: LARGE_BUFFER, + windowsHide: true, }); // Expected to run as part of the Github `publish` workflow @@ -44,11 +45,13 @@ const VALID_AUTHORS_FOR_LATEST = [ execSync('find ./build -name "*.node" -delete', { stdio: [0, 1, 2], maxBuffer: LARGE_BUFFER, + windowsHide: true, }); execSync('pnpm nx run-many --target=artifacts', { stdio: [0, 1, 2], maxBuffer: LARGE_BUFFER, + windowsHide: true, }); } @@ -66,6 +69,7 @@ const VALID_AUTHORS_FOR_LATEST = [ execSync(versionCommand, { stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', maxBuffer: LARGE_BUFFER, + windowsHide: true, }); }; @@ -74,7 +78,9 @@ const VALID_AUTHORS_FOR_LATEST = [ // For this important use-case it makes sense to always have full logs isVerboseLogging = true; - execSync('git status --ahead-behind'); + execSync('git status --ahead-behind', { + windowsHide: true, + }); if (isRelativeVersionKeyword(options.version)) { throw new Error( @@ -87,6 +93,7 @@ const VALID_AUTHORS_FOR_LATEST = [ execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, { stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', maxBuffer: LARGE_BUFFER, + windowsHide: true, }); let changelogCommand = `pnpm nx release changelog ${options.version} --interactive workspace`; @@ -106,6 +113,7 @@ const VALID_AUTHORS_FOR_LATEST = [ execSync(changelogCommand, { stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', maxBuffer: LARGE_BUFFER, + windowsHide: true, }); console.log( @@ -119,6 +127,7 @@ const VALID_AUTHORS_FOR_LATEST = [ execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, { stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', maxBuffer: LARGE_BUFFER, + windowsHide: true, }); const distTag = determineDistTag(options.version); @@ -174,12 +183,17 @@ const VALID_AUTHORS_FOR_LATEST = [ execSync(publishCommand, { stdio: [0, 1, 2], maxBuffer: LARGE_BUFFER, + windowsHide: true, }); if (!options.dryRun) { let version; if (['minor', 'major', 'patch'].includes(options.version)) { - version = execSync(`npm view nx@${distTag} version`).toString().trim(); + version = execSync(`npm view nx@${distTag} version`, { + windowsHide: true, + }) + .toString() + .trim(); } else { version = options.version; } @@ -256,10 +270,14 @@ function parseArgs() { * Handle the special case of `canary` */ - const currentLatestVersion = execSync('npm view nx@latest version') + const currentLatestVersion = execSync('npm view nx@latest version', { + windowsHide: true, + }) .toString() .trim(); - const currentNextVersion = execSync('npm view nx@next version') + const currentNextVersion = execSync('npm view nx@next version', { + windowsHide: true, + }) .toString() .trim(); @@ -290,7 +308,11 @@ function parseArgs() { const YYYYMMDD = `${year}${month}${day}`; // Get the current short git sha - const gitSha = execSync('git rev-parse --short HEAD').toString().trim(); + const gitSha = execSync('git rev-parse --short HEAD', { + windowsHide: true, + }) + .toString() + .trim(); const canaryVersion = `${canaryBaseVersion}-canary.${YYYYMMDD}-${gitSha}`; @@ -358,7 +380,13 @@ function parseArgs() { } function getRegistry() { - return new URL(execSync('npm config get registry').toString().trim()); + return new URL( + execSync('npm config get registry', { + windowsHide: true, + }) + .toString() + .trim() + ); } function determineDistTag( @@ -392,7 +420,9 @@ function determineDistTag( ); } - const currentLatestVersion = execSync('npm view nx version') + const currentLatestVersion = execSync('npm view nx version', { + windowsHide: true, + }) .toString() .trim(); const parsedCurrentLatestVersion = parse(currentLatestVersion); diff --git a/scripts/release-docs.ts b/scripts/release-docs.ts index ddfc1f11770e1..6fce35d15a961 100644 --- a/scripts/release-docs.ts +++ b/scripts/release-docs.ts @@ -8,7 +8,9 @@ console.log(`Comparing ${currentVersion} to npm versions`); const majorVersion = major(currentVersion); const releasedVersions: string[] = JSON.parse( - execSync(`npm show nx@^${majorVersion} version --json`).toString() + execSync(`npm show nx@^${majorVersion} version --json`, { + windowsHide: true, + }).toString() ); const latestVersion = maxSatisfying(releasedVersions, `^${majorVersion}`); @@ -23,8 +25,12 @@ if (currentVersion && latestVersion && gte(currentVersion, latestVersion)) { `Publishing docs site for ${process.env.GITHUB_REF_NAME} to ${branchName}` ); // We force recreate the branch in order to always be up to date and avoid merge conflicts within the automated workflow - execSync(`git branch -f ${branchName}`); - execSync(`git push -f origin ${branchName}`); + execSync(`git branch -f ${branchName}`, { + windowsHide: true, + }); + execSync(`git push -f origin ${branchName}`, { + windowsHide: true, + }); } else { console.log(`Not publishing docs to ${branchName}`); }