Skip to content

Commit 293e130

Browse files
feat(all): migrate to NX release
* chore: adding Nx workspace configuration * ci: adding Github Actions to run tests/build/linters using NX * fix: installing nx for project * fix: CI fix * fix: nx.json config * fix: CI fix * fix: using yarn build instead of rollup * fix: removing uneeded typecheck from parser and removing uneeded implicit dependencies * fix: making nx release run * ci: adding --first-release tag * fix: empty commit * ci: Running CI checks also on push * feat: removing lerna and semantic-release * fix: fixing failing test in form renderer * Adding script for project.json generation for sub-packages * Revert "Adding script for project.json generation for sub-packages" This reverts commit 5ecbdd8. * adding .nxignore files so the nx would not be confused with generated packages * making sure that nx publish the build files in the package directory * allow npm trusted publishing --------- Co-authored-by: Martin Marosi <marvusm.mmi@gmail.com>
1 parent e03943e commit 293e130

File tree

52 files changed

+3512
-5380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3512
-5380
lines changed

.github/workflows/main.yml

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,98 @@ on:
22
pull_request:
33
branches:
44
- master
5+
push:
6+
branches:
7+
- master
8+
9+
permissions:
10+
id-token: write
11+
contents: write
512

613
jobs:
7-
github-action-show-version:
14+
# Job that runs for both PR and merge
15+
ci-checks:
816
runs-on: ubuntu-latest
9-
name: Next version is
17+
name: CI Checks (Build, Lint, Test, Release Dry-Run)
1018
steps:
11-
- name: Publish a version comment
12-
uses: rvsia/github-action-show-version@v1.9alpha
13-
id: comment
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20'
28+
cache: 'yarn'
29+
30+
- name: Install dependencies
31+
run: yarn install --frozen-lockfile
32+
33+
- name: Derive appropriate SHAs for base and head for nx affected commands
34+
uses: nrwl/nx-set-shas@v4
1435
with:
15-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
36+
main-branch-name: 'master'
37+
38+
- name: Run build on affected projects
39+
run: npx nx affected --target=build --parallel=3
40+
continue-on-error: false
41+
42+
- name: Run lint on affected projects
43+
run: npx nx affected --target=lint --parallel=3
44+
continue-on-error: false
45+
46+
- name: Run typecheck on affected projects
47+
run: npx nx affected --target=typecheck --parallel=3
48+
continue-on-error: false
49+
50+
- name: Clear Jest cache
51+
run: yarn jest --clearCache
52+
53+
- name: Run tests on affected projects
54+
run: npx nx affected --target=test --parallel=3 --coverage
55+
continue-on-error: false
56+
57+
- name: Run Nx release dry-run (PR only)
58+
if: github.event_name == 'pull_request'
59+
run: npx nx release --dry-run --verbose
60+
61+
# Job that runs ONLY after merge (on push to master)
62+
release:
63+
if: github.event_name != 'pull_request'
64+
needs: ci-checks
65+
runs-on: ubuntu-latest
66+
name: Release
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Setup Node.js
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: '20'
77+
cache: 'yarn'
78+
79+
- name: Install dependencies
80+
run: yarn install --frozen-lockfile
81+
82+
- name: Derive appropriate SHAs for base and head for nx affected commands
83+
uses: nrwl/nx-set-shas@v4
84+
with:
85+
main-branch-name: 'master'
86+
87+
- name: Build affected packages
88+
run: npx nx affected --target=build --parallel=3
89+
90+
- name: 🚀 Run Nx Release
91+
run: |
92+
git config --global user.email "marvusm.mmi@gmail.com"
93+
git config --global user.name "Martin Marosi"
94+
95+
npx nx release --skip-publish
96+
npx nx release publish
97+
env:
98+
# NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
99+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ packages/**/size-snapshot.json
7878
.nvmrc
7979

