@nx/cypress 16.8.0-beta.0 → 16.8.0-beta.2

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": "16.8.0-beta.0",
3
+ "version": "16.8.0-beta.2",
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": {
@@ -34,13 +34,12 @@
34
34
  "migrations": "./migrations.json"
35
35
  },
36
36
  "dependencies": {
37
- "@nrwl/cypress": "16.8.0-beta.0",
38
- "@nx/devkit": "16.8.0-beta.0",
39
- "@nx/js": "16.8.0-beta.0",
40
- "@nx/linter": "16.8.0-beta.0",
37
+ "@nrwl/cypress": "16.8.0-beta.2",
38
+ "@nx/devkit": "16.8.0-beta.2",
39
+ "@nx/js": "16.8.0-beta.2",
40
+ "@nx/linter": "16.8.0-beta.2",
41
41
  "@phenomnomnominal/tsquery": "~5.0.1",
42
42
  "detect-port": "^1.5.1",
43
- "dotenv": "~16.3.1",
44
43
  "semver": "7.5.3",
45
44
  "tslib": "^2.3.0"
46
45
  },
@@ -56,5 +55,5 @@
56
55
  "access": "public"
57
56
  },
58
57
  "type": "commonjs",
59
- "gitHead": "818352404283c1d34ab303d91b3bd16474f54916"
58
+ "gitHead": "9bcc04742f9e1516d8c1ddbfb1907770c347876f"
60
59
  }
@@ -1,5 +1,4 @@
1
1
  import { ExecutorContext } from '@nx/devkit';
2
- import 'dotenv/config';
3
2
  export type Json = {
4
3
  [k: string]: any;
5
4
  };
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const executor_utils_1 = require("nx/src/command-line/run/executor-utils");
6
- require("dotenv/config");
7
6
  const fs_1 = require("fs");
8
7
  const path_1 = require("path");
9
8
  const ct_helpers_1 = require("../../utils/ct-helpers");
@@ -4,9 +4,10 @@ exports.addLinterToCyProject = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const linter_1 = require("@nx/linter");
7
- const global_eslint_config_1 = require("@nx/linter/src/generators/init/global-eslint-config");
8
7
  const cypress_version_1 = require("./cypress-version");
9
8
  const versions_1 = require("./versions");
9
+ const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
10
+ const global_eslint_config_1 = require("@nx/linter/src/generators/init/global-eslint-config");
10
11
  function addLinterToCyProject(tree, options) {
11
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
13
  if (options.linter === linter_1.Linter.None) {
@@ -14,7 +15,8 @@ function addLinterToCyProject(tree, options) {
14
15
  }
15
16
  const tasks = [];
16
17
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
17
- if (!tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, '.eslintrc.json'))) {
18
+ const eslintFile = (0, eslint_file_1.findEslintFile)(tree, projectConfig.root);
19
+ if (!eslintFile) {
18
20
  tasks.push(yield (0, linter_1.lintProjectGenerator)(tree, {
19
21
  project: options.project,
20
22
  linter: options.linter,
@@ -34,55 +36,60 @@ function addLinterToCyProject(tree, options) {
34
36
  tasks.push(!options.skipPackageJson
35
37
  ? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'eslint-plugin-cypress': versions_1.eslintPluginCypressVersion })
36
38
  : () => { });
37
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectConfig.root, '.eslintrc.json'), (json) => {
38
- var _a;
39
+ if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
40
+ const overrides = [];
39
41
  if (options.rootProject) {
40
- json.plugins = ['@nx'];
41
- json.extends = ['plugin:cypress/recommended'];
42
- }
43
- else {
44
- json.extends = ['plugin:cypress/recommended', ...json.extends];
42
+ (0, eslint_file_1.addPluginsToLintConfig)(tree, projectConfig.root, '@nx');
43
+ overrides.push(global_eslint_config_1.javaScriptOverride);
45
44
  }
46
- (_a = json.overrides) !== null && _a !== void 0 ? _a : (json.overrides = []);
47
- const globals = options.rootProject ? [global_eslint_config_1.globalJavaScriptOverrides] : [];
48
- const override = {
49
- files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
50
- parserOptions: !options.setParserOptionsProject
51
- ? undefined
52
- : {
53
- project: `${projectConfig.root}/tsconfig.*?.json`,
54
- },
55
- rules: {},
45
+ (0, eslint_file_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:cypress/recommended');
46
+ const cyVersion = (0, cypress_version_1.installedCypressVersion)();
47
+ /**
48
+ * We need this override because we enabled allowJS in the tsconfig to allow for JS based Cypress tests.
49
+ * That however leads to issues with the CommonJS Cypress plugin file.
50
+ */
51
+ const cy6Override = {
52
+ files: [`${options.cypressDir}/plugins/index.js`],
53
+ rules: {
54
+ '@typescript-eslint/no-var-requires': 'off',
55
+ 'no-undef': 'off',
56
+ },
56
57
  };
57
- const cyFiles = [
58
- Object.assign(Object.assign({}, override), { files: [
59
- '*.cy.{ts,js,tsx,jsx}',
60
- `${options.cypressDir}/**/*.{ts,js,tsx,jsx}`,
61
- ] }),
62
- ];
58
+ const addCy6Override = cyVersion && cyVersion < 7;
63
59
  if (options.overwriteExisting) {
64
- json.overrides = [...globals, override];
60
+ overrides.push({
61
+ files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
62
+ parserOptions: !options.setParserOptionsProject
63
+ ? undefined
64
+ : {
65
+ project: `${projectConfig.root}/tsconfig.*?.json`,
66
+ },
67
+ rules: {},
68
+ });
69
+ if (addCy6Override) {
70
+ overrides.push(cy6Override);
71
+ }
72
+ (0, eslint_file_1.replaceOverridesInLintConfig)(tree, projectConfig.root, overrides);
65
73
  }
66
74
  else {
67
- json.overrides.push(...globals);
68
- json.overrides.push(...cyFiles);
69
- }
70
- const cyVersion = (0, cypress_version_1.installedCypressVersion)();
71
- if (cyVersion && cyVersion < 7) {
72
- /**
73
- * We need this override because we enabled allowJS in the tsconfig to allow for JS based Cypress tests.
74
- * That however leads to issues with the CommonJS Cypress plugin file.
75
- */
76
- json.overrides.push({
77
- files: [`${options.cypressDir}/plugins/index.js`],
78
- rules: {
79
- '@typescript-eslint/no-var-requires': 'off',
80
- 'no-undef': 'off',
81
- },
75
+ overrides.unshift({
76
+ files: [
77
+ '*.cy.{ts,js,tsx,jsx}',
78
+ `${options.cypressDir}/**/*.{ts,js,tsx,jsx}`,
79
+ ],
80
+ parserOptions: !options.setParserOptionsProject
81
+ ? undefined
82
+ : {
83
+ project: `${projectConfig.root}/tsconfig.*?.json`,
84
+ },
85
+ rules: {},
82
86
  });
87
+ if (addCy6Override) {
88
+ overrides.push(cy6Override);
89
+ }
90
+ overrides.forEach((override) => (0, eslint_file_1.addOverrideToLintConfig)(tree, projectConfig.root, override));
83
91
  }
84
- return json;
85
- });
92
+ }
86
93
  return (0, devkit_1.runTasksInSerial)(...tasks);
87
94
  });
88
95
  }