@nx/workspace 20.0.0-beta.3 → 20.0.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -4
- package/src/generators/new/files-readme/README.md.template +45 -5
- package/src/generators/new/generate-preset.js +1 -0
- package/src/generators/new/generate-workspace-files.js +16 -7
- package/src/generators/new/new.d.ts +1 -0
- package/src/generators/new/schema.json +6 -0
- package/src/generators/preset/preset.js +5 -1
- package/src/generators/preset/schema.d.ts +1 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/workspace",
|
3
|
-
"version": "20.0.0-beta.
|
3
|
+
"version": "20.0.0-beta.4",
|
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": "20.0.0-beta.
|
64
|
+
"@nx/devkit": "20.0.0-beta.4",
|
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": "20.0.0-beta.
|
70
|
-
"@nrwl/workspace": "20.0.0-beta.
|
69
|
+
"nx": "20.0.0-beta.4",
|
70
|
+
"@nrwl/workspace": "20.0.0-beta.4"
|
71
71
|
},
|
72
72
|
"publishConfig": {
|
73
73
|
"access": "public"
|
@@ -12,15 +12,15 @@ Run `npx nx graph` to visually explore what got created. Now, let's get you up t
|
|
12
12
|
|
13
13
|
[Click here to finish setting up your workspace!](<%= nxCloudOnboardingUrl %>)
|
14
14
|
|
15
|
-
<% } %>
|
15
|
+
<% } %><% if (!isEmptyRepo) { %>
|
16
16
|
## Run tasks
|
17
|
-
<% if (
|
17
|
+
<% if (isJsStandalone) { %>
|
18
18
|
To build the library use:
|
19
19
|
|
20
20
|
```sh
|
21
21
|
npx nx build
|
22
22
|
```
|
23
|
-
|
23
|
+
<% } else { %>
|
24
24
|
To run the dev server for your app, use:
|
25
25
|
|
26
26
|
```sh
|
@@ -38,7 +38,29 @@ To see all available targets to run for a project, run:
|
|
38
38
|
```sh
|
39
39
|
npx nx show project <%= appName %>
|
40
40
|
```
|
41
|
-
|
41
|
+
<% } %><% } else if (isTsPreset) { %>
|
42
|
+
## Generate a library
|
43
|
+
|
44
|
+
```sh
|
45
|
+
npx nx g @nx/js:lib packages/pkg1 --publishable --importPath=@my-org/pkg1
|
46
|
+
```
|
47
|
+
|
48
|
+
## Run tasks
|
49
|
+
|
50
|
+
To build the library use:
|
51
|
+
|
52
|
+
```sh
|
53
|
+
npx nx build pkg1
|
54
|
+
```
|
55
|
+
|
56
|
+
To run any task with Nx use:
|
57
|
+
|
58
|
+
```sh
|
59
|
+
npx nx <target> <project-name>
|
60
|
+
```
|
61
|
+
<% } else { %>
|
62
|
+
## Run tasks
|
63
|
+
|
42
64
|
To run tasks with Nx use:
|
43
65
|
|
44
66
|
```sh
|
@@ -66,7 +88,25 @@ npx nx release
|
|
66
88
|
Pass `--dry-run` to see what would happen without actually releasing the library.
|
67
89
|
|
68
90
|
[Learn more about Nx release »](hhttps://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
69
|
-
<% } %><% if (
|
91
|
+
<% } %><% if (isTsPreset && isUsingNewTsSolutionSetup) { %>
|
92
|
+
## Keep TypeScript project references up to date
|
93
|
+
|
94
|
+
Nx automatically updates TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) in `tsconfig.json` files to ensure they remain accurate based on your project dependencies (`import` or `require` statements). This sync is automatically done when running tasks such as `build` or `typecheck`, which require updated references to function correctly.
|
95
|
+
|
96
|
+
To manually trigger the process to sync the project graph dependencies information to the TypeScript project references, run the following command:
|
97
|
+
|
98
|
+
```sh
|
99
|
+
npx nx sync
|
100
|
+
```
|
101
|
+
|
102
|
+
You can enforce that the TypeScript project references are always in the correct state when running in CI by adding a step to your CI job configuration that runs the following command:
|
103
|
+
|
104
|
+
```sh
|
105
|
+
npx nx sync:check
|
106
|
+
```
|
107
|
+
|
108
|
+
[Learn more about nx sync](https://nx.dev/reference/nx-commands#sync)
|
109
|
+
<% } %><% if (!isJsStandalone && !isTsPreset) { %>
|
70
110
|
## Add new projects
|
71
111
|
|
72
112
|
While you could add new projects to your workspace manually, you might want to leverage [Nx plugins](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) and their [code generation](https://nx.dev/features/generate-code?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) feature.
|
@@ -70,6 +70,7 @@ function generatePreset(host, opts) {
|
|
70
70
|
opts.ssr ? `--ssr` : null,
|
71
71
|
opts.prefix !== undefined ? `--prefix=${opts.prefix}` : null,
|
72
72
|
opts.nxCloudToken ? `--nxCloudToken=${opts.nxCloudToken}` : null,
|
73
|
+
opts.formatter ? `--formatter=${opts.formatter}` : null,
|
73
74
|
].filter((e) => !!e);
|
74
75
|
}
|
75
76
|
}
|
@@ -159,12 +159,12 @@ async function generateWorkspaceFiles(tree, options) {
|
|
159
159
|
return token;
|
160
160
|
}
|
161
161
|
function setPresetProperty(tree, options) {
|
162
|
-
(
|
163
|
-
|
162
|
+
if (options.preset === presets_1.Preset.NPM) {
|
163
|
+
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.directory, 'nx.json'), (json) => {
|
164
164
|
addPropertyWithStableKeys(json, 'extends', 'nx/presets/npm.json');
|
165
|
-
|
166
|
-
|
167
|
-
}
|
165
|
+
return json;
|
166
|
+
});
|
167
|
+
}
|
168
168
|
}
|
169
169
|
function createNxJson(tree, { directory, defaultBase, preset }) {
|
170
170
|
const nxJson = {
|
@@ -210,7 +210,10 @@ function createFiles(tree, options) {
|
|
210
210
|
options.preset === presets_1.Preset.RemixStandalone ||
|
211
211
|
options.preset === presets_1.Preset.TsStandalone
|
212
212
|
? './files-root-app'
|
213
|
-
: options.preset === presets_1.Preset.
|
213
|
+
: (options.preset === presets_1.Preset.TS &&
|
214
|
+
process.env.NX_ADD_PLUGINS !== 'false' &&
|
215
|
+
process.env.NX_ADD_TS_PLUGIN === 'true') ||
|
216
|
+
options.preset === presets_1.Preset.NPM
|
214
217
|
? './files-package-based-repo'
|
215
218
|
: './files-integrated-repo';
|
216
219
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, filesDirName), options.directory, {
|
@@ -237,6 +240,9 @@ async function createReadme(tree, { name, appName, directory, preset, nxCloud },
|
|
237
240
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files-readme'), directory, {
|
238
241
|
formattedNames,
|
239
242
|
isJsStandalone: preset === presets_1.Preset.TsStandalone,
|
243
|
+
isTsPreset: preset === presets_1.Preset.TS,
|
244
|
+
isUsingNewTsSolutionSetup: process.env.NX_ADD_PLUGINS !== 'false' &&
|
245
|
+
process.env.NX_ADD_TS_PLUGIN === 'true',
|
240
246
|
isEmptyRepo: !appName,
|
241
247
|
appName,
|
242
248
|
generateAppCmd: presetInfo.generateAppCmd,
|
@@ -316,7 +322,10 @@ function normalizeOptions(options) {
|
|
316
322
|
};
|
317
323
|
}
|
318
324
|
function setUpWorkspacesInPackageJson(tree, options) {
|
319
|
-
if (options.preset === presets_1.Preset.NPM
|
325
|
+
if (options.preset === presets_1.Preset.NPM ||
|
326
|
+
(options.preset === presets_1.Preset.TS &&
|
327
|
+
process.env.NX_ADD_PLUGINS !== 'false' &&
|
328
|
+
process.env.NX_ADD_TS_PLUGIN === 'true')) {
|
320
329
|
if (options.packageManager === 'pnpm') {
|
321
330
|
tree.write((0, path_1.join)(options.directory, 'pnpm-workspace.yaml'), `packages:
|
322
331
|
- 'packages/*'
|
@@ -86,6 +86,12 @@
|
|
86
86
|
"prefix": {
|
87
87
|
"description": "The prefix to use for Angular component and directive selectors.",
|
88
88
|
"type": "string"
|
89
|
+
},
|
90
|
+
"formatter": {
|
91
|
+
"description": "The tool to use for code formatting.",
|
92
|
+
"type": "string",
|
93
|
+
"enum": ["none", "prettier"],
|
94
|
+
"default": "none"
|
89
95
|
}
|
90
96
|
},
|
91
97
|
"additionalProperties": true
|
@@ -272,7 +272,11 @@ async function createPreset(tree, options) {
|
|
272
272
|
}
|
273
273
|
else if (options.preset === presets_1.Preset.TS) {
|
274
274
|
const { initGenerator } = require('@nx' + '/js');
|
275
|
-
return initGenerator(tree, {
|
275
|
+
return initGenerator(tree, {
|
276
|
+
formatter: options.formatter,
|
277
|
+
addTsPlugin: process.env.NX_ADD_PLUGINS !== 'false' &&
|
278
|
+
process.env.NX_ADD_TS_PLUGIN === 'true',
|
279
|
+
});
|
276
280
|
}
|
277
281
|
else if (options.preset === presets_1.Preset.TsStandalone) {
|
278
282
|
const { libraryGenerator } = require('@nx' + '/js');
|