@nx/cypress 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/package.json +6 -6
- package/plugins/cypress-preset.js +15 -6
- package/src/executors/cypress/cypress.impl.js +179 -210
- package/src/generators/base-setup/base-setup.js +15 -5
- package/src/generators/component-configuration/component-configuration.js +42 -30
- package/src/generators/configuration/configuration.js +87 -70
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +75 -78
- package/src/generators/cypress-project/cypress-project.js +76 -63
- package/src/generators/init/init.js +16 -18
- package/src/generators/migrate-to-cypress-11/conversion.util.js +22 -16
- package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.js +38 -35
- package/src/migrations/update-12-8-0/remove-typescript-plugin.js +23 -26
- package/src/migrations/update-14-6-1/update-cypress-configs-presets.js +79 -68
- package/src/migrations/update-14-7-0/update-cypress-version-if-10.js +1 -2
- package/src/migrations/update-15-0-0/add-cypress-inputs.js +24 -29
- package/src/migrations/update-15-0-0/update-cy-mount-usage.js +25 -29
- package/src/migrations/update-15-1-0/cypress-11.js +34 -37
- package/src/migrations/update-15-5-0/update-to-cypress-12.js +3 -5
- 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/update-cy-tsconfig.js +25 -24
- package/src/migrations/update-16-4-0/tsconfig-sourcemaps.js +52 -49
- package/src/plugins/preprocessor-vite.js +7 -5
- package/src/utils/add-linter.js +78 -81
- package/src/utils/config.js +54 -62
- package/src/utils/ct-helpers.js +6 -8
- package/src/utils/cypress-version.js +1 -1
- package/src/utils/find-target-options.js +37 -43
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compat = exports.updateTsConfigForComponentTesting = exports.componentConfigurationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const cypress_version_1 = require("../../utils/cypress-version");
|
|
7
6
|
const versions_1 = require("../../utils/versions");
|
|
8
7
|
const base_setup_1 = require("../base-setup/base-setup");
|
|
9
|
-
function componentConfigurationGenerator(tree, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
});
|
|
8
|
+
async function componentConfigurationGenerator(tree, options) {
|
|
9
|
+
const opts = normalizeOptions(options);
|
|
10
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.project);
|
|
11
|
+
const installDepsTask = updateDeps(tree, opts);
|
|
12
|
+
addProjectFiles(tree, projectConfig, opts);
|
|
13
|
+
addTargetToProject(tree, projectConfig, opts);
|
|
14
|
+
updateNxJsonConfiguration(tree);
|
|
15
|
+
updateTsConfigForComponentTesting(tree, projectConfig);
|
|
16
|
+
if (!opts.skipFormat) {
|
|
17
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
installDepsTask();
|
|
21
|
+
};
|
|
25
22
|
}
|
|
26
23
|
exports.componentConfigurationGenerator = componentConfigurationGenerator;
|
|
27
24
|
function normalizeOptions(options) {
|
|
28
|
-
var _a;
|
|
29
25
|
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
30
26
|
if (cyVersion && cyVersion < 10) {
|
|
31
27
|
throw new Error('Cypress version of 10 or higher is required to use component testing. See the migration guide to upgrade. https://nx.dev/cypress/v11-migration-guide');
|
|
32
28
|
}
|
|
33
|
-
return
|
|
29
|
+
return {
|
|
30
|
+
...options,
|
|
31
|
+
directory: options.directory ?? 'cypress',
|
|
32
|
+
};
|
|
34
33
|
}
|
|
35
34
|
function updateDeps(tree, opts) {
|
|
36
35
|
const devDeps = {
|
|
@@ -50,7 +49,12 @@ function addProjectFiles(tree, projectConfig, opts) {
|
|
|
50
49
|
project: opts.project,
|
|
51
50
|
directory: opts.directory,
|
|
52
51
|
});
|
|
53
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), projectConfig.root,
|
|
52
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), projectConfig.root, {
|
|
53
|
+
...opts,
|
|
54
|
+
projectRoot: projectConfig.root,
|
|
55
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root),
|
|
56
|
+
ext: '',
|
|
57
|
+
});
|
|
54
58
|
}
|
|
55
59
|
function addTargetToProject(tree, projectConfig, opts) {
|
|
56
60
|
projectConfig.targets['component-test'] = {
|
|
@@ -63,16 +67,24 @@ function addTargetToProject(tree, projectConfig, opts) {
|
|
|
63
67
|
(0, devkit_1.updateProjectConfiguration)(tree, opts.project, projectConfig);
|
|
64
68
|
}
|
|
65
69
|
function updateNxJsonConfiguration(tree) {
|
|
66
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
67
|
-
var _m, _o;
|
|
68
70
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
69
|
-
nxJson.tasksRunnerOptions =
|
|
70
|
-
|
|
71
|
+
nxJson.tasksRunnerOptions = {
|
|
72
|
+
...nxJson?.tasksRunnerOptions,
|
|
73
|
+
default: {
|
|
74
|
+
...nxJson?.tasksRunnerOptions?.default,
|
|
75
|
+
options: {
|
|
76
|
+
...nxJson?.tasksRunnerOptions?.default?.options,
|
|
77
|
+
cacheableOperations: Array.from(new Set([
|
|
78
|
+
...(nxJson?.tasksRunnerOptions?.default?.options
|
|
79
|
+
?.cacheableOperations ?? []),
|
|
71
80
|
'component-test',
|
|
72
|
-
]))
|
|
81
|
+
])),
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
73
85
|
if (nxJson.namedInputs) {
|
|
74
|
-
|
|
75
|
-
const productionFileSet =
|
|
86
|
+
nxJson.targetDefaults ??= {};
|
|
87
|
+
const productionFileSet = nxJson.namedInputs?.production;
|
|
76
88
|
if (productionFileSet) {
|
|
77
89
|
nxJson.namedInputs.production = Array.from(new Set([
|
|
78
90
|
...productionFileSet,
|
|
@@ -81,11 +93,11 @@ function updateNxJsonConfiguration(tree) {
|
|
|
81
93
|
'!{projectRoot}/cypress.config.[jt]s',
|
|
82
94
|
]));
|
|
83
95
|
}
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
nxJson.targetDefaults['component-test'] ??= {};
|
|
97
|
+
nxJson.targetDefaults['component-test'].inputs ??= [
|
|
86
98
|
'default',
|
|
87
99
|
productionFileSet ? '^production' : '^default',
|
|
88
|
-
]
|
|
100
|
+
];
|
|
89
101
|
}
|
|
90
102
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
91
103
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compat = exports.configurationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const js_1 = require("@nx/js");
|
|
7
6
|
const linter_1 = require("@nx/linter");
|
|
@@ -12,30 +11,30 @@ const cypress_version_1 = require("../../utils/cypress-version");
|
|
|
12
11
|
const versions_1 = require("../../utils/versions");
|
|
13
12
|
const init_1 = require("../init/init");
|
|
14
13
|
const base_setup_1 = require("../base-setup/base-setup");
|
|
15
|
-
function configurationGenerator(tree, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
30
|
-
}
|
|
31
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
14
|
+
async function configurationGenerator(tree, options) {
|
|
15
|
+
const opts = normalizeOptions(tree, options);
|
|
16
|
+
const tasks = [];
|
|
17
|
+
if (!(0, cypress_version_1.installedCypressVersion)()) {
|
|
18
|
+
tasks.push(await (0, init_1.default)(tree, opts));
|
|
19
|
+
}
|
|
20
|
+
if (opts.bundler === 'vite') {
|
|
21
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { vite: versions_1.viteVersion }));
|
|
22
|
+
}
|
|
23
|
+
await addFiles(tree, opts);
|
|
24
|
+
addTarget(tree, opts);
|
|
25
|
+
(0, add_linter_1.addLinterToCyProject)(tree, {
|
|
26
|
+
...opts,
|
|
27
|
+
cypressDir: opts.directory,
|
|
32
28
|
});
|
|
29
|
+
if (!opts.skipFormat) {
|
|
30
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
31
|
+
}
|
|
32
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
33
33
|
}
|
|
34
34
|
exports.configurationGenerator = configurationGenerator;
|
|
35
35
|
function normalizeOptions(tree, options) {
|
|
36
|
-
var _a, _b, _c, _d, _e;
|
|
37
36
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
38
|
-
if (
|
|
37
|
+
if (projectConfig?.targets?.e2e) {
|
|
39
38
|
throw new Error(`Project ${options.project} already has an e2e target.
|
|
40
39
|
Rename or remove the existing e2e target.`);
|
|
41
40
|
}
|
|
@@ -45,57 +44,68 @@ Rename or remove the existing e2e target.`);
|
|
|
45
44
|
throw new Error(`The project ${options.project} does not have a 'serve' target.
|
|
46
45
|
In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:<configName>]', or a baseUrl option`);
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
return
|
|
47
|
+
options.directory ??= 'src';
|
|
48
|
+
return {
|
|
49
|
+
...options,
|
|
50
|
+
bundler: options.bundler ?? 'webpack',
|
|
51
|
+
rootProject: projectConfig.root === '.',
|
|
52
|
+
linter: options.linter ?? linter_1.Linter.EsLint,
|
|
53
|
+
devServerTarget: options.devServerTarget ??
|
|
54
|
+
(projectConfig.targets.serve ? `${options.project}:serve` : undefined),
|
|
55
|
+
};
|
|
50
56
|
}
|
|
51
|
-
function addFiles(tree, options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
57
|
+
async function addFiles(tree, options) {
|
|
58
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
59
|
+
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
60
|
+
const filesToUse = cyVersion && cyVersion < 10 ? 'v9' : 'v10';
|
|
61
|
+
const hasTsConfig = tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'));
|
|
62
|
+
const offsetFromProjectRoot = options.directory
|
|
63
|
+
.split('/')
|
|
64
|
+
.map((_) => '..')
|
|
65
|
+
.join('/');
|
|
66
|
+
const fileOpts = {
|
|
67
|
+
...options,
|
|
68
|
+
dir: options.directory ?? 'src',
|
|
69
|
+
ext: options.js ? 'js' : 'ts',
|
|
70
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root),
|
|
71
|
+
offsetFromProjectRoot,
|
|
72
|
+
tsConfigPath: hasTsConfig
|
|
73
|
+
? `${offsetFromProjectRoot}/tsconfig.json`
|
|
74
|
+
: (0, js_1.getRelativePathToRootTsConfig)(tree, projectConfig.root),
|
|
75
|
+
tmpl: '',
|
|
76
|
+
};
|
|
77
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', filesToUse), projectConfig.root, fileOpts);
|
|
78
|
+
if (filesToUse === 'v10') {
|
|
79
|
+
(0, base_setup_1.addBaseCypressSetup)(tree, {
|
|
80
|
+
project: options.project,
|
|
81
|
+
directory: options.directory,
|
|
82
|
+
});
|
|
83
|
+
const cyFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
|
|
84
|
+
const updatedCyConfig = await (0, config_1.addDefaultE2EConfig)(tree.read(cyFile, 'utf-8'), {
|
|
85
|
+
directory: options.directory,
|
|
86
|
+
bundler: options.bundler,
|
|
87
|
+
});
|
|
88
|
+
tree.write(cyFile, updatedCyConfig);
|
|
89
|
+
}
|
|
90
|
+
if (cyVersion &&
|
|
91
|
+
cyVersion < 7 &&
|
|
92
|
+
tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'src', 'plugins', 'index.js'))) {
|
|
93
|
+
(0, devkit_1.updateJson)(tree, (0, path_1.join)(projectConfig.root, 'cypress.json'), (json) => {
|
|
94
|
+
json.pluginsFile = './src/plugins/index';
|
|
95
|
+
return json;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else if (cyVersion < 10) {
|
|
99
|
+
const pluginPath = (0, path_1.join)(projectConfig.root, 'src/plugins/index.js');
|
|
100
|
+
if (tree.exists(pluginPath)) {
|
|
101
|
+
tree.delete(pluginPath);
|
|
94
102
|
}
|
|
95
|
-
}
|
|
103
|
+
}
|
|
104
|
+
if (options.js) {
|
|
105
|
+
(0, devkit_1.toJS)(tree);
|
|
106
|
+
}
|
|
96
107
|
}
|
|
97
108
|
function addTarget(tree, opts) {
|
|
98
|
-
var _a;
|
|
99
109
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.project);
|
|
100
110
|
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
101
111
|
projectConfig.targets.e2e = {
|
|
@@ -106,18 +116,25 @@ function addTarget(tree, opts) {
|
|
|
106
116
|
},
|
|
107
117
|
};
|
|
108
118
|
if (opts.baseUrl) {
|
|
109
|
-
projectConfig.targets.e2e.options =
|
|
119
|
+
projectConfig.targets.e2e.options = {
|
|
120
|
+
...projectConfig.targets.e2e.options,
|
|
121
|
+
baseUrl: opts.baseUrl,
|
|
122
|
+
};
|
|
110
123
|
}
|
|
111
124
|
else if (opts.devServerTarget) {
|
|
112
125
|
const parsedTarget = (0, devkit_1.parseTargetString)(opts.devServerTarget);
|
|
113
|
-
projectConfig.targets.e2e.options =
|
|
126
|
+
projectConfig.targets.e2e.options = {
|
|
127
|
+
...projectConfig.targets.e2e.options,
|
|
128
|
+
devServerTarget: opts.devServerTarget,
|
|
129
|
+
port: opts.port,
|
|
130
|
+
};
|
|
114
131
|
projectConfig.targets.e2e.configurations = {
|
|
115
132
|
[parsedTarget.configuration || 'production']: {
|
|
116
133
|
devServerTarget: `${opts.devServerTarget}${parsedTarget.configuration ? '' : ':production'}`,
|
|
117
134
|
},
|
|
118
135
|
};
|
|
119
136
|
const devServerProjectConfig = (0, devkit_1.readProjectConfiguration)(tree, parsedTarget.project);
|
|
120
|
-
if (
|
|
137
|
+
if (devServerProjectConfig.targets?.['serve-static']) {
|
|
121
138
|
projectConfig.targets.e2e.configurations.ci = {
|
|
122
139
|
devServerTarget: `${parsedTarget.project}:serve-static`,
|
|
123
140
|
};
|
|
@@ -1,91 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.conversionSchematic = exports.conversionGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const linter_1 = require("@nx/linter");
|
|
7
6
|
const add_linter_1 = require("../../utils/add-linter");
|
|
8
7
|
/**
|
|
9
8
|
* @deprecated This generator will be removed in v17
|
|
10
9
|
*/
|
|
11
|
-
function conversionGenerator(host, options) {
|
|
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
|
-
* If root eslint configuration already exists it will not be recreated
|
|
44
|
-
* but we also don't want to re-run the tslint config conversion
|
|
45
|
-
* as it was likely already done
|
|
46
|
-
*/
|
|
47
|
-
const rootEslintConfigExists = host.exists('.eslintrc.json');
|
|
48
|
-
/**
|
|
49
|
-
* Create the standard (which is applicable to the current package) ESLint setup
|
|
50
|
-
* for converting the project.
|
|
51
|
-
*/
|
|
52
|
-
const eslintInitInstallTask = yield projectConverter.initESLint();
|
|
53
|
-
/**
|
|
54
|
-
* Convert the root tslint.json and apply the converted rules to the root .eslintrc.json.
|
|
55
|
-
*/
|
|
56
|
-
const rootConfigInstallTask = yield projectConverter.convertRootTSLintConfig((json) => removeCodelyzerRelatedRules(json), rootEslintConfigExists);
|
|
57
|
-
/**
|
|
58
|
-
* Convert the project's tslint.json to an equivalent ESLint config.
|
|
59
|
-
*/
|
|
60
|
-
const projectConfigInstallTask = yield projectConverter.convertProjectConfig((json) => json);
|
|
61
|
-
/**
|
|
62
|
-
* Clean up the original TSLint configuration for the project.
|
|
63
|
-
*/
|
|
64
|
-
projectConverter.removeProjectTSLintFile();
|
|
65
|
-
// Only project shouldn't be added as a default
|
|
66
|
-
const { project } = options, defaults = tslib_1.__rest(options, ["project"]);
|
|
67
|
-
/**
|
|
68
|
-
* Store user preferences for the collection
|
|
69
|
-
*/
|
|
70
|
-
projectConverter.setDefaults('@nx/cypress', defaults);
|
|
71
|
-
/**
|
|
72
|
-
* Based on user preference and remaining usage, remove TSLint from the workspace entirely.
|
|
73
|
-
*/
|
|
74
|
-
let uninstallTSLintTask = () => Promise.resolve(undefined);
|
|
75
|
-
if (options.removeTSLintIfNoMoreTSLintTargets &&
|
|
76
|
-
!projectConverter.isTSLintUsedInWorkspace()) {
|
|
77
|
-
uninstallTSLintTask = projectConverter.removeTSLintFromWorkspace();
|
|
78
|
-
}
|
|
79
|
-
if (!options.skipFormat) {
|
|
80
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
81
|
-
}
|
|
82
|
-
return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
yield eslintInitInstallTask();
|
|
84
|
-
yield rootConfigInstallTask();
|
|
85
|
-
yield projectConfigInstallTask();
|
|
86
|
-
yield uninstallTSLintTask();
|
|
87
|
-
});
|
|
10
|
+
async function conversionGenerator(host, options) {
|
|
11
|
+
/**
|
|
12
|
+
* The ProjectConverter instance encapsulates all the standard operations we need
|
|
13
|
+
* to perform in order to convert a project from TSLint to ESLint, as well as some
|
|
14
|
+
* extensibility points for adjusting the behavior on a per package basis.
|
|
15
|
+
*
|
|
16
|
+
* E.g. @nx/angular projects might need to make different changes to the final
|
|
17
|
+
* ESLint config when compared with @nx/next projects.
|
|
18
|
+
*
|
|
19
|
+
* See the ProjectConverter implementation for a full breakdown of what it does.
|
|
20
|
+
*/
|
|
21
|
+
const projectConverter = new linter_1.ProjectConverter({
|
|
22
|
+
host,
|
|
23
|
+
projectName: options.project,
|
|
24
|
+
ignoreExistingTslintConfig: options.ignoreExistingTslintConfig,
|
|
25
|
+
eslintInitializer: async ({ projectName, projectConfig }) => {
|
|
26
|
+
await (0, add_linter_1.addLinterToCyProject)(host, {
|
|
27
|
+
linter: linter_1.Linter.EsLint,
|
|
28
|
+
project: projectName,
|
|
29
|
+
/**
|
|
30
|
+
* We set the parserOptions.project config just in case the converted config uses
|
|
31
|
+
* rules which require type-checking. Later in the conversion we check if it actually
|
|
32
|
+
* does and remove the config again if it doesn't, so that it is most efficient.
|
|
33
|
+
*/
|
|
34
|
+
setParserOptionsProject: true,
|
|
35
|
+
cypressDir: 'src',
|
|
36
|
+
overwriteExisting: true,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
88
39
|
});
|
|
40
|
+
/**
|
|
41
|
+
* If root eslint configuration already exists it will not be recreated
|
|
42
|
+
* but we also don't want to re-run the tslint config conversion
|
|
43
|
+
* as it was likely already done
|
|
44
|
+
*/
|
|
45
|
+
const rootEslintConfigExists = host.exists('.eslintrc.json');
|
|
46
|
+
/**
|
|
47
|
+
* Create the standard (which is applicable to the current package) ESLint setup
|
|
48
|
+
* for converting the project.
|
|
49
|
+
*/
|
|
50
|
+
const eslintInitInstallTask = await projectConverter.initESLint();
|
|
51
|
+
/**
|
|
52
|
+
* Convert the root tslint.json and apply the converted rules to the root .eslintrc.json.
|
|
53
|
+
*/
|
|
54
|
+
const rootConfigInstallTask = await projectConverter.convertRootTSLintConfig((json) => removeCodelyzerRelatedRules(json), rootEslintConfigExists);
|
|
55
|
+
/**
|
|
56
|
+
* Convert the project's tslint.json to an equivalent ESLint config.
|
|
57
|
+
*/
|
|
58
|
+
const projectConfigInstallTask = await projectConverter.convertProjectConfig((json) => json);
|
|
59
|
+
/**
|
|
60
|
+
* Clean up the original TSLint configuration for the project.
|
|
61
|
+
*/
|
|
62
|
+
projectConverter.removeProjectTSLintFile();
|
|
63
|
+
// Only project shouldn't be added as a default
|
|
64
|
+
const { project, ...defaults } = options;
|
|
65
|
+
/**
|
|
66
|
+
* Store user preferences for the collection
|
|
67
|
+
*/
|
|
68
|
+
projectConverter.setDefaults('@nx/cypress', defaults);
|
|
69
|
+
/**
|
|
70
|
+
* Based on user preference and remaining usage, remove TSLint from the workspace entirely.
|
|
71
|
+
*/
|
|
72
|
+
let uninstallTSLintTask = () => Promise.resolve(undefined);
|
|
73
|
+
if (options.removeTSLintIfNoMoreTSLintTargets &&
|
|
74
|
+
!projectConverter.isTSLintUsedInWorkspace()) {
|
|
75
|
+
uninstallTSLintTask = projectConverter.removeTSLintFromWorkspace();
|
|
76
|
+
}
|
|
77
|
+
if (!options.skipFormat) {
|
|
78
|
+
await (0, devkit_1.formatFiles)(host);
|
|
79
|
+
}
|
|
80
|
+
return async () => {
|
|
81
|
+
await eslintInitInstallTask();
|
|
82
|
+
await rootConfigInstallTask();
|
|
83
|
+
await projectConfigInstallTask();
|
|
84
|
+
await uninstallTSLintTask();
|
|
85
|
+
};
|
|
89
86
|
}
|
|
90
87
|
exports.conversionGenerator = conversionGenerator;
|
|
91
88
|
exports.conversionSchematic = (0, devkit_1.convertNxGenerator)(conversionGenerator);
|