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
This commit is contained in:
Daniel Lockyer 2023-12-13 10:26:33 +01:00 committed by Daniel Lockyer
parent efec8b5fba
commit a9c9202b5c
5 changed files with 31 additions and 40 deletions

View File

@ -55,13 +55,13 @@ const adminXApps = '@tryghost/admin-x-demo,@tryghost/admin-x-settings';
const COMMANDS_ADMINX = [{ const COMMANDS_ADMINX = [{
name: 'adminXDeps', 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, '../..'), cwd: path.resolve(__dirname, '../..'),
prefixColor: '#C35831', prefixColor: '#C35831',
env: {} env: {}
}, { }, {
name: 'adminX', 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'), cwd: path.resolve(__dirname, '../../apps/admin-x-settings'),
prefixColor: '#C35831', prefixColor: '#C35831',
env: {} env: {}

View File

@ -25,7 +25,7 @@
"lint": "yarn run lint:code && yarn run lint:test", "lint": "yarn run lint:code && yarn run lint:test",
"lint:code": "eslint --ext .js,.ts,.cjs,.tsx --cache src", "lint:code": "eslint --ext .js,.ts,.cjs,.tsx --cache src",
"lint:test": "eslint -c test/.eslintrc.cjs --ext .js,.ts,.cjs,.tsx --cache test", "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": "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:slowmo": "TIMEOUT=100000 PLAYWRIGHT_SLOWMO=100 yarn test:acceptance --headed",
"test:acceptance:full": "ALL_BROWSERS=1 yarn test:acceptance", "test:acceptance:full": "ALL_BROWSERS=1 yarn test:acceptance",
@ -42,28 +42,19 @@
}, },
"nx": { "nx": {
"targets": { "targets": {
"build": { "dev": {
"dependsOn": [ "dependsOn": [
"build", "^build"
{ ]
"projects": [ },
"@tryghost/admin-x-design-system", "test:unit": {
"@tryghost/admin-x-framework" "dependsOn": [
], "^build"
"target": "build"
}
] ]
}, },
"test:acceptance": { "test:acceptance": {
"dependsOn": [ "dependsOn": [
"test:acceptance", "^build"
{
"projects": [
"@tryghost/admin-x-design-system",
"@tryghost/admin-x-framework"
],
"target": "build"
}
] ]
} }
} }

View File

@ -100,16 +100,15 @@
}, },
"nx": { "nx": {
"targets": { "targets": {
"build": { "dev": {
"dependsOn": [ "dependsOn": [
"build", "^build"
{"projects": ["@tryghost/admin-x-design-system"], "target": "build"}
] ]
}, },
"test:unit": { "test:unit": {
"dependsOn": [ "dependsOn": [
"test:unit", "test:unit",
{"projects": ["@tryghost/admin-x-design-system"], "target": "build"} "^build"
] ]
} }
} }

View File

@ -66,28 +66,15 @@
}, },
"nx": { "nx": {
"targets": { "targets": {
"build": { "dev": {
"dependsOn": [ "dependsOn": [
"build", "^build"
{
"projects": [
"@tryghost/admin-x-design-system",
"@tryghost/admin-x-framework"
],
"target": "build"
}
] ]
}, },
"test:acceptance": { "test:acceptance": {
"dependsOn": [ "dependsOn": [
"test:acceptance", "test:acceptance",
{ "^build"
"projects": [
"@tryghost/admin-x-design-system",
"@tryghost/admin-x-framework"
],
"target": "build"
}
] ]
} }
} }

14
nx.json
View File

@ -22,6 +22,20 @@
] ]
}, },
"targetDefaults": { "targetDefaults": {
"build": {
"dependsOn": [
"^build"
],
"inputs": [
"default",
"^default"
],
"outputs": [
"{projectRoot}/dist",
"{projectRoot}/es",
"{projectRoot}/umd"
]
},
"build:ts": { "build:ts": {
"dependsOn": [ "dependsOn": [
"^build:ts" "^build:ts"