Skip to content

Commit

Permalink
chore(monorepo): migrate nx to v18 and adjust dependencies (#72)
Browse files Browse the repository at this point in the history
* chore: migrate nx to v18

* chore: adjust config

* chore: change dependencies

* Update tsconfig.json

* Update tsconfig.lib.json

* Update package.json

* chore: adjust dependencies in monorepo

* chore: add pending eslint config for example project

* Update .eslintrc.json

* chore: adjust ci trigger

* chore: remove codecov from ci step

* chore: update codecov action version
  • Loading branch information
lukascivil authored Feb 4, 2024
1 parent 28ae374 commit 58a332b
Show file tree
Hide file tree
Showing 24 changed files with 884 additions and 677 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Nx 18 enables using plugins to infer targets by default
# This is disabled for existing workspaces to maintain compatibility
# For more info, see: https://nx.dev/concepts/inferred-tasks
NX_ADD_PLUGINS=false
4 changes: 3 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
run: yarn nx run-many --target=test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Build
run: |
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: CI

on:
pull_request:
branches: [master]
types:
- opened
- synchronize

jobs:
build:
Expand Down Expand Up @@ -33,8 +35,5 @@ jobs:
- name: Test
run: yarn nx run-many --target=test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1

- name: Build
run: yarn nx run-many --target=build
16 changes: 16 additions & 0 deletions apps/example/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"root": true,
"env": { "es2020": true, "node": true },
"extends": ["../../.eslintrc.base.json", "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended"],
"ignorePatterns": ["!**/*"],
"plugins": ["react-refresh"],
"overrides": [
{
"files": ["package.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
14 changes: 1 addition & 13 deletions apps/example/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# Example

## Example

[master](http://jsondifference.lukascivil.com.br)

## Installation

`npm install`

## Usage

`npm run simple`

`npm run stress`
A simple node project that runs the "json-difference" lib.
1 change: 1 addition & 0 deletions apps/example/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "example",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"targets": {
Expand Down
6 changes: 3 additions & 3 deletions apps/example/src/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { getDiff } from 'json-difference'
const coffee = { color: { color1: 'black', color2: 'brown' }, special: true }
const oil = { color: { color1: 'red', color2: 'blue' }, special2: false }

const start: any = new Date()
const start = new Date()

const diff = getDiff(coffee, oil)

console.log('diff', JSON.stringify(diff))

const end: any = new Date()
const diffTime = end - start
const end = new Date()
const diffTime = Number(end) - Number(start)

console.info('Execution time: %dms', diffTime)
6 changes: 3 additions & 3 deletions apps/example/src/stress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import * as path from 'path'
const oldJson = JSON.parse(fs.readFileSync(path.join(__dirname, './assets/oldJson.json'), 'utf8'))
const newJson = JSON.parse(fs.readFileSync(path.join(__dirname, './assets/newJson.json'), 'utf8'))

const start: any = new Date()
const start = new Date()

const delta: Delta = getDiff(oldJson, newJson)

console.log('diff', JSON.stringify(delta))

const end: any = new Date()
const diffTime = end - start
const end = new Date()
const diffTime = Number(end) - Number(start)

console.info('Execution time: %dms', diffTime)
3 changes: 2 additions & 1 deletion apps/example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
Expand All @@ -12,5 +13,5 @@
"strict": true /* Enable all strict type-checking options. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"exclude": ["node_modules"]
"include": ["src"]
}
7 changes: 6 additions & 1 deletion apps/playground/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
"files": ["package.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["apps/playground/vite.config.ts"]
}
]
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion apps/playground/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# GH Playground demo

The playground is a live demo to help you better understand how the "json-difference" tool works.
The playground is a live demo to help you better understand how the "json-difference" tool works on web application.
8 changes: 5 additions & 3 deletions apps/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
"react": "^18.2.0",
"@chakra-ui/icons": "^2.1.0",
"@chakra-ui/react": "^2.8.0",
"json-difference": "1.15.7",
"json-difference": "1.16.0",
"react-dom": "^18.2.0",
"react-monaco-editor": "^0.55.0"
},
"devDependencies": {
"vite": "^5.0.10",
"@vitejs/plugin-react": "^4.0.3",
"vite-tsconfig-paths": "^4.2.0",
"react-monaco-editor": "^0.55.0"
"vite-tsconfig-paths": "^4.2.0"
}
}
4 changes: 2 additions & 2 deletions apps/playground/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "playground",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"targets": {
Expand All @@ -21,9 +22,8 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/playground/**/*.{js,ts}", "apps/playground/package.json"],
"lintFilePatterns": ["{projectRoot}/**/*.{js,ts}", "{projectRoot}/package.json"],
"maxWarnings": 0
}
},
Expand Down
13 changes: 13 additions & 0 deletions libs/json-difference-cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../.eslintrc.base.json",
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["package.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
1 change: 0 additions & 1 deletion libs/json-difference-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"json-difference-cli": "./bin/src/index.js"
},
"dependencies": {
"json-difference": "*",
"yargs": "^17.7.2"
}
}
2 changes: 1 addition & 1 deletion libs/json-difference-cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import yargs from 'yargs'
import { getDiff } from 'json-difference'
import { getDiff } from '@json-difference'

/**
* @description This is a cli tool to get the difference between two json strings
Expand Down
12 changes: 3 additions & 9 deletions libs/json-difference-cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
"extends": "../../tsconfig.base.json",
"files": [],
"include": ["src/**/*"]
}
8 changes: 2 additions & 6 deletions libs/json-difference-cli/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"compilerOptions": {
"module": "commonjs",
"target": "ES6",
"outDir": "bin",
"baseUrl": "./",
"types": []
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
"outDir": "bin"
}
}
7 changes: 6 additions & 1 deletion libs/json-difference/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
"files": ["package.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["libs/json-difference/vite.config.ts", "libs/json-difference/vite.config.browser.ts"]
}
]
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion libs/json-difference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"json",
"diff"
],
"dependencies": {
"devDependencies": {
"vite": "^5.0.10",
"vite-plugin-dts": "~2.3.0"
}
Expand Down
4 changes: 2 additions & 2 deletions libs/json-difference/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "json-difference",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"targets": {
Expand Down Expand Up @@ -50,9 +51,8 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/json-difference/**/*.{js,ts}", "libs/json-difference/package.json"],
"lintFilePatterns": ["{projectRoot}/**/*.{js,ts}", "{projectRoot}/package.json"],
"maxWarnings": 0
}
},
Expand Down
9 changes: 4 additions & 5 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
"build": {
"dependsOn": ["^build"]
},
"lint": {
"dependsOn": ["^lint"]
},
"type-check": {
"dependsOn": ["^type-check"]
},
"test": {
"dependsOn": ["^test"]
},
"build-playground": {
"dependsOn": ["^build-playground"]
"@nx/eslint:lint": {
"dependsOn": ["^lint"],
"cache": true,
"inputs": ["default", "{workspaceRoot}/.eslintrc.base.json", "{workspaceRoot}/tools/eslint-rules/**/*"]
}
},
"affected": {
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"license": "MIT",
"scripts": {
"show": "yarn nx show project json-difference --web",
"graph": "yarn nx graph",
"graph:affected": "yarn nx graph --affected",
"release": "npx nx run-many --target=version --parallel=1 ${0}"
Expand All @@ -14,13 +15,13 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@jscutlery/semver": "^4.2.0",
"@nx/devkit": "^17.2.7",
"@nx/eslint": "^17.2.7",
"@nx/eslint-plugin": "^17.2.7",
"@nx/jest": "^17.2.7",
"@nx/js": "^17.2.7",
"@nx/vite": "^17.2.7",
"@nx/workspace": "17.2.7",
"@nx/devkit": "18.0.0",
"@nx/eslint": "18.0.0",
"@nx/eslint-plugin": "18.0.0",
"@nx/jest": "18.0.0",
"@nx/js": "18.0.0",
"@nx/vite": "18.0.0",
"@nx/workspace": "18.0.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^11.1.0",
"@semantic-release/exec": "^6.0.3",
Expand All @@ -31,8 +32,8 @@
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.0.0",
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/parser": "6.13.2",
"@vitejs/plugin-react": "^4.0.3",
"@yarnpkg/plugin-version": "^4.0.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
Expand All @@ -53,7 +54,7 @@
"jsonc-eslint-parser": "^2.4.0",
"monaco-editor": "^0.40.0",
"ngx-deploy-npm": "^7.1.0",
"nx": "^17.2.7",
"nx": "18.0.0",
"prettier": "^3.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Loading

0 comments on commit 58a332b

Please sign in to comment.