@nx/react 19.5.7 → 19.6.0-beta.1
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/package.json +6 -6
- package/src/generators/application/application.js +1 -1
- package/src/generators/application/files/nx-welcome/claimed/src/app/nx-welcome.tsx__tmpl__ +862 -0
- package/src/generators/application/files/nx-welcome/{src/app/nx-welcome.tsx → not-configured/src/app/nx-welcome.tsx__tmpl__} +191 -211
- package/src/generators/application/files/nx-welcome/unclaimed/src/app/nx-welcome.tsx__tmpl__ +864 -0
- package/src/generators/application/lib/add-e2e.js +55 -14
- package/src/generators/application/lib/create-application-files.d.ts +1 -1
- package/src/generators/application/lib/create-application-files.js +9 -2
- package/src/generators/application/lib/normalize-options.js +21 -9
- package/src/generators/application/schema.d.ts +3 -0
|
@@ -6,18 +6,20 @@ const web_1 = require("@nx/web");
|
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
7
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
|
8
8
|
const has_vite_plugin_1 = require("../../../utils/has-vite-plugin");
|
|
9
|
+
const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
|
|
10
|
+
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
9
11
|
async function addE2e(tree, options) {
|
|
12
|
+
const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
|
|
13
|
+
(options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
|
|
14
|
+
if (!hasNxBuildPlugin) {
|
|
15
|
+
await (0, web_1.webStaticServeGenerator)(tree, {
|
|
16
|
+
buildTarget: `${options.projectName}:build`,
|
|
17
|
+
targetName: 'serve-static',
|
|
18
|
+
spa: true,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
10
21
|
switch (options.e2eTestRunner) {
|
|
11
22
|
case 'cypress': {
|
|
12
|
-
const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
|
|
13
|
-
(options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
|
|
14
|
-
if (!hasNxBuildPlugin) {
|
|
15
|
-
await (0, web_1.webStaticServeGenerator)(tree, {
|
|
16
|
-
buildTarget: `${options.projectName}:build`,
|
|
17
|
-
targetName: 'serve-static',
|
|
18
|
-
spa: true,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
23
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
22
24
|
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
23
25
|
projectType: 'application',
|
|
@@ -27,7 +29,7 @@ async function addE2e(tree, options) {
|
|
|
27
29
|
implicitDependencies: [options.projectName],
|
|
28
30
|
tags: [],
|
|
29
31
|
});
|
|
30
|
-
|
|
32
|
+
const e2eTask = await configurationGenerator(tree, {
|
|
31
33
|
...options,
|
|
32
34
|
project: options.e2eProjectName,
|
|
33
35
|
directory: 'src',
|
|
@@ -45,9 +47,29 @@ async function addE2e(tree, options) {
|
|
|
45
47
|
}
|
|
46
48
|
: undefined,
|
|
47
49
|
ciWebServerCommand: hasNxBuildPlugin
|
|
48
|
-
? `nx run ${options.projectName}
|
|
50
|
+
? `nx run ${options.projectName}:${options.e2eCiWebServerTarget}`
|
|
49
51
|
: undefined,
|
|
52
|
+
ciBaseUrl: options.bundler === 'vite' ? options.e2eCiBaseUrl : undefined,
|
|
50
53
|
});
|
|
54
|
+
if (options.addPlugin ||
|
|
55
|
+
(0, devkit_1.readNxJson)(tree).plugins?.find((p) => typeof p === 'string'
|
|
56
|
+
? p === '@nx/cypress/plugin'
|
|
57
|
+
: p.plugin === '@nx/cypress/plugin')) {
|
|
58
|
+
let buildTarget = '^build';
|
|
59
|
+
if (hasNxBuildPlugin) {
|
|
60
|
+
const configFile = options.bundler === 'webpack'
|
|
61
|
+
? 'webpack.config.js'
|
|
62
|
+
: options.bundler === 'vite'
|
|
63
|
+
? `vite.config.${options.js ? 'js' : 'ts'}`
|
|
64
|
+
: 'webpack.config.js';
|
|
65
|
+
const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(tree, `@nx/${options.bundler}/plugin`, (0, devkit_1.joinPathFragments)(options.appProjectRoot, configFile));
|
|
66
|
+
if (matchingPlugin && typeof matchingPlugin !== 'string') {
|
|
67
|
+
buildTarget = `^${matchingPlugin.options?.buildTargetName ?? 'build'}`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(tree, '@nx/cypress/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `cypress.config.${options.js ? 'js' : 'ts'}`));
|
|
71
|
+
}
|
|
72
|
+
return e2eTask;
|
|
51
73
|
}
|
|
52
74
|
case 'playwright': {
|
|
53
75
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
@@ -58,7 +80,7 @@ async function addE2e(tree, options) {
|
|
|
58
80
|
targets: {},
|
|
59
81
|
implicitDependencies: [options.projectName],
|
|
60
82
|
});
|
|
61
|
-
|
|
83
|
+
const e2eTask = await configurationGenerator(tree, {
|
|
62
84
|
project: options.e2eProjectName,
|
|
63
85
|
skipFormat: true,
|
|
64
86
|
skipPackageJson: options.skipPackageJson,
|
|
@@ -66,11 +88,30 @@ async function addE2e(tree, options) {
|
|
|
66
88
|
js: false,
|
|
67
89
|
linter: options.linter,
|
|
68
90
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
69
|
-
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.
|
|
70
|
-
webServerAddress: options.
|
|
91
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx run ${options.projectName}:${options.e2eCiWebServerTarget}`,
|
|
92
|
+
webServerAddress: options.e2eCiBaseUrl,
|
|
71
93
|
rootProject: options.rootProject,
|
|
72
94
|
addPlugin: options.addPlugin,
|
|
73
95
|
});
|
|
96
|
+
if (options.addPlugin ||
|
|
97
|
+
(0, devkit_1.readNxJson)(tree).plugins?.find((p) => typeof p === 'string'
|
|
98
|
+
? p === '@nx/playwright/plugin'
|
|
99
|
+
: p.plugin === '@nx/playwright/plugin')) {
|
|
100
|
+
let buildTarget = '^build';
|
|
101
|
+
if (hasNxBuildPlugin) {
|
|
102
|
+
const configFile = options.bundler === 'webpack'
|
|
103
|
+
? 'webpack.config.js'
|
|
104
|
+
: options.bundler === 'vite'
|
|
105
|
+
? `vite.config.${options.js ? 'js' : 'ts'}`
|
|
106
|
+
: 'webpack.config.js';
|
|
107
|
+
const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(tree, `@nx/${options.bundler}/plugin`, (0, devkit_1.joinPathFragments)(options.appProjectRoot, configFile));
|
|
108
|
+
if (matchingPlugin && typeof matchingPlugin !== 'string') {
|
|
109
|
+
buildTarget = `^${matchingPlugin.options?.buildTargetName ?? 'build'}`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(tree, '@nx/playwright/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `playwright.config.ts`));
|
|
113
|
+
}
|
|
114
|
+
return e2eTask;
|
|
74
115
|
}
|
|
75
116
|
case 'none':
|
|
76
117
|
default:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { NormalizedSchema } from '../schema';
|
|
3
|
-
export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): void
|
|
3
|
+
export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): Promise<void>;
|
|
@@ -9,7 +9,8 @@ const get_in_source_vitest_tests_template_1 = require("../../../utils/get-in-sou
|
|
|
9
9
|
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
10
10
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
|
11
11
|
const get_app_tests_1 = require("./get-app-tests");
|
|
12
|
-
|
|
12
|
+
const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
|
|
13
|
+
async function createApplicationFiles(host, options) {
|
|
13
14
|
let styleSolutionSpecificAppFiles;
|
|
14
15
|
if (options.styledModule && options.style !== 'styled-jsx') {
|
|
15
16
|
styleSolutionSpecificAppFiles = '../files/style-styled-module';
|
|
@@ -29,6 +30,9 @@ function createApplicationFiles(host, options) {
|
|
|
29
30
|
else {
|
|
30
31
|
styleSolutionSpecificAppFiles = '../files/style-css-module';
|
|
31
32
|
}
|
|
33
|
+
const onBoardingStatus = await (0, onboarding_1.createNxCloudOnboardingURLForWelcomeApp)(host, options.nxCloudToken);
|
|
34
|
+
const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
|
|
35
|
+
(await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
|
|
32
36
|
const relativePathToRootTsConfig = (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot);
|
|
33
37
|
const appTests = (0, get_app_tests_1.getAppTests)(options);
|
|
34
38
|
const templateVariables = {
|
|
@@ -114,7 +118,10 @@ function createApplicationFiles(host, options) {
|
|
|
114
118
|
host.delete(`${options.appProjectRoot}/src/app/${options.fileName}.spec.tsx`);
|
|
115
119
|
}
|
|
116
120
|
if (!options.minimal) {
|
|
117
|
-
|
|
121
|
+
const tutorialUrl = options.rootProject
|
|
122
|
+
? 'https://nx.dev/getting-started/tutorials/react-standalone-tutorial'
|
|
123
|
+
: 'https://nx.dev/react-tutorial/1-code-generation?utm_source=nx-project';
|
|
124
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/nx-welcome', onBoardingStatus), options.appProjectRoot, { ...templateVariables, connectCloudUrl, tutorialUrl });
|
|
118
125
|
}
|
|
119
126
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, styleSolutionSpecificAppFiles), options.appProjectRoot, templateVariables);
|
|
120
127
|
if (options.js) {
|
|
@@ -32,28 +32,35 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
|
|
|
32
32
|
options.addPlugin ??= addPlugin;
|
|
33
33
|
options.rootProject = appProjectRoot === '.';
|
|
34
34
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
35
|
+
let e2ePort = options.devServerPort ?? 4200;
|
|
35
36
|
let e2eWebServerTarget = 'serve';
|
|
37
|
+
let e2eCiWebServerTarget = options.bundler === 'vite' ? 'preview' : 'serve-static';
|
|
36
38
|
if (options.addPlugin) {
|
|
37
39
|
if (nxJson.plugins) {
|
|
38
40
|
for (const plugin of nxJson.plugins) {
|
|
39
41
|
if (options.bundler === 'vite' &&
|
|
40
42
|
typeof plugin === 'object' &&
|
|
41
|
-
plugin.plugin === '@nx/vite/plugin'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
plugin.plugin === '@nx/vite/plugin') {
|
|
44
|
+
e2eCiWebServerTarget =
|
|
45
|
+
plugin.options?.previewTargetName ??
|
|
46
|
+
e2eCiWebServerTarget;
|
|
47
|
+
e2eWebServerTarget =
|
|
48
|
+
plugin.options?.serveTargetName ??
|
|
49
|
+
e2eWebServerTarget;
|
|
45
50
|
}
|
|
46
51
|
else if (options.bundler === 'webpack' &&
|
|
47
52
|
typeof plugin === 'object' &&
|
|
48
|
-
plugin.plugin === '@nx/webpack/plugin'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
plugin.plugin === '@nx/webpack/plugin') {
|
|
54
|
+
e2eCiWebServerTarget =
|
|
55
|
+
plugin.options?.serveStaticTargetName ??
|
|
56
|
+
e2eCiWebServerTarget;
|
|
57
|
+
e2eWebServerTarget =
|
|
58
|
+
plugin.options?.serveTargetName ??
|
|
59
|
+
e2eWebServerTarget;
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
|
-
let e2ePort = options.devServerPort ?? 4200;
|
|
57
64
|
if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
|
|
58
65
|
nxJson.targetDefaults?.[e2eWebServerTarget].options?.port) {
|
|
59
66
|
e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options?.port;
|
|
@@ -61,6 +68,9 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
|
|
|
61
68
|
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
62
69
|
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
63
70
|
const e2eWebServerAddress = `http://localhost:${e2ePort}`;
|
|
71
|
+
const e2eCiBaseUrl = options.bundler === 'vite'
|
|
72
|
+
? 'http://localhost:4300'
|
|
73
|
+
: `http://localhost:${e2ePort}`;
|
|
64
74
|
const parsedTags = options.tags
|
|
65
75
|
? options.tags.split(',').map((s) => s.trim())
|
|
66
76
|
: [];
|
|
@@ -78,6 +88,8 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
|
|
|
78
88
|
e2eProjectRoot,
|
|
79
89
|
e2eWebServerAddress,
|
|
80
90
|
e2eWebServerTarget,
|
|
91
|
+
e2eCiWebServerTarget,
|
|
92
|
+
e2eCiBaseUrl,
|
|
81
93
|
e2ePort,
|
|
82
94
|
parsedTags,
|
|
83
95
|
fileName,
|
|
@@ -29,6 +29,7 @@ export interface Schema {
|
|
|
29
29
|
bundler?: 'webpack' | 'vite' | 'rspack';
|
|
30
30
|
minimal?: boolean;
|
|
31
31
|
addPlugin?: boolean;
|
|
32
|
+
nxCloudToken?: string;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
@@ -38,6 +39,8 @@ export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
|
38
39
|
e2eProjectRoot: string;
|
|
39
40
|
e2eWebServerAddress: string;
|
|
40
41
|
e2eWebServerTarget: string;
|
|
42
|
+
e2eCiWebServerTarget: string;
|
|
43
|
+
e2eCiBaseUrl: string;
|
|
41
44
|
e2ePort: number;
|
|
42
45
|
parsedTags: string[];
|
|
43
46
|
fileName: string;
|