@nx/react 19.8.0 → 20.0.0-beta.0
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/generators.json +5 -5
- package/package.json +6 -6
- package/src/generators/application/application.js +0 -1
- package/src/generators/application/lib/normalize-options.d.ts +1 -1
- package/src/generators/application/lib/normalize-options.js +2 -3
- package/src/generators/application/schema.d.ts +0 -1
- package/src/generators/application/schema.json +1 -7
- package/src/generators/component/component.d.ts +0 -1
- package/src/generators/component/component.js +0 -7
- package/src/generators/component/lib/normalize-options.js +0 -7
- package/src/generators/component/schema.d.ts +2 -20
- package/src/generators/component/schema.json +0 -29
- package/src/generators/federate-module/federate-module.js +4 -5
- package/src/generators/hook/hook.d.ts +0 -1
- package/src/generators/hook/hook.js +9 -42
- package/src/generators/hook/schema.d.ts +3 -17
- package/src/generators/hook/schema.json +0 -29
- package/src/generators/host/host.d.ts +0 -1
- package/src/generators/host/host.js +1 -8
- package/src/generators/host/lib/normalize-remote.js +10 -5
- package/src/generators/host/schema.d.ts +0 -1
- package/src/generators/host/schema.json +0 -6
- package/src/generators/library/lib/normalize-options.js +0 -1
- package/src/generators/library/library.js +0 -4
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +0 -6
- package/src/generators/redux/redux.d.ts +0 -1
- package/src/generators/redux/redux.js +0 -12
- package/src/generators/redux/schema.d.ts +3 -5
- package/src/generators/redux/schema.json +0 -9
- package/src/generators/remote/remote.d.ts +0 -1
- package/src/generators/remote/remote.js +1 -8
- package/src/generators/remote/schema.d.ts +0 -1
- package/src/generators/remote/schema.json +0 -6
package/generators.json
CHANGED
@@ -25,13 +25,13 @@
|
|
25
25
|
"description": "Create a React library."
|
26
26
|
},
|
27
27
|
"component": {
|
28
|
-
"factory": "./src/generators/component/component
|
28
|
+
"factory": "./src/generators/component/component",
|
29
29
|
"schema": "./src/generators/component/schema.json",
|
30
30
|
"description": "Create a React component.",
|
31
31
|
"aliases": ["c"]
|
32
32
|
},
|
33
33
|
"redux": {
|
34
|
-
"factory": "./src/generators/redux/redux
|
34
|
+
"factory": "./src/generators/redux/redux",
|
35
35
|
"schema": "./src/generators/redux/schema.json",
|
36
36
|
"description": "Create a Redux slice for a project.",
|
37
37
|
"aliases": ["slice"]
|
@@ -61,19 +61,19 @@
|
|
61
61
|
"hidden": false
|
62
62
|
},
|
63
63
|
"hook": {
|
64
|
-
"factory": "./src/generators/hook/hook
|
64
|
+
"factory": "./src/generators/hook/hook",
|
65
65
|
"schema": "./src/generators/hook/schema.json",
|
66
66
|
"description": "Create a hook.",
|
67
67
|
"aliases": ["c"]
|
68
68
|
},
|
69
69
|
"host": {
|
70
|
-
"factory": "./src/generators/host/host
|
70
|
+
"factory": "./src/generators/host/host",
|
71
71
|
"schema": "./src/generators/host/schema.json",
|
72
72
|
"x-type": "application",
|
73
73
|
"description": "Generate a host react application"
|
74
74
|
},
|
75
75
|
"remote": {
|
76
|
-
"factory": "./src/generators/remote/remote
|
76
|
+
"factory": "./src/generators/remote/remote",
|
77
77
|
"schema": "./src/generators/remote/schema.json",
|
78
78
|
"x-type": "application",
|
79
79
|
"description": "Generate a remote react application"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/react",
|
3
|
-
"version": "
|
3
|
+
"version": "20.0.0-beta.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
|
6
6
|
"repository": {
|
@@ -39,13 +39,13 @@
|
|
39
39
|
"minimatch": "9.0.3",
|
40
40
|
"tslib": "^2.3.0",
|
41
41
|
"@module-federation/enhanced": "~0.6.0",
|
42
|
-
"@nx/devkit": "
|
43
|
-
"@nx/js": "
|
44
|
-
"@nx/eslint": "
|
45
|
-
"@nx/web": "
|
42
|
+
"@nx/devkit": "20.0.0-beta.0",
|
43
|
+
"@nx/js": "20.0.0-beta.0",
|
44
|
+
"@nx/eslint": "20.0.0-beta.0",
|
45
|
+
"@nx/web": "20.0.0-beta.0",
|
46
46
|
"express": "^4.19.2",
|
47
47
|
"http-proxy-middleware": "^3.0.0",
|
48
|
-
"@nrwl/react": "
|
48
|
+
"@nrwl/react": "20.0.0-beta.0"
|
49
49
|
},
|
50
50
|
"publishConfig": {
|
51
51
|
"access": "public"
|
@@ -2,4 +2,4 @@ import { Tree } from '@nx/devkit';
|
|
2
2
|
import { NormalizedSchema, Schema } from '../schema';
|
3
3
|
export declare function normalizeDirectory(options: Schema): string;
|
4
4
|
export declare function normalizeProjectName(options: Schema): string;
|
5
|
-
export declare function normalizeOptions<T extends Schema = Schema>(host: Tree, options: Schema
|
5
|
+
export declare function normalizeOptions<T extends Schema = Schema>(host: Tree, options: Schema): Promise<NormalizedSchema<T>>;
|
@@ -17,14 +17,13 @@ function normalizeDirectory(options) {
|
|
17
17
|
function normalizeProjectName(options) {
|
18
18
|
return normalizeDirectory(options).replace(new RegExp('/', 'g'), '-');
|
19
19
|
}
|
20
|
-
async function normalizeOptions(host, options
|
20
|
+
async function normalizeOptions(host, options) {
|
21
21
|
const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
22
22
|
name: options.name,
|
23
23
|
projectType: 'application',
|
24
24
|
directory: options.directory,
|
25
25
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
26
26
|
rootProject: options.rootProject,
|
27
|
-
callingGenerator,
|
28
27
|
});
|
29
28
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
30
29
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
@@ -37,7 +36,7 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
|
|
37
36
|
const parsedTags = options.tags
|
38
37
|
? options.tags.split(',').map((s) => s.trim())
|
39
38
|
: [];
|
40
|
-
const fileName =
|
39
|
+
const fileName = 'app';
|
41
40
|
const styledModule = /^(css|scss|less|tailwind|none)$/.test(options.style)
|
42
41
|
? null
|
43
42
|
: options.style;
|
@@ -132,12 +132,6 @@
|
|
132
132
|
"description": "Add tags to the application (used for linting).",
|
133
133
|
"alias": "t"
|
134
134
|
},
|
135
|
-
"pascalCaseFiles": {
|
136
|
-
"type": "boolean",
|
137
|
-
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
138
|
-
"alias": "P",
|
139
|
-
"default": false
|
140
|
-
},
|
141
135
|
"classComponent": {
|
142
136
|
"type": "boolean",
|
143
137
|
"description": "Use class components instead of functional component.",
|
@@ -187,7 +181,7 @@
|
|
187
181
|
"type": "string",
|
188
182
|
"enum": ["vite", "webpack", "rspack"],
|
189
183
|
"x-prompt": "Which bundler do you want to use to build the application?",
|
190
|
-
"default": "
|
184
|
+
"default": "vite",
|
191
185
|
"x-priority": "important"
|
192
186
|
},
|
193
187
|
"minimal": {
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
2
2
|
import { Schema } from './schema';
|
3
3
|
export declare function componentGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
4
|
-
export declare function componentGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
5
4
|
export default componentGenerator;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.componentGenerator = componentGenerator;
|
4
|
-
exports.componentGeneratorInternal = componentGeneratorInternal;
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
6
5
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
7
6
|
const path_1 = require("path");
|
@@ -12,12 +11,6 @@ const versions_1 = require("../../utils/versions");
|
|
12
11
|
const get_component_tests_1 = require("./lib/get-component-tests");
|
13
12
|
const normalize_options_1 = require("./lib/normalize-options");
|
14
13
|
async function componentGenerator(host, schema) {
|
15
|
-
return componentGeneratorInternal(host, {
|
16
|
-
nameAndDirectoryFormat: 'derived',
|
17
|
-
...schema,
|
18
|
-
});
|
19
|
-
}
|
20
|
-
async function componentGeneratorInternal(host, schema) {
|
21
14
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
22
15
|
createComponentFiles(host, options);
|
23
16
|
const tasks = [];
|
@@ -7,18 +7,11 @@ const assertion_1 = require("../../../utils/assertion");
|
|
7
7
|
async function normalizeOptions(tree, options) {
|
8
8
|
(0, assertion_1.assertValidStyle)(options.style);
|
9
9
|
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
10
|
-
artifactType: 'component',
|
11
|
-
callingGenerator: '@nx/react:component',
|
12
10
|
name: options.name,
|
13
11
|
directory: options.directory,
|
14
|
-
derivedDirectory: options.derivedDirectory ?? options.directory,
|
15
|
-
flat: options.flat,
|
16
12
|
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
17
|
-
project: options.project,
|
18
13
|
fileExtension: 'tsx',
|
19
14
|
fileName: options.fileName,
|
20
|
-
pascalCaseFile: options.pascalCaseFiles,
|
21
|
-
pascalCaseDirectory: options.pascalCaseDirectory,
|
22
15
|
});
|
23
16
|
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
24
17
|
const { className } = (0, devkit_1.names)(name);
|
@@ -1,38 +1,20 @@
|
|
1
|
+
import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
1
2
|
import { SupportedStyles } from '../../../typings/style';
|
2
3
|
|
3
4
|
export interface Schema {
|
4
5
|
name: string;
|
5
|
-
/**
|
6
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
|
7
|
-
*/
|
8
|
-
project?: string;
|
9
6
|
style: SupportedStyles;
|
10
7
|
skipTests?: boolean;
|
11
8
|
directory?: string;
|
12
9
|
export?: boolean;
|
13
|
-
/**
|
14
|
-
* @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
|
15
|
-
*/
|
16
|
-
pascalCaseFiles?: boolean;
|
17
|
-
/**
|
18
|
-
* @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
|
19
|
-
*/
|
20
|
-
pascalCaseDirectory?: boolean;
|
21
10
|
classComponent?: boolean;
|
22
11
|
routing?: boolean;
|
23
12
|
js?: boolean;
|
24
|
-
/**
|
25
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
26
|
-
*/
|
27
|
-
flat?: boolean;
|
28
13
|
globalCss?: boolean;
|
29
14
|
fileName?: string;
|
30
15
|
inSourceTests?: boolean;
|
31
16
|
skipFormat?: boolean;
|
32
|
-
nameAndDirectoryFormat?:
|
33
|
-
// Used by other wrapping generators to preserve previous behavior
|
34
|
-
// e.g. @nx/next:component
|
35
|
-
derivedDirectory?: string;
|
17
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
36
18
|
// Used by Next.js to determine how React should generate the page
|
37
19
|
isNextPage?: boolean;
|
38
20
|
}
|
@@ -6,15 +6,6 @@
|
|
6
6
|
"description": "Create a React Component for Nx.",
|
7
7
|
"type": "object",
|
8
8
|
"properties": {
|
9
|
-
"project": {
|
10
|
-
"type": "string",
|
11
|
-
"description": "The name of the project.",
|
12
|
-
"alias": "p",
|
13
|
-
"$default": {
|
14
|
-
"$source": "projectName"
|
15
|
-
},
|
16
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
|
17
|
-
},
|
18
9
|
"name": {
|
19
10
|
"type": "string",
|
20
11
|
"description": "The name of the component.",
|
@@ -87,12 +78,6 @@
|
|
87
78
|
"type": "string",
|
88
79
|
"enum": ["as-provided", "derived"]
|
89
80
|
},
|
90
|
-
"flat": {
|
91
|
-
"type": "boolean",
|
92
|
-
"description": "Create component at the source root rather than its own directory.",
|
93
|
-
"default": false,
|
94
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
|
95
|
-
},
|
96
81
|
"export": {
|
97
82
|
"type": "boolean",
|
98
83
|
"description": "When true, the component is exported from the project `index.ts` (if it exists).",
|
@@ -100,20 +85,6 @@
|
|
100
85
|
"default": false,
|
101
86
|
"x-prompt": "Should this component be exported in the project?"
|
102
87
|
},
|
103
|
-
"pascalCaseFiles": {
|
104
|
-
"type": "boolean",
|
105
|
-
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
106
|
-
"alias": "P",
|
107
|
-
"default": false,
|
108
|
-
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
109
|
-
},
|
110
|
-
"pascalCaseDirectory": {
|
111
|
-
"type": "boolean",
|
112
|
-
"description": "Use pascal case directory name (e.g. `App/App.tsx`).",
|
113
|
-
"alias": "R",
|
114
|
-
"default": false,
|
115
|
-
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
116
|
-
},
|
117
88
|
"classComponent": {
|
118
89
|
"type": "boolean",
|
119
90
|
"alias": "C",
|
@@ -19,7 +19,7 @@ async function federateModuleGenerator(tree, schema) {
|
|
19
19
|
let projectRoot, remoteName;
|
20
20
|
if (!remote) {
|
21
21
|
// create remote
|
22
|
-
const
|
22
|
+
const remoteGeneratorTask = await (0, remote_1.remoteGenerator)(tree, {
|
23
23
|
name: schema.remote,
|
24
24
|
directory: schema.remoteDirectory,
|
25
25
|
e2eTestRunner: schema.e2eTestRunner,
|
@@ -28,16 +28,15 @@ async function federateModuleGenerator(tree, schema) {
|
|
28
28
|
style: schema.style,
|
29
29
|
unitTestRunner: schema.unitTestRunner,
|
30
30
|
host: schema.host,
|
31
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat ?? 'derived',
|
32
31
|
bundler: schema.bundler ?? 'rspack',
|
32
|
+
projectNameAndRootFormat: schema.projectNameAndRootFormat,
|
33
33
|
});
|
34
|
-
tasks.push(
|
34
|
+
tasks.push(remoteGeneratorTask);
|
35
35
|
const { projectName, projectRoot: remoteRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
36
36
|
name: schema.remote,
|
37
37
|
directory: schema.remoteDirectory,
|
38
38
|
projectType: 'application',
|
39
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat
|
40
|
-
callingGenerator: '@nx/react:federate-module',
|
39
|
+
projectNameAndRootFormat: schema.projectNameAndRootFormat,
|
41
40
|
});
|
42
41
|
projectRoot = remoteRoot;
|
43
42
|
remoteName = projectName;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
2
2
|
import { Schema } from './schema';
|
3
3
|
export declare function hookGenerator(host: Tree, schema: Schema): Promise<void>;
|
4
|
-
export declare function hookGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
|
5
4
|
export default hookGenerator;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.hookGenerator = hookGenerator;
|
4
|
-
exports.hookGeneratorInternal = hookGeneratorInternal;
|
5
4
|
// TODO(jack): Remove inline renderHook function when RTL releases with its own version
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
7
6
|
const ast_utils_1 = require("../../utils/ast-utils");
|
@@ -9,12 +8,6 @@ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescri
|
|
9
8
|
const path_1 = require("path");
|
10
9
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
11
10
|
async function hookGenerator(host, schema) {
|
12
|
-
return hookGeneratorInternal(host, {
|
13
|
-
nameAndDirectoryFormat: 'derived',
|
14
|
-
...schema,
|
15
|
-
});
|
16
|
-
}
|
17
|
-
async function hookGeneratorInternal(host, schema) {
|
18
11
|
const options = await normalizeOptions(host, schema);
|
19
12
|
createFiles(host, options);
|
20
13
|
addExportsToBarrel(host, options);
|
@@ -57,53 +50,27 @@ function addExportsToBarrel(host, options) {
|
|
57
50
|
}
|
58
51
|
async function normalizeOptions(host, options) {
|
59
52
|
assertValidOptions(options);
|
60
|
-
const {
|
61
|
-
artifactType: 'hook',
|
62
|
-
callingGenerator: '@nx/react:hook',
|
53
|
+
const { directory, fileName: _fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
63
54
|
name: options.name,
|
64
55
|
directory: options.directory,
|
65
|
-
derivedDirectory: options.directory,
|
66
|
-
flat: options.flat,
|
67
56
|
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
68
|
-
project: options.project,
|
69
57
|
fileExtension: 'tsx',
|
70
|
-
pascalCaseFile: options.pascalCaseFiles,
|
71
|
-
pascalCaseDirectory: options.pascalCaseDirectory,
|
72
58
|
});
|
73
|
-
|
74
|
-
if (base.startsWith('use-')) {
|
75
|
-
base = base.substring(4);
|
76
|
-
}
|
77
|
-
else if (base.startsWith('use')) {
|
78
|
-
base = base.substring(3);
|
79
|
-
}
|
80
|
-
const { className, fileName } = (0, devkit_1.names)(base);
|
59
|
+
const { className, fileName } = (0, devkit_1.names)(_fileName);
|
81
60
|
// If using `as-provided` file and directory, then don't normalize.
|
82
61
|
// Otherwise, support legacy behavior of prefixing filename with `use-`.
|
83
|
-
const hookFilename =
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
62
|
+
const hookFilename = fileName;
|
63
|
+
const hookName = className.toLocaleLowerCase().startsWith('use')
|
64
|
+
? className
|
65
|
+
: 'use'.concat(className);
|
66
|
+
const hookTypeName = className.toLocaleLowerCase().startsWith('use')
|
67
|
+
? className
|
68
|
+
: 'Use'.concat(className);
|
90
69
|
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
91
70
|
const { sourceRoot: projectSourceRoot, projectType } = project;
|
92
71
|
if (options.export && projectType === 'application') {
|
93
72
|
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
94
73
|
}
|
95
|
-
// Support legacy behavior of derived directory to prefix with `use-`.
|
96
|
-
let directory = _directory;
|
97
|
-
if (nameAndDirectoryFormat === 'derived') {
|
98
|
-
const parts = directory.split('/');
|
99
|
-
parts.pop();
|
100
|
-
if (!options.flat) {
|
101
|
-
parts.push(options.pascalCaseDirectory
|
102
|
-
? 'use'.concat(className)
|
103
|
-
: 'use-'.concat(fileName));
|
104
|
-
}
|
105
|
-
directory = parts.join('/');
|
106
|
-
}
|
107
74
|
return {
|
108
75
|
...options,
|
109
76
|
directory,
|
@@ -1,24 +1,10 @@
|
|
1
|
+
import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
2
|
+
|
1
3
|
export interface Schema {
|
2
4
|
name: string;
|
3
|
-
/**
|
4
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
|
5
|
-
*/
|
6
|
-
project: string;
|
7
5
|
skipTests?: boolean;
|
8
6
|
directory?: string;
|
9
7
|
export?: boolean;
|
10
|
-
/**
|
11
|
-
* @deprecated Provide the `name` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
12
|
-
*/
|
13
|
-
pascalCaseFiles?: boolean;
|
14
|
-
/**
|
15
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
16
|
-
*/
|
17
|
-
pascalCaseDirectory?: boolean;
|
18
|
-
/**
|
19
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
20
|
-
*/
|
21
|
-
flat?: boolean;
|
22
8
|
js?: boolean;
|
23
|
-
nameAndDirectoryFormat?:
|
9
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
24
10
|
}
|
@@ -12,15 +12,6 @@
|
|
12
12
|
}
|
13
13
|
],
|
14
14
|
"properties": {
|
15
|
-
"project": {
|
16
|
-
"type": "string",
|
17
|
-
"description": "The name of the project.",
|
18
|
-
"alias": "p",
|
19
|
-
"$default": {
|
20
|
-
"$source": "projectName"
|
21
|
-
},
|
22
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
|
23
|
-
},
|
24
15
|
"name": {
|
25
16
|
"type": "string",
|
26
17
|
"description": "The name of the hook.",
|
@@ -52,32 +43,12 @@
|
|
52
43
|
"type": "string",
|
53
44
|
"enum": ["as-provided", "derived"]
|
54
45
|
},
|
55
|
-
"flat": {
|
56
|
-
"type": "boolean",
|
57
|
-
"description": "Create hook at the source root rather than its own directory.",
|
58
|
-
"default": false,
|
59
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
|
60
|
-
},
|
61
46
|
"export": {
|
62
47
|
"type": "boolean",
|
63
48
|
"description": "When true, the hook is exported from the project `index.ts` (if it exists).",
|
64
49
|
"alias": "e",
|
65
50
|
"default": false,
|
66
51
|
"x-prompt": "Should this hook be exported in the project?"
|
67
|
-
},
|
68
|
-
"pascalCaseFiles": {
|
69
|
-
"type": "boolean",
|
70
|
-
"description": "Use pascal case hook file name (e.g. `useHook.ts`).",
|
71
|
-
"alias": "P",
|
72
|
-
"default": false,
|
73
|
-
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
74
|
-
},
|
75
|
-
"pascalCaseDirectory": {
|
76
|
-
"type": "boolean",
|
77
|
-
"description": "Use pascal case directory name (e.g. `useHook/useHook.ts`).",
|
78
|
-
"alias": "R",
|
79
|
-
"default": false,
|
80
|
-
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
81
52
|
}
|
82
53
|
},
|
83
54
|
"required": ["name"]
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
2
2
|
import { Schema } from './schema';
|
3
3
|
export declare function hostGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
4
|
-
export declare function hostGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
5
4
|
export default hostGenerator;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.hostGenerator = hostGenerator;
|
4
|
-
exports.hostGeneratorInternal = hostGeneratorInternal;
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
6
5
|
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
7
6
|
const application_1 = require("../application/application");
|
@@ -16,15 +15,9 @@ const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
16
15
|
const js_1 = require("@nx/js");
|
17
16
|
const versions_1 = require("../../utils/versions");
|
18
17
|
async function hostGenerator(host, schema) {
|
19
|
-
return hostGeneratorInternal(host, {
|
20
|
-
projectNameAndRootFormat: 'derived',
|
21
|
-
...schema,
|
22
|
-
});
|
23
|
-
}
|
24
|
-
async function hostGeneratorInternal(host, schema) {
|
25
18
|
const tasks = [];
|
26
19
|
const options = {
|
27
|
-
...(await (0, normalize_options_1.normalizeOptions)(host, schema
|
20
|
+
...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
|
28
21
|
js: schema.js ?? false,
|
29
22
|
typescriptConfiguration: schema.js
|
30
23
|
? false
|
@@ -10,18 +10,23 @@ async function normalizeRemoteName(tree, remote, options) {
|
|
10
10
|
projectType: 'application',
|
11
11
|
directory: options.directory,
|
12
12
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
13
|
-
callingGenerator: '@nx/react:host',
|
14
13
|
});
|
15
14
|
return remoteName;
|
16
15
|
}
|
17
16
|
function normalizeRemoteDirectory(remote, options) {
|
18
|
-
if (options.projectNameAndRootFormat === 'derived' || !options.directory) {
|
19
|
-
return options.directory;
|
20
|
-
}
|
21
17
|
/**
|
22
18
|
* With the `as-provided` format, the provided directory would be the root
|
23
19
|
* of the host application. Append the remote name to the host parent
|
24
20
|
* directory to get the remote directory.
|
21
|
+
*
|
22
|
+
* If no directory is provided, the remote directory will use the grandparent of the hostRoot 'acme/host/src' -> 'acme'
|
25
23
|
*/
|
26
|
-
|
24
|
+
if (options.directory) {
|
25
|
+
return (0, devkit_1.joinPathFragments)(options.directory, '..', remote);
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
return options.appProjectRoot === '.'
|
29
|
+
? remote
|
30
|
+
: (0, devkit_1.joinPathFragments)(options.appProjectRoot, '..', remote);
|
31
|
+
}
|
27
32
|
}
|
@@ -113,12 +113,6 @@
|
|
113
113
|
"description": "Add tags to the application (used for linting).",
|
114
114
|
"alias": "t"
|
115
115
|
},
|
116
|
-
"pascalCaseFiles": {
|
117
|
-
"type": "boolean",
|
118
|
-
"description": "Use pascal case component file name (e.g. App.tsx).",
|
119
|
-
"alias": "P",
|
120
|
-
"default": false
|
121
|
-
},
|
122
116
|
"classComponent": {
|
123
117
|
"type": "boolean",
|
124
118
|
"description": "Use class components instead of functional component.",
|
@@ -11,7 +11,6 @@ async function normalizeOptions(host, options) {
|
|
11
11
|
directory: options.directory,
|
12
12
|
importPath: options.importPath,
|
13
13
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
14
|
-
callingGenerator: '@nx/react:library',
|
15
14
|
});
|
16
15
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
17
16
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
@@ -23,7 +23,6 @@ const set_defaults_1 = require("./lib/set-defaults");
|
|
23
23
|
async function libraryGenerator(host, schema) {
|
24
24
|
return await libraryGeneratorInternal(host, {
|
25
25
|
addPlugin: false,
|
26
|
-
projectNameAndRootFormat: 'derived',
|
27
26
|
...schema,
|
28
27
|
});
|
29
28
|
}
|
@@ -151,15 +150,12 @@ async function libraryGeneratorInternal(host, schema) {
|
|
151
150
|
const componentTask = await (0, component_1.default)(host, {
|
152
151
|
nameAndDirectoryFormat: 'as-provided',
|
153
152
|
name: relativeCwd ? (0, path_1.relative)(relativeCwd, name) : name,
|
154
|
-
project: options.name,
|
155
|
-
flat: true,
|
156
153
|
style: options.style,
|
157
154
|
skipTests: options.unitTestRunner === 'none' ||
|
158
155
|
(options.unitTestRunner === 'vitest' && options.inSourceTests == true),
|
159
156
|
export: true,
|
160
157
|
routing: options.routing,
|
161
158
|
js: options.js,
|
162
|
-
pascalCaseFiles: options.pascalCaseFiles,
|
163
159
|
inSourceTests: options.inSourceTests,
|
164
160
|
skipFormat: true,
|
165
161
|
globalCss: options.globalCss,
|
@@ -109,12 +109,6 @@
|
|
109
109
|
"description": "Do not update `tsconfig.json` for development experience.",
|
110
110
|
"x-priority": "internal"
|
111
111
|
},
|
112
|
-
"pascalCaseFiles": {
|
113
|
-
"type": "boolean",
|
114
|
-
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
115
|
-
"alias": "P",
|
116
|
-
"default": false
|
117
|
-
},
|
118
112
|
"routing": {
|
119
113
|
"type": "boolean",
|
120
114
|
"description": "Generate library with routes."
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Schema } from './schema';
|
2
2
|
import { Tree } from '@nx/devkit';
|
3
3
|
export declare function reduxGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
4
|
-
export declare function reduxGeneratorInternal(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
5
4
|
export default reduxGenerator;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.reduxGenerator = reduxGenerator;
|
4
|
-
exports.reduxGeneratorInternal = reduxGeneratorInternal;
|
5
4
|
const path = require("path");
|
6
5
|
const ast_utils_1 = require("../../utils/ast-utils");
|
7
6
|
const versions_1 = require("../../utils/versions");
|
@@ -11,12 +10,6 @@ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescri
|
|
11
10
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
12
11
|
let tsModule;
|
13
12
|
async function reduxGenerator(host, schema) {
|
14
|
-
return reduxGeneratorInternal(host, {
|
15
|
-
nameAndDirectoryFormat: 'derived',
|
16
|
-
...schema,
|
17
|
-
});
|
18
|
-
}
|
19
|
-
async function reduxGeneratorInternal(host, schema) {
|
20
13
|
const options = await normalizeOptions(host, schema);
|
21
14
|
generateReduxFiles(host, options);
|
22
15
|
addExportsToBarrel(host, options);
|
@@ -85,14 +78,9 @@ function updateReducerConfiguration(host, options) {
|
|
85
78
|
}
|
86
79
|
async function normalizeOptions(host, options) {
|
87
80
|
const { artifactName: name, directory, fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
88
|
-
artifactType: 'slice',
|
89
|
-
callingGenerator: '@nx/react:redux',
|
90
81
|
name: options.name,
|
91
82
|
directory: options.directory,
|
92
|
-
derivedDirectory: options.directory,
|
93
|
-
flat: true,
|
94
83
|
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
95
|
-
project: options.project,
|
96
84
|
fileExtension: 'tsx',
|
97
85
|
});
|
98
86
|
let appProjectSourcePath;
|
@@ -1,13 +1,11 @@
|
|
1
|
+
import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
2
|
+
|
1
3
|
export interface Schema {
|
2
4
|
name: string;
|
3
|
-
/**
|
4
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
|
5
|
-
*/
|
6
|
-
project?: string;
|
7
5
|
directory?: string;
|
8
6
|
appProject?: string;
|
9
7
|
js?: string;
|
10
|
-
nameAndDirectoryFormat?:
|
8
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
11
9
|
}
|
12
10
|
|
13
11
|
interface NormalizedSchema extends Schema {
|
@@ -15,15 +15,6 @@
|
|
15
15
|
},
|
16
16
|
"x-priority": "important"
|
17
17
|
},
|
18
|
-
"project": {
|
19
|
-
"type": "string",
|
20
|
-
"description": "The name of the project to add the slice to. If it is an application, then the store configuration will be updated too.",
|
21
|
-
"alias": "p",
|
22
|
-
"$default": {
|
23
|
-
"$source": "projectName"
|
24
|
-
},
|
25
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
|
26
|
-
},
|
27
18
|
"directory": {
|
28
19
|
"type": "string",
|
29
20
|
"alias": "dir",
|
@@ -3,5 +3,4 @@ import { NormalizedSchema } from '../application/schema';
|
|
3
3
|
import { Schema } from './schema';
|
4
4
|
export declare function addModuleFederationFiles(host: Tree, options: NormalizedSchema<Schema>): void;
|
5
5
|
export declare function remoteGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
6
|
-
export declare function remoteGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
7
6
|
export default remoteGenerator;
|
@@ -2,7 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addModuleFederationFiles = addModuleFederationFiles;
|
4
4
|
exports.remoteGenerator = remoteGenerator;
|
5
|
-
exports.remoteGeneratorInternal = remoteGeneratorInternal;
|
6
5
|
const path_1 = require("path");
|
7
6
|
const devkit_1 = require("@nx/devkit");
|
8
7
|
const normalize_options_1 = require("../application/lib/normalize-options");
|
@@ -46,15 +45,9 @@ function addModuleFederationFiles(host, options) {
|
|
46
45
|
}
|
47
46
|
}
|
48
47
|
async function remoteGenerator(host, schema) {
|
49
|
-
return await remoteGeneratorInternal(host, {
|
50
|
-
projectNameAndRootFormat: 'derived',
|
51
|
-
...schema,
|
52
|
-
});
|
53
|
-
}
|
54
|
-
async function remoteGeneratorInternal(host, schema) {
|
55
48
|
const tasks = [];
|
56
49
|
const options = {
|
57
|
-
...(await (0, normalize_options_1.normalizeOptions)(host, schema
|
50
|
+
...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
|
58
51
|
// when js is set to true, we want to use the js configuration
|
59
52
|
js: schema.js ?? false,
|
60
53
|
typescriptConfiguration: schema.js
|
@@ -119,12 +119,6 @@
|
|
119
119
|
"description": "Add tags to the application (used for linting).",
|
120
120
|
"alias": "t"
|
121
121
|
},
|
122
|
-
"pascalCaseFiles": {
|
123
|
-
"type": "boolean",
|
124
|
-
"description": "Use pascal case component file name (e.g. App.tsx).",
|
125
|
-
"alias": "P",
|
126
|
-
"default": false
|
127
|
-
},
|
128
122
|
"classComponent": {
|
129
123
|
"type": "boolean",
|
130
124
|
"description": "Use class components instead of functional component.",
|