fix(release): do not restart the daemon when skipLockFileUpdate is set (#21389)
This commit is contained in:
parent
c811be5131
commit
69636ad7ba
@ -27,7 +27,7 @@ import {
|
|||||||
deriveNewSemverVersion,
|
deriveNewSemverVersion,
|
||||||
validReleaseVersionPrefixes,
|
validReleaseVersionPrefixes,
|
||||||
} from 'nx/src/command-line/release/version';
|
} from 'nx/src/command-line/release/version';
|
||||||
import { daemonClient } from 'nx/src/daemon/client/client';
|
|
||||||
import { interpolate } from 'nx/src/tasks-runner/utils';
|
import { interpolate } from 'nx/src/tasks-runner/utils';
|
||||||
import * as ora from 'ora';
|
import * as ora from 'ora';
|
||||||
import { relative } from 'path';
|
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,
|
data: versionData,
|
||||||
callback: async (tree, opts) => {
|
callback: async (tree, opts) => {
|
||||||
const cwd = tree.root;
|
const cwd = tree.root;
|
||||||
|
const updatedFiles = await updateLockFile(cwd, opts);
|
||||||
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],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return updatedFiles;
|
return updatedFiles;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,11 +5,12 @@ import {
|
|||||||
output,
|
output,
|
||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
|
import { daemonClient } from 'nx/src/daemon/client/client';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import { getLockFileName } from 'nx/src/plugins/js/lock-file/lock-file';
|
import { getLockFileName } from 'nx/src/plugins/js/lock-file/lock-file';
|
||||||
import { gte } from 'semver';
|
import { gte } from 'semver';
|
||||||
|
|
||||||
export function updateLockFile(
|
export async function updateLockFile(
|
||||||
cwd: string,
|
cwd: string,
|
||||||
{
|
{
|
||||||
dryRun,
|
dryRun,
|
||||||
@ -30,6 +31,12 @@ export function updateLockFile(
|
|||||||
return [];
|
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 packageManager = detectPackageManager(cwd);
|
||||||
const packageManagerCommands = getPackageManagerCommand(packageManager);
|
const packageManagerCommands = getPackageManagerCommand(packageManager);
|
||||||
|
|
||||||
@ -72,6 +79,21 @@ export function updateLockFile(
|
|||||||
|
|
||||||
execLockFileUpdate(command, cwd, env);
|
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];
|
return [lockFile];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { createProjectGraphAsync, workspaceRoot } from '@nx/devkit';
|
import { createProjectGraphAsync, workspaceRoot } from '@nx/devkit';
|
||||||
|
import * as chalk from 'chalk';
|
||||||
import { execSync } from 'node:child_process';
|
import { execSync } from 'node:child_process';
|
||||||
import { rmSync, writeFileSync } from 'node:fs';
|
import { rmSync, writeFileSync } from 'node:fs';
|
||||||
import { join } from 'node:path';
|
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 { isRelativeVersionKeyword } from 'nx/src/command-line/release/utils/semver';
|
||||||
import { ReleaseType, inc, major, parse } from 'semver';
|
import { ReleaseType, inc, major, parse } from 'semver';
|
||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
import * as chalk from 'chalk';
|
|
||||||
|
|
||||||
const LARGE_BUFFER = 1024 * 1000000;
|
const LARGE_BUFFER = 1024 * 1000000;
|
||||||
|
|
||||||
@ -58,6 +58,9 @@ const LARGE_BUFFER = 1024 * 1000000;
|
|||||||
if (options.dryRun) {
|
if (options.dryRun) {
|
||||||
versionCommand += ' --dry-run';
|
versionCommand += ' --dry-run';
|
||||||
}
|
}
|
||||||
|
if (isVerboseLogging) {
|
||||||
|
versionCommand += ' --verbose';
|
||||||
|
}
|
||||||
console.log(`> ${versionCommand}`);
|
console.log(`> ${versionCommand}`);
|
||||||
execSync(versionCommand, {
|
execSync(versionCommand, {
|
||||||
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
||||||
@ -95,6 +98,9 @@ const LARGE_BUFFER = 1024 * 1000000;
|
|||||||
if (options.dryRun) {
|
if (options.dryRun) {
|
||||||
changelogCommand += ' --dry-run';
|
changelogCommand += ' --dry-run';
|
||||||
}
|
}
|
||||||
|
if (isVerboseLogging) {
|
||||||
|
changelogCommand += ' --verbose';
|
||||||
|
}
|
||||||
console.log(`> ${changelogCommand}`);
|
console.log(`> ${changelogCommand}`);
|
||||||
execSync(changelogCommand, {
|
execSync(changelogCommand, {
|
||||||
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user