Skip to content

Commit 8989698

Browse files
committed
feat: update Nx workspace to v20.1.2
BREAKING CHANGE: Nx `v20` is now the minimal version to use the plugins
1 parent 1d02167 commit 8989698

Some content is hidden

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

76 files changed

+717
-942
lines changed

nx.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,6 @@
161161
],
162162
"sharedGlobals": ["{workspaceRoot}/.nx/workflows/**/**"]
163163
},
164-
"defaultBase": "develop"
164+
"defaultBase": "develop",
165+
"useLegacyCache": true
165166
}

package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"license": "MIT",
55
"scripts": {
66
"nx": "nx",
7-
"build": "nx run-many --target build --parallel 4 --exclude smoke",
7+
"build": "nx run-many --target build --parallel 4",
88
"test": "nx run-many --target test --parallel 4",
99
"e2e": "ts-node -P ./tools/tsconfig.tools.json ./tools/scripts/run-all-e2e-tests.ts",
10-
"lint": "nx run-many --target lint --fix --parallel 4 --exclude smoke",
11-
"affected:build": "nx affected --target build --exclude=smoke",
10+
"lint": "nx run-many --target lint --fix --parallel 4",
11+
"affected:build": "nx affected --target build",
1212
"affected:e2e": "nx affected --target e2e --exclude=smoke",
1313
"affected:test": "nx affected --target test",
1414
"affected:lint": "nx affected --target lint --fix",
@@ -27,9 +27,9 @@
2727
},
2828
"private": true,
2929
"dependencies": {
30-
"@clack/prompts": "^0.7.0",
30+
"@clack/prompts": "^0.8.1",
3131
"@swc/helpers": "0.5.11",
32-
"create-nx-workspace": "~18.1.3",
32+
"create-nx-workspace": "20.1.2",
3333
"enquirer": "^2.4.1",
3434
"hpagent": "^1.2.0",
3535
"js-yaml": "^4.1.0",
@@ -47,13 +47,13 @@
4747
"@commitlint/cli": "^19.3.0",
4848
"@commitlint/config-angular": "^19.3.0",
4949
"@jest/globals": "29.7.0",
50-
"@nx/devkit": "19.6.4",
51-
"@nx/eslint-plugin": "19.6.4",
52-
"@nx/jest": "19.6.4",
53-
"@nx/js": "19.6.4",
54-
"@nx/node": "19.6.4",
55-
"@nx/plugin": "19.6.4",
56-
"@nx/workspace": "19.6.4",
50+
"@nx/devkit": "20.1.2",
51+
"@nx/eslint-plugin": "20.1.2",
52+
"@nx/jest": "20.1.2",
53+
"@nx/js": "20.1.2",
54+
"@nx/node": "20.1.2",
55+
"@nx/plugin": "20.1.2",
56+
"@nx/workspace": "20.1.2",
5757
"@swc-node/register": "1.9.1",
5858
"@swc/cli": "0.3.12",
5959
"@swc/core": "1.5.7",
@@ -78,7 +78,7 @@
7878
"jest-environment-node": "^29.4.1",
7979
"jest-mock": "28.1.3",
8080
"lint-staged": "^15.2.7",
81-
"nx": "19.6.4",
81+
"nx": "20.1.2",
8282
"prettier": "2.6.2",
8383
"ts-jest": "29.1.0",
8484
"ts-node": "10.9.1",

packages/common-cli/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
"create-nx-ktor"
2626
],
2727
"dependencies": {
28-
"create-nx-workspace": ">=18.0.0",
29-
"@clack/prompts": "^0.7.0",
28+
"create-nx-workspace": ">=20.0.0",
29+
"@clack/prompts": "^0.8.1",
3030
"yargs": "^17.7.2",
3131
"tslib": "^2.6.1",
32-
"@nx/devkit": ">=18.0.0",
32+
"@nx/devkit": ">=20.0.0",
3333
"fs-extra": "^10.1.0",
3434
"terminal-link": "^2.1.1"
3535
},

