Skip to content

Commit

Permalink
fix(nx-cloud): include nxCloudId when generating connect urls
Browse files Browse the repository at this point in the history
  • Loading branch information
lourw committed Sep 11, 2024
1 parent 5784b88 commit 157440c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/create-nx-workspace/src/utils/nx/nx-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export function readNxCloudToken(directory: string) {
// nx-ignore-next-line
)) as typeof import('nx/src/nx-cloud/utilities/get-cloud-options');

const { accessToken } = getCloudOptions(directory);
const { accessToken, nxCloudId } = getCloudOptions(directory);
nxCloudSpinner.succeed('Nx Cloud has been set up successfully');
return accessToken;
return accessToken || nxCloudId;
}

export async function getOnboardingInfo(
Expand Down
9 changes: 7 additions & 2 deletions packages/nx/src/nx-cloud/utilities/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export async function getNxCloudAppOnBoardingUrl(token: string) {

export function readNxCloudToken(tree: Tree) {
const nxJson = readNxJson(tree);
const { accessToken } = getRunnerOptions('default', nxJson, {}, true);
return accessToken;
const { accessToken, nxCloudId } = getRunnerOptions(
'default',
nxJson,
{},
true
);
return accessToken || nxCloudId;
}
18 changes: 0 additions & 18 deletions packages/nx/src/utils/nx-cloud-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,3 @@ export function getNxCloudUrl(nxJson: NxJsonConfiguration): string {
throw new Error('nx-cloud runner not found in nx.json');
return cloudRunner?.options?.url ?? nxJson.nxCloudUrl ?? 'https://nx.app';
}

export function getNxCloudToken(nxJson: NxJsonConfiguration): string {
const cloudRunner = Object.values(nxJson.tasksRunnerOptions ?? {}).find(
(r) => r.runner == '@nrwl/nx-cloud' || r.runner == 'nx-cloud'
);

if (
!cloudRunner &&
!(nxJson.nxCloudAccessToken || process.env.NX_CLOUD_ACCESS_TOKEN)
)
throw new Error('nx-cloud runner not found in nx.json');

return (
process.env.NX_CLOUD_ACCESS_TOKEN ??
cloudRunner?.options.accessToken ??
nxJson.nxCloudAccessToken
);
}

0 comments on commit 157440c

Please sign in to comment.