@nx/workspace 23.2.0-beta.8 → 23.2.0-beta.9
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/dist/src/generators/new/files-integrated-repo/__dot__vscode/extensions.json__tmpl__ +3 -2
- package/dist/src/generators/new/generate-preset.js +4 -2
- package/dist/src/generators/new/generate-workspace-files.js +4 -0
- package/dist/src/generators/new/new.d.ts +1 -1
- package/dist/src/generators/new/new.js +10 -1
- package/dist/src/generators/new/schema.json +1 -0
- package/dist/src/generators/preset/preset.js +37 -2
- package/dist/src/generators/preset/schema.d.ts +2 -1
- package/dist/src/generators/preset/schema.json +6 -0
- package/package.json +4 -4
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
<% if(cliCommand === 'ng') { %>
|
|
4
4
|
"angular.ng-template",<% }
|
|
5
5
|
%>
|
|
6
|
-
"nrwl.angular-console"
|
|
7
|
-
"esbenp.prettier-vscode"
|
|
6
|
+
"nrwl.angular-console"<% if(formatter === 'prettier') { %>,
|
|
7
|
+
"esbenp.prettier-vscode"<% } %><% if(formatter === 'oxfmt') { %>,
|
|
8
|
+
"oxc.oxc-vscode"<% } %>
|
|
8
9
|
]
|
|
9
10
|
}
|
|
@@ -89,6 +89,7 @@ function generatePreset(host, opts) {
|
|
|
89
89
|
: null,
|
|
90
90
|
opts.nxCloudToken ? `--nxCloudToken=${opts.nxCloudToken}` : null,
|
|
91
91
|
opts.formatter ? `--formatter=${opts.formatter}` : null,
|
|
92
|
+
opts.skipInstall ? `--skipInstall` : null,
|
|
92
93
|
opts.workspaces !== false ? `--workspaces` : `--no-workspaces`,
|
|
93
94
|
opts.useProjectJson ? `--useProjectJson` : null,
|
|
94
95
|
].filter((e) => !!e);
|
|
@@ -99,8 +100,9 @@ function generatePreset(host, opts) {
|
|
|
99
100
|
// `typescript: >3.0.0` peer to 7.x, whose entry point dropped the compiler API.
|
|
100
101
|
function getPresetDependencies({ preset, presetVersion, bundler, e2eTestRunner, js, }) {
|
|
101
102
|
switch (preset) {
|
|
102
|
-
//
|
|
103
|
-
//
|
|
103
|
+
// These generate no project, so `@nx/js:init` never runs to add typescript
|
|
104
|
+
// and pinning it here would be net-new. The preset generator itself does
|
|
105
|
+
// run - it sets up the chosen formatter.
|
|
104
106
|
case presets_1.Preset.Apps:
|
|
105
107
|
case presets_1.Preset.NPM:
|
|
106
108
|
return { dependencies: {}, dev: { '@nx/js': versions_1.nxVersion } };
|
|
@@ -227,6 +227,10 @@ function createFiles(tree, options) {
|
|
|
227
227
|
...options,
|
|
228
228
|
nxVersion: versions_1.nxVersion,
|
|
229
229
|
packageManager: options.packageManager,
|
|
230
|
+
// After the spread and always defined: `formatter` is optional on the
|
|
231
|
+
// schema, and EJS throws a ReferenceError on a key that is absent rather
|
|
232
|
+
// than treating it as undefined.
|
|
233
|
+
formatter: options.formatter ?? 'none',
|
|
230
234
|
});
|
|
231
235
|
}
|
|
232
236
|
async function createReadme(tree, { name, appName, directory, preset, nxCloud, workspaces }, nxCloudToken) {
|
|
@@ -28,7 +28,7 @@ interface Schema {
|
|
|
28
28
|
useGitHub?: boolean;
|
|
29
29
|
nxCloud?: 'yes' | 'skip' | 'circleci' | 'github';
|
|
30
30
|
analytics?: boolean;
|
|
31
|
-
formatter?:
|
|
31
|
+
formatter?: 'none' | 'prettier' | 'oxfmt';
|
|
32
32
|
workspaces?: boolean;
|
|
33
33
|
workspaceGlobs?: string | string[];
|
|
34
34
|
useProjectJson?: boolean;
|
|
@@ -27,7 +27,16 @@ async function newGenerator(tree, opts) {
|
|
|
27
27
|
(0, devkit_1.installPackagesTask)(tree, false, options.directory, options.packageManager);
|
|
28
28
|
}
|
|
29
29
|
// TODO: move all of these into create-nx-workspace
|
|
30
|
-
|
|
30
|
+
// The npm preset normally skips the preset generator entirely, which is why
|
|
31
|
+
// `--formatter` used to be dropped for it. Run it when there is a formatter
|
|
32
|
+
// to set up. `schema.json` defaults to `none`, so this fork is taken only
|
|
33
|
+
// when a formatter was actually asked for, which on this preset means an
|
|
34
|
+
// explicit `--formatter`.
|
|
35
|
+
const npmPresetNeedsFormatter = options.preset === presets_1.Preset.NPM &&
|
|
36
|
+
!!options.formatter &&
|
|
37
|
+
options.formatter !== 'none';
|
|
38
|
+
if ((options.preset !== presets_1.Preset.NPM || npmPresetNeedsFormatter) &&
|
|
39
|
+
!options.isCustomPreset) {
|
|
31
40
|
await (0, generate_preset_1.generatePreset)(tree, options);
|
|
32
41
|
}
|
|
33
42
|
// if we move this into create-nx-workspace, we can also easily log things out like nx console install success
|
|
@@ -17,8 +17,28 @@ async function createPreset(tree, options) {
|
|
|
17
17
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
18
18
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
19
19
|
nxJson.useInferencePlugins !== false;
|
|
20
|
-
if (options.preset === presets_1.Preset.Apps) {
|
|
21
|
-
|
|
20
|
+
if (options.preset === presets_1.Preset.Apps || options.preset === presets_1.Preset.NPM) {
|
|
21
|
+
// These presets generate no project, so nothing downstream would set the
|
|
22
|
+
// formatter up and the choice would be dropped. Only the formatter is
|
|
23
|
+
// configured here - `@nx/js:init` would also add TypeScript and register
|
|
24
|
+
// its plugin, which both presets deliberately leave out.
|
|
25
|
+
//
|
|
26
|
+
// `@nx/js` is only in the new workspace's package.json, not necessarily on
|
|
27
|
+
// disk. `validateOptions` allows `skipInstall` with these presets, so the
|
|
28
|
+
// require has to be reached only when there is a formatter to set up AND
|
|
29
|
+
// the install that puts `@nx/js` there actually ran.
|
|
30
|
+
if (!options.formatter || options.formatter === 'none') {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (options.skipInstall) {
|
|
34
|
+
// No follow-up command to name: `@nx/js:init` is what sets a formatter
|
|
35
|
+
// up, and running it here is what the comment above rules out for these
|
|
36
|
+
// presets.
|
|
37
|
+
devkit_1.logger.warn(`Skipped ${options.formatter} setup: it lives in @nx/js, which --skipInstall leaves uninstalled.`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const { setUpFormatter } = require('@nx' + '/js');
|
|
41
|
+
return setUpFormatter(tree, options.formatter);
|
|
22
42
|
}
|
|
23
43
|
else if (options.preset === presets_1.Preset.AngularMonorepo) {
|
|
24
44
|
const { applicationGenerator: angularApplicationGenerator } = require('@nx' + '/angular/generators');
|
|
@@ -39,6 +59,7 @@ async function createPreset(tree, options) {
|
|
|
39
59
|
ssr: options.ssr,
|
|
40
60
|
prefix: options.prefix,
|
|
41
61
|
zoneless: options.zoneless,
|
|
62
|
+
formatter: options.formatter,
|
|
42
63
|
nxCloudToken: options.nxCloudToken,
|
|
43
64
|
});
|
|
44
65
|
}
|
|
@@ -62,6 +83,7 @@ async function createPreset(tree, options) {
|
|
|
62
83
|
ssr: options.ssr,
|
|
63
84
|
prefix: options.prefix,
|
|
64
85
|
zoneless: options.zoneless,
|
|
86
|
+
formatter: options.formatter,
|
|
65
87
|
nxCloudToken: options.nxCloudToken,
|
|
66
88
|
});
|
|
67
89
|
}
|
|
@@ -132,6 +154,7 @@ async function createPreset(tree, options) {
|
|
|
132
154
|
unitTestRunner: options.unitTestRunner ?? 'vitest',
|
|
133
155
|
addPlugin,
|
|
134
156
|
nxCloudToken: options.nxCloudToken,
|
|
157
|
+
formatter: options.formatter,
|
|
135
158
|
});
|
|
136
159
|
}
|
|
137
160
|
else if (options.preset === presets_1.Preset.Nuxt) {
|
|
@@ -162,6 +185,7 @@ async function createPreset(tree, options) {
|
|
|
162
185
|
unitTestRunner: options.unitTestRunner ?? 'vitest',
|
|
163
186
|
addPlugin,
|
|
164
187
|
nxCloudToken: options.nxCloudToken,
|
|
188
|
+
formatter: options.formatter,
|
|
165
189
|
});
|
|
166
190
|
}
|
|
167
191
|
else if (options.preset === presets_1.Preset.NextJs) {
|
|
@@ -208,6 +232,7 @@ async function createPreset(tree, options) {
|
|
|
208
232
|
e2eTestRunner: options.e2eTestRunner ?? 'playwright',
|
|
209
233
|
addPlugin,
|
|
210
234
|
nxCloudToken: options.nxCloudToken,
|
|
235
|
+
formatter: options.formatter,
|
|
211
236
|
});
|
|
212
237
|
}
|
|
213
238
|
else if (options.preset === presets_1.Preset.Nest) {
|
|
@@ -271,9 +296,17 @@ async function createPreset(tree, options) {
|
|
|
271
296
|
}
|
|
272
297
|
else if (options.preset === presets_1.Preset.TS) {
|
|
273
298
|
const { initGenerator } = require('@nx' + '/js');
|
|
299
|
+
// `validateOptions` allows `skipInstall` here, and this run must then stay
|
|
300
|
+
// install-free: `skipPackageJson` gates both `ensurePackage` and the
|
|
301
|
+
// package.json write that would make `installPackagesTask` install, and
|
|
302
|
+
// `skipFormat` keeps `formatFiles` from loading the formatter. The
|
|
303
|
+
// formatter config is still written, so detection restores the dependency
|
|
304
|
+
// on the next `@nx/js:init`-running generator.
|
|
274
305
|
return initGenerator(tree, {
|
|
275
306
|
formatter: options.formatter,
|
|
276
307
|
addTsPlugin: process.env.NX_ADD_PLUGINS !== 'false' && options.workspaces,
|
|
308
|
+
skipPackageJson: options.skipInstall,
|
|
309
|
+
skipFormat: options.skipInstall,
|
|
277
310
|
});
|
|
278
311
|
}
|
|
279
312
|
else if (options.preset === presets_1.Preset.TsStandalone) {
|
|
@@ -290,6 +323,7 @@ async function createPreset(tree, options) {
|
|
|
290
323
|
js: options.js,
|
|
291
324
|
rootProject: true,
|
|
292
325
|
addPlugin,
|
|
326
|
+
formatter: options.formatter,
|
|
293
327
|
});
|
|
294
328
|
}
|
|
295
329
|
else if (options.preset === presets_1.Preset.NodeStandalone) {
|
|
@@ -306,6 +340,7 @@ async function createPreset(tree, options) {
|
|
|
306
340
|
e2eTestRunner: options.e2eTestRunner ?? 'jest',
|
|
307
341
|
unitTestRunner: options.unitTestRunner,
|
|
308
342
|
addPlugin,
|
|
343
|
+
formatter: options.formatter,
|
|
309
344
|
});
|
|
310
345
|
}
|
|
311
346
|
else if (options.preset === presets_1.Preset.NodeMonorepo) {
|
|
@@ -103,9 +103,15 @@
|
|
|
103
103
|
"description": "Generate an application that does not use 'zone.js'.",
|
|
104
104
|
"type": "boolean"
|
|
105
105
|
},
|
|
106
|
+
"skipInstall": {
|
|
107
|
+
"description": "Skip installing dependencies. Formatter setup needs @nx/js on disk, so it is skipped too.",
|
|
108
|
+
"type": "boolean",
|
|
109
|
+
"default": false
|
|
110
|
+
},
|
|
106
111
|
"formatter": {
|
|
107
112
|
"description": "The tool to use for code formatting.",
|
|
108
113
|
"type": "string",
|
|
114
|
+
"enum": ["none", "prettier", "oxfmt"],
|
|
109
115
|
"default": "none"
|
|
110
116
|
},
|
|
111
117
|
"workspaces": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/workspace",
|
|
3
|
-
"version": "23.2.0-beta.
|
|
3
|
+
"version": "23.2.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -84,11 +84,11 @@
|
|
|
84
84
|
"semver": "^7.6.3",
|
|
85
85
|
"tslib": "^2.3.0",
|
|
86
86
|
"yargs-parser": "21.1.1",
|
|
87
|
-
"nx": "23.2.0-beta.
|
|
88
|
-
"@nx/devkit": "23.2.0-beta.
|
|
87
|
+
"nx": "23.2.0-beta.9",
|
|
88
|
+
"@nx/devkit": "23.2.0-beta.9"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"nx": "23.2.0-beta.
|
|
91
|
+
"nx": "23.2.0-beta.9"
|
|
92
92
|
},
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|