chore(core): refactor implicit dependencies code (#18825)
This commit is contained in:
parent
ed6d7f721f
commit
83ebf0f799
@ -1 +0,0 @@
|
||||
export * from './implicit-project-dependencies';
|
||||
@ -10,7 +10,7 @@ import {
|
||||
shouldRecomputeWholeGraph,
|
||||
writeCache,
|
||||
} from './nx-deps-cache';
|
||||
import { buildImplicitProjectDependencies } from './build-dependencies';
|
||||
import { applyImplicitDependencies } from './utils/implicit-project-dependencies';
|
||||
import { normalizeProjectNodes } from './utils/normalize-project-nodes';
|
||||
import { isNxPluginV1, isNxPluginV2, loadNxPlugins } from '../utils/nx-plugin';
|
||||
import { getRootTsConfigPath } from '../plugins/js/utils/typescript';
|
||||
@ -167,7 +167,7 @@ async function buildProjectGraphUsingContext(
|
||||
}
|
||||
}
|
||||
|
||||
buildImplicitProjectDependencies(ctx, updatedBuilder);
|
||||
applyImplicitDependencies(ctx.projectsConfigurations, updatedBuilder);
|
||||
|
||||
const finalGraph = updatedBuilder.getUpdatedProjectGraph();
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { ProjectGraphProcessorContext } from '../../config/project-graph';
|
||||
import { ProjectGraphBuilder } from '../project-graph-builder';
|
||||
import { buildImplicitProjectDependencies } from './implicit-project-dependencies';
|
||||
import { applyImplicitDependencies } from './implicit-project-dependencies';
|
||||
|
||||
jest.mock('fs', () => {
|
||||
const memFs = require('memfs').fs;
|
||||
@ -13,7 +12,7 @@ jest.mock('nx/src/utils/workspace-root', () => ({
|
||||
workspaceRoot: '/root',
|
||||
}));
|
||||
|
||||
describe('explicit project dependencies', () => {
|
||||
describe('implicit project dependencies', () => {
|
||||
it(`should add implicit deps`, () => {
|
||||
const builder = new ProjectGraphBuilder();
|
||||
builder.addNode({
|
||||
@ -25,17 +24,13 @@ describe('explicit project dependencies', () => {
|
||||
data: {},
|
||||
} as any);
|
||||
|
||||
buildImplicitProjectDependencies(
|
||||
applyImplicitDependencies(
|
||||
{
|
||||
filesToProcess: {},
|
||||
fileMap: {},
|
||||
projectsConfigurations: {
|
||||
version: 2,
|
||||
projects: {
|
||||
proj1: { root: '', implicitDependencies: ['proj2'] },
|
||||
},
|
||||
version: 2,
|
||||
projects: {
|
||||
proj1: { root: '', implicitDependencies: ['proj2'] },
|
||||
},
|
||||
} as Partial<ProjectGraphProcessorContext> as ProjectGraphProcessorContext,
|
||||
},
|
||||
builder
|
||||
);
|
||||
|
||||
@ -60,17 +55,13 @@ describe('explicit project dependencies', () => {
|
||||
} as any);
|
||||
builder.addImplicitDependency('proj1', 'proj2');
|
||||
|
||||
buildImplicitProjectDependencies(
|
||||
applyImplicitDependencies(
|
||||
{
|
||||
filesToProcess: {},
|
||||
fileMap: {},
|
||||
projectsConfigurations: {
|
||||
version: 2,
|
||||
projects: {
|
||||
proj1: { root: '', implicitDependencies: ['!proj2'] },
|
||||
},
|
||||
version: 2,
|
||||
projects: {
|
||||
proj1: { root: '', implicitDependencies: ['!proj2'] },
|
||||
},
|
||||
} as Partial<ProjectGraphProcessorContext> as ProjectGraphProcessorContext,
|
||||
},
|
||||
builder
|
||||
);
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { ProjectGraphProcessorContext } from '../../config/project-graph';
|
||||
import { ProjectsConfigurations } from '../../config/workspace-json-project-json';
|
||||
import { ProjectGraphBuilder } from '../project-graph-builder';
|
||||
|
||||
export function buildImplicitProjectDependencies(
|
||||
ctx: ProjectGraphProcessorContext,
|
||||
export function applyImplicitDependencies(
|
||||
projectsConfigurations: ProjectsConfigurations,
|
||||
builder: ProjectGraphBuilder
|
||||
) {
|
||||
Object.keys(ctx.projectsConfigurations.projects).forEach((source) => {
|
||||
const p = ctx.projectsConfigurations.projects[source];
|
||||
Object.keys(projectsConfigurations.projects).forEach((source) => {
|
||||
const p = projectsConfigurations.projects[source];
|
||||
if (p.implicitDependencies && p.implicitDependencies.length > 0) {
|
||||
p.implicitDependencies.forEach((target) => {
|
||||
if (target.startsWith('!')) {
|
||||
Loading…
x
Reference in New Issue
Block a user