diff --git a/packages/js/src/generators/release-version/release-version.ts b/packages/js/src/generators/release-version/release-version.ts index f6c2b88e79..23a17728ce 100644 --- a/packages/js/src/generators/release-version/release-version.ts +++ b/packages/js/src/generators/release-version/release-version.ts @@ -27,7 +27,7 @@ import { deriveNewSemverVersion, validReleaseVersionPrefixes, } from 'nx/src/command-line/release/version'; -import { daemonClient } from 'nx/src/daemon/client/client'; + import { interpolate } from 'nx/src/tasks-runner/utils'; import * as ora from 'ora'; import { relative } from 'path'; @@ -500,29 +500,7 @@ To fix this you will either need to add a package.json file at that location, or data: versionData, callback: async (tree, opts) => { const cwd = tree.root; - - const isDaemonEnabled = daemonClient.enabled(); - if (isDaemonEnabled) { - // temporarily stop the daemon, as it will error if the lock file is updated - await daemonClient.stop(); - } - - const updatedFiles = updateLockFile(cwd, opts); - - if (isDaemonEnabled) { - try { - await daemonClient.startInBackground(); - } catch (e) { - // If the daemon fails to start, we don't want to prevent the user from continuing, so we just log the error and move on - if (opts.verbose) { - output.warn({ - title: - 'Unable to restart the Nx Daemon. It will be disabled until you run "nx reset"', - bodyLines: [e.message], - }); - } - } - } + const updatedFiles = await updateLockFile(cwd, opts); return updatedFiles; }, }; 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 976c7e445d..3f3ec5a744 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 @@ -5,11 +5,12 @@ import { output, } from '@nx/devkit'; import { execSync } from 'child_process'; +import { daemonClient } from 'nx/src/daemon/client/client'; // eslint-disable-next-line @typescript-eslint/no-restricted-imports import { getLockFileName } from 'nx/src/plugins/js/lock-file/lock-file'; import { gte } from 'semver'; -export function updateLockFile( +export async function updateLockFile( cwd: string, { dryRun, @@ -30,6 +31,12 @@ export function updateLockFile( return []; } + const isDaemonEnabled = daemonClient.enabled(); + if (isDaemonEnabled) { + // temporarily stop the daemon, as it will error if the lock file is updated + await daemonClient.stop(); + } + const packageManager = detectPackageManager(cwd); const packageManagerCommands = getPackageManagerCommand(packageManager); @@ -72,6 +79,21 @@ export function updateLockFile( execLockFileUpdate(command, cwd, env); + if (isDaemonEnabled) { + try { + await daemonClient.startInBackground(); + } catch (e) { + // If the daemon fails to start, we don't want to prevent the user from continuing, so we just log the error and move on + if (verbose) { + output.warn({ + title: + 'Unable to restart the Nx Daemon. It will be disabled until you run "nx reset"', + bodyLines: [e.message], + }); + } + } + } + return [lockFile]; } diff --git a/scripts/nx-release.ts b/scripts/nx-release.ts index b313dbbd12..8cf8fa7aa3 100755 --- a/scripts/nx-release.ts +++ b/scripts/nx-release.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node import { createProjectGraphAsync, workspaceRoot } from '@nx/devkit'; +import * as chalk from 'chalk'; import { execSync } from 'node:child_process'; import { rmSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; @@ -7,7 +8,6 @@ import { URL } from 'node:url'; import { isRelativeVersionKeyword } from 'nx/src/command-line/release/utils/semver'; import { ReleaseType, inc, major, parse } from 'semver'; import * as yargs from 'yargs'; -import * as chalk from 'chalk'; const LARGE_BUFFER = 1024 * 1000000; @@ -58,6 +58,9 @@ const LARGE_BUFFER = 1024 * 1000000; if (options.dryRun) { versionCommand += ' --dry-run'; } + if (isVerboseLogging) { + versionCommand += ' --verbose'; + } console.log(`> ${versionCommand}`); execSync(versionCommand, { stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', @@ -95,6 +98,9 @@ const LARGE_BUFFER = 1024 * 1000000; if (options.dryRun) { changelogCommand += ' --dry-run'; } + if (isVerboseLogging) { + changelogCommand += ' --verbose'; + } console.log(`> ${changelogCommand}`); execSync(changelogCommand, { stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',