Skip to content

Commit

Permalink
chore: reduce project.json duplication
Browse files Browse the repository at this point in the history
chore: split npm prepublish task
  • Loading branch information
kpanot committed Jan 7, 2025
1 parent 0d746ca commit e6d7fd8
Show file tree
Hide file tree
Showing 76 changed files with 428 additions and 1,915 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ on:

env:
NX_PARALLEL: ${{ vars.NX_PARALLEL }}
NX_TASK_TARGET_CONFIGURATION: ci
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
Expand Down Expand Up @@ -72,9 +73,10 @@ jobs:
run: yarn nx run ama-sdk-schematics:build-swagger
- name: Test
env:
testCmd: ${{ inputs.affected && format('test:affected --base=remotes/origin/{0}', github.base_ref || github.ref_name) || 'test'}}
NX_BASE: ${{ format('remotes/origin/{0}', github.base_ref || github.ref_name) }}
testCmd: ${{ inputs.affected && 'test:affected' || 'test'}}
NODE_OPTIONS: ${{ runner.os == 'Windows' && '--max_old_space_size=4096' || '' }}
run: yarn ${{ env.testCmd }} --collectCoverage
run: yarn ${{ env.testCmd }}
- name: Upload results to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
Expand Down Expand Up @@ -114,7 +116,8 @@ jobs:
${{ runner.os }}
- name: Lint
env:
lintCmd: ${{ inputs.affected && format('lint:affected --base=remotes/origin/{0}', github.base_ref || github.ref_name) || 'lint'}}
NX_BASE: ${{ format('remotes/origin/{0}', github.base_ref || github.ref_name) }}
lintCmd: ${{ inputs.affected && 'lint:affected' || 'lint'}}
run: yarn ${{ env.lintCmd }} --configuration ci

# Check that the packaging of github-actions is still working
Expand All @@ -128,6 +131,7 @@ jobs:
uses: ./tools/github-actions/setup
- name: Package github actions
env:
nxCmd: ${{ inputs.affected && format('nx affected --base=remotes/origin/{0}', github.base_ref || github.ref_name) || 'nx run-many'}}
NX_BASE: ${{ format('remotes/origin/{0}', github.base_ref || github.ref_name) }}
nxCmd: ${{ inputs.affected && 'nx affected' || 'nx run-many'}}
run: yarn ${{ env.nxCmd }} --target=package-github-action

1 change: 1 addition & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:

env:
NX_PARALLEL: ${{ vars.NX_PARALLEL }}
NX_TASK_TARGET_CONFIGURATION: ci
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/it-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:

env:
NX_PARALLEL: ${{ vars.NX_PARALLEL }}
NX_TASK_TARGET_CONFIGURATION: ci
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:

