fix(devkit): use Workspace in devkit for backwards compatibility (#18246)

This commit is contained in:
Emily Xiong 2023-07-21 16:54:30 -04:00 committed by GitHub
parent 8407d7aedf
commit 2e6592c533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 13 deletions

View File

@ -6,7 +6,7 @@ import {
import type { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils'; import type { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils';
import { WebpackNxBuildCoordinationPlugin } from '@nx/webpack/src/plugins/webpack-nx-build-coordination-plugin'; import { WebpackNxBuildCoordinationPlugin } from '@nx/webpack/src/plugins/webpack-nx-build-coordination-plugin';
import { existsSync } from 'fs'; 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 { isNpmProject } from 'nx/src/project-graph/operators';
import { getDependencyConfigs } from 'nx/src/tasks-runner/utils'; import { getDependencyConfigs } from 'nx/src/tasks-runner/utils';
import { from, Observable } from 'rxjs'; import { from, Observable } from 'rxjs';

View File

@ -13,7 +13,7 @@ import {
findProjectForPath, findProjectForPath,
} from 'nx/src/project-graph/utils/find-project-for-path'; } from 'nx/src/project-graph/utils/find-project-for-path';
import { readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph'; 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?$/); export const CY_FILE_MATCHER = new RegExp(/\.cy\.[tj]sx?$/);
/** /**

View File

@ -13,7 +13,7 @@ import {
Tree, Tree,
workspaceRoot, workspaceRoot,
} from '@nx/devkit'; } 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'; import { readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph';
interface FindTargetOptions { interface FindTargetOptions {

View File

@ -22,11 +22,10 @@ export function readTargetOptions<T = any>(
const ws = new Workspaces(context.root); const ws = new Workspaces(context.root);
const [nodeModule, executorName] = targetConfiguration.executor.split(':'); const [nodeModule, executorName] = targetConfiguration.executor.split(':');
const { schema } = getExecutorInformation( const { schema } = getExecutorInformation
nodeModule, ? getExecutorInformation(nodeModule, executorName, context.root)
executorName, : // TODO(v18): remove readExecutor. This is to be backwards compatible with Nx 16.5 and below.
context.root (ws as any).readExecutor(nodeModule, executorName);
);
const defaultProject = ws.calculateDefaultProjectName( const defaultProject = ws.calculateDefaultProjectName(
context.cwd, context.cwd,

View File

@ -13,9 +13,10 @@ const { Workspaces, readNxJsonFromDisk } = requireNx();
export function convertNxExecutor(executor: Executor) { export function convertNxExecutor(executor: Executor) {
const builderFunction = (options, builderContext) => { const builderFunction = (options, builderContext) => {
const workspaces = new Workspaces(builderContext.workspaceRoot); const workspaces = new Workspaces(builderContext.workspaceRoot);
const nxJsonConfiguration = readNxJsonFromDisk( const nxJsonConfiguration = readNxJsonFromDisk
builderContext.workspaceRoot ? 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({ const projectsConfigurations = workspaces.readProjectsConfigurations({
_includeProjectsFromAngularJson: true, _includeProjectsFromAngularJson: true,
}); });

View File

@ -9,7 +9,7 @@ import {
createProjectRootMappings, createProjectRootMappings,
ProjectRootMappings, ProjectRootMappings,
} from 'nx/src/project-graph/utils/find-project-for-path'; } 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 { TargetProjectLocator } from '@nx/js/src/internal';
import { readProjectFileMapCache } from 'nx/src/project-graph/nx-deps-cache'; import { readProjectFileMapCache } from 'nx/src/project-graph/nx-deps-cache';

View File

@ -1,5 +1,5 @@
import { join } from 'path'; import { join } from 'path';
import { readNxJson } from 'nx/src/config/nx-json'; import { readNxJson } from 'nx/src/config/configuration';
import { import {
getTargetInputs, getTargetInputs,
filterUsingGlobPatterns, filterUsingGlobPatterns,