From a9c9202b5c4bbb6cfb1cdd689cf3402ffb61be97 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Wed, 13 Dec 2023 10:26:33 +0100 Subject: [PATCH] Added defaults to Nx build step refs https://github.com/TryGhost/DevOps/issues/122 - this allows us to DRY up some of the other configuration we have dotted around and fixes a niche bug with overlapping builds that we were seeing before, because Nx should only allow one build at a time --- .github/scripts/dev.js | 4 ++-- apps/admin-x-demo/package.json | 27 +++++++++------------------ apps/admin-x-framework/package.json | 7 +++---- apps/admin-x-settings/package.json | 19 +++---------------- nx.json | 14 ++++++++++++++ 5 files changed, 31 insertions(+), 40 deletions(-) diff --git a/.github/scripts/dev.js b/.github/scripts/dev.js index 31c9b14092..f5974f3965 100644 --- a/.github/scripts/dev.js +++ b/.github/scripts/dev.js @@ -55,13 +55,13 @@ const adminXApps = '@tryghost/admin-x-demo,@tryghost/admin-x-settings'; const COMMANDS_ADMINX = [{ name: 'adminXDeps', - command: 'while [ 1 ]; do nx watch --projects=apps/admin-x-design-system,apps/admin-x-framework -- nx run \\$NX_PROJECT_NAME:build --skip-nx-cache; done', + command: 'while [ 1 ]; do nx watch --projects=apps/admin-x-design-system,apps/admin-x-framework -- nx run \\$NX_PROJECT_NAME:build; done', cwd: path.resolve(__dirname, '../..'), prefixColor: '#C35831', env: {} }, { name: 'adminX', - command: `nx run-many --projects=${adminXApps} --targets=build && nx run-many --projects=${adminXApps} --parallel=${adminXApps.length} --targets=dev`, + command: `nx run-many --projects=${adminXApps} --parallel=${adminXApps.length} --targets=dev`, cwd: path.resolve(__dirname, '../../apps/admin-x-settings'), prefixColor: '#C35831', env: {} diff --git a/apps/admin-x-demo/package.json b/apps/admin-x-demo/package.json index f0ce3a60d2..d949f11fa5 100644 --- a/apps/admin-x-demo/package.json +++ b/apps/admin-x-demo/package.json @@ -25,7 +25,7 @@ "lint": "yarn run lint:code && yarn run lint:test", "lint:code": "eslint --ext .js,.ts,.cjs,.tsx --cache src", "lint:test": "eslint -c test/.eslintrc.cjs --ext .js,.ts,.cjs,.tsx --cache test", - "test:unit": "yarn nx build && vitest run", + "test:unit": "vitest run", "test:acceptance": "NODE_OPTIONS='--experimental-specifier-resolution=node --no-warnings' VITE_TEST=true playwright test", "test:acceptance:slowmo": "TIMEOUT=100000 PLAYWRIGHT_SLOWMO=100 yarn test:acceptance --headed", "test:acceptance:full": "ALL_BROWSERS=1 yarn test:acceptance", @@ -42,28 +42,19 @@ }, "nx": { "targets": { - "build": { + "dev": { "dependsOn": [ - "build", - { - "projects": [ - "@tryghost/admin-x-design-system", - "@tryghost/admin-x-framework" - ], - "target": "build" - } + "^build" + ] + }, + "test:unit": { + "dependsOn": [ + "^build" ] }, "test:acceptance": { "dependsOn": [ - "test:acceptance", - { - "projects": [ - "@tryghost/admin-x-design-system", - "@tryghost/admin-x-framework" - ], - "target": "build" - } + "^build" ] } } diff --git a/apps/admin-x-framework/package.json b/apps/admin-x-framework/package.json index 50550f84d8..ad6293f734 100644 --- a/apps/admin-x-framework/package.json +++ b/apps/admin-x-framework/package.json @@ -100,16 +100,15 @@ }, "nx": { "targets": { - "build": { + "dev": { "dependsOn": [ - "build", - {"projects": ["@tryghost/admin-x-design-system"], "target": "build"} + "^build" ] }, "test:unit": { "dependsOn": [ "test:unit", - {"projects": ["@tryghost/admin-x-design-system"], "target": "build"} + "^build" ] } } diff --git a/apps/admin-x-settings/package.json b/apps/admin-x-settings/package.json index 5ef8b5e7fc..6740c1f8f8 100644 --- a/apps/admin-x-settings/package.json +++ b/apps/admin-x-settings/package.json @@ -66,28 +66,15 @@ }, "nx": { "targets": { - "build": { + "dev": { "dependsOn": [ - "build", - { - "projects": [ - "@tryghost/admin-x-design-system", - "@tryghost/admin-x-framework" - ], - "target": "build" - } + "^build" ] }, "test:acceptance": { "dependsOn": [ "test:acceptance", - { - "projects": [ - "@tryghost/admin-x-design-system", - "@tryghost/admin-x-framework" - ], - "target": "build" - } + "^build" ] } } diff --git a/nx.json b/nx.json index 096b1ad75c..aba23a9546 100644 --- a/nx.json +++ b/nx.json @@ -22,6 +22,20 @@ ] }, "targetDefaults": { + "build": { + "dependsOn": [ + "^build" + ], + "inputs": [ + "default", + "^default" + ], + "outputs": [ + "{projectRoot}/dist", + "{projectRoot}/es", + "{projectRoot}/umd" + ] + }, "build:ts": { "dependsOn": [ "^build:ts"