From a22a43141b76819906c55170a77629c002bbced3 Mon Sep 17 00:00:00 2001 From: Louie Weng <56288712+lourw@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:17:56 -0800 Subject: [PATCH] =?UTF-8?q?feat(nx-cloud):=20configure=20import=20paths=20?= =?UTF-8?q?for=20light=20client=20when=20running=20=E2=80=A6=20(#28735)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …login/logout ## Current Behavior When you call `nx login` and `nx logout`, we did not pass in import paths to node modules so the displayed messages for each command were just raw text. ## Expected Behavior When you call `login` or `logout`, you get formatting on the command output. ## Related Issue(s) Fixes # --- packages/nx/src/command-line/login/login.ts | 5 +++++ packages/nx/src/command-line/logout/logout.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/packages/nx/src/command-line/login/login.ts b/packages/nx/src/command-line/login/login.ts index 6b8c74ef51ec1..9d22e738f33ac 100644 --- a/packages/nx/src/command-line/login/login.ts +++ b/packages/nx/src/command-line/login/login.ts @@ -1,6 +1,7 @@ import { verifyOrUpdateNxCloudClient } from '../../nx-cloud/update-manager'; import { getCloudOptions } from '../../nx-cloud/utilities/get-cloud-options'; import { handleErrors } from '../../utils/handle-errors'; +import { findAncestorNodeModules } from '../../nx-cloud/resolution-helpers'; export interface LoginArgs { nxCloudUrl?: string; @@ -15,6 +16,10 @@ export function loginHandler(args: LoginArgs): Promise { return handleErrors(args.verbose, async () => { const nxCloudClient = (await verifyOrUpdateNxCloudClient(getCloudOptions())) .nxCloudClient; + + const paths = findAncestorNodeModules(__dirname, []); + nxCloudClient.configureLightClientRequire()(paths); + await nxCloudClient.commands.login(); }); } diff --git a/packages/nx/src/command-line/logout/logout.ts b/packages/nx/src/command-line/logout/logout.ts index 1e5b49035dcd9..b14ef54a79c2e 100644 --- a/packages/nx/src/command-line/logout/logout.ts +++ b/packages/nx/src/command-line/logout/logout.ts @@ -1,6 +1,7 @@ import { verifyOrUpdateNxCloudClient } from '../../nx-cloud/update-manager'; import { getCloudOptions } from '../../nx-cloud/utilities/get-cloud-options'; import { handleErrors } from '../../utils/handle-errors'; +import { findAncestorNodeModules } from '../../nx-cloud/resolution-helpers'; export interface LogoutArgs { verbose?: boolean; @@ -10,6 +11,10 @@ export function logoutHandler(args: LogoutArgs): Promise { return handleErrors(args.verbose, async () => { const nxCloudClient = (await verifyOrUpdateNxCloudClient(getCloudOptions())) .nxCloudClient; + + const paths = findAncestorNodeModules(__dirname, []); + nxCloudClient.configureLightClientRequire()(paths); + await nxCloudClient.commands.logout(); }); }