8080
.DS_STORE
81+
82+
# NX cache
83+
.nx/

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Please use our [documentation site](https://data-driven-forms.org/). In case of
235235

236236
# Development setup
237237

238-
Data Driven Forms is a monorepo that uses [Lerna](https://github.com/lerna/lerna) and [yarn workspaces](https://classic.yarnpkg.com/blog/2017/08/02/introducing-workspaces/), so you can use all its commands as well.
238+
Data Driven Forms is a monorepo that uses [NX](https://nx.dev/) and [yarn workspaces](https://classic.yarnpkg.com/blog/2017/08/02/introducing-workspaces/), so you can use all its commands as well.
239239

240240
---
241241

@@ -286,7 +286,7 @@ yarn dev
286286
### How to clean node_modules
287287

288288
```bash
289-
yarn lerna clean
289+
nx reset
290290
rm -rf node_modules
291291
```
292292
### Cleaning built files
@@ -341,7 +341,7 @@ If you introduce a new feature, you should document this change in our documenta
341341

342342
### Correct commit message
343343

344-
A correct commit message is important, because we are using [semantic release](https://github.com/semantic-release/commit-analyzer) to automatically releease new versions. These messages are also used in our release notes, so other users can see what is being changed.
344+
A correct commit message is important, because we are using [nx release](https://nx.dev/features/manage-releases) with conventional commits to automatically release new versions. These messages are also used in our release notes, so other users can see what is being changed.
345345

346346
**My change introduces a new feature**
347347

lerna.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

nx.json

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"$schema": "./node_modules/nx/schemas/nx-schema.json",
3+
"defaultBase": "master",
4+
"workspaceLayout": {
5+
"libsDir": "packages",
6+
"appsDir": "apps"
7+
},
8+
"plugins": [
9+
{
10+
"plugin": "@nx/js",
11+
"exclude": ["**/node_modules/**"],
12+
"options": {
13+
"typecheck": {
14+
"targetName": "typecheck"
15+
},
16+
"build": {
17+
"targetName": "build"
18+
}
19+
}
20+
},
21+
{
22+
"plugin": "@nx/js/typescript",
23+
"exclude": ["**/node_modules/**"],
24+
"options": {
25+
"typecheck": {
26+
"targetName": "typecheck"
27+
},
28+
"build": {
29+
"targetName": "build",
30+
"buildDepsName": "build-deps",
31+
"watchDepsName": "watch-deps"
32+
}
33+
}
34+
}
35+
],
36+
"release": {
37+
"projects": [
38+
"@data-driven-forms/ant-component-mapper",
39+
"@data-driven-forms/blueprint-component-mapper",
40+
"@data-driven-forms/carbon-component-mapper",
41+
"@data-driven-forms/common",
42+
"@data-driven-forms/mui-component-mapper",
43+
"@data-driven-forms/parsers",
44+
"@data-driven-forms/pf4-component-mapper",
45+
"@data-driven-forms/react-form-renderer",
46+
"@data-driven-forms/suir-component-mapper"
47+
],
48+
"changelog": {
49+
"projectChangelogs": {
50+
"createRelease": "github"
51+
}
52+
},
53+
"projectsRelationship": "independent",
54+
"version": {
55+
"conventionalCommits": true,
56+
"fallbackCurrentVersionResolver": "disk"
57+
}
58+
},
59+
"targetDefaults": {
60+
"nx-release-publish": {
61+
"options": {
62+
"packageRoot": "{projectRoot}"
63+
}
64+
}
65+
},
66+
"namedInputs": {
67+
"sharedGlobals": ["{workspaceRoot}/.github/workflows/release.yml"],
68+
"default": [
69+
"sharedGlobals",
70+
"{projectRoot}/src/**/*",
71+
"{projectRoot}/package.json",
72+
"{projectRoot}/README.md",
73+
"{projectRoot}/LICENSE",
74+
"{projectRoot}/babel.config.js",
75+
"{projectRoot}/tsconfig.json",
76+
"!{projectRoot}/src/tests/**/*"
77+
]
78+
}
79+
}

package.json

Lines changed: 16 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
"license": "Apache-2.0",
1010
"private": true,
1111
"scripts": {
12-
"bootstrap": "lerna bootstrap",
13-
"build": "yarn clean-build && lerna run build --concurrency 1 --ignore @data-driven-forms/react-renderer-demo --ignore @data-driven-forms/parsers",
14-
"vendor": "lerna run vendor",
12+
"bootstrap": "yarn install",
13+
"build": "yarn clean-build && nx run-many -t build --exclude @data-driven-forms/react-renderer-demo,@data-driven-forms/parsers --parallel=1",
14+
"vendor": "nx run-many -t vendor",
1515
"test": "jest --coverage",
1616
"test:ci": "jest --coverage --runInBand",
1717
"test:update": "jest -u",
18-
"release": "semantic-release",
18+
"release": "nx release",
1919
"codecov": "codecov",
20-
"start-demo": "lerna run start --scope=@data-driven-forms/react-render-demo",
20+
"start-demo": "nx run @data-driven-forms/react-renderer-demo:start",
2121
"lint": "yarn eslint ./packages/*/src --ext .js",
2222
"lint:ts": "tslint -c ./tslint.json 'packages/**/*.d.ts'",
2323
"generate-template": "node ./scripts/generate-mapper.js",
@@ -32,7 +32,8 @@
3232
"verbose": true,
3333
"testPathIgnorePatterns": [
3434
"/node_modules/",
35-
"packages/suir-component-mapper/"
35+
"packages/suir-component-mapper/",
36+
"/.nx/"
3637
],
3738
"setupFilesAfterEnv": [
3839
"<rootDir>/config/jest.setup.js"
@@ -53,7 +54,8 @@
5354
"\\.(css|scss)$": "identity-obj-proxy"
5455
},
5556
"modulePathIgnorePatterns": [
56-
"<rootDir>/templates/"
57+
"<rootDir>/templates/",
58+
"<rootDir>/.nx/"
5759
],
5860
"globalSetup": "<rootDir>/config/globalSetup.js"
5961
},
@@ -67,16 +69,13 @@
6769
"@babel/preset-env": "^7.16.8",
6870
"@babel/preset-react": "^7.16.7",
6971
"@babel/preset-typescript": "^7.16.7",
70-
"@khala/commit-analyzer-wildcard": "^2.5.2",
71-
"@khala/npm-release-monorepo": "^2.5.2",
72-
"@khala/wildcard-release-notes": "^2.5.2",
73-
"@semantic-release/exec": "^6.0.3",
74-
"@semantic-release/git": "^10.0.1",
75-
"@semantic-release/github": "^8.0.2",
76-
"@semantic-release/npm": "^8.0.3",
72+
"@nx/js": "22.0.1",
73+
"@swc-node/register": "~1.9.1",
74+
"@swc/core": "~1.5.7",
75+
"@swc/helpers": "~0.5.11",
7776
"@testing-library/dom": "^8.17.1",
7877
"@testing-library/jest-dom": "^5.16.5",
79-
"@testing-library/react": "^13.4.0",
78+
"@testing-library/react": "^14.3.1",
8079
"@testing-library/user-event": "^14.4.3",
8180
"@types/react": "^19.1.2",
8281
"@types/react-dom": "^19.1.3",
@@ -104,16 +103,15 @@
104103
"identity-obj-proxy": "^3.0.0",
105104
"inquirer": "^8.2.0",
106105
"jest": "^27.4.7",
107-
"lerna": "^4.0.0",
108106
"ncp": "^2.0.0",
109-
"sass": "^1.77.8",
107+
"nx": "^22.0.2",
110108
"prettier": "^2.5.1",
111109
"react": "^19.1.0",
112110
"react-dom": "^19.1.0",
113111
"regenerator-runtime": "^0.13.9",
114112
"replace-in-file": "^6.3.2",
113+
"sass": "^1.77.8",
115114
"sass-loader": "^12.4.0",
116-
"semantic-release": "^19.0.3",
117115
"strip-ansi": "^7.0.1",
118116
"style-loader": "^3.3.1",
119117
"terser-webpack-plugin": "^5.3.0",
@@ -128,71 +126,6 @@
128126
"resolutions": {
129127
"react-is": "^19.0.0"
130128
},
131-
"release": {
132-
"monorepo": "./packages",
133-
"branches": [
134-
"+([0-9])?(.{+([0-9]),x}).x",
135-
"master",
136-
"next",
137-
"next-major",
138-
{
139-
"name": "beta",
140-
"prerelease": true
141-
},
142-
{
143-
"name": "alpha",
144-
"prerelease": true
145-
}
146-
],
147-
"plugins": [
148-
"@khala/npm-release-monorepo",
149-
[
150-
"@khala/wildcard-release-notes",
151-
{
152-
"patterns": {
153-
"major": "^(majormajor|breakingbreaking)\\(",
154-
"minor": "^feat\\(",
155-
"patch": "^(fix|patch)\\("
156-
},
157-
"repositoryName": "data-driven-forms/react-forms"
158-
}
159-
],
160-
[
161-
"@khala/commit-analyzer-wildcard",
162-
{
163-
"patterns": {
164-
"major": "^(majormajor|breakingbreaking)\\(",
165-
"minor": "^feat\\(",
166-
"patch": "^(fix|patch)\\("
167-
},
168-
"defaultRelease": "no-release"
169-
}
170-
],
171-
{
172-
"path": "@semantic-release/github",
173-
"assets": [
174-
"package.json"
175-
],
176-
"successComment": ":tada: This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\n\nThe release is available on \n\n- [react-form-renderer (@latest dist-tag)](https://www.npmjs.com/package/@data-driven-forms/react-form-renderer)\n\n- [ant-component-mapper (@latest dist-tag)](https://www.npmjs.com/package/@data-driven-forms/ant-component-mapper)\n\n- [blueprint-component-mapper (@latest dist-tag)](https://www.npmjs.com/package/@data-driven-forms/blueprint-component-mapper)\n\n- [carbon-component-mapper (@latest dist-tag)](https://www.npmjs.com/package/@data-driven-forms/carbon-component-mapper)\n\n- [mui-component-mapper (@latest dist-tag)](https://www.npmjs.com/package/@data-driven-forms/mui-component-mapper)\n\n- [pf4-component-mapper (@latest dist-tag)](https://www.npmjs.com/package/@data-driven-forms/pf4-component-mapper)\n\n- [suir-component-mapper (@latest dist-tag)](https://www.npmjs.com/package/@data-driven-forms/suir-component-mapper)\n\n[Data-Driven-Forms.org](http://data-driven-forms.org/)!"
177-
},
178-
[
179-
"@semantic-release/git",
180-
{
181-
"assets": [
182-
"package.json",
183-
"packages/*/package.json"
184-
],
185-
"message": "Release of new version: ${nextRelease.version} <no> [skip ci]"
186-
}
187-
],
188-
[
189-
"@semantic-release/exec",
190-
{
191-
"prepareCmd": "node ./scripts/update-common.js ${nextRelease.version}"
192-
}
193-
]
194-
]
195-
},
196129
"dependencies": {
197130
"ts-node": "^10.9.1"
198131
},

packages/ant-component-mapper/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ vendor
7878
!config
7979
!.npmignore
8080
!.gitignore
81+
!.nxignore
8182
!babel.config.js
8283
!generate-packages.js
8384
!LICENSE
8485
!package.json
86+
!project.json
8587
!README.md
8688
!tsconfig.json
8789
!generate-typings.js

0 commit comments

Comments
 (0)