@nx/workspace 18.1.0-canary.20240223-21e7648 → 18.1.0-canary.20240224-26b266f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/generators/move/lib/update-jest-config.js +5 -3
- package/src/generators/new/files-readme/README.md.template +42 -22
- package/src/generators/new/generate-workspace-files.js +4 -1
- package/src/generators/remove/lib/update-jest-config.js +18 -6
- package/src/generators/utils/jest-config.d.ts +2 -0
- package/src/generators/utils/jest-config.js +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/workspace",
|
|
3
|
-
"version": "18.1.0-canary.
|
|
3
|
+
"version": "18.1.0-canary.20240224-26b266f",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.",
|
|
6
6
|
"repository": {
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@nx/devkit": "18.1.0-canary.
|
|
64
|
+
"@nx/devkit": "18.1.0-canary.20240224-26b266f",
|
|
65
65
|
"chalk": "^4.1.0",
|
|
66
66
|
"enquirer": "~2.3.6",
|
|
67
67
|
"tslib": "^2.3.0",
|
|
68
68
|
"yargs-parser": "21.1.1",
|
|
69
|
-
"nx": "18.1.0-canary.
|
|
70
|
-
"@nrwl/workspace": "18.1.0-canary.
|
|
69
|
+
"nx": "18.1.0-canary.20240224-26b266f",
|
|
70
|
+
"@nrwl/workspace": "18.1.0-canary.20240224-26b266f"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateJestConfig = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const jest_config_1 = require("../../utils/jest-config");
|
|
5
6
|
/**
|
|
6
7
|
* Updates the project name and coverage folder in the jest.config.js if it exists
|
|
7
8
|
*
|
|
@@ -34,13 +35,14 @@ function updateJestConfig(tree, schema, project) {
|
|
|
34
35
|
tree.write(jestConfigPath, newContent);
|
|
35
36
|
}
|
|
36
37
|
// update root jest.config.ts
|
|
37
|
-
const rootJestConfigPath =
|
|
38
|
-
if (!tree.exists(rootJestConfigPath)) {
|
|
38
|
+
const rootJestConfigPath = (0, jest_config_1.findRootJestConfig)(tree);
|
|
39
|
+
if (!rootJestConfigPath || !tree.exists(rootJestConfigPath)) {
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
42
|
const findProject = `'<rootDir>/${project.root}'`;
|
|
42
43
|
const oldRootJestConfigContent = tree.read(rootJestConfigPath, 'utf-8');
|
|
43
|
-
const usingJestProjects = oldRootJestConfigContent.includes('getJestProjects()')
|
|
44
|
+
const usingJestProjects = oldRootJestConfigContent.includes('getJestProjects()') ||
|
|
45
|
+
oldRootJestConfigContent.includes('getJestProjectsAsync()');
|
|
44
46
|
const newRootJestConfigContent = oldRootJestConfigContent.replace(findProject, usingJestProjects ? `` : `'<rootDir>/${schema.relativeToRootDestination}'`);
|
|
45
47
|
tree.write(rootJestConfigPath, newRootJestConfigContent);
|
|
46
48
|
}
|
|
@@ -2,52 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
|
|
4
4
|
|
|
5
|
-
✨ **This workspace has been generated by [Nx, Smart Monorepos · Fast CI.](https://nx.dev)**
|
|
5
|
+
✨ **This workspace has been generated by [Nx, Smart Monorepos · Fast CI.](https://nx.dev)** ✨
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
## Start the app
|
|
7
|
+
## Integrate with editors
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
Enhance your Nx experience by installing [Nx Console](https://nx.dev/nx-console) for your favorite editor. Nx Console
|
|
10
|
+
provides an interactive UI to view your projects, run tasks, generate code, and more! Available for VSCode, IntelliJ and
|
|
11
|
+
comes with a LSP for Vim users.
|
|
12
|
+
<% if (!!appName) {
|
|
13
|
+
if (isJsStandalone) { %>
|
|
14
|
+
## Build the library
|
|
15
|
+
|
|
16
|
+
Run `npx nx build` to build the library. The build artifacts are stored in the output directory (i.e. `dist/`), ready to be published.
|
|
17
|
+
<% } else { %>
|
|
18
|
+
## Start the application
|
|
19
|
+
|
|
20
|
+
Run `npx nx <%= serveCommand %> <%= appName %>` to start the development server. Happy coding!
|
|
21
|
+
|
|
22
|
+
## Build for production
|
|
12
23
|
|
|
13
|
-
|
|
24
|
+
Run `npx nx build <%= appName %>` to build the application. The build artifacts are stored in the output directory (e.g. `dist/` or `build/`), ready to be deployed.
|
|
25
|
+
<% } } else { %>
|
|
26
|
+
## Nx plugins and code generators
|
|
14
27
|
|
|
15
|
-
|
|
28
|
+
Add Nx plugins to leverage their code generators and automated, inferred tasks.
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
```
|
|
31
|
+
# Add plugin
|
|
32
|
+
npx nx add @nx/react
|
|
33
|
+
|
|
34
|
+
# Use code generator
|
|
35
|
+
npx nx generate @nx/react:app demo
|
|
18
36
|
|
|
19
|
-
|
|
37
|
+
# Run development server
|
|
38
|
+
npx nx serve demo
|
|
39
|
+
|
|
40
|
+
# View project details
|
|
41
|
+
npx nx show project demo --web
|
|
42
|
+
```
|
|
20
43
|
|
|
44
|
+
Run `npx nx list` to get a list of available plugins and whether they have generators. Then run `npx nx list <plugin-name>` to see what generators are available.
|
|
45
|
+
|
|
46
|
+
Learn more about [code generators](https://nx.dev/features/generate-code) and [inferred tasks](https://nx.dev/concepts/inferred-tasks) in the docs.
|
|
47
|
+
<% } %>
|
|
21
48
|
## Running tasks
|
|
22
49
|
|
|
23
50
|
To execute tasks with Nx use the following syntax:
|
|
24
51
|
|
|
25
52
|
```
|
|
26
|
-
nx <target> <project> <...options>
|
|
53
|
+
npx nx <target> <project> <...options>
|
|
27
54
|
```
|
|
28
55
|
|
|
29
56
|
You can also run multiple targets:
|
|
30
57
|
|
|
31
58
|
```
|
|
32
|
-
nx run-many -t <target1> <target2>
|
|
59
|
+
npx nx run-many -t <target1> <target2>
|
|
33
60
|
```
|
|
34
61
|
|
|
35
62
|
..or add `-p` to filter specific projects
|
|
36
63
|
|
|
37
64
|
```
|
|
38
|
-
nx run-many -t <target1> <target2> -p <proj1> <proj2>
|
|
65
|
+
npx nx run-many -t <target1> <target2> -p <proj1> <proj2>
|
|
39
66
|
```
|
|
40
67
|
|
|
41
68
|
Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/features/run-tasks).
|
|
42
69
|
|
|
43
|
-
## Want better Editor Integration?
|
|
44
|
-
|
|
45
|
-
Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.
|
|
46
|
-
|
|
47
|
-
## Ready to deploy?
|
|
48
|
-
|
|
49
|
-
Just run `nx build demoapp` to build the application. The build artifacts will be stored in the `dist/` directory, ready to be deployed.
|
|
50
|
-
|
|
51
70
|
## Set up CI!
|
|
52
71
|
|
|
53
72
|
Nx comes with local caching already built-in (check your `nx.json`). On CI you might want to go a step further.
|
|
@@ -56,8 +75,9 @@ Nx comes with local caching already built-in (check your `nx.json`). On CI you m
|
|
|
56
75
|
- [Set up task distribution across multiple machines](https://nx.dev/nx-cloud/features/distribute-task-execution)
|
|
57
76
|
- [Learn more how to setup CI](https://nx.dev/recipes/ci)
|
|
58
77
|
|
|
59
|
-
## Explore the
|
|
60
|
-
|
|
78
|
+
## Explore the project graph
|
|
79
|
+
|
|
80
|
+
Run `npx nx graph` to show the graph of the workspace.
|
|
61
81
|
It will show tasks that you can run with Nx.
|
|
62
82
|
|
|
63
83
|
- [Learn more about Exploring the Project Graph](https://nx.dev/core-features/explore-graph)
|
|
@@ -101,8 +101,11 @@ function createReadme(tree, { name, appName, directory, preset }) {
|
|
|
101
101
|
const formattedNames = (0, devkit_1.names)(name);
|
|
102
102
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files-readme'), directory, {
|
|
103
103
|
formattedNames,
|
|
104
|
-
|
|
104
|
+
isJsStandalone: preset === presets_1.Preset.TsStandalone,
|
|
105
105
|
appName,
|
|
106
|
+
serveCommand: preset === presets_1.Preset.NextJs || preset === presets_1.Preset.NextJsStandalone
|
|
107
|
+
? 'dev'
|
|
108
|
+
: 'serve',
|
|
106
109
|
name,
|
|
107
110
|
});
|
|
108
111
|
}
|
|
@@ -5,9 +5,16 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const get_source_nodes_1 = require("../../../utilities/typescript/get-source-nodes");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const typescript_1 = require("../../../utilities/typescript");
|
|
8
|
+
const jest_config_1 = require("../../utils/jest-config");
|
|
8
9
|
let tsModule;
|
|
9
10
|
function isUsingUtilityFunction(host) {
|
|
10
|
-
|
|
11
|
+
const rootConfigPath = (0, jest_config_1.findRootJestConfig)(host);
|
|
12
|
+
if (!rootConfigPath) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const rootConfig = host.read(rootConfigPath, 'utf-8');
|
|
16
|
+
return (rootConfig.includes('getJestProjects()') ||
|
|
17
|
+
rootConfig.includes('getJestProjectsAsync()'));
|
|
11
18
|
}
|
|
12
19
|
/**
|
|
13
20
|
* in a standalone project, the root jest.config.ts is a project config instead
|
|
@@ -15,7 +22,11 @@ function isUsingUtilityFunction(host) {
|
|
|
15
22
|
* in that case we do not need to edit it to remove it
|
|
16
23
|
**/
|
|
17
24
|
function isMonorepoConfig(tree) {
|
|
18
|
-
|
|
25
|
+
const rootConfigPath = (0, jest_config_1.findRootJestConfig)(tree);
|
|
26
|
+
if (!rootConfigPath) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return tree.read(rootConfigPath, 'utf-8').includes('projects:');
|
|
19
30
|
}
|
|
20
31
|
/**
|
|
21
32
|
* Updates the root jest config projects array and removes the project.
|
|
@@ -26,14 +37,15 @@ function updateJestConfig(tree, schema, projectConfig) {
|
|
|
26
37
|
}
|
|
27
38
|
const { createSourceFile, ScriptTarget, isPropertyAssignment, isArrayLiteralExpression, isStringLiteral, } = tsModule;
|
|
28
39
|
const projectToRemove = schema.projectName;
|
|
29
|
-
|
|
40
|
+
const rootConfigPath = (0, jest_config_1.findRootJestConfig)(tree);
|
|
41
|
+
if (!tree.exists(rootConfigPath) ||
|
|
30
42
|
!tree.exists((0, path_1.join)(projectConfig.root, 'jest.config.ts')) ||
|
|
31
43
|
isUsingUtilityFunction(tree) ||
|
|
32
44
|
!isMonorepoConfig(tree)) {
|
|
33
45
|
return;
|
|
34
46
|
}
|
|
35
|
-
const contents = tree.read(
|
|
36
|
-
const sourceFile = createSourceFile(
|
|
47
|
+
const contents = tree.read(rootConfigPath, 'utf-8');
|
|
48
|
+
const sourceFile = createSourceFile(rootConfigPath, contents, ScriptTarget.Latest);
|
|
37
49
|
const sourceNodes = (0, get_source_nodes_1.getSourceNodes)(sourceFile);
|
|
38
50
|
const projectsAssignment = sourceNodes.find((node) => isPropertyAssignment(node) &&
|
|
39
51
|
node.name.getText(sourceFile) === 'projects' &&
|
|
@@ -52,7 +64,7 @@ function updateJestConfig(tree, schema, projectConfig) {
|
|
|
52
64
|
const start = previousProject
|
|
53
65
|
? previousProject.getEnd()
|
|
54
66
|
: project.getStart(sourceFile);
|
|
55
|
-
tree.write(
|
|
67
|
+
tree.write(rootConfigPath, (0, devkit_1.applyChangesToString)(contents, [
|
|
56
68
|
{
|
|
57
69
|
type: devkit_1.ChangeType.Delete,
|
|
58
70
|
start,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findRootJestConfig = void 0;
|
|
4
|
+
function findRootJestConfig(tree) {
|
|
5
|
+
if (tree.exists('jest.config.js')) {
|
|
6
|
+
return 'jest.config.js';
|
|
7
|
+
}
|
|
8
|
+
if (tree.exists('jest.config.ts')) {
|
|
9
|
+
return 'jest.config.ts';
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
exports.findRootJestConfig = findRootJestConfig;
|