Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions packages/nx/src/command-line/show/show-target/info.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,4 +838,49 @@ describe('show target info', () => {
expect(allLogged).not.toContain('(from');
expect(allLogged).not.toContain('(by');
});

it('includes continuous and default-configuration deps in show target', async () => {
setGraph(
new GraphBuilder()
.addProjectConfiguration(
{
root: 'apps/my-app-e2e',
name: 'my-app-e2e',
targets: {
e2e: {
executor: 'nx:run-commands',
options: { command: 'playwright test' },
configurations: { ci: {} },
defaultConfiguration: 'ci',
dependsOn: [{ projects: ['my-app'], target: 'serve' }],
},
},
},
'app'
)
.addProjectConfiguration(
{
root: 'apps/my-app',
name: 'my-app',
targets: {
serve: {
executor: '@nx/web:dev-server',
continuous: true,
dependsOn: ['build'],
},
build: { executor: '@nx/web:build' },
},
},
'app'
)
.build()
);

await showTargetInfoHandler({ target: 'my-app-e2e:e2e', json: true });

const parsed = JSON.parse((console.log as jest.Mock).mock.calls[0][0]);
expect(parsed.dependsOn).toEqual(['my-app:serve']);
expect(parsed.transitiveTasks).toEqual(['my-app:build']);
expect(parsed.transitiveTasks).not.toContain('my-app-e2e:e2e:ci');
});
});
17 changes: 15 additions & 2 deletions packages/nx/src/command-line/show/show-target/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,21 @@ function resolveTaskGraphDependencies(
{}
);

const rootId = createTaskId(projectName, targetName, configuration);
const directDeps = taskGraph.dependencies[rootId] ?? [];
// `createTaskGraph` resolves the target's `defaultConfiguration`, so the real
// root task id may carry a `:config` suffix that `createTaskId` with the raw
// configuration would omit. Find the root task by (project, target) instead.
const rootTask = Object.values(taskGraph.tasks).find(
(task) =>
task.target.project === projectName && task.target.target === targetName
);
const rootId =
rootTask?.id ?? createTaskId(projectName, targetName, configuration);
// Continuous dependencies (e.g. dev servers) live in a separate map but are
// direct dependencies just like the entries in `dependencies`.
const directDeps = [
...(taskGraph.dependencies[rootId] ?? []),
...(taskGraph.continuousDependencies[rootId] ?? []),
];
const directDepSet = new Set<string>(directDeps);

const depSourceIndices = directDeps.map((depTaskId) => {
Expand Down
Loading