Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nx-cloud): display current token for connect-to-nx-cloud #14315

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/nx/src/command-line/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { output } from '../utils/output';
import { getPackageManagerCommand } from '../utils/package-manager';
import { execSync } from 'child_process';
import { readNxJson } from '../config/configuration';
import { isNxCloudUsed } from '../utils/nx-cloud-utils';
import {
getNxCloudToken,
getNxCloudUrl,
isNxCloudUsed,
} from '../utils/nx-cloud-utils';

export async function connectToNxCloudIfExplicitlyAsked(opts: {
[k: string]: any;
Expand Down Expand Up @@ -33,7 +37,14 @@ export async function connectToNxCloudCommand(
): Promise<boolean> {
if (isNxCloudUsed()) {
output.log({
title: 'This workspace is already connected to Nx Cloud.',
title: '✅ This workspace is already connected to Nx Cloud.',
bodyLines: [
'This means your workspace can use computation caching, distributed task execution, and show you run analytics.',
'Go to https://nx.app to learn more.',
' ',
'If you have not done so already, please claim this workspace:',
`${getNxCloudUrl()}'/orgs/workspace-setup?accessToken=${getNxCloudToken()}`,
],
});
return false;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/nx/src/utils/nx-cloud-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,14 @@ export function isNxCloudUsed() {
(r) => r.runner == '@nrwl/nx-cloud'
);
}

export function getNxCloudUrl(): string {
const taskRunner = isNxCloudUsed();
if (!taskRunner) throw new Error('@nrwl/nx-cloud runner not find in nx.json');
return taskRunner.options.url || 'https://nx.app';
}
export function getNxCloudToken(): string {
const taskRunner = isNxCloudUsed();
if (!taskRunner) throw new Error('@nrwl/nx-cloud runner not find in nx.json');
return taskRunner.options.accessToken;
}