Skip to content

Commit

Permalink
chore: migrate to nx 19.7.2 (#32)
Browse files Browse the repository at this point in the history
* chore: ignore yarn install-state

* chore: migrate to 19.7.2

* test: fix test execution for nx v19
  • Loading branch information
llwt authored Sep 11, 2024
1 parent cc72bab commit 738967e
Show file tree
Hide file tree
Showing 12 changed files with 7,226 additions and 2,190 deletions.
10 changes: 8 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
"rules": {
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
"rules": {
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
}
]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
/libpeerconnection.log
npm-debug.log
yarn-error.log
.yarn/install-state.gz
testem.log
/typings

Expand All @@ -45,3 +46,4 @@ Thumbs.db
.bashrc
.nx
.nx/cache
.nx/workspace-data
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@

/.nx/cache
examples

/.nx/workspace-data
5 changes: 5 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
module.exports = {
docs: {
autodocs: true
},

addons: ["@storybook/addon-webpack5-compiler-swc", "@chromatic-com/storybook"]
};
Binary file removed .yarn/install-state.gz
Binary file not shown.
3 changes: 2 additions & 1 deletion apps/nx-workshop-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/nx-workshop-e2e/jest.config.js",
"runInBand": true
"runInBand": true,
"passWithNoTests": false
},
"dependsOn": ["nx-react-workshop:build"]
}
Expand Down
52 changes: 24 additions & 28 deletions apps/nx-workshop-e2e/tests/nx-workshop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ExecSyncOptionsWithStringEncoding, execSync } from 'child_process';
import { ensureDirSync, removeSync, existsSync } from 'fs-extra';
import { dirname, join } from 'path';

const LAB_INDICES = Array.from({ length: 22 }, (_, i) => [i + 1]);

