Skip to content

Commit

Permalink
build: lint projects with @nx/dependency-checks (#497)
Browse files Browse the repository at this point in the history
* build: lint projects

* build: work in progress

* build: work in progress

* build: work in progress

* build: work in progress

* build: work in progress

* build: work in progress

---------

Co-authored-by: khalilou88 <[email protected]>
  • Loading branch information
khalilou88 and khalilou88 authored Oct 6, 2023
1 parent 2def134 commit 1730444
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
- name: Install dependencies
run: npm ci

# - name: Lint
# run: npm run nx affected -- --target=lint --parallel=3
- name: Lint
run: npm run nx affected -- --target=lint --parallel=3

- name: Unit tests
run: npm run nx affected -- --target=test --parallel=3 --ci --code-coverage
Expand Down
7 changes: 5 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"nx-workspace",
"nx-plugin"
],
"peerDependencies": {
"@nx/devkit": ">=16.0.0"
"dependencies": {
"@nx/devkit": "16.10.0",
"axios": "^1.5.1",
"nx": "16.10.0",
"tslib": "^2.6.2"
}
}
7 changes: 4 additions & 3 deletions packages/common/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"main": "packages/common/src/index.ts",
"packageJson": "packages/common/package.json",
"tsConfig": "packages/common/tsconfig.lib.json",
"updateBuildableProjectDepsInPackageJson": true,
"buildableProjectDepsInPackageJsonType": "dependencies",
"assets": [
"packages/common/*.md",
{
Expand All @@ -33,7 +31,10 @@
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/common/**/*.ts"]
"lintFilePatterns": [
"packages/common/**/*.ts",
"packages/common/package.json"
]
}
},
"test": {
Expand Down
10 changes: 6 additions & 4 deletions packages/internal/gradle-executors/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "@jnxplus/internal-gradle-executors",
"version": "0.0.1",
"dependencies": {
"tslib": "^2.3.0"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"executors": "./executors.json"
"executors": "./executors.json",
"dependencies": {
"tslib": "^2.3.0",
"@jnxplus/common": "*",
"@nx/devkit": "16.10.0"
}
}
3 changes: 2 additions & 1 deletion packages/internal/gradle-executors/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"options": {
"lintFilePatterns": [
"packages/internal/gradle-executors/**/*.ts",
"packages/internal/gradle-executors/package.json"
"packages/internal/gradle-executors/package.json",
"packages/internal/gradle-executors/executors.json"
]
}
},
Expand Down
9 changes: 9 additions & 0 deletions packages/internal/testing/src/lib/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ export function patchRootPackageJson(
writeJsonFile(path, json);
}

export function addPrettierToPackageJsonFile(pluginDistAbsulutePath: string) {
const packageJsonPath = path.join(pluginDistAbsulutePath, 'package.json');
const packageJson = readJsonFile(packageJsonPath);
packageJson.dependencies['prettier'] = '^2.8.7';
packageJson.dependencies['@prettier/plugin-xml'] = '^2.2.0';
packageJson.dependencies['prettier-plugin-java'] = '^2.1.0';
writeJsonFile(packageJsonPath, packageJson);
}

export function patchPackageJson(
pluginDistAbsulutePath: string,
npmPackageName: string,
Expand Down
13 changes: 6 additions & 7 deletions packages/nx-gradle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@
"scripts": {
"postinstall": "node src/scripts/install-linters.js"
},
"dependencies": {
"prettier": "^2.8.7",
"prettier-plugin-java": "^2.1.0"
},
"peerDependencies": {
"@nx/devkit": ">=16.3.0"
},
"repository": {
"type": "git",
"url": "https://github.com/khalilou88/jnxplus.git",
"directory": "packages/nx-gradle"
},
"dependencies": {
"@jnxplus/common": "*",
"nx": "16.10.0",
"tslib": "^2.6.2",
"@nx/devkit": "16.10.0"
}
}
9 changes: 6 additions & 3 deletions packages/nx-gradle/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"main": "packages/nx-gradle/src/index.ts",
"packageJson": "packages/nx-gradle/package.json",
"tsConfig": "packages/nx-gradle/tsconfig.lib.json",
"updateBuildableProjectDepsInPackageJson": true,
"buildableProjectDepsInPackageJsonType": "dependencies",

