From c36e246c6fb3805e46c3ffe0ed11747f3e10e03a Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Fri, 26 Apr 2024 12:40:40 -0400 Subject: [PATCH] fix(core): affect all projects when nx.json is touched (#23036) --- .../locators/workspace-projects.spec.ts | 20 +++++++++++++++++++ .../affected/locators/workspace-projects.ts | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/nx/src/project-graph/affected/locators/workspace-projects.spec.ts b/packages/nx/src/project-graph/affected/locators/workspace-projects.spec.ts index 7177042f612a2..2bb8bed92ba1f 100644 --- a/packages/nx/src/project-graph/affected/locators/workspace-projects.spec.ts +++ b/packages/nx/src/project-graph/affected/locators/workspace-projects.spec.ts @@ -171,6 +171,26 @@ describe('getImplicitlyTouchedProjects', () => { [] ); }); + + it('should return every project when nx.json is touched', () => { + const graph = buildProjectGraphNodes({ + a: { + root: 'a', + namedInputs: { + files: ['{workspaceRoot}/a.txt'], + }, + targets: {}, + }, + b: { + root: 'b', + }, + }); + let fileChanges = getFileChanges(['nx.json']); + expect(getImplicitlyTouchedProjects(fileChanges, graph, nxJson)).toEqual([ + 'a', + 'b', + ]); + }); }); function buildProjectGraphNodes( diff --git a/packages/nx/src/project-graph/affected/locators/workspace-projects.ts b/packages/nx/src/project-graph/affected/locators/workspace-projects.ts index d7a1a777f6b4c..b95e1e5f0fb01 100644 --- a/packages/nx/src/project-graph/affected/locators/workspace-projects.ts +++ b/packages/nx/src/project-graph/affected/locators/workspace-projects.ts @@ -26,7 +26,9 @@ export const getImplicitlyTouchedProjects: TouchedProjectLocator = ( projectGraphNodes, nxJson ): string[] => { - const implicits = {}; + const implicits = { + 'nx.json': '*', + }; Object.values(projectGraphNodes || {}).forEach((node) => { const namedInputs = {