From caec117288560cc7bbaae7a545f332e6dcfc0119 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Thu, 8 Sep 2022 14:59:01 -0700 Subject: [PATCH] fix(core): add back target defaults for all new workspaces (#11936) --- e2e/nx-run/src/cache.test.ts | 4 ++-- .../src/generators/workspace/workspace.spec.ts | 5 +++++ .../workspace/src/generators/workspace/workspace.ts | 13 +++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/e2e/nx-run/src/cache.test.ts b/e2e/nx-run/src/cache.test.ts index 0868b05d88288..249220afcfbc1 100644 --- a/e2e/nx-run/src/cache.test.ts +++ b/e2e/nx-run/src/cache.test.ts @@ -64,9 +64,9 @@ describe('cache', () => { // touch package.json // -------------------------------------------- - updateFile(`package.json`, (c) => { + updateFile(`nx.json`, (c) => { const r = JSON.parse(c); - r.description = 'different'; + r.affected.defaultBase = 'different'; return JSON.stringify(r); }); const outputWithNoBuildCached = runCLI(`affected:build ${files}`); diff --git a/packages/workspace/src/generators/workspace/workspace.spec.ts b/packages/workspace/src/generators/workspace/workspace.spec.ts index 57d94b4a2cbde..15c2da4c0e839 100644 --- a/packages/workspace/src/generators/workspace/workspace.spec.ts +++ b/packages/workspace/src/generators/workspace/workspace.spec.ts @@ -53,6 +53,11 @@ describe('@nrwl/workspace:workspace', () => { }, }, }, + targetDefaults: { + build: { + dependsOn: ['^build'], + }, + }, }); const validateNxJson = ajv.compile(nxSchema); expect(validateNxJson(nxJson)).toEqual(true); diff --git a/packages/workspace/src/generators/workspace/workspace.ts b/packages/workspace/src/generators/workspace/workspace.ts index 502022de2a305..ff320f6f37a7a 100644 --- a/packages/workspace/src/generators/workspace/workspace.ts +++ b/packages/workspace/src/generators/workspace/workspace.ts @@ -80,6 +80,12 @@ function createNxJson( }, }; + nxJson.targetDefaults = { + build: { + dependsOn: ['^build'], + }, + }; + if ( preset !== Preset.Core && preset !== Preset.NPM && @@ -90,12 +96,7 @@ function createNxJson( production: ['default'], sharedGlobals: [], }; - nxJson.targetDefaults = { - build: { - dependsOn: ['^build'], - inputs: ['production', '^production'], - }, - }; + nxJson.targetDefaults.build.inputs = ['production', '^production']; } if (packageManager && cli === 'angular') {