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