From 4484e569f0a2456674e99c2b70572ed310807a3d Mon Sep 17 00:00:00 2001 From: Emily Xiong Date: Fri, 21 Jul 2023 14:52:28 -0400 Subject: [PATCH] fix(devkit): use Workspace in devkit for backwards compatibility --- packages/devkit/src/executors/read-target-options.ts | 9 ++++----- packages/devkit/src/utils/convert-nx-executor.ts | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/devkit/src/executors/read-target-options.ts b/packages/devkit/src/executors/read-target-options.ts index 679848c24ea086..4c7417f5739d65 100644 --- a/packages/devkit/src/executors/read-target-options.ts +++ b/packages/devkit/src/executors/read-target-options.ts @@ -22,11 +22,10 @@ export function readTargetOptions( const ws = new Workspaces(context.root); const [nodeModule, executorName] = targetConfiguration.executor.split(':'); - const { schema } = getExecutorInformation( - nodeModule, - executorName, - context.root - ); + const { schema } = getExecutorInformation + ? getExecutorInformation(nodeModule, executorName, context.root) + : // TODO(v18): remove readExecutor. This is to be backwards compatible with Nx 16.5 and below. + (ws as any).readExecutor(nodeModule, executorName); const defaultProject = ws.calculateDefaultProjectName( context.cwd, diff --git a/packages/devkit/src/utils/convert-nx-executor.ts b/packages/devkit/src/utils/convert-nx-executor.ts index 2690929adec2d4..77a1fe4d815ad5 100644 --- a/packages/devkit/src/utils/convert-nx-executor.ts +++ b/packages/devkit/src/utils/convert-nx-executor.ts @@ -13,9 +13,10 @@ const { Workspaces, readNxJsonFromDisk } = requireNx(); export function convertNxExecutor(executor: Executor) { const builderFunction = (options, builderContext) => { const workspaces = new Workspaces(builderContext.workspaceRoot); - const nxJsonConfiguration = readNxJsonFromDisk( - builderContext.workspaceRoot - ); + const nxJsonConfiguration = readNxJsonFromDisk + ? readNxJsonFromDisk(builderContext.workspaceRoot) + : // TODO(v18): remove readNxJson. This is to be backwards compatible with Nx 16.5 and below. + (workspaces as any).readNxJson(); const projectsConfigurations = workspaces.readProjectsConfigurations({ _includeProjectsFromAngularJson: true, });