@nx/cypress 20.3.2 → 20.4.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.4.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Cypress contains executors and generators allowing your workspace to use the powerful Cypress integration testing capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"migrations": "./migrations.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nx/devkit": "20.
|
|
40
|
-
"@nx/eslint": "20.
|
|
41
|
-
"@nx/js": "20.
|
|
39
|
+
"@nx/devkit": "20.4.0-beta.1",
|
|
40
|
+
"@nx/eslint": "20.4.0-beta.1",
|
|
41
|
+
"@nx/js": "20.4.0-beta.1",
|
|
42
42
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
43
43
|
"detect-port": "^1.5.1",
|
|
44
44
|
"tslib": "^2.3.0"
|
|
@@ -12,19 +12,27 @@ function addBaseCypressSetup(tree, options) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
const opts = normalizeOptions(tree, projectConfig, options);
|
|
15
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
15
16
|
const templateVars = {
|
|
16
17
|
...opts,
|
|
17
18
|
jsx: !!opts.jsx,
|
|
18
19
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root),
|
|
19
20
|
offsetFromProjectRoot: opts.hasTsConfig ? opts.offsetFromProjectRoot : '',
|
|
20
|
-
tsConfigPath:
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
tsConfigPath:
|
|
22
|
+
// TS solution setup should always extend from tsconfig.base.json to use shared compilerOptions, the project's tsconfig.json will not have compilerOptions.
|
|
23
|
+
isUsingTsSolutionConfig
|
|
24
|
+
? (0, js_1.getRelativePathToRootTsConfig)(tree, opts.hasTsConfig
|
|
25
|
+
? (0, devkit_1.joinPathFragments)(projectConfig.root, options.directory)
|
|
26
|
+
: // If an existing tsconfig.json file does not exist, then cypress tsconfig will be moved to the project root.
|
|
27
|
+
projectConfig.root)
|
|
28
|
+
: opts.hasTsConfig
|
|
29
|
+
? `${opts.offsetFromProjectRoot}tsconfig.json`
|
|
30
|
+
: (0, js_1.getRelativePathToRootTsConfig)(tree, projectConfig.root),
|
|
23
31
|
linter: isEslintInstalled(tree) ? 'eslint' : 'none',
|
|
24
32
|
ext: '',
|
|
25
33
|
};
|
|
26
34
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files/common'), projectConfig.root, templateVars);
|
|
27
|
-
(0, devkit_1.generateFiles)(tree,
|
|
35
|
+
(0, devkit_1.generateFiles)(tree, isUsingTsSolutionConfig
|
|
28
36
|
? (0, path_1.join)(__dirname, 'files/tsconfig/ts-solution')
|
|
29
37
|
: (0, path_1.join)(__dirname, 'files/tsconfig/non-ts-solution'), projectConfig.root, templateVars);
|
|
30
38
|
if (options.js) {
|
|
@@ -15,6 +15,7 @@ const cypress_version_1 = require("../../utils/cypress-version");
|
|
|
15
15
|
const versions_1 = require("../../utils/versions");
|
|
16
16
|
const base_setup_1 = require("../base-setup/base-setup");
|
|
17
17
|
const init_1 = require("../init/init");
|
|
18
|
+
const prompt_1 = require("@nx/devkit/src/generators/prompt");
|
|
18
19
|
function configurationGenerator(tree, options) {
|
|
19
20
|
return configurationGeneratorInternal(tree, {
|
|
20
21
|
addPlugin: false,
|
|
@@ -106,6 +107,13 @@ async function normalizeOptions(tree, options) {
|
|
|
106
107
|
throw new Error(`Project ${options.project} already has an e2e target.
|
|
107
108
|
Rename or remove the existing e2e target.`);
|
|
108
109
|
}
|
|
110
|
+
if (!options.baseUrl &&
|
|
111
|
+
!options.devServerTarget &&
|
|
112
|
+
!projectConfig?.targets?.serve) {
|
|
113
|
+
const { devServerTarget, baseUrl } = await promptForMissingServeData(options.project);
|
|
114
|
+
options.devServerTarget = devServerTarget;
|
|
115
|
+
options.baseUrl = baseUrl;
|
|
116
|
+
}
|
|
109
117
|
if (!options.baseUrl &&
|
|
110
118
|
!options.devServerTarget &&
|
|
111
119
|
!projectConfig?.targets?.serve) {
|
|
@@ -131,6 +139,29 @@ In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:
|
|
|
131
139
|
devServerTarget,
|
|
132
140
|
};
|
|
133
141
|
}
|
|
142
|
+
async function promptForMissingServeData(projectName) {
|
|
143
|
+
const { devServerTarget, port } = await (0, prompt_1.promptWhenInteractive)([
|
|
144
|
+
{
|
|
145
|
+
type: 'input',
|
|
146
|
+
name: 'devServerTarget',
|
|
147
|
+
message: 'What is the name of the target used to serve the application locally?',
|
|
148
|
+
initial: `${projectName}:serve`,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: 'numeral',
|
|
152
|
+
name: 'port',
|
|
153
|
+
message: 'What port will the application be served on?',
|
|
154
|
+
initial: 3000,
|
|
155
|
+
},
|
|
156
|
+
], {
|
|
157
|
+
devServerTarget: `${projectName}:serve`,
|
|
158
|
+
port: 3000,
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
devServerTarget,
|
|
162
|
+
baseUrl: `http://localhost:${port}`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
134
165
|
async function addFiles(tree, options, projectGraph, hasPlugin) {
|
|
135
166
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
136
167
|
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|