@nx/react 16.8.0-beta.4 → 16.8.0-beta.5
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/babel.js +2 -3
- package/package.json +7 -7
- package/plugins/bundle-rollup.js +9 -3
- package/plugins/component-testing/index.js +57 -37
- package/plugins/jest.js +4 -6
- package/plugins/storybook/index.js +46 -17
- package/plugins/with-react.js +5 -9
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +101 -103
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +67 -72
- package/src/generators/application/application.js +124 -124
- package/src/generators/application/lib/add-e2e.js +41 -37
- package/src/generators/application/lib/add-jest.js +13 -8
- package/src/generators/application/lib/add-project.js +4 -3
- package/src/generators/application/lib/create-application-files.js +8 -1
- package/src/generators/application/lib/find-free-port.js +1 -2
- package/src/generators/application/lib/normalize-options.js +49 -47
- package/src/generators/application/lib/set-defaults.js +25 -5
- package/src/generators/component/component.js +68 -64
- package/src/generators/component-cypress-spec/component-cypress-spec.js +6 -9
- package/src/generators/component-story/component-story.js +8 -9
- package/src/generators/component-test/component-test.js +15 -18
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +23 -26
- package/src/generators/cypress-component-configuration/lib/add-files.js +38 -42
- package/src/generators/hook/hook.js +59 -58
- package/src/generators/host/host.js +54 -53
- package/src/generators/host/lib/add-module-federation-files.js +11 -3
- package/src/generators/host/lib/normalize-remote.js +8 -11
- package/src/generators/host/lib/setup-ssr-for-host.js +21 -15
- package/src/generators/host/lib/update-module-federation-e2e-project.js +5 -2
- package/src/generators/init/init.js +30 -20
- package/src/generators/library/lib/add-linting.js +24 -27
- package/src/generators/library/lib/add-rollup-build-target.js +42 -46
- package/src/generators/library/lib/create-files.js +7 -1
- package/src/generators/library/lib/normalize-options.js +53 -50
- package/src/generators/library/lib/set-defaults.js +12 -4
- package/src/generators/library/library.js +122 -111
- package/src/generators/redux/redux.js +25 -16
- package/src/generators/remote/lib/setup-ssr-for-remote.js +25 -23
- package/src/generators/remote/remote.js +44 -39
- package/src/generators/setup-ssr/setup-ssr.js +134 -132
- package/src/generators/setup-tailwind/lib/update-project.js +3 -5
- package/src/generators/setup-tailwind/setup-tailwind.js +23 -26
- package/src/generators/stories/stories.js +79 -88
- package/src/generators/storybook-configuration/configuration.js +40 -47
- package/src/migrations/update-12-0-0/remove-react-redux-types-package.js +2 -5
- package/src/migrations/update-12-0-0/update-emotion-setup.js +50 -55
- package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.js +14 -18
- package/src/migrations/update-12-8-0/update-12-8-0.js +3 -6
- package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.js +23 -26
- package/src/migrations/update-13-0-0/update-emotion-setup.js +24 -27
- package/src/migrations/update-13-0-0/webpack5-changes-utils.js +30 -34
- package/src/migrations/update-13-10-0/update-13-10-0.js +15 -18
- package/src/migrations/update-14-0-0/add-default-development-configurations.js +26 -31
- package/src/migrations/update-14-0-0/replace-testing-library-react-hook.js +12 -16
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js +13 -17
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js +24 -27
- package/src/migrations/update-14-6-0/add-preset-jest-config.js +1 -2
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +3 -4
- package/src/migrations/update-15-3-0/update-rollup-executor.js +1 -2
- package/src/migrations/update-15-6-3/webpack-config-setup.js +53 -57
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +3 -6
- package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +3 -6
- package/src/migrations/update-16-7-0/add-babel-core.js +8 -11
- package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +36 -41
- package/src/module-federation/ast-utils.js +1 -1
- package/src/module-federation/load-config.js +1 -1
- package/src/module-federation/utils.js +36 -37
- package/src/module-federation/with-module-federation-ssr.js +24 -25
- package/src/module-federation/with-module-federation.js +23 -22
- package/src/rules/update-module-federation-project.js +9 -2
- package/src/utils/ast-utils.js +12 -15
- package/src/utils/create-ts-config.js +6 -4
- package/src/utils/ct-utils.js +31 -33
- package/src/utils/lint.js +5 -3
- package/src/utils/testing-generators.js +18 -23
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applicationSchematic = exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const lint_1 = require("../../utils/lint");
|
|
6
5
|
const create_application_files_1 = require("./lib/create-application-files");
|
|
7
6
|
const update_jest_config_1 = require("./lib/update-jest-config");
|
|
@@ -23,129 +22,131 @@ const chalk = require("chalk");
|
|
|
23
22
|
const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
|
24
23
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
25
24
|
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
26
|
-
function addLinting(host, options) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, 'plugin:@nx/react');
|
|
47
|
-
}
|
|
48
|
-
if (!options.skipPackageJson) {
|
|
49
|
-
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
50
|
-
const addSwcTask = (0, add_swc_dependencies_1.addSwcDependencies)(host);
|
|
51
|
-
tasks.push(installTask, addSwcTask);
|
|
52
|
-
}
|
|
25
|
+
async function addLinting(host, options) {
|
|
26
|
+
const tasks = [];
|
|
27
|
+
if (options.linter === linter_1.Linter.EsLint) {
|
|
28
|
+
const lintTask = await (0, linter_1.lintProjectGenerator)(host, {
|
|
29
|
+
linter: options.linter,
|
|
30
|
+
project: options.projectName,
|
|
31
|
+
tsConfigPaths: [
|
|
32
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
33
|
+
],
|
|
34
|
+
unitTestRunner: options.unitTestRunner,
|
|
35
|
+
eslintFilePatterns: [
|
|
36
|
+
(0, lint_project_1.mapLintPattern)(options.appProjectRoot, '{ts,tsx,js,jsx}', options.rootProject),
|
|
37
|
+
],
|
|
38
|
+
skipFormat: true,
|
|
39
|
+
rootProject: options.rootProject,
|
|
40
|
+
skipPackageJson: options.skipPackageJson,
|
|
41
|
+
});
|
|
42
|
+
tasks.push(lintTask);
|
|
43
|
+
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
44
|
+
(0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, 'plugin:@nx/react');
|
|
53
45
|
}
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
if (!options.skipPackageJson) {
|
|
47
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
48
|
+
const addSwcTask = (0, add_swc_dependencies_1.addSwcDependencies)(host);
|
|
49
|
+
tasks.push(installTask, addSwcTask);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
56
53
|
}
|
|
57
|
-
function applicationGenerator(host, schema) {
|
|
58
|
-
return
|
|
59
|
-
|
|
54
|
+
async function applicationGenerator(host, schema) {
|
|
55
|
+
return await applicationGeneratorInternal(host, {
|
|
56
|
+
projectNameAndRootFormat: 'derived',
|
|
57
|
+
...schema,
|
|
60
58
|
});
|
|
61
59
|
}
|
|
62
60
|
exports.applicationGenerator = applicationGenerator;
|
|
63
|
-
function applicationGeneratorInternal(host, schema) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
(0,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
project: options.projectName,
|
|
85
|
-
newProject: true,
|
|
86
|
-
includeVitest: options.unitTestRunner === 'vitest',
|
|
87
|
-
inSourceTests: options.inSourceTests,
|
|
88
|
-
compiler: options.compiler,
|
|
89
|
-
skipFormat: true,
|
|
90
|
-
});
|
|
91
|
-
tasks.push(viteTask);
|
|
92
|
-
}
|
|
93
|
-
else if (options.bundler === 'webpack') {
|
|
94
|
-
const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
|
|
95
|
-
const webpackInitTask = yield webpackInitGenerator(host, {
|
|
96
|
-
uiFramework: 'react',
|
|
97
|
-
skipFormat: true,
|
|
98
|
-
});
|
|
99
|
-
tasks.push(webpackInitTask);
|
|
100
|
-
}
|
|
101
|
-
else if (options.bundler === 'rspack') {
|
|
102
|
-
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
|
|
103
|
-
const rspackTask = yield configurationGenerator(host, {
|
|
104
|
-
project: options.projectName,
|
|
105
|
-
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, add_project_1.maybeJs)(options, `src/main.tsx`)),
|
|
106
|
-
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
107
|
-
target: 'web',
|
|
108
|
-
newProject: true,
|
|
109
|
-
uiFramework: 'react',
|
|
110
|
-
});
|
|
111
|
-
tasks.push(rspackTask);
|
|
112
|
-
}
|
|
113
|
-
if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
|
|
114
|
-
const { vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
115
|
-
const vitestTask = yield vitestGenerator(host, {
|
|
116
|
-
uiFramework: 'react',
|
|
117
|
-
coverageProvider: 'c8',
|
|
118
|
-
project: options.projectName,
|
|
119
|
-
inSourceTests: options.inSourceTests,
|
|
120
|
-
skipFormat: true,
|
|
121
|
-
});
|
|
122
|
-
tasks.push(vitestTask);
|
|
123
|
-
}
|
|
124
|
-
if ((options.bundler === 'vite' || options.unitTestRunner === 'vitest') &&
|
|
125
|
-
options.inSourceTests) {
|
|
126
|
-
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/app/${options.fileName}.spec.tsx`));
|
|
127
|
-
}
|
|
128
|
-
const lintTask = yield addLinting(host, options);
|
|
129
|
-
tasks.push(lintTask);
|
|
130
|
-
const e2eTask = yield (0, add_e2e_1.addE2e)(host, options);
|
|
131
|
-
tasks.push(e2eTask);
|
|
132
|
-
if (options.unitTestRunner === 'jest') {
|
|
133
|
-
const jestTask = yield (0, add_jest_1.addJest)(host, options);
|
|
134
|
-
tasks.push(jestTask);
|
|
61
|
+
async function applicationGeneratorInternal(host, schema) {
|
|
62
|
+
const tasks = [];
|
|
63
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
64
|
+
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
65
|
+
const initTask = await (0, init_1.default)(host, {
|
|
66
|
+
...options,
|
|
67
|
+
skipFormat: true,
|
|
68
|
+
skipHelperLibs: options.bundler === 'vite',
|
|
69
|
+
});
|
|
70
|
+
tasks.push(initTask);
|
|
71
|
+
if (!options.rootProject) {
|
|
72
|
+
(0, create_ts_config_1.extractTsConfigBase)(host);
|
|
73
|
+
}
|
|
74
|
+
(0, create_application_files_1.createApplicationFiles)(host, options);
|
|
75
|
+
(0, add_project_1.addProject)(host, options);
|
|
76
|
+
if (options.bundler === 'vite') {
|
|
77
|
+
const { viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
78
|
+
// We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
|
|
79
|
+
// See: https://vitejs.dev/guide/env-and-mode.html
|
|
80
|
+
if (host.exists((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'))) {
|
|
81
|
+
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'));
|
|
135
82
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
83
|
+
const viteTask = await viteConfigurationGenerator(host, {
|
|
84
|
+
uiFramework: 'react',
|
|
85
|
+
project: options.projectName,
|
|
86
|
+
newProject: true,
|
|
87
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
88
|
+
inSourceTests: options.inSourceTests,
|
|
89
|
+
compiler: options.compiler,
|
|
90
|
+
skipFormat: true,
|
|
91
|
+
});
|
|
92
|
+
tasks.push(viteTask);
|
|
93
|
+
}
|
|
94
|
+
else if (options.bundler === 'webpack') {
|
|
95
|
+
const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
|
|
96
|
+
const webpackInitTask = await webpackInitGenerator(host, {
|
|
97
|
+
uiFramework: 'react',
|
|
98
|
+
skipFormat: true,
|
|
99
|
+
});
|
|
100
|
+
tasks.push(webpackInitTask);
|
|
101
|
+
}
|
|
102
|
+
else if (options.bundler === 'rspack') {
|
|
103
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
|
|
104
|
+
const rspackTask = await configurationGenerator(host, {
|
|
105
|
+
project: options.projectName,
|
|
106
|
+
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, add_project_1.maybeJs)(options, `src/main.tsx`)),
|
|
107
|
+
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
108
|
+
target: 'web',
|
|
109
|
+
newProject: true,
|
|
110
|
+
uiFramework: 'react',
|
|
111
|
+
});
|
|
112
|
+
tasks.push(rspackTask);
|
|
113
|
+
}
|
|
114
|
+
if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
|
|
115
|
+
const { vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
116
|
+
const vitestTask = await vitestGenerator(host, {
|
|
117
|
+
uiFramework: 'react',
|
|
118
|
+
coverageProvider: 'c8',
|
|
119
|
+
project: options.projectName,
|
|
120
|
+
inSourceTests: options.inSourceTests,
|
|
121
|
+
skipFormat: true,
|
|
122
|
+
});
|
|
123
|
+
tasks.push(vitestTask);
|
|
124
|
+
}
|
|
125
|
+
if ((options.bundler === 'vite' || options.unitTestRunner === 'vitest') &&
|
|
126
|
+
options.inSourceTests) {
|
|
127
|
+
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/app/${options.fileName}.spec.tsx`));
|
|
128
|
+
}
|
|
129
|
+
const lintTask = await addLinting(host, options);
|
|
130
|
+
tasks.push(lintTask);
|
|
131
|
+
const e2eTask = await (0, add_e2e_1.addE2e)(host, options);
|
|
132
|
+
tasks.push(e2eTask);
|
|
133
|
+
if (options.unitTestRunner === 'jest') {
|
|
134
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options);
|
|
135
|
+
tasks.push(jestTask);
|
|
136
|
+
}
|
|
137
|
+
// Handle tsconfig.spec.json for jest or vitest
|
|
138
|
+
(0, update_jest_config_1.updateSpecConfig)(host, options);
|
|
139
|
+
const stylePreprocessorTask = (0, install_common_dependencies_1.installCommonDependencies)(host, options);
|
|
140
|
+
tasks.push(stylePreprocessorTask);
|
|
141
|
+
const styledTask = (0, add_styled_dependencies_1.addStyledModuleDependencies)(host, options);
|
|
142
|
+
tasks.push(styledTask);
|
|
143
|
+
const routingTask = (0, add_routing_1.addRouting)(host, options);
|
|
144
|
+
tasks.push(routingTask);
|
|
145
|
+
(0, set_defaults_1.setDefaults)(host, options);
|
|
146
|
+
if (options.bundler === 'rspack' && options.style === 'styled-jsx') {
|
|
147
|
+
devkit_1.logger.warn(`${chalk.bold('styled-jsx')} is not supported by ${chalk.bold('Rspack')}. We've added ${chalk.bold('babel-loader')} to your project, but using babel will slow down your build.`);
|
|
148
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
|
|
149
|
+
host.write((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'), (0, devkit_1.stripIndents) `
|
|
149
150
|
const { composePlugins, withNx, withWeb } = require('@nx/rspack');
|
|
150
151
|
module.exports = composePlugins(withNx(), withWeb(), (config) => {
|
|
151
152
|
config.module.rules.push({
|
|
@@ -163,12 +164,11 @@ function applicationGeneratorInternal(host, schema) {
|
|
|
163
164
|
return config;
|
|
164
165
|
});
|
|
165
166
|
`);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
167
|
+
}
|
|
168
|
+
if (!options.skipFormat) {
|
|
169
|
+
await (0, devkit_1.formatFiles)(host);
|
|
170
|
+
}
|
|
171
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
172
172
|
}
|
|
173
173
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
174
174
|
exports.default = applicationGenerator;
|
|
@@ -1,45 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addE2e = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const web_1 = require("@nx/web");
|
|
7
6
|
const versions_1 = require("../../../utils/versions");
|
|
8
|
-
function addE2e(tree, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
7
|
+
async function addE2e(tree, options) {
|
|
8
|
+
switch (options.e2eTestRunner) {
|
|
9
|
+
case 'cypress':
|
|
10
|
+
(0, web_1.webStaticServeGenerator)(tree, {
|
|
11
|
+
buildTarget: `${options.projectName}:build`,
|
|
12
|
+
targetName: 'serve-static',
|
|
13
|
+
});
|
|
14
|
+
const { cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
15
|
+
return await cypressProjectGenerator(tree, {
|
|
16
|
+
...options,
|
|
17
|
+
name: options.e2eProjectName,
|
|
18
|
+
directory: options.e2eProjectRoot,
|
|
19
|
+
// the name and root are already normalized, instruct the generator to use them as is
|
|
20
|
+
projectNameAndRootFormat: 'as-provided',
|
|
21
|
+
project: options.projectName,
|
|
22
|
+
bundler: options.bundler === 'rspack' ? 'webpack' : options.bundler,
|
|
23
|
+
skipFormat: true,
|
|
24
|
+
});
|
|
25
|
+
case 'playwright':
|
|
26
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
27
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
28
|
+
root: options.e2eProjectRoot,
|
|
29
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
30
|
+
targets: {},
|
|
31
|
+
implicitDependencies: [options.projectName],
|
|
32
|
+
});
|
|
33
|
+
return configurationGenerator(tree, {
|
|
34
|
+
project: options.e2eProjectName,
|
|
35
|
+
skipFormat: true,
|
|
36
|
+
skipPackageJson: options.skipPackageJson,
|
|
37
|
+
directory: 'src',
|
|
38
|
+
js: false,
|
|
39
|
+
linter: options.linter,
|
|
40
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
41
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
|
|
42
|
+
webServerAddress: 'http://localhost:4200',
|
|
43
|
+
});
|
|
44
|
+
case 'none':
|
|
45
|
+
default:
|
|
46
|
+
return () => { };
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
exports.addE2e = addE2e;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addJest = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const versions_1 = require("../../../utils/versions");
|
|
7
|
-
function addJest(host, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
async function addJest(host, options) {
|
|
7
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
8
|
+
if (options.unitTestRunner !== 'jest') {
|
|
9
|
+
return () => { };
|
|
10
|
+
}
|
|
11
|
+
return await configurationGenerator(host, {
|
|
12
|
+
...options,
|
|
13
|
+
project: options.projectName,
|
|
14
|
+
supportTsx: true,
|
|
15
|
+
skipSerializers: true,
|
|
16
|
+
setupFile: 'none',
|
|
17
|
+
compiler: options.compiler,
|
|
18
|
+
skipFormat: true,
|
|
14
19
|
});
|
|
15
20
|
}
|
|
16
21
|
exports.addJest = addJest;
|
|
@@ -16,7 +16,9 @@ function addProject(host, options) {
|
|
|
16
16
|
serve: createServeTarget(options),
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
(0, devkit_1.addProjectConfiguration)(host, options.projectName,
|
|
19
|
+
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
20
|
+
...project,
|
|
21
|
+
});
|
|
20
22
|
}
|
|
21
23
|
exports.addProject = addProject;
|
|
22
24
|
function maybeJs(options, path) {
|
|
@@ -26,13 +28,12 @@ function maybeJs(options, path) {
|
|
|
26
28
|
}
|
|
27
29
|
exports.maybeJs = maybeJs;
|
|
28
30
|
function createBuildTarget(options) {
|
|
29
|
-
var _a;
|
|
30
31
|
return {
|
|
31
32
|
executor: '@nx/webpack:webpack',
|
|
32
33
|
outputs: ['{options.outputPath}'],
|
|
33
34
|
defaultConfiguration: 'production',
|
|
34
35
|
options: {
|
|
35
|
-
compiler:
|
|
36
|
+
compiler: options.compiler ?? 'babel',
|
|
36
37
|
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot != '.'
|
|
37
38
|
? options.appProjectRoot
|
|
38
39
|
: options.projectName),
|
|
@@ -26,7 +26,14 @@ function createApplicationFiles(host, options) {
|
|
|
26
26
|
}
|
|
27
27
|
const relativePathToRootTsConfig = (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot);
|
|
28
28
|
const appTests = (0, get_app_tests_1.getAppTests)(options);
|
|
29
|
-
const templateVariables =
|
|
29
|
+
const templateVariables = {
|
|
30
|
+
...(0, devkit_1.names)(options.name),
|
|
31
|
+
...options,
|
|
32
|
+
tmpl: '',
|
|
33
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
34
|
+
appTests,
|
|
35
|
+
inSourceVitestTests: (0, get_in_source_vitest_tests_template_1.getInSourceVitestTestsTemplate)(appTests),
|
|
36
|
+
};
|
|
30
37
|
if (options.bundler === 'vite') {
|
|
31
38
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-vite'), options.appProjectRoot, templateVariables);
|
|
32
39
|
}
|
|
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.findFreePort = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function findFreePort(host) {
|
|
6
|
-
var _a, _b, _c;
|
|
7
6
|
const projects = (0, devkit_1.getProjects)(host);
|
|
8
7
|
let port = -Infinity;
|
|
9
8
|
for (const [, p] of projects.entries()) {
|
|
10
|
-
const curr =
|
|
9
|
+
const curr = p.targets?.serve?.options?.port;
|
|
11
10
|
if (typeof curr === 'number') {
|
|
12
11
|
port = Math.max(port, curr);
|
|
13
12
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = exports.normalizeProjectName = exports.normalizeDirectory = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
6
|
const assertion_1 = require("../../../utils/assertion");
|
|
8
7
|
const find_free_port_1 = require("./find-free-port");
|
|
9
8
|
function normalizeDirectory(options) {
|
|
10
|
-
|
|
11
|
-
options.directory = (_a = options.directory) === null || _a === void 0 ? void 0 : _a.replace(/\\{1,2}/g, '/');
|
|
9
|
+
options.directory = options.directory?.replace(/\\{1,2}/g, '/');
|
|
12
10
|
const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
|
|
13
11
|
return projectDirectory
|
|
14
12
|
? `${(0, devkit_1.names)(projectDirectory).fileName}/${(0, devkit_1.names)(options.name).fileName}`
|
|
@@ -19,50 +17,54 @@ function normalizeProjectName(options) {
|
|
|
19
17
|
return normalizeDirectory(options).replace(new RegExp('/', 'g'), '-');
|
|
20
18
|
}
|
|
21
19
|
exports.normalizeProjectName = normalizeProjectName;
|
|
22
|
-
function normalizeOptions(host, options, callingGenerator = '@nx/react:application') {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
rootProject: options.rootProject,
|
|
31
|
-
callingGenerator,
|
|
32
|
-
});
|
|
33
|
-
options.rootProject = appProjectRoot === '.';
|
|
34
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
35
|
-
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
36
|
-
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
37
|
-
const parsedTags = options.tags
|
|
38
|
-
? options.tags.split(',').map((s) => s.trim())
|
|
39
|
-
: [];
|
|
40
|
-
const fileName = options.pascalCaseFiles ? 'App' : 'app';
|
|
41
|
-
const styledModule = /^(css|scss|less|styl|none)$/.test(options.style)
|
|
42
|
-
? null
|
|
43
|
-
: options.style;
|
|
44
|
-
(0, assertion_1.assertValidStyle)(options.style);
|
|
45
|
-
if (options.bundler === 'vite') {
|
|
46
|
-
options.unitTestRunner = 'vitest';
|
|
47
|
-
}
|
|
48
|
-
const normalized = Object.assign(Object.assign({}, options), { name: (0, devkit_1.names)(options.name).fileName, projectName: appProjectName, appProjectRoot,
|
|
49
|
-
e2eProjectName,
|
|
50
|
-
e2eProjectRoot,
|
|
51
|
-
parsedTags,
|
|
52
|
-
fileName,
|
|
53
|
-
styledModule, hasStyles: options.style !== 'none' });
|
|
54
|
-
normalized.routing = (_a = normalized.routing) !== null && _a !== void 0 ? _a : false;
|
|
55
|
-
normalized.strict = (_b = normalized.strict) !== null && _b !== void 0 ? _b : true;
|
|
56
|
-
normalized.classComponent = (_c = normalized.classComponent) !== null && _c !== void 0 ? _c : false;
|
|
57
|
-
normalized.compiler = (_d = normalized.compiler) !== null && _d !== void 0 ? _d : 'babel';
|
|
58
|
-
normalized.bundler = (_e = normalized.bundler) !== null && _e !== void 0 ? _e : 'webpack';
|
|
59
|
-
normalized.unitTestRunner =
|
|
60
|
-
(_f = normalized.unitTestRunner) !== null && _f !== void 0 ? _f : (normalized.bundler === 'vite' ? 'vitest' : 'jest');
|
|
61
|
-
normalized.e2eTestRunner = (_g = normalized.e2eTestRunner) !== null && _g !== void 0 ? _g : 'cypress';
|
|
62
|
-
normalized.inSourceTests = normalized.minimal || normalized.inSourceTests;
|
|
63
|
-
(_h = normalized.devServerPort) !== null && _h !== void 0 ? _h : (normalized.devServerPort = (0, find_free_port_1.findFreePort)(host));
|
|
64
|
-
normalized.minimal = (_j = normalized.minimal) !== null && _j !== void 0 ? _j : false;
|
|
65
|
-
return normalized;
|
|
20
|
+
async function normalizeOptions(host, options, callingGenerator = '@nx/react:application') {
|
|
21
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
22
|
+
name: options.name,
|
|
23
|
+
projectType: 'application',
|
|
24
|
+
directory: options.directory,
|
|
25
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
26
|
+
rootProject: options.rootProject,
|
|
27
|
+
callingGenerator,
|
|
66
28
|
});
|
|
29
|
+
options.rootProject = appProjectRoot === '.';
|
|
30
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
31
|
+
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
32
|
+
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
33
|
+
const parsedTags = options.tags
|
|
34
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
35
|
+
: [];
|
|
36
|
+
const fileName = options.pascalCaseFiles ? 'App' : 'app';
|
|
37
|
+
const styledModule = /^(css|scss|less|styl|none)$/.test(options.style)
|
|
38
|
+
? null
|
|
39
|
+
: options.style;
|
|
40
|
+
(0, assertion_1.assertValidStyle)(options.style);
|
|
41
|
+
if (options.bundler === 'vite') {
|
|
42
|
+
options.unitTestRunner = 'vitest';
|
|
43
|
+
}
|
|
44
|
+
const normalized = {
|
|
45
|
+
...options,
|
|
46
|
+
name: (0, devkit_1.names)(options.name).fileName,
|
|
47
|
+
projectName: appProjectName,
|
|
48
|
+
appProjectRoot,
|
|
49
|
+
e2eProjectName,
|
|
50
|
+
e2eProjectRoot,
|
|
51
|
+
parsedTags,
|
|
52
|
+
fileName,
|
|
53
|
+
styledModule,
|
|
54
|
+
hasStyles: options.style !== 'none',
|
|
55
|
+
};
|
|
56
|
+
normalized.routing = normalized.routing ?? false;
|
|
57
|
+
normalized.strict = normalized.strict ?? true;
|
|
58
|
+
normalized.classComponent = normalized.classComponent ?? false;
|
|
59
|
+
normalized.compiler = normalized.compiler ?? 'babel';
|
|
60
|
+
normalized.bundler = normalized.bundler ?? 'webpack';
|
|
61
|
+
normalized.unitTestRunner =
|
|
62
|
+
normalized.unitTestRunner ??
|
|
63
|
+
(normalized.bundler === 'vite' ? 'vitest' : 'jest');
|
|
64
|
+
normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'cypress';
|
|
65
|
+
normalized.inSourceTests = normalized.minimal || normalized.inSourceTests;
|
|
66
|
+
normalized.devServerPort ??= (0, find_free_port_1.findFreePort)(host);
|
|
67
|
+
normalized.minimal = normalized.minimal ?? false;
|
|
68
|
+
return normalized;
|
|
67
69
|
}
|
|
68
70
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -12,11 +12,31 @@ function setDefaults(host, options) {
|
|
|
12
12
|
}
|
|
13
13
|
nxJson.generators = nxJson.generators || {};
|
|
14
14
|
nxJson.generators['@nx/react'] = nxJson.generators['@nx/react'] || {};
|
|
15
|
-
const prev =
|
|
16
|
-
const appDefaults =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const prev = { ...nxJson.generators['@nx/react'] };
|
|
16
|
+
const appDefaults = {
|
|
17
|
+
style: options.style,
|
|
18
|
+
linter: options.linter,
|
|
19
|
+
bundler: options.bundler,
|
|
20
|
+
...prev.application,
|
|
21
|
+
};
|
|
22
|
+
const componentDefaults = {
|
|
23
|
+
style: options.style,
|
|
24
|
+
...prev.component,
|
|
25
|
+
};
|
|
26
|
+
const libDefaults = {
|
|
27
|
+
style: options.style,
|
|
28
|
+
linter: options.linter,
|
|
29
|
+
...prev.library,
|
|
30
|
+
};
|
|
31
|
+
nxJson.generators = {
|
|
32
|
+
...nxJson.generators,
|
|
33
|
+
'@nx/react': {
|
|
34
|
+
...prev,
|
|
35
|
+
application: appDefaults,
|
|
36
|
+
component: componentDefaults,
|
|
37
|
+
library: libDefaults,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
20
40
|
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
21
41
|
}
|
|
22
42
|
exports.setDefaults = setDefaults;
|