Skip to content

Commit

Permalink
Merge pull request #33 from koliveira15/feature/nx-16
Browse files Browse the repository at this point in the history
Nx 16 Migration
  • Loading branch information
koliveira15 committed May 27, 2023
2 parents 2450c19 + 4285a47 commit 1f615b3
Show file tree
Hide file tree
Showing 23 changed files with 17,322 additions and 5,525 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
Expand All @@ -23,12 +23,12 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
node-version: 18.14.0
cache: 'npm'
- run: npm ci
- run: npx nx affected --target=lint --parallel=3
- run: npx nx affected --target=test --parallel=3 --ci
- run: npx nx affected --target=build --parallel=3
- run: npx nx affected --target=lint
- run: npx nx affected --target=test --ci
- run: npx nx affected --target=build
- run: npx nx affected --target=e2e --parallel=1
15 changes: 8 additions & 7 deletions e2e/nx-sonarqube-e2e/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
export default {
displayName: 'nx-sonarqube-e2e',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
globals: {},
transform: {
'^.+\\.[tj]s$': 'ts-jest',
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/e2e/nx-sonarqube-e2e',
moduleFileExtensions: ['ts', 'js', 'html'],
};
10 changes: 6 additions & 4 deletions e2e/nx-sonarqube-e2e/project.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "nx-sonarqube-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "e2e/nx-sonarqube-e2e/src",
"targets": {
"e2e": {
"executor": "@nrwl/nx-plugin:e2e",
"executor": "@nx/jest:jest",
"options": {
"target": "nx-sonarqube:build",
"jestConfig": "e2e/nx-sonarqube-e2e/jest.config.ts"
}
"jestConfig": "e2e/nx-sonarqube-e2e/jest.config.ts",
"runInBand": true
},
"dependsOn": ["nx-sonarqube:build"]
}
},
"tags": [],
Expand Down
16 changes: 8 additions & 8 deletions e2e/nx-sonarqube-e2e/tests/nx-sonarqube.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
runCommand,
runNxCommandAsync,
uniq,
} from '@nrwl/nx-plugin/testing';
} from '@nx/plugin/testing';
import { copyFileSync, readFileSync, writeFileSync, rmSync } from 'fs';
import {
checkFilesExist,
updateFile,
} from '@nrwl/nx-plugin/src/utils/testing-utils/utils';
import { names } from '@nrwl/devkit';
} from '@nx/plugin/src/utils/testing-utils/utils';
import { names } from '@nx/devkit';

const TIMEOUT = 120000;
const projectName = 'nx-sonarqube';
Expand All @@ -29,15 +29,15 @@ describe('nx-sonarqube e2e', () => {

beforeAll(async () => {
ensureNxProject('@koliveira15/nx-sonarqube', 'dist/packages/nx-sonarqube');
copyNodeModules(['@nrwl/jest', '@nrwl/js']);
copyNodeModules(['@nx/jest', '@nx/js']);
await createLibs(projects);
await createDependency(project, project2);
setupGlobalJest();
runCommand(`git init`); // workaround for initiating nx & projectGraph
runCommand(`git init`, {}); // workaround for initiating nx & projectGraph
}, TIMEOUT);

afterAll(() => {
runNxCommandAsync('reset');
afterAll(async () => {
await runNxCommandAsync('reset');
});

it(
Expand Down Expand Up @@ -177,7 +177,7 @@ async function createDependency(project: string, project2: string) {
async function createLibs(projects: string[]) {
for (let i = 0; i < projects.length; i++) {
await runNxCommandAsync(
`generate @nrwl/js:lib --name ${projects[i]} --unitTestRunner=jest`
`generate @nx/js:lib --name ${projects[i]} --unitTestRunner=jest`
);

const projectPath = `libs/${projects[i]}/project.json`;
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getJestProjects } from '@nrwl/jest';
import { getJestProjects } from '@nx/jest';

export default {
projects: getJestProjects(),
Expand Down
2 changes: 1 addition & 1 deletion jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const nxPreset = require('@nrwl/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default;

module.exports = {
...nxPreset,
Expand Down
33 changes: 22 additions & 11 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,41 @@
"affected": {
"defaultBase": "origin/main"
},
"implicitDependencies": {
"package.json": {
"dependencies": "*",
"devDependencies": "*"
},
".eslintrc.json": "*",
".github/workflows/ci.yml": "*"
},
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"runner": "nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"accessToken": "MWM4ZWZiNDgtOGYwMi00ZDI3LTllMDUtYTNkYTExMmU3MDY2fHJlYWQ="
"accessToken": "MWM4ZWZiNDgtOGYwMi00ZDI3LTllMDUtYTNkYTExMmU3MDY2fHJlYWQ=",
"parallel": 3
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"]
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
}
},
"workspaceLayout": {
"appsDir": "e2e",
"libsDir": "packages"
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": ["{workspaceRoot}/.github/workflows/ci.yml"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s"
]
}
}

0 comments on commit 1f615b3

Please sign in to comment.