Skip to content

Commit

Permalink
fix(devkit): use Workspace in devkit for backwards compatibility (#18246
Browse files Browse the repository at this point in the history
)
  • Loading branch information
xiongemi authored Jul 21, 2023
1 parent 8407d7a commit 2e6592c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import type { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils';
import { WebpackNxBuildCoordinationPlugin } from '@nx/webpack/src/plugins/webpack-nx-build-coordination-plugin';
import { existsSync } from 'fs';
import { readNxJson } from 'nx/src/config/nx-json';
import { readNxJson } from 'nx/src/config/configuration';
import { isNpmProject } from 'nx/src/project-graph/operators';
import { getDependencyConfigs } from 'nx/src/tasks-runner/utils';
import { from, Observable } from 'rxjs';
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/utils/ct-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
findProjectForPath,
} from 'nx/src/project-graph/utils/find-project-for-path';
import { readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph';
import { readNxJson } from 'nx/src/config/nx-json';
import { readNxJson } from 'nx/src/config/configuration';

export const CY_FILE_MATCHER = new RegExp(/\.cy\.[tj]sx?$/);
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/utils/find-target-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Tree,
workspaceRoot,
} from '@nx/devkit';
import { readNxJson } from 'nx/src/config/nx-json';
import { readNxJson } from 'nx/src/config/configuration';
import { readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph';

interface FindTargetOptions {
Expand Down
9 changes: 4 additions & 5 deletions packages/devkit/src/executors/read-target-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ export function readTargetOptions<T = any>(

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,
Expand Down
7 changes: 4 additions & 3 deletions packages/devkit/src/utils/convert-nx-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/utils/project-graph-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
createProjectRootMappings,
ProjectRootMappings,
} from 'nx/src/project-graph/utils/find-project-for-path';
import { readNxJson } from 'nx/src/config/nx-json';
import { readNxJson } from 'nx/src/config/configuration';
import { TargetProjectLocator } from '@nx/js/src/internal';
import { readProjectFileMapCache } from 'nx/src/project-graph/nx-deps-cache';

Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/utils/find-npm-dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from 'path';
import { readNxJson } from 'nx/src/config/nx-json';
import { readNxJson } from 'nx/src/config/configuration';
import {
getTargetInputs,
filterUsingGlobPatterns,
Expand Down

1 comment on commit 2e6592c

@vercel
Copy link

@vercel vercel bot commented on 2e6592c Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.