env:
NX_PARALLEL: ${{ vars.NX_PARALLEL }}
NX_TASK_TARGET_CONFIGURATION: ci
YARN_ENABLE_HARDENED_MODE: 0
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ jobs:
- run: yarn set:version ${{ inputs.version }}
- name: Publish Extensions
if: '!inputs.prerelease'
run: yarn run ${{ endsWith(inputs.version, '.0') && 'publish:extensions' || 'publish:extensions:affected --base=HEAD~1' }}
run: yarn run ${{ endsWith(inputs.version, '.0') && 'publish:extensions' || 'publish:extensions:affected' }}
env:
NX_BASE: HEAD~1
VSCE_PAT: ${{ secrets.AZURE_VSC_EXT_TOKEN }}
CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CHROME_EXT_ID: ${{ secrets.CHROME_EXT_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ packageExtensions:
"@swc/types": "*"
"@typescript-eslint/rule-tester@*":
dependencies:
"@typescript-eslint/parser": ~8.18.0
"@typescript-eslint/parser": ~8.19.0
"@angular-eslint/eslint-plugin-template@*":
dependencies:
"@typescript-eslint/types": "^8.0.0"
Expand Down
7 changes: 1 addition & 6 deletions apps/chrome-devtools/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,7 @@
}
}
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/chrome-devtools/jest.config.js"
}
},
"test": {},
"copy-assets": {
"executor": "nx:run-script",
"options": {
Expand Down
11 changes: 2 additions & 9 deletions apps/github-cascading-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@
"script": "build"
}
},
"lint": {
"executor": "nx:run-commands"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/github-cascading-app/jest.config.js"
}
}
"lint": {},
"test": {}
},
"tags": []
}
5 changes: 1 addition & 4 deletions apps/showcase/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@
"dependsOn": ["^build", "^build-builders"]
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/showcase/jest.config.js"
}
"executor": "@nx/jest:jest"
},
"generate-theme": {
"executor": "@o3r/design:generate-css",
Expand Down
18 changes: 3 additions & 15 deletions apps/vscode-extension/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,9 @@
},
"outputs": ["{projectRoot}/dist/src/extension.js"]
},
"lint": {
"executor": "nx:run-commands"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/vscode-extension/jest.config.js"
}
},
"prepare-publish": {
"executor": "nx:run-script",
"options": {
"script": "prepare:publish"
}
},
"lint": {},
"test": {},
"prepare-publish": {},
"publish-extension": {
"executor": "nx:run-commands",
"options": {
Expand Down
52 changes: 51 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"cache": true
},
"test": {
"executor": "@nx/jest:jest",
"inputs": [
{
"env": "RUNNER_OS"
Expand All @@ -179,6 +180,8 @@
"{projectRoot}/coverage/cobertura-coverage.xml"
],
"options": {
"jestConfig": "{projectRoot}/jest.config.js",
"cacheDirectory": "{workspaceRoot}/.cache/jest",
"passWithNoTests": false,
"silent": true
},
Expand All @@ -191,6 +194,7 @@
"cache": true
},
"test-int": {
"executor": "@nx/jest:jest",
"inputs": [
{
"env": "RUNNER_OS"
Expand All @@ -211,6 +215,7 @@
"{projectRoot}/coverage/cobertura-coverage.xml"
],
"options": {
"jestConfig": "{projectRoot}/testing/jest.config.it.js",
"quiet": false,
"passWithNoTests": false
},
Expand All @@ -222,10 +227,39 @@
},
"cache": true
},
"publish": {
"cache": false,
"executor": "nx:run-commands",
"options": {
"command": "npm publish {projectRoot}/dist"
},
"outputs": [],
"inputs": [
"{projectRoot}/dist"
],
"dependsOn": [
"prepare-publish"
]
},
"prepare-publish": {
"cache": false,
"executor": "nx:run-script",
"options": {
"script": "prepare:publish"
},
"inputs": [
"{workspaceRoot}/readme.md",
"{workspaceRoot}/package.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/.npmignore",
"{projectRoot}/readme.md",
"{projectRoot}/.npmignore",
"{projectRoot}/package.json"
],
"outputs": [
"{projectRoot}/dist/package.json"
"{projectRoot}/dist/package.json",
"{projectRoot}/dist/readme.json",
"{projectRoot}/dist/LICENSE"
]
},
"publish-extension": {
Expand Down Expand Up @@ -325,6 +359,10 @@
"cache": true
},
"prepare-build-builders": {
"executor": "nx:run-script",
"options": {
"script": "prepare:build:builders"
},
"dependsOn": [
"compile"
],
Expand All @@ -345,6 +383,10 @@
"cache": true
},
"build-cli": {
"executor": "nx:run-script",
"options": {
"script": "build:cli"
},
"dependsOn": [
"compile"
],
Expand All @@ -364,6 +406,10 @@
"cache": true
},
"build-builders": {
"executor": "nx:run-script",
"options": {
"script": "build:builders"
},
"dependsOn": [
"^build",
"prepare-build-builders",
Expand Down Expand Up @@ -410,6 +456,10 @@
"cache": true
},
"documentation": {
"executor": "nx:run-script",
"options": {
"script": "compodoc"
},
"outputs": [
"{workspaceRoot}/generated-doc/{projectName}/**/*"
],
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
"build:tools": "yarn nx run-many --target=build --projects=eslint-plugin,workspace",
"build:lint": "yarn nx run-many --target=build --projects=eslint-plugin",
"build:swagger-gen": "yarn nx run-many --target=build-swagger",
"prepare:publish": "yarn prepare-publish \"$(yarn workspaces:list)\" --append dist",
"publish": "yarn run prepare:publish && yarn nx run-many --target=publish --exclude=tag:private --nx-bail",
"publish": "yarn nx run-many --target=publish --exclude=tag:private --nx-bail",
"publish:extensions": "yarn nx run-many --target=publish-extension",
"publish:extensions:affected": "yarn nx affected --target=publish-extension",
"package-github-actions:affected": "yarn nx affected --target=package-github-action",
"lint": "yarn nx run-many --target=lint",
"lint:affected": "yarn nx affected --target=lint",
"test": "yarn nx run-many --target=test --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test:affected": "yarn nx affected --target=test --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test": "yarn nx run-many --target=test",
"test:affected": "yarn nx affected --target=test",
"test-e2e": "yarn nx run-many --target=test-e2e",
"test-int": "yarn nx run-many --target=test-int",
"postinstall": "husky && yarn build:lint && yarn harmonize:version && yarn update-yarn-sdks",
Expand All @@ -44,7 +43,7 @@
"verdaccio:start-persistent": "docker run -d -it --rm --name verdaccio -p 4873:4873 -v \"$(yarn get:current-dir)/.verdaccio/conf\":/verdaccio/conf -v \"$(yarn get:current-dir)/.verdaccio/storage\":/verdaccio/storage:z verdaccio/verdaccio",
"verdaccio:clean": "rimraf -g \".verdaccio/storage/@{o3r,ama-sdk,ama-terasu}\"",
"verdaccio:login": "yarn cpy --cwd=./.verdaccio/conf .npmrc . --rename=.npmrc-logged && npx --yes npm-cli-login -u verdaccio -p verdaccio -e [email protected] -r http://127.0.0.1:4873 --config-path \".verdaccio/conf/.npmrc-logged\"",
"verdaccio:prepare-publish": "yarn verdaccio:clean && yarn set:version 999.0.$(node -e 'process.stdout.write(String(Date.now()))') --include \"!**/!(dist)/package.json\" --include !package.json && yarn verdaccio:login && replace-in-files --regex=\"private(.*)true\" --replacement=private\\$1false '**/dist/package.json' && yarn run prepare:publish",
"verdaccio:prepare-publish": "yarn verdaccio:clean && yarn set:version 999.0.$(node -e 'process.stdout.write(String(Date.now()))') --include \"!**/!(dist)/package.json\" --include !package.json && yarn verdaccio:login && replace-in-files --regex=\"private(.*)true\" --replacement=private\\$1false '**/dist/package.json'",
"verdaccio:publish": "yarn run verdaccio:prepare-publish && yarn nx run-many --target=publish --nx-bail --userconfig \".verdaccio/conf/.npmrc-logged\" --tag=latest --@o3r:registry=http://127.0.0.1:4873 --@ama-sdk:registry=http://127.0.0.1:4873 --@ama-terasu:registry=http://127.0.0.1:4873 --@o3r-training:registry=http://127.0.0.1:4873",
"verdaccio:stop": "docker container stop $(docker ps -a -q --filter=\"name=verdaccio\")",
"verdaccio:all": "yarn verdaccio:stop && yarn verdaccio:start && yarn verdaccio:publish",
Expand Down Expand Up @@ -186,7 +185,6 @@
"@nx/jest": "~19.8.0",
"@nx/js": "~19.8.0",
"@nx/workspace": "~19.8.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-config": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/telemetry": "workspace:^",
Expand Down
39 changes: 6 additions & 33 deletions packages/@ama-sdk/client-angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,12 @@
},
"outputs": ["{projectRoot}/dist/src"]
},
"lint": {
"executor": "nx:run-commands"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "packages/@ama-sdk/client-angular/jest.config.js"
}
},
"prepare-publish": {
"executor": "nx:run-script",
"options": {
"script": "prepare:publish"
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "npm publish packages/@ama-sdk/client-angular/dist"
}
},
"prepare-build-builders": {
"executor": "nx:run-script",
"options": {
"script": "prepare:build:builders"
}
},
"build-builders": {
"executor": "nx:run-script",
"options": {
"script": "build:builders"
}
}
"lint": {},
"test": {},
"prepare-publish": {},
"publish": {},
"prepare-build-builders": {},
"build-builders": {}
},
"tags": []
}
39 changes: 6 additions & 33 deletions packages/@ama-sdk/client-beacon/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,12 @@
},
"outputs": ["{projectRoot}/dist/src"]
},
"lint": {
"executor": "nx:run-commands"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "packages/@ama-sdk/client-beacon/jest.config.js"
}
},
"prepare-publish": {
"executor": "nx:run-script",
"options": {
"script": "prepare:publish"
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "npm publish packages/@ama-sdk/client-beacon/dist"
}
},
"prepare-build-builders": {
"executor": "nx:run-script",
"options": {
"script": "prepare:build:builders"
}
},
"build-builders": {
"executor": "nx:run-script",
"options": {
"script": "build:builders"
}
}
"lint": {},
"test": {},
"prepare-publish": {},
"publish": {},
"prepare-build-builders": {},
"build-builders": {}
},
"tags": []
}
Loading

0 comments on commit e6d7fd8

Please sign in to comment.