"assets": [
"packages/nx-gradle/*.md",
{
Expand Down Expand Up @@ -158,7 +157,11 @@
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/nx-gradle/**/*.ts"]
"lintFilePatterns": [
"packages/nx-gradle/**/*.ts",
"packages/nx-gradle/package.json",
"packages/nx-gradle/executors.json"
]
}
},
"test": {
Expand Down
17 changes: 8 additions & 9 deletions packages/nx-maven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@
"scripts": {
"postinstall": "node src/scripts/install-linters.js"
},
"dependencies": {
"prettier": "^2.8.7",
"prettier-plugin-java": "^2.1.0",
"@prettier/plugin-xml": "^2.2.0",
"xmldoc": "~1.3.0"
},
"peerDependencies": {
"@nx/devkit": ">=16.3.0"
},
"repository": {
"type": "git",
"url": "https://github.com/khalilou88/jnxplus.git",
"directory": "packages/nx-maven"
},
"dependencies": {
"@jnxplus/common": "*",
"@jnxplus/xml": "*",
"nx": "16.10.0",
"tslib": "^2.6.2",
"@nx/devkit": "16.10.0",
"xmldoc": "^1.3.0"
}
}
8 changes: 5 additions & 3 deletions packages/nx-maven/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/nx-maven/**/*.ts"]
"lintFilePatterns": [
"packages/nx-maven/**/*.ts",
"packages/nx-maven/package.json",
"packages/nx-maven/executors.json"
]
}
},
"test": {
Expand All @@ -27,8 +31,6 @@
"main": "packages/nx-maven/src/index.ts",
"packageJson": "packages/nx-maven/package.json",
"tsConfig": "packages/nx-maven/tsconfig.lib.json",
"updateBuildableProjectDepsInPackageJson": true,
"buildableProjectDepsInPackageJsonType": "dependencies",
"assets": [
"packages/nx-maven/*.md",
{
Expand Down
6 changes: 4 additions & 2 deletions packages/xml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"maven",
"maven multi-module project"
],
"peerDependencies": {
"@nx/devkit": ">=16.0.0"
"dependencies": {
"xmldoc": "^1.3.0",
"tslib": "^2.6.2",
"@nx/devkit": "16.10.0"
}
}
2 changes: 0 additions & 2 deletions packages/xml/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"main": "packages/xml/src/index.ts",
"packageJson": "packages/xml/package.json",
"tsConfig": "packages/xml/tsconfig.lib.json",
"updateBuildableProjectDepsInPackageJson": true,
"buildableProjectDepsInPackageJsonType": "dependencies",
"assets": [
"packages/xml/*.md",
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as fse from 'fs-extra';
import * as path from 'path';
import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand All @@ -39,7 +40,7 @@ describe('nx-boot-gradle e2e', () => {
runNxNewCommand('', true);

const pluginName = '@jnxplus/nx-gradle';
const nxBootGradleDistAbsolutePath = path.join(
const nxGradleDistAbsolutePath = path.join(
workspaceRoot,
'dist',
'packages',
Expand All @@ -61,7 +62,7 @@ describe('nx-boot-gradle e2e', () => {
'gradle-executors',
);

patchRootPackageJson(pluginName, nxBootGradleDistAbsolutePath);
patchRootPackageJson(pluginName, nxGradleDistAbsolutePath);
patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath);
patchRootPackageJson(
'@jnxplus/internal-gradle-executors',
Expand All @@ -75,16 +76,17 @@ describe('nx-boot-gradle e2e', () => {
);

patchPackageJson(
nxBootGradleDistAbsolutePath,
nxGradleDistAbsolutePath,
'@jnxplus/common',
commonDistAbsolutePath,
);
patchPackageJson(
nxBootGradleDistAbsolutePath,
nxGradleDistAbsolutePath,
'@jnxplus/internal-gradle-executors',
gradleDistAbsolutePath,
);

addPrettierToPackageJsonFile(nxGradleDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as path from 'path';

import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand Down Expand Up @@ -41,7 +42,7 @@ describe('nx-boot-gradle kt e2e', () => {
runNxNewCommand('', true);

const pluginName = '@jnxplus/nx-gradle';
const nxBootGradleDistAbsolutePath = path.join(
const nxGradleDistAbsolutePath = path.join(
workspaceRoot,
'dist',
'packages',
Expand All @@ -63,7 +64,7 @@ describe('nx-boot-gradle kt e2e', () => {
'gradle-executors',
);

patchRootPackageJson(pluginName, nxBootGradleDistAbsolutePath);
patchRootPackageJson(pluginName, nxGradleDistAbsolutePath);
patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath);
patchRootPackageJson(
'@jnxplus/internal-gradle-executors',
Expand All @@ -77,16 +78,17 @@ describe('nx-boot-gradle kt e2e', () => {
);

patchPackageJson(
nxBootGradleDistAbsolutePath,
nxGradleDistAbsolutePath,
'@jnxplus/common',
commonDistAbsolutePath,
);
patchPackageJson(
nxBootGradleDistAbsolutePath,
nxGradleDistAbsolutePath,
'@jnxplus/internal-gradle-executors',
gradleDistAbsolutePath,
);

addPrettierToPackageJsonFile(nxGradleDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand Down Expand Up @@ -79,6 +80,7 @@ describe('nx-boot-maven e2e', () => {
xmlDistAbsolutePath,
);

addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
2 changes: 2 additions & 0 deletions testing-projects/e2e/nx-gradle-e2e/tests/nx-gradle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { checkstyleVersion } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
patchPackageJson,
patchRootPackageJson,
Expand Down Expand Up @@ -81,6 +82,7 @@ describe('nx-gradle e2e', () => {
gradleDistAbsolutePath,
);

addPrettierToPackageJsonFile(nxGradleDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as path from 'path';

import { checkstyleVersion } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
patchPackageJson,
patchRootPackageJson,
Expand Down Expand Up @@ -82,6 +83,7 @@ describe('nx-gradle kotlin dsl e2e', () => {
gradleDistAbsolutePath,
);

addPrettierToPackageJsonFile(nxGradleDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
3 changes: 2 additions & 1 deletion testing-projects/e2e/nx-maven-e2e/tests/nx-maven.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addSpringBootVersion,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
killPorts,
patchPackageJson,
Expand Down Expand Up @@ -80,6 +80,7 @@ describe('nx-maven e2e', () => {
xmlDistAbsolutePath,
);

addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
Loading

0 comments on commit 1730444

Please sign in to comment.