describe('nx-react-workshop e2e', () => {
describe('migrations for alternative option', () => {
it('should run the migrations', () => {
Expand All @@ -11,18 +13,16 @@ describe('nx-react-workshop e2e', () => {
expect(() => checkFilesExist(`node_modules/.bin/nx`)).not.toThrow();
}, 120000);

for (let i = 1; i < 23; i++) {
it(`should complete lab ${i}`, () => {
runNxCommand(
`generate @nrwl/nx-react-workshop:complete-labs --lab=${i} --option=option1`
);
runNxCommand('migrate --run-migrations=migrations.json --verbose');
runNxCommand(
'run-many --target=e2e --parallel=false --exclude=internal-plugin-e2e'
);
runNxCommand('run-many --target=lint --parallel=false');
});
}
it.each(LAB_INDICES)(`should complete lab %i`, (i) => {
runNxCommand(
`generate @nrwl/nx-react-workshop:complete-labs --lab=${i} --option=option1`
);
runNxCommand('migrate --run-migrations=migrations.json --verbose');
runNxCommand(
'run-many --target=e2e --parallel=false --exclude=internal-plugin-e2e'
);
runNxCommand('run-many --target=lint --parallel=false');
});
});

describe('migrations for deployment path', () => {
Expand All @@ -32,18 +32,16 @@ describe('nx-react-workshop e2e', () => {
expect(() => checkFilesExist(`node_modules/.bin/nx`)).not.toThrow();
}, 120000);

for (let i = 1; i < 23; i++) {
it(`should complete lab ${i}`, () => {
runNxCommand(
`generate @nrwl/nx-react-workshop:complete-labs --lab=${i} --option=option2`
);
runNxCommand('migrate --run-migrations=migrations.json');
runNxCommand(
'run-many --target=e2e --parallel=false --exclude=internal-plugin-e2e'
);
runNxCommand('run-many --target=lint --parallel=false');
});
}
it.each(LAB_INDICES)(`should complete lab %i`, (i) => {
runNxCommand(
`generate @nrwl/nx-react-workshop:complete-labs --lab=${i} --option=option2`
);
runNxCommand('migrate --run-migrations=migrations.json');
runNxCommand(
'run-many --target=e2e --parallel=false --exclude=internal-plugin-e2e'
);
runNxCommand('run-many --target=lint --parallel=false');
});
});
});

Expand All @@ -59,9 +57,7 @@ function createNewWorkspace() {
removeSync(tmpProjPath());
// create new workspace
execSync(
`node ${require.resolve(
'nx'
)} new ${scope} --nx-workspace-root=${localTmpDir} --no-interactive --skip-install --collection=@nx/workspace --npmScope=${scope} --preset=apps --packageManager=npm`,
`npx create-nx-workspace ${scope} --no-interactive --skip-install --preset=apps --packageManager=npm --ci=skip`,
{
cwd: localTmpDir,
}
Expand All @@ -83,7 +79,7 @@ function createNewWorkspace() {
function checkFilesExist(...expectedPaths) {
expectedPaths.forEach((path) => {
const filePath = join(tmpProjPath(), path);
if (!execSync(filePath)) {
if (!existsSync(filePath)) {
throw new Error(`'${filePath}' does not exist`);
}
});
Expand Down
8 changes: 2 additions & 6 deletions libs/nx-react-workshop/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
"tags": [],
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": ["libs/nx-react-workshop/**/*.ts"]
}
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/libs/nx-react-workshop"],
"options": {
"jestConfig": "libs/nx-react-workshop/jest.config.ts",
"passWithNoTests": true
"jestConfig": "libs/nx-react-workshop/jest.config.ts"
}
},
"build": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function update(host: Tree) {
);
// nx generate @nx/react:storybook-configuration store-ui-shared
await storybookConfigurationGenerator(host, {
name: 'store-ui-shared',
project: 'store-ui-shared',
configureCypress: false,
generateStories: true,
interactionTests: true,
Expand Down
33 changes: 15 additions & 18 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
{
"affected": {
"defaultBase": "main"
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"],
"cache": true
},
"test": {
"@nx/jest:jest": {
"cache": true,
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"cache": true
"options": {
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"lint": {
"@nx/eslint:lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
"cache": true
},
"e2e": {
"cache": true
},
"build-storybook": {
"inputs": [
"default",
"^production",
"{projectRoot}/.storybook/**/*",
"{projectRoot}/tsconfig.storybook.json"
]
}
},
"namedInputs": {
Expand All @@ -44,5 +39,7 @@
]
},
"nxCloudAccessToken": "NzdhYTRjNmQtNGYwMC00MGE0LTk2YzEtNWFlNGU1MDk3OTczfHJlYWQtd3JpdGU=",
"nxCloudUrl": "https://staging.nx.app"
"nxCloudUrl": "https://staging.nx.app",
"useInferencePlugins": false,
"defaultBase": "main"
}
62 changes: 33 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,51 @@
},
"private": true,
"dependencies": {
"@storybook/builder-webpack5": "7.0.9",
"@storybook/core-server": "7.5.2",
"@storybook/addon-interactions": "^8.2.9",
"@storybook/builder-webpack5": "^8.2.9",
"@storybook/core-server": "^8.2.9",
"@storybook/manager-webpack5": "6.5.16",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-is": "18.2.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-is": "18.3.1",
"storybook": "^8.2.9",
"tslib": "^2.3.0"
},
"devDependencies": {
"@nx/devkit": "17.0.2",
"@nx/eslint": "17.0.2",
"@nx/eslint-plugin": "17.0.2",
"@nx/express": "17.0.2",
"@nx/jest": "17.0.2",
"@nx/js": "17.0.2",
"@nx/nest": "17.0.2",
"@nx/next": "17.0.2",
"@nx/node": "17.0.2",
"@nx/plugin": "17.0.2",
"@nx/react": "17.0.2",
"@nx/storybook": "17.0.2",
"@nx/workspace": "17.0.2",
"@chromatic-com/storybook": "^1",
"@nx/devkit": "19.7.2",
"@nx/eslint": "19.7.2",
"@nx/eslint-plugin": "19.7.2",
"@nx/express": "19.7.2",
"@nx/jest": "19.7.2",
"@nx/js": "19.7.2",
"@nx/nest": "19.7.2",
"@nx/next": "19.7.2",
"@nx/node": "19.7.2",
"@nx/plugin": "19.7.2",
"@nx/react": "19.7.2",
"@nx/storybook": "19.7.2",
"@nx/workspace": "19.7.2",
"@phenomnomnominal/tsquery": "^4.1.1",
"@swc-node/register": "1.6.8",
"@swc/core": "1.3.95",
"@types/jest": "29.4.4",
"@types/node": "18.11.9",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@storybook/addon-webpack5-compiler-swc": "^1.0.5",
"@swc-node/register": "1.8.0",
"@swc/core": "1.5.7",
"@types/jest": "29.5.12",
"@types/node": "18.19.9",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"dotenv": "10.0.0",
"eslint": "8.46.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.0.0",
"fs-extra": "^11.1.1",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"node-fetch": "^2.6.1",
"nx": "17.0.2",
"nx": "19.7.2",
"prettier": "2.6.2",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"typescript": "5.1.6",
"typescript": "5.5.4",
"verdaccio": "^5.27.0"
},
"packageManager": "[email protected]"
Expand Down
Loading

0 comments on commit 738967e

Please sign in to comment.