@nx/react 0.0.0-pr-27957-a99d5ea → 0.0.0-pr-28229-afe192c
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 -11
- package/index.d.ts +0 -1
- package/index.js +1 -3
- package/package.json +9 -10
- package/plugins/storybook/index.js +1 -2
- package/src/generators/application/application.js +2 -3
- package/src/generators/application/lib/normalize-options.d.ts +1 -1
- package/src/generators/application/lib/normalize-options.js +4 -6
- package/src/generators/application/lib/show-possible-warnings.js +2 -2
- package/src/generators/application/schema.d.ts +2 -5
- package/src/generators/application/schema.json +14 -25
- 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 +2 -10
- package/src/generators/component/schema.d.ts +4 -22
- package/src/generators/component/schema.json +7 -41
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +0 -2
- package/src/generators/federate-module/federate-module.js +12 -22
- package/src/generators/federate-module/schema.d.ts +0 -1
- package/src/generators/federate-module/schema.json +0 -5
- package/src/generators/hook/hook.d.ts +0 -1
- package/src/generators/hook/hook.js +10 -44
- package/src/generators/hook/schema.d.ts +3 -18
- package/src/generators/hook/schema.json +8 -31
- package/src/generators/host/host.d.ts +0 -1
- package/src/generators/host/host.js +4 -9
- package/src/generators/host/lib/add-module-federation-files.js +2 -2
- package/src/generators/host/lib/normalize-remote.js +10 -6
- package/src/generators/host/schema.d.ts +2 -5
- package/src/generators/host/schema.json +8 -20
- package/src/generators/library/lib/normalize-options.js +1 -2
- package/src/generators/library/library.js +3 -7
- package/src/generators/library/schema.d.ts +2 -5
- package/src/generators/library/schema.json +13 -22
- package/src/generators/redux/redux.d.ts +0 -1
- package/src/generators/redux/redux.js +8 -21
- package/src/generators/redux/schema.d.ts +3 -7
- package/src/generators/redux/schema.json +6 -21
- package/src/generators/remote/lib/setup-tspath-for-remote.d.ts +2 -2
- package/src/generators/remote/lib/setup-tspath-for-remote.js +2 -2
- package/src/generators/remote/remote.d.ts +0 -1
- package/src/generators/remote/remote.js +8 -12
- package/src/generators/remote/schema.d.ts +2 -5
- package/src/generators/remote/schema.json +8 -20
- package/src/generators/setup-ssr/setup-ssr.js +6 -0
- package/src/generators/setup-tailwind/lib/update-project.js +1 -2
- package/src/generators/stories/schema.json +0 -10
- package/src/generators/stories/stories.d.ts +1 -3
- package/src/generators/stories/stories.js +2 -17
- package/src/generators/storybook-configuration/configuration.js +0 -9
- package/src/generators/storybook-configuration/schema.d.ts +0 -3
- package/src/generators/storybook-configuration/schema.json +0 -15
- package/src/utils/ct-utils.js +2 -7
- package/src/utils/testing-generators.js +1 -2
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +0 -13
- package/src/generators/component-cypress-spec/component-cypress-spec.js +0 -104
- package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +0 -13
- package/src/generators/component-cypress-spec/schema.json +0 -45
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"]
|
|
@@ -54,26 +54,20 @@
|
|
|
54
54
|
"description": "Create stories/specs for all components declared in an app or library.",
|
|
55
55
|
"hidden": false
|
|
56
56
|
},
|
|
57
|
-
"component-cypress-spec": {
|
|
58
|
-
"factory": "./src/generators/component-cypress-spec/component-cypress-spec#componentCypressGenerator",
|
|
59
|
-
"schema": "./src/generators/component-cypress-spec/schema.json",
|
|
60
|
-
"description": "Create a Cypress spec for a UI component that has a story.",
|
|
61
|
-
"hidden": false
|
|
62
|
-
},
|
|
63
57
|
"hook": {
|
|
64
|
-
"factory": "./src/generators/hook/hook
|
|
58
|
+
"factory": "./src/generators/hook/hook",
|
|
65
59
|
"schema": "./src/generators/hook/schema.json",
|
|
66
60
|
"description": "Create a hook.",
|
|
67
61
|
"aliases": ["c"]
|
|
68
62
|
},
|
|
69
63
|
"host": {
|
|
70
|
-
"factory": "./src/generators/host/host
|
|
64
|
+
"factory": "./src/generators/host/host",
|
|
71
65
|
"schema": "./src/generators/host/schema.json",
|
|
72
66
|
"x-type": "application",
|
|
73
67
|
"description": "Generate a host react application"
|
|
74
68
|
},
|
|
75
69
|
"remote": {
|
|
76
|
-
"factory": "./src/generators/remote/remote
|
|
70
|
+
"factory": "./src/generators/remote/remote",
|
|
77
71
|
"schema": "./src/generators/remote/schema.json",
|
|
78
72
|
"x-type": "application",
|
|
79
73
|
"description": "Generate a remote react application"
|
package/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export { reactDomVersion, reactVersion } from './src/utils/versions';
|
|
|
8
8
|
export { applicationGenerator } from './src/generators/application/application';
|
|
9
9
|
export { componentGenerator } from './src/generators/component/component';
|
|
10
10
|
export { hookGenerator } from './src/generators/hook/hook';
|
|
11
|
-
export { componentCypressGenerator } from './src/generators/component-cypress-spec/component-cypress-spec';
|
|
12
11
|
export { componentStoryGenerator } from './src/generators/component-story/component-story';
|
|
13
12
|
export { libraryGenerator } from './src/generators/library/library';
|
|
14
13
|
export { reactInitGenerator } from './src/generators/init/init';
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupTailwindGenerator = exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.
|
|
3
|
+
exports.setupTailwindGenerator = exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.cssInJsDependenciesBabel = exports.extendReactEslintJson = exports.extraEslintDependencies = exports.NxReactWebpackPlugin = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const nx_react_webpack_plugin_1 = require("./plugins/nx-react-webpack-plugin/nx-react-webpack-plugin");
|
|
6
6
|
// TODO(v20): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
|
|
@@ -22,8 +22,6 @@ var component_1 = require("./src/generators/component/component");
|
|
|
22
22
|
Object.defineProperty(exports, "componentGenerator", { enumerable: true, get: function () { return component_1.componentGenerator; } });
|
|
23
23
|
var hook_1 = require("./src/generators/hook/hook");
|
|
24
24
|
Object.defineProperty(exports, "hookGenerator", { enumerable: true, get: function () { return hook_1.hookGenerator; } });
|
|
25
|
-
var component_cypress_spec_1 = require("./src/generators/component-cypress-spec/component-cypress-spec");
|
|
26
|
-
Object.defineProperty(exports, "componentCypressGenerator", { enumerable: true, get: function () { return component_cypress_spec_1.componentCypressGenerator; } });
|
|
27
25
|
var component_story_1 = require("./src/generators/component-story/component-story");
|
|
28
26
|
Object.defineProperty(exports, "componentStoryGenerator", { enumerable: true, get: function () { return component_story_1.componentStoryGenerator; } });
|
|
29
27
|
var library_1 = require("./src/generators/library/library");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-28229-afe192c",
|
|
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": {
|
|
@@ -34,22 +34,21 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
36
36
|
"@svgr/webpack": "^8.0.1",
|
|
37
|
-
"chalk": "^4.1.0",
|
|
38
37
|
"file-loader": "^6.2.0",
|
|
39
38
|
"minimatch": "9.0.3",
|
|
39
|
+
"picocolors": "^1.1.0",
|
|
40
40
|
"tslib": "^2.3.0",
|
|
41
|
-
"@module-federation/enhanced": "
|
|
42
|
-
"@nx/devkit": "0.0.0-pr-
|
|
43
|
-
"@nx/js": "0.0.0-pr-
|
|
44
|
-
"@nx/eslint": "0.0.0-pr-
|
|
45
|
-
"@nx/web": "0.0.0-pr-
|
|
41
|
+
"@module-federation/enhanced": "0.6.6",
|
|
42
|
+
"@nx/devkit": "0.0.0-pr-28229-afe192c",
|
|
43
|
+
"@nx/js": "0.0.0-pr-28229-afe192c",
|
|
44
|
+
"@nx/eslint": "0.0.0-pr-28229-afe192c",
|
|
45
|
+
"@nx/web": "0.0.0-pr-28229-afe192c",
|
|
46
46
|
"express": "^4.19.2",
|
|
47
|
-
"http-proxy-middleware": "^3.0.0"
|
|
48
|
-
"@nrwl/react": "0.0.0-pr-27957-a99d5ea"
|
|
47
|
+
"http-proxy-middleware": "^3.0.0"
|
|
49
48
|
},
|
|
50
49
|
"publishConfig": {
|
|
51
50
|
"access": "public"
|
|
52
51
|
},
|
|
53
52
|
"type": "commonjs",
|
|
54
53
|
"types": "./index.d.ts"
|
|
55
|
-
}
|
|
54
|
+
}
|
|
@@ -73,8 +73,7 @@ const fixBabelConfigurationIfNeeded = (webpackConfig, projectData) => {
|
|
|
73
73
|
return;
|
|
74
74
|
const isUsingBabelUpwardRootMode = Object.keys(projectData.projectNode.data.targets).find((k) => {
|
|
75
75
|
const targetConfig = projectData.projectNode.data.targets[k];
|
|
76
|
-
return (
|
|
77
|
-
targetConfig.executor === '@nrwl/webpack:webpack') &&
|
|
76
|
+
return (targetConfig.executor === '@nx/webpack:webpack' &&
|
|
78
77
|
targetConfig.options?.babelUpwardRootMode);
|
|
79
78
|
});
|
|
80
79
|
if (isUsingBabelUpwardRootMode)
|
|
@@ -19,7 +19,7 @@ const maybe_js_1 = require("../../utils/maybe-js");
|
|
|
19
19
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
20
20
|
const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
21
21
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
22
|
-
const
|
|
22
|
+
const pc = require("picocolors");
|
|
23
23
|
const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
|
24
24
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
25
25
|
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
@@ -68,7 +68,6 @@ async function addLinting(host, options) {
|
|
|
68
68
|
async function applicationGenerator(host, schema) {
|
|
69
69
|
return await applicationGeneratorInternal(host, {
|
|
70
70
|
addPlugin: false,
|
|
71
|
-
projectNameAndRootFormat: 'derived',
|
|
72
71
|
...schema,
|
|
73
72
|
});
|
|
74
73
|
}
|
|
@@ -227,7 +226,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
227
226
|
tasks.push(routingTask);
|
|
228
227
|
(0, set_defaults_1.setDefaults)(host, options);
|
|
229
228
|
if (options.bundler === 'rspack' && options.style === 'styled-jsx') {
|
|
230
|
-
devkit_1.logger.warn(`${
|
|
229
|
+
devkit_1.logger.warn(`${pc.bold('styled-jsx')} is not supported by ${pc.bold('Rspack')}. We've added ${pc.bold('babel-loader')} to your project, but using babel will slow down your build.`);
|
|
231
230
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
|
|
232
231
|
host.write((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'), (0, devkit_1.stripIndents) `
|
|
233
232
|
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
|
@@ -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,27 +17,25 @@ 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
|
|
21
|
-
|
|
20
|
+
async function normalizeOptions(host, options) {
|
|
21
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
22
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
22
23
|
name: options.name,
|
|
23
24
|
projectType: 'application',
|
|
24
25
|
directory: options.directory,
|
|
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' &&
|
|
31
30
|
nxJson.useInferencePlugins !== false;
|
|
32
31
|
options.addPlugin ??= addPlugin;
|
|
33
32
|
options.rootProject = appProjectRoot === '.';
|
|
34
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
35
33
|
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
36
34
|
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
37
35
|
const parsedTags = options.tags
|
|
38
36
|
? options.tags.split(',').map((s) => s.trim())
|
|
39
37
|
: [];
|
|
40
|
-
const fileName =
|
|
38
|
+
const fileName = 'app';
|
|
41
39
|
const styledModule = /^(css|scss|less|tailwind|none)$/.test(options.style)
|
|
42
40
|
? null
|
|
43
41
|
: options.style;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.showPossibleWarnings = showPossibleWarnings;
|
|
4
|
-
const
|
|
4
|
+
const pc = require("picocolors");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
function showPossibleWarnings(tree, options) {
|
|
7
7
|
if (options.style === 'styled-jsx' && options.compiler === 'swc') {
|
|
8
|
-
devkit_1.logger.warn(`styled-jsx may not work with SWC. Try using ${
|
|
8
|
+
devkit_1.logger.warn(`styled-jsx may not work with SWC. Try using ${pc.bold('nx g @nx/react:app --compiler=babel')} instead.`);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
|
3
2
|
import type { SupportedStyles } from '../../../typings/style';
|
|
4
3
|
|
|
5
4
|
export interface Schema {
|
|
6
|
-
|
|
5
|
+
directory: string;
|
|
6
|
+
name?: string;
|
|
7
7
|
style: SupportedStyles;
|
|
8
8
|
skipFormat?: boolean;
|
|
9
|
-
directory?: string;
|
|
10
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
9
|
tags?: string;
|
|
12
10
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
13
11
|
inSourceTests?: boolean;
|
|
14
12
|
e2eTestRunner: 'cypress' | 'playwright' | 'none';
|
|
15
13
|
linter: Linter | LinterType;
|
|
16
|
-
pascalCaseFiles?: boolean;
|
|
17
14
|
classComponent?: boolean;
|
|
18
15
|
routing?: boolean;
|
|
19
16
|
skipNxJson?: boolean;
|
|
@@ -6,41 +6,36 @@
|
|
|
6
6
|
"description": "Create a React application for Nx.",
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
|
-
"command": "nx g app myapp
|
|
9
|
+
"command": "nx g app apps/myorg/myapp",
|
|
10
10
|
"description": "Generate `apps/myorg/myapp` and `apps/myorg/myapp-e2e`"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
|
-
"command": "nx g app myapp --classComponent",
|
|
13
|
+
"command": "nx g app apps/myapp --classComponent",
|
|
14
14
|
"description": "Use class components instead of functional components"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
"command": "nx g app myapp --routing",
|
|
17
|
+
"command": "nx g app apps/myapp --routing",
|
|
18
18
|
"description": "Set up React Router"
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"type": "object",
|
|
22
22
|
"properties": {
|
|
23
|
-
"
|
|
24
|
-
"description": "The
|
|
23
|
+
"directory": {
|
|
24
|
+
"description": "The directory of the new application.",
|
|
25
25
|
"type": "string",
|
|
26
|
+
"alias": "dir",
|
|
26
27
|
"$default": {
|
|
27
28
|
"$source": "argv",
|
|
28
29
|
"index": 0
|
|
29
30
|
},
|
|
30
|
-
"x-prompt": "
|
|
31
|
-
"pattern": "^[a-zA-Z][^:]*$"
|
|
31
|
+
"x-prompt": "Which directory do you want to create the application in?"
|
|
32
32
|
},
|
|
33
|
-
"
|
|
34
|
-
"description": "The
|
|
33
|
+
"name": {
|
|
34
|
+
"description": "The name of the application.",
|
|
35
35
|
"type": "string",
|
|
36
|
-
"
|
|
36
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
|
37
37
|
"x-priority": "important"
|
|
38
38
|
},
|
|
39
|
-
"projectNameAndRootFormat": {
|
|
40
|
-
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
41
|
-
"type": "string",
|
|
42
|
-
"enum": ["as-provided", "derived"]
|
|
43
|
-
},
|
|
44
39
|
"style": {
|
|
45
40
|
"description": "The file extension to be used for style files.",
|
|
46
41
|
"type": "string",
|
|
@@ -111,9 +106,9 @@
|
|
|
111
106
|
},
|
|
112
107
|
"unitTestRunner": {
|
|
113
108
|
"type": "string",
|
|
114
|
-
"enum": ["
|
|
109
|
+
"enum": ["vitest", "jest", "none"],
|
|
115
110
|
"description": "Test runner to use for unit tests.",
|
|
116
|
-
"default": "
|
|
111
|
+
"default": "vitest"
|
|
117
112
|
},
|
|
118
113
|
"inSourceTests": {
|
|
119
114
|
"type": "boolean",
|
|
@@ -132,12 +127,6 @@
|
|
|
132
127
|
"description": "Add tags to the application (used for linting).",
|
|
133
128
|
"alias": "t"
|
|
134
129
|
},
|
|
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
130
|
"classComponent": {
|
|
142
131
|
"type": "boolean",
|
|
143
132
|
"description": "Use class components instead of functional component.",
|
|
@@ -187,7 +176,7 @@
|
|
|
187
176
|
"type": "string",
|
|
188
177
|
"enum": ["vite", "webpack", "rspack"],
|
|
189
178
|
"x-prompt": "Which bundler do you want to use to build the application?",
|
|
190
|
-
"default": "
|
|
179
|
+
"default": "vite",
|
|
191
180
|
"x-priority": "important"
|
|
192
181
|
},
|
|
193
182
|
"minimal": {
|
|
@@ -196,6 +185,6 @@
|
|
|
196
185
|
"default": false
|
|
197
186
|
}
|
|
198
187
|
},
|
|
199
|
-
"required": ["
|
|
188
|
+
"required": ["directory"],
|
|
200
189
|
"examplesFile": "../../../docs/application-examples.md"
|
|
201
190
|
}
|
|
@@ -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,10 @@ 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
|
-
|
|
11
|
-
callingGenerator: '@nx/react:component',
|
|
10
|
+
path: options.path,
|
|
12
11
|
name: options.name,
|
|
13
|
-
directory: options.directory,
|
|
14
|
-
derivedDirectory: options.derivedDirectory ?? options.directory,
|
|
15
|
-
flat: options.flat,
|
|
16
|
-
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
17
|
-
project: options.project,
|
|
18
12
|
fileExtension: 'tsx',
|
|
19
13
|
fileName: options.fileName,
|
|
20
|
-
pascalCaseFile: options.pascalCaseFiles,
|
|
21
|
-
pascalCaseDirectory: options.pascalCaseDirectory,
|
|
22
14
|
});
|
|
23
15
|
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
24
16
|
const { className } = (0, devkit_1.names)(name);
|
|
@@ -37,8 +29,8 @@ async function normalizeOptions(tree, options) {
|
|
|
37
29
|
options.isNextPage = options.isNextPage ?? false;
|
|
38
30
|
return {
|
|
39
31
|
...options,
|
|
40
|
-
projectName,
|
|
41
32
|
directory,
|
|
33
|
+
projectName,
|
|
42
34
|
styledModule,
|
|
43
35
|
hasStyles: options.style !== 'none',
|
|
44
36
|
className,
|
|
@@ -1,43 +1,25 @@
|
|
|
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
|
-
|
|
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;
|
|
5
|
+
path: string;
|
|
6
|
+
name?: string;
|
|
9
7
|
style: SupportedStyles;
|
|
10
8
|
skipTests?: boolean;
|
|
11
|
-
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?: 'as-provided' | 'derived';
|
|
33
|
-
// Used by other wrapping generators to preserve previous behavior
|
|
34
|
-
// e.g. @nx/next:component
|
|
35
|
-
derivedDirectory?: string;
|
|
36
17
|
// Used by Next.js to determine how React should generate the page
|
|
37
18
|
isNextPage?: boolean;
|
|
38
19
|
}
|
|
39
20
|
|
|
40
21
|
export interface NormalizedSchema extends Schema {
|
|
22
|
+
directory: string;
|
|
41
23
|
projectSourceRoot: string;
|
|
42
24
|
projectName: string;
|
|
43
25
|
fileName: string;
|
|
@@ -6,22 +6,19 @@
|
|
|
6
6
|
"description": "Create a React Component for Nx.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
9
|
+
"path": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "
|
|
12
|
-
"alias": "p",
|
|
11
|
+
"description": "Path where the component will be generated.",
|
|
13
12
|
"$default": {
|
|
14
|
-
"$source": "
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
15
|
},
|
|
16
|
-
"x-
|
|
16
|
+
"x-prompt": "Where should the component be generated?",
|
|
17
|
+
"x-priority": "important"
|
|
17
18
|
},
|
|
18
19
|
"name": {
|
|
19
20
|
"type": "string",
|
|
20
21
|
"description": "The name of the component.",
|
|
21
|
-
"$default": {
|
|
22
|
-
"$source": "argv",
|
|
23
|
-
"index": 0
|
|
24
|
-
},
|
|
25
22
|
"x-prompt": "What name would you like to use for the component?",
|
|
26
23
|
"x-priority": "important"
|
|
27
24
|
},
|
|
@@ -76,23 +73,6 @@
|
|
|
76
73
|
"default": false,
|
|
77
74
|
"x-priority": "internal"
|
|
78
75
|
},
|
|
79
|
-
"directory": {
|
|
80
|
-
"type": "string",
|
|
81
|
-
"description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
|
|
82
|
-
"alias": "dir",
|
|
83
|
-
"x-priority": "important"
|
|
84
|
-
},
|
|
85
|
-
"nameAndDirectoryFormat": {
|
|
86
|
-
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
87
|
-
"type": "string",
|
|
88
|
-
"enum": ["as-provided", "derived"]
|
|
89
|
-
},
|
|
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
76
|
"export": {
|
|
97
77
|
"type": "boolean",
|
|
98
78
|
"description": "When true, the component is exported from the project `index.ts` (if it exists).",
|
|
@@ -100,20 +80,6 @@
|
|
|
100
80
|
"default": false,
|
|
101
81
|
"x-prompt": "Should this component be exported in the project?"
|
|
102
82
|
},
|
|
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
83
|
"classComponent": {
|
|
118
84
|
"type": "boolean",
|
|
119
85
|
"alias": "C",
|
|
@@ -145,6 +111,6 @@
|
|
|
145
111
|
"x-priority": "internal"
|
|
146
112
|
}
|
|
147
113
|
},
|
|
148
|
-
"required": ["
|
|
114
|
+
"required": ["path"],
|
|
149
115
|
"examplesFile": "../../../docs/component-examples.md"
|
|
150
116
|
}
|
|
@@ -37,8 +37,6 @@ async function cypressComponentConfigGeneratorInternal(tree, options) {
|
|
|
37
37
|
validExecutorNames: new Set([
|
|
38
38
|
'@nx/webpack:webpack',
|
|
39
39
|
'@nx/vite:build',
|
|
40
|
-
'@nrwl/webpack:webpack',
|
|
41
|
-
'@nrwl/vite:build',
|
|
42
40
|
]),
|
|
43
41
|
});
|
|
44
42
|
await (0, add_files_1.addFiles)(tree, projectConfig, options, found);
|
|
@@ -14,43 +14,33 @@ async function federateModuleGenerator(tree, schema) {
|
|
|
14
14
|
Path: ${schema.path}`);
|
|
15
15
|
}
|
|
16
16
|
const tasks = [];
|
|
17
|
+
const { projectName: remoteName, projectRoot: remoteRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
18
|
+
name: schema.remote,
|
|
19
|
+
directory: schema.remoteDirectory,
|
|
20
|
+
projectType: 'application',
|
|
21
|
+
});
|
|
17
22
|
// Check remote exists
|
|
18
|
-
const remote = (0, utils_1.checkRemoteExists)(tree,
|
|
19
|
-
let projectRoot, remoteName;
|
|
23
|
+
const remote = (0, utils_1.checkRemoteExists)(tree, remoteName);
|
|
20
24
|
if (!remote) {
|
|
21
25
|
// create remote
|
|
22
|
-
const
|
|
23
|
-
name:
|
|
24
|
-
directory:
|
|
26
|
+
const remoteGeneratorTask = await (0, remote_1.remoteGenerator)(tree, {
|
|
27
|
+
name: remoteName,
|
|
28
|
+
directory: remoteRoot,
|
|
25
29
|
e2eTestRunner: schema.e2eTestRunner,
|
|
26
30
|
skipFormat: schema.skipFormat,
|
|
27
31
|
linter: schema.linter,
|
|
28
32
|
style: schema.style,
|
|
29
33
|
unitTestRunner: schema.unitTestRunner,
|
|
30
34
|
host: schema.host,
|
|
31
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat ?? 'derived',
|
|
32
35
|
bundler: schema.bundler ?? 'rspack',
|
|
33
36
|
});
|
|
34
|
-
tasks.push(
|
|
35
|
-
const { projectName, projectRoot: remoteRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
36
|
-
name: schema.remote,
|
|
37
|
-
directory: schema.remoteDirectory,
|
|
38
|
-
projectType: 'application',
|
|
39
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat ?? 'derived',
|
|
40
|
-
callingGenerator: '@nx/react:federate-module',
|
|
41
|
-
});
|
|
42
|
-
projectRoot = remoteRoot;
|
|
43
|
-
remoteName = projectName;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
projectRoot = remote.root;
|
|
47
|
-
remoteName = remote.name;
|
|
37
|
+
tasks.push(remoteGeneratorTask);
|
|
48
38
|
}
|
|
49
39
|
// add path to exposes property
|
|
50
40
|
const normalizedModulePath = schema.bundler === 'rspack'
|
|
51
|
-
? (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(
|
|
41
|
+
? (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(remoteRoot), schema.path)
|
|
52
42
|
: schema.path;
|
|
53
|
-
(0, utils_1.addPathToExposes)(tree,
|
|
43
|
+
(0, utils_1.addPathToExposes)(tree, remoteRoot, schema.name, normalizedModulePath);
|
|
54
44
|
// Add new path to tsconfig
|
|
55
45
|
const rootJSON = (0, devkit_1.readJson)(tree, (0, js_1.getRootTsConfigPathInTree)(tree));
|
|
56
46
|
if (!rootJSON?.compilerOptions?.paths[`${remoteName}/${schema.name}`]) {
|
|
@@ -37,11 +37,6 @@
|
|
|
37
37
|
"description": "The directory of the new remote application if one needs to be created.",
|
|
38
38
|
"type": "string"
|
|
39
39
|
},
|
|
40
|
-
"projectNameAndRootFormat": {
|
|
41
|
-
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
42
|
-
"type": "string",
|
|
43
|
-
"enum": ["as-provided", "derived"]
|
|
44
|
-
},
|
|
45
40
|
"style": {
|
|
46
41
|
"description": "The file extension to be used for style files.",
|
|
47
42
|
"type": "string",
|
|
@@ -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;
|