From 0eb4cae4580418e3c466832824a155b937d2fa7e Mon Sep 17 00:00:00 2001 From: FrozenPandaz Date: Wed, 11 Oct 2023 16:56:43 -0400 Subject: [PATCH] chore(core): fix outputs --- e2e/angular-core/src/config.test.ts | 2 +- e2e/next-core/src/next-webpack.test.ts | 2 +- e2e/nx-run/src/invoke-runner.test.ts | 4 ++-- packages/nx/src/tasks-runner/init-tasks-runner.ts | 9 +++++++++ .../files/hasher/__fileName__/hasher.spec.ts__tmpl__ | 3 ++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/e2e/angular-core/src/config.test.ts b/e2e/angular-core/src/config.test.ts index 36f16520947d7c..663bd42631fe00 100644 --- a/e2e/angular-core/src/config.test.ts +++ b/e2e/angular-core/src/config.test.ts @@ -130,7 +130,7 @@ const angularV1Json = (appName: string) => `{ }, "test": { "builder": "@nx/jest:jest", - "outputs": ["coverage${appName}"], + "outputs": ["{workspaceRoot}/coverage${appName}"], "options": { "jestConfig": "${appName}/jest.config.ts", "passWithNoTests": true diff --git a/e2e/next-core/src/next-webpack.test.ts b/e2e/next-core/src/next-webpack.test.ts index cc69d36acc15df..6881944affdc31 100644 --- a/e2e/next-core/src/next-webpack.test.ts +++ b/e2e/next-core/src/next-webpack.test.ts @@ -84,7 +84,7 @@ describe('Next.js Webpack', () => { updateJson(join('apps', appName, 'project.json'), (json) => { json.targets.build = { command: 'npx next build', - outputs: [`apps/${appName}/.next`], + outputs: [`{projectRoot}/.next`], options: { cwd: `apps/${appName}`, }, diff --git a/e2e/nx-run/src/invoke-runner.test.ts b/e2e/nx-run/src/invoke-runner.test.ts index 4f6f27073c5ea4..c28d4285f2f163 100644 --- a/e2e/nx-run/src/invoke-runner.test.ts +++ b/e2e/nx-run/src/invoke-runner.test.ts @@ -35,8 +35,8 @@ describe('Invoke Runner', () => { async function main(){ const r = await initTasksRunner({}); - await r.invoke({tasks: [{id: '${mylib}:prebuild', target: {project: '${mylib}', target: 'prebuild'}, overrides: {__overrides_unparsed__: ''}}]}); - await r.invoke({tasks: [{id: '${mylib}:build', target: {project: '${mylib}', target: 'build'}, overrides: {__overrides_unparsed__: ''}}]}); + await r.invoke({tasks: [{id: '${mylib}:prebuild', target: {project: '${mylib}', target: 'prebuild'}, outputs: [], overrides: {__overrides_unparsed__: ''}}]}); + await r.invoke({tasks: [{id: '${mylib}:build', target: {project: '${mylib}', target: 'build'}, outputs: [], overrides: {__overrides_unparsed__: ''}}]}); } main().then(q => { diff --git a/packages/nx/src/tasks-runner/init-tasks-runner.ts b/packages/nx/src/tasks-runner/init-tasks-runner.ts index ba4d5c4ad3a25e..26e9bb956ec646 100644 --- a/packages/nx/src/tasks-runner/init-tasks-runner.ts +++ b/packages/nx/src/tasks-runner/init-tasks-runner.ts @@ -6,6 +6,7 @@ import { Task, TaskGraph } from '../config/task-graph'; import { invokeTasksRunner } from './run-command'; import { InvokeRunnerTerminalOutputLifeCycle } from './life-cycles/invoke-runner-terminal-output-life-cycle'; import { performance } from 'perf_hooks'; +import { getOutputs } from './utils'; export async function initTasksRunner(nxArgs: NxArgs) { performance.mark('init-local'); @@ -21,6 +22,14 @@ export async function initTasksRunner(nxArgs: NxArgs) { parallel: number; }): Promise<{ status: number; taskGraph: TaskGraph }> => { performance.mark('code-loading:end'); + + // TODO: This polyfills the outputs if someone doesn't pass a task with outputs. Remove this in Nx 18 + opts.tasks.forEach((t) => { + if (!t.outputs) { + t.outputs = getOutputs(projectGraph.nodes, t.target, t.overrides); + } + }); + const lifeCycle = new InvokeRunnerTerminalOutputLifeCycle(opts.tasks); const taskGraph = { diff --git a/packages/plugin/src/generators/executor/files/hasher/__fileName__/hasher.spec.ts__tmpl__ b/packages/plugin/src/generators/executor/files/hasher/__fileName__/hasher.spec.ts__tmpl__ index d52999c71fda03..bcdaac89f331ad 100644 --- a/packages/plugin/src/generators/executor/files/hasher/__fileName__/hasher.spec.ts__tmpl__ +++ b/packages/plugin/src/generators/executor/files/hasher/__fileName__/hasher.spec.ts__tmpl__ @@ -13,7 +13,8 @@ describe('<%=propertyName%>Hasher', () => { project: 'proj', target: 'target' }, - overrides: {} + overrides: {}, + outputs: [] }, { hasher: mockHasher } as unknown as HasherContext)