Skip to content

Commit 03b9aa0

Browse files
feat: add support for nx 18.x (#192)
also, migrate from jest to vitest BREAKING CHANGE: To use this version the nx workspace needs to be migrated to version 18.x re #191
1 parent a5de804 commit 03b9aa0

File tree

130 files changed

+13391
-9084
lines changed

Some content is hidden

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

130 files changed

+13391
-9084
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Nx 18 enables using plugins to infer targets by default
2+
# This is disabled for existing workspaces to maintain compatibility
3+
# For more info, see: https://nx.dev/concepts/inferred-tasks
4+
NX_ADD_PLUGINS=false

.eslintrc.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
},
3434
{
3535
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
36-
"env": {
37-
"jest": true
38-
},
3936
"rules": {}
4037
},
4138
{

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ jobs:
2424
- run: npm ci
2525

2626
- run: npx nx format:check
27-
- run: npx nx affected --target=lint --parallel=3
28-
- run: npx nx affected --target=test --parallel=3 --ci --code-coverage --silent
29-
- run: npx nx affected --target=build --parallel=3
27+
- run: npx nx affected -t lint test build
3028
- run: |
3129
echo "NO_COVERAGE_RUN=$(if [ -z "$(npx nx print-affected --select=projects)" ]; then echo "true"; else echo "false";fi)" >> $GITHUB_ENV
3230
- name: Merge coverage

.sonarcloud.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
sonar.exclusions=**/tests/**/*, **/test/**/*, **/*.spec.*
33

44
# Exclude from SonarCloud duplication measure
5-
sonar.cpd.exclusions=**/jest.config.ts
5+
sonar.cpd.exclusions=**/vite.config.ts

e2e/data-migration-e2e/jest.config.ts

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

e2e/data-migration-e2e/project.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
"sourceRoot": "e2e/data-migration-e2e/src",
66
"targets": {
77
"e2e": {
8-
"executor": "@nx/jest:jest",
9-
"options": {
10-
"jestConfig": "e2e/data-migration-e2e/jest.config.ts",
11-
"runInBand": true,
12-
"passWithNoTests": false
13-
},
8+
"executor": "@nx/vite:test",
9+
"options": {},
1410
"dependsOn": ["data-migration:build"]
1511
},
1612
"lint": {

e2e/data-migration-e2e/tests/dynamodb-migration.spec.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ describe('dynamodb-migration e2e', () => {
1414
// on a unique project in the workspace, such that they
1515
// are not dependant on one another.
1616
beforeAll(() => {
17-
ensureNxProject(
18-
'@nxlv/dynamodb-python',
19-
'dist/packages/dynamodb-migration'
20-
);
17+
ensureNxProject('@nxlv/data-migration', 'dist/packages/dynamodb-migration');
2118
});
2219

2320
afterAll(() => {
@@ -29,7 +26,7 @@ describe('dynamodb-migration e2e', () => {
2926
it('should create dynamodb-migration', async () => {
3027
const project = uniq('dynamodb-migration');
3128
await runNxCommandAsync(
32-
`generate @nxlv/dynamodb-python:dynamodb-migration ${project}`
29+
`generate @nxlv/data-migration:dynamodb-migration ${project}`,
3330
);
3431
const result = await runNxCommandAsync(`build ${project}`);
3532
expect(result.stdout).toContain('Executor ran');
@@ -39,10 +36,10 @@ describe('dynamodb-migration e2e', () => {
3936
it('should create src in the specified directory', async () => {
4037
const project = uniq('dynamodb-migration');
4138
await runNxCommandAsync(
42-
`generate @nxlv/dynamodb-python:dynamodb-migration ${project} --directory subdir`
39+
`generate @nxlv/data-migration:dynamodb-migration ${project} --directory subdir`,
4340
);
4441
expect(() =>
45-
checkFilesExist(`libs/subdir/${project}/src/index.ts`)
42+
checkFilesExist(`libs/subdir/${project}/src/index.ts`),
4643
).not.toThrow();
4744
}, 120000);
4845
});
@@ -51,11 +48,11 @@ describe('dynamodb-migration e2e', () => {
5148
it('should add tags to the project', async () => {
5249
const projectName = uniq('dynamodb-migration');
5350
ensureNxProject(
54-
'@nxlv/dynamodb-python',
55-
'dist/packages/dynamodb-migration'
51+
'@nxlv/data-migration',
52+
'dist/packages/dynamodb-migration',
5653
);
5754
await runNxCommandAsync(
58-
`generate @nxlv/dynamodb-python:dynamodb-migration ${projectName} --tags e2etag,e2ePackage`
55+
`generate @nxlv/data-migration:dynamodb-migration ${projectName} --tags e2etag,e2ePackage`,
5956
);
6057
const project = readJson(`libs/${projectName}/project.json`);
6158
expect(project.tags).toEqual(['e2etag', 'e2ePackage']);

e2e/data-migration-e2e/tsconfig.spec.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../../dist/out-tsc",
5-
"module": "commonjs",
6-
"types": ["jest", "node"]
5+
"types": [
6+
"vitest/globals",
7+
"vitest/importMeta",
8+
"vite/client",
9+
"node",
10+
"vitest"
11+
]
712
},
813
"include": [
9-
"jest.config.ts",
14+
"vite.config.ts",
15+
"vitest.config.ts",
1016
"src/**/*.test.ts",
1117
"src/**/*.spec.ts",
18+
"src/**/*.test.tsx",
19+
"src/**/*.spec.tsx",
20+
"src/**/*.test.js",
21+
"src/**/*.spec.js",
22+
"src/**/*.test.jsx",
23+
"src/**/*.spec.jsx",
1224
"src/**/*.d.ts"
1325
]
1426
}

e2e/data-migration-e2e/vite.config.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// <reference types='vitest' />
2+
import { defineConfig } from 'vite';
3+
4+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
5+
6+
export default defineConfig({
7+
root: __dirname,
8+
cacheDir: '../../node_modules/.vite/e2e/data-migration-e2e',
9+
10+
plugins: [nxViteTsPaths()],
11+
12+
// Uncomment this if you are using workers.
13+
// worker: {
14+
// plugins: [ nxViteTsPaths() ],
15+
// },
16+
17+
test: {
18+
name: 'data-migration-e2e',
19+
minWorkers: 1,
20+
maxWorkers: 1,
21+
globals: true,
22+
cache: {
23+
dir: '../../node_modules/.vitest',
24+
},
25+
environment: 'node',
26+
include: ['tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
27+
28+
reporters: ['default'],
29+
coverage: {
30+
reportsDirectory: '../../coverage/e2e/data-migration-e2e',
31+
provider: 'v8',
32+
},
33+
},
34+
});

packages/testing/dynamoose-mock/.eslintrc.json renamed to e2e/nx-python-e2e/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": ["../../../.eslintrc.json"],
2+
"extends": ["../../.eslintrc.json"],
33
"ignorePatterns": ["!**/*"],
44
"overrides": [
55
{

e2e/nx-python-e2e/jest.config.ts

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

e2e/nx-python-e2e/project.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"sourceRoot": "e2e/nx-python-e2e/src",
66
"targets": {
77
"e2e": {
8-
"executor": "@nx/jest:jest",
9-
"options": {
10-
"jestConfig": "e2e/nx-python-e2e/jest.config.ts",
11-
"runInBand": true,
12-
"passWithNoTests": false
13-
},
8+
"executor": "@nx/vite:test",
9+
"options": {},
1410
"dependsOn": ["nx-python:build"]
11+
},
12+
"lint": {
13+
"executor": "@nx/eslint:lint",
14+
"outputs": ["{options.outputFile}"]
1515
}
1616
},
1717
"tags": [],

e2e/nx-python-e2e/tests/__snapshots__/nx-python.spec.ts.snap

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,86 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`nx-python e2e > shared virtual environment > should create nx-python project with 3 levels with shared virtual environment 1`] = `
4+
"[tool.nx]
5+
autoActivate = true
6+
7+
[tool.poetry]
8+
name = "@proj/source"
9+
version = "1.0.0"
10+
description = ""
11+
authors = [ ]
12+
license = "Proprietary"
13+
readme = "README.md"
14+
15+
[tool.poetry.dependencies]
16+
python = ">=3.9,<3.11"
17+
18+
[tool.poetry.dependencies.app1]
19+
path = "app1"
20+
develop = true
21+
22+
[tool.poetry.dependencies.lib1]
23+
path = "lib1"
24+
develop = true
25+
26+
[tool.poetry.dependencies.lib2]
27+
path = "lib2"
28+
develop = true
29+
30+
[tool.poetry.group.dev.dependencies]
31+
autopep8 = "2.0.2"
32+
flake8 = "6.0.0"
33+
pytest = "7.3.1"
34+
pytest-sugar = "0.9.7"
35+
pytest-cov = "4.1.0"
36+
pytest-html = "3.2.0"
37+
38+
[build-system]
39+
requires = [ "poetry-core==1.1.0" ]
40+
build-backend = "poetry.core.masonry.api"
41+
"
42+
`;
43+
44+
exports[`nx-python e2e > shared virtual environment > should create one nx-python project, migrate to shared venv and add 3 levels 1`] = `
45+
"[tool.nx]
46+
autoActivate = true
47+
48+
[tool.poetry]
49+
name = "@proj/source"
50+
version = "1.0.0"
51+
description = ""
52+
authors = [ ]
53+
license = "Proprietary"
54+
readme = "README.md"
55+
56+
[tool.poetry.dependencies]
57+
python = ">=3.9,<3.11"
58+
59+
[tool.poetry.dependencies.app1]
60+
path = "app1"
61+
develop = true
62+
63+
[tool.poetry.dependencies.lib1]
64+
path = "lib1"
65+
develop = true
66+
67+
[tool.poetry.dependencies.lib2]
68+
path = "lib2"
69+
develop = true
70+
71+
[tool.poetry.group.dev.dependencies]
72+
autopep8 = "2.0.2"
73+
flake8 = "6.0.0"
74+
pytest = "7.3.1"
75+
pytest-sugar = "0.9.7"
76+
pytest-cov = "4.1.0"
77+
pytest-html = "3.2.0"
78+
79+
[build-system]
80+
requires = [ "poetry-core==1.1.0" ]
81+
build-backend = "poetry.core.masonry.api"
82+
"
83+
`;
284

385
exports[`nx-python e2e shared virtual environment should create nx-python project with 3 levels with shared virtual environment 1`] = `
486
"[tool.nx]

0 commit comments

Comments
 (0)