packages/common-jvm/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
],
2626
"dependencies": {
2727
"@nxrocks/common": "file:../common",
28-
"@nx/workspace": ">=18.0.0",
29-
"@nx/devkit": ">=18.0.0",
28+
"@nx/workspace": ">=20.0.0",
29+
"@nx/devkit": ">=20.0.0",
3030
"tslib": "^2.6.1",
3131
"xmlbuilder2": "^3.1.1",
3232
"xpath": "^0.0.34"

packages/common/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"hpagent": "^1.2.0",
3030
"unzipper": "^0.10.14",
3131
"fs-extra": "^10.1.0",
32-
"@nx/devkit": ">=18.0.0",
32+
"@nx/devkit": ">=20.0.0",
3333
"tslib": "^2.6.1",
3434
"minimatch": "^9.0.3",
3535
"semver": "^7.6.0"

packages/common/src/lib/workspace/project-graph.ts

+87-79
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import {
22
CreateDependenciesContext,
3+
CreateNodes,
34
CreateNodesContext,
5+
CreateNodesContextV2,
6+
createNodesFromFiles,
47
CreateNodesResult,
8+
CreateNodesResultV2,
9+
CreateNodesV2,
510
DependencyType,
611
joinPathFragments,
712
logger,
813
ProjectConfiguration,
9-
ProjectGraph,
10-
ProjectGraphBuilder,
11-
ProjectGraphProcessorContext,
1214
ProjectType,
1315
RawProjectGraphDependency,
1416
TargetConfiguration,
@@ -116,95 +118,58 @@ function getProjectFilesGlob(projectFiles: string[]): string {
116118
: `**/${projectFiles[0]}`;
117119
}
118120

119-
// Project Graph V1
120-
121-
export function getProjectGraph(
122-
pluginName: string,
123-
projectFilter: (project: { root: string }) => boolean,
124-
getPackageInfo: (project: { root: string }) => PackageInfo,
125-
graph: ProjectGraph,
126-
ctx: ProjectGraphProcessorContext
127-
): ProjectGraph {
128-
const builder = new ProjectGraphBuilder(graph);
129-
if (process.env['NX_VERBOSE_LOGGING'] === 'true') {
130-
logger.debug(
131-
`[${pluginName}]: Looking related projects inside the workspace...`
132-
);
133-
}
134-
let workspace = undefined;
135-
let dependencies: RawProjectGraphDependency[] = [];
136-
137-
for (const source in ctx.filesToProcess) {
138-
const changed = ctx.filesToProcess[source];
139-
for (const file of changed) {
140-
// we only create the workspace map once and only if changed file is of interest
141-
workspace ??= getPackageInfosForNxProjects(
142-
pluginName,
143-
projectFilter,
144-
getPackageInfo,
145-
ctx.projectsConfigurations
146-
);
147-
148-
dependencies = dependencies.concat(
149-
getDependenciesForProject(pluginName, file.file, source, workspace)
150-
);
151-
}
152-
}
153-
154-
for (const dep of dependencies) {
155-
builder.addDependency(dep.source, dep.target, dep.type, dep.source);
156-
}
157-
158-
return builder.getUpdatedProjectGraph();
159-
}
160-
161-
// Project Graph V2
162-
121+
// Project Graph using CreateNode (V1)
163122
export const createNodesFor = <T = unknown>(
164123
projectFiles: string[],
165124
projectFilter: (project: { root: string }) => boolean,
166125
getProjectTypeAndTargets: (
167126
projectFile: string,
168-
options?: T
127+
options?: T | undefined
169128
) => {
170129
projectType: ProjectType;
171130
targets: {
172131
[targetName: string]: TargetConfiguration;
173132
};
174133
},
175134
pluginName: string
176-
) =>
177-
[
178-
getProjectFilesGlob(projectFiles),
179-
(
180-
file: string,
181-
options: T,
182-
context: CreateNodesContext
183-
): CreateNodesResult => {
184-
if (!projectFilter({ root: getProjectRootFromFile(file) })) {
185-
return {}; // back off if the file/project does not match the criteria
186-
}
135+
): CreateNodes<T> => [
136+
getProjectFilesGlob(projectFiles),
137+
createNodesInternal<T>(projectFilter, getProjectTypeAndTargets, pluginName),
138+
];
187139

188-
const root = dirname(file);
189-
190-
// eslint-disable-next-line no-useless-escape -- eslint's wrong
191-
const parts = root.split(/[\/\\]/g);
192-
const name = parts[parts.length - 1].toLowerCase();
193-
194-
return {
195-
projects: {
196-
[name]: {
197-
name,
198-
root,
199-
...(isNxCrystalEnabled()
200-
? getProjectTypeAndTargets(file, options)
201-
: {}),
202-
tags: [`type:${pluginName.replace('@nxrocks/', '')}`],
203-
},
204-
},
205-
};
206-
},
207-
] as const;
140+
// Project Graph using CreateNode (V2)
141+
export const createNodesForV2 = <T = unknown>(
142+
projectFiles: string[],
143+
projectFilter: (project: { root: string }) => boolean,
144+
getProjectTypeAndTargets: (
145+
projectFile: string,
146+
options: T | undefined
147+
) => {
148+
projectType: ProjectType;
149+
targets: {
150+
[targetName: string]: TargetConfiguration;
151+
};
152+
},
153+
pluginName: string
154+
): CreateNodesV2<T> => [
155+
getProjectFilesGlob(projectFiles),
156+
(
157+
files: readonly string[],
158+
options: T | undefined,
159+
context: CreateNodesContextV2
160+
) => {
161+
return createNodesFromFiles<T>(
162+
createNodesInternal<T>(
163+
projectFilter,
164+
getProjectTypeAndTargets,
165+
pluginName
166+
),
167+
files,
168+
options as T,
169+
context
170+
);
171+
},
172+
];
208173

209174
export const createDependenciesIf = (
210175
pluginName: string,
@@ -246,3 +211,46 @@ export const createDependenciesIf = (
246211

247212
return dependencies;
248213
};
214+
215+
function createNodesInternal<T = unknown>(
216+
projectFilter: (project: { root: string }) => boolean,
217+
getProjectTypeAndTargets: (
218+
projectFile: string,
219+
options: T | undefined
220+
) => {
221+
projectType: ProjectType;
222+
targets: {
223+
[targetName: string]: TargetConfiguration;
224+
};
225+
},
226+
pluginName: string
227+
) {
228+
return (
229+
file: string,
230+
options: T | undefined,
231+
context: CreateNodesContext
232+
): CreateNodesResult => {
233+
if (!projectFilter({ root: getProjectRootFromFile(file) })) {
234+
return {}; // back off if the file/project does not match the criteria
235+
}
236+
237+
const root = dirname(file);
238+
239+
// eslint-disable-next-line no-useless-escape -- eslint's wrong
240+
const parts = root.split(/[\/\\]/g);
241+
const name = parts[parts.length - 1].toLowerCase();
242+
243+
return {
244+
projects: {
245+
[name]: {
246+
name,
247+
root,
248+
...(isNxCrystalEnabled()
249+
? getProjectTypeAndTargets(file, options)
250+
: {}),
251+
tags: [`type:${pluginName.replace('@nxrocks/', '')}`],
252+
},
253+
},
254+
};
255+
};
256+
}

packages/common/testing/utils.ts

+11-17
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,20 @@ function toEntry(e: string | { filePath: string; fileContent?: string }) {
1515

1616
export function mockExecutorContext(
1717
pluginName: string,
18-
executorName: string,
19-
workspaceVersion = 2
18+
executorName: string
2019
): ExecutorContext {
2120
return {
22-
root: '/root',
23-
cwd: 'root',
24-
projectName: 'proj',
25-
workspace: {
26-
version: workspaceVersion,
27-
projects: {
28-
proj: {
29-
root: 'proj',
30-
targets: {
31-
test: {
32-
executor: `${pluginName}:${executorName}`,
33-
},
34-
},
35-
},
36-
},
21+
root: '',
22+
cwd: '',
23+
projectGraph: {
24+
nodes: {},
25+
dependencies: {},
3726
},
27+
projectsConfigurations: {
28+
projects: {},
29+
version: 2,
30+
},
31+
nxJsonConfiguration: {},
3832
target: {
3933
executor: `${pluginName}:${executorName}`,
4034
},

packages/create-nx-flutter/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# create-nx-flutter
1+
# create-nx-flutter
22

33
[![npm version](https://img.shields.io/npm/v/create-nx-flutter?style=flat-square)](https://www.npmjs.com/package/create-nx-flutter)
44
[![github action - release](https://img.shields.io/github/actions/workflow/status/tinesoft/nxrocks/release.yml?label=release&style=flat-square)](https://github.com/tinesoft/nxrocks/actions?query=workflow%3ARelease)
@@ -10,7 +10,7 @@
1010

1111
The goal of this CLI is to ease the process of creating a Nx workspace that can host and manage Flutter projects, thanks to our [@nxrocks/nx-flutter](https://github.com/tinesoft/nxrocks/blob/develop/packages/nx-flutter) plugin, that is automatically installed within it.
1212

13-
## Prerequisites
13+
## Prerequisites
1414

1515
To run this CLI, all you need is to have [NodeJS](https://nodejs.org/en/download) installed (preferably the current LTS version).
1616
Then to later create and run your Flutter projets, you'll need [Flutter CLI](https://docs.flutter.dev/get-started/install) as well.
@@ -32,12 +32,12 @@ Run `npx create-nx-flutter --help` to print some helpful info on available optio
3232

3333
Every Nx package relies on the underlying Nx Workspace/DevKit it runs on. This table provides the compatibility matrix between major versions of Nx workspace and this package.
3434

35-
| Package Version | Nx Workspace version
36-
| --------------- | --------------------
37-
| `>=v3.0.0` | `>=v17.3.0`
38-
| `<v3.0.0` | `<17.3.0`
35+
| Package Version | Nx Workspace version |
36+
| --------------- | -------------------- |
37+
| `>=v4.0.0` | `>=v20.0.0` |
38+
| `>=v3.0.0` | `>=v17.3.0` |
39+
| `<v3.0.0` | `<17.3.0` |
3940

4041
## License
4142

4243
Copyright (c) 2023-present Tine Kondo. Licensed under the MIT License (MIT)
43-

0 commit comments

Comments
 (0)