Skip to content

Commit 7df9d96

Browse files
feat(core): add command to download cloud client (#34333)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> The only way to download the cloud client is to run a specific cloud command or a task with cloud configured. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> A new command is added where we only download the cloud client with: ``` nx download-cloud-client ``` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
1 parent 05fb208 commit 7df9d96

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { CommandModule } from 'yargs';
2+
import { withVerbose } from '../../yargs-utils/shared-options';
3+
4+
export const yargsDownloadCloudClientCommand: CommandModule = {
5+
command: 'download-cloud-client',
6+
describe: 'Download the Nx Cloud client.',
7+
builder: (yargs) => withVerbose(yargs),
8+
handler: async (args: any) => {
9+
process.exit(
10+
await (
11+
await import('./download-cloud-client')
12+
).downloadCloudClientHandler(args)
13+
);
14+
},
15+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { readNxJson } from '../../../config/nx-json';
2+
import { verifyOrUpdateNxCloudClient } from '../../../nx-cloud/update-manager';
3+
import { getCloudOptions } from '../../../nx-cloud/utilities/get-cloud-options';
4+
import { isNxCloudUsed } from '../../../utils/nx-cloud-utils';
5+
import { handleErrors } from '../../../utils/handle-errors';
6+
import { output } from '../../../utils/output';
7+
import { warnNotConnectedToCloud } from '../utils';
8+
9+
export interface DownloadCloudClientArgs {
10+
verbose?: boolean;
11+
}
12+
13+
export function downloadCloudClientHandler(
14+
args: DownloadCloudClientArgs
15+
): Promise<number> {
16+
if (!isNxCloudUsed(readNxJson())) {
17+
warnNotConnectedToCloud();
18+
return Promise.resolve(1);
19+
}
20+
21+
return handleErrors(args.verbose, async () => {
22+
const options = getCloudOptions();
23+
const result = await verifyOrUpdateNxCloudClient(options);
24+
25+
if (result) {
26+
output.success({
27+
title: 'Nx Cloud client downloaded successfully',
28+
bodyLines: [`Version: ${result.version}`],
29+
});
30+
}
31+
});
32+
}

packages/nx/src/command-line/nx-commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { yargsStartCiRunCommand } from './nx-cloud/start-ci-run/command-object';
4646
import { yargsStartAgentCommand } from './nx-cloud/start-agent/command-object';
4747
import { yargsStopAllAgentsCommand } from './nx-cloud/complete-run/command-object';
4848
import { yargsFixCiCommand } from './nx-cloud/fix-ci/command-object';
49+
import { yargsDownloadCloudClientCommand } from './nx-cloud/download-cloud-client/command-object';
4950
import {
5051
yargsPrintAffectedCommand,
5152
yargsAffectedGraphCommand,
@@ -114,6 +115,7 @@ export const commandsObject = yargs
114115
.command(yargsStartAgentCommand)
115116
.command(yargsStopAllAgentsCommand)
116117
.command(yargsFixCiCommand)
118+
.command(yargsDownloadCloudClientCommand)
117119
.command(yargsMcpCommand)
118120
.command(resolveConformanceCommandObject())
119121
.command(resolveConformanceCheckCommandObject())

0 commit comments

Comments
 (0)