@nx/cypress 16.0.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/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/executors.json +16 -0
- package/generators.json +66 -0
- package/index.d.ts +5 -0
- package/index.js +14 -0
- package/index.js.map +1 -0
- package/migrations.json +53 -0
- package/package.json +59 -0
- package/plugins/cypress-preset.d.ts +62 -0
- package/plugins/cypress-preset.js +53 -0
- package/plugins/cypress-preset.js.map +1 -0
- package/src/executors/cypress/compat.d.ts +2 -0
- package/src/executors/cypress/compat.js +6 -0
- package/src/executors/cypress/compat.js.map +1 -0
- package/src/executors/cypress/cypress.impl.d.ts +40 -0
- package/src/executors/cypress/cypress.impl.js +372 -0
- package/src/executors/cypress/cypress.impl.js.map +1 -0
- package/src/executors/cypress/schema.json +158 -0
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.d.ts +4 -0
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +104 -0
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js.map +1 -0
- package/src/generators/convert-tslint-to-eslint/schema.json +44 -0
- package/src/generators/cypress-component-project/cypress-component-project.d.ts +4 -0
- package/src/generators/cypress-component-project/cypress-component-project.js +127 -0
- package/src/generators/cypress-component-project/cypress-component-project.js.map +1 -0
- package/src/generators/cypress-component-project/files/cypress/fixtures/example.json +5 -0
- package/src/generators/cypress-component-project/files/cypress/support/commands.ts__ext__ +34 -0
- package/src/generators/cypress-component-project/files/cypress/support/component-index.html +13 -0
- package/src/generators/cypress-component-project/files/cypress/support/component.ts__ext__ +17 -0
- package/src/generators/cypress-component-project/files/cypress/tsconfig.cy.json +17 -0
- package/src/generators/cypress-component-project/files/cypress.config.ts__ext__ +3 -0
- package/src/generators/cypress-component-project/schema.d.ts +5 -0
- package/src/generators/cypress-component-project/schema.json +33 -0
- package/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.d.ts +18 -0
- package/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.js +133 -0
- package/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.js.map +1 -0
- package/src/generators/cypress-e2e-configuration/files/v10/__dir__/e2e/app.cy.ts__tmpl__ +13 -0
- package/src/generators/cypress-e2e-configuration/files/v10/__dir__/fixtures/example.json__tmpl__ +4 -0
- package/src/generators/cypress-e2e-configuration/files/v10/__dir__/support/app.po.ts__tmpl__ +1 -0
- package/src/generators/cypress-e2e-configuration/files/v10/__dir__/support/commands.ts__tmpl__ +33 -0
- package/src/generators/cypress-e2e-configuration/files/v10/__dir__/support/e2e.ts__tmpl__ +17 -0
- package/src/generators/cypress-e2e-configuration/files/v10/cypress.config.ts__tmpl__ +9 -0
- package/src/generators/cypress-e2e-configuration/files/v10/tsconfig__tsFileExt__ +10 -0
- package/src/generators/cypress-e2e-configuration/files/v9/__dir__/fixtures/example.json__tmpl__ +4 -0
- package/src/generators/cypress-e2e-configuration/files/v9/__dir__/integration/app.spec.ts__tmpl__ +13 -0
- package/src/generators/cypress-e2e-configuration/files/v9/__dir__/plugins/index.js +22 -0
- package/src/generators/cypress-e2e-configuration/files/v9/__dir__/support/app.po.ts__tmpl__ +1 -0
- package/src/generators/cypress-e2e-configuration/files/v9/__dir__/support/commands.ts__tmpl__ +33 -0
- package/src/generators/cypress-e2e-configuration/files/v9/__dir__/support/index.ts__tmpl__ +17 -0
- package/src/generators/cypress-e2e-configuration/files/v9/cypress.json +12 -0
- package/src/generators/cypress-e2e-configuration/files/v9/tsconfig__tsFileExt__ +10 -0
- package/src/generators/cypress-e2e-configuration/schema.json +91 -0
- package/src/generators/cypress-project/cypress-project.d.ts +13 -0
- package/src/generators/cypress-project/cypress-project.js +172 -0
- package/src/generators/cypress-project/cypress-project.js.map +1 -0
- package/src/generators/cypress-project/files/v10-and-after/cypress.config.ts__tmpl__ +10 -0
- package/src/generators/cypress-project/files/v10-and-after/src/e2e/app.cy.ts__tmpl__ +13 -0
- package/src/generators/cypress-project/files/v10-and-after/src/fixtures/example.json__tmpl__ +4 -0
- package/src/generators/cypress-project/files/v10-and-after/src/support/app.po.ts__tmpl__ +1 -0
- package/src/generators/cypress-project/files/v10-and-after/src/support/commands.ts__tmpl__ +33 -0
- package/src/generators/cypress-project/files/v10-and-after/src/support/e2e.ts__tmpl__ +17 -0
- package/src/generators/cypress-project/files/v10-and-after/tsconfig.json +10 -0
- package/src/generators/cypress-project/files/v9-and-under/cypress.json +12 -0
- package/src/generators/cypress-project/files/v9-and-under/src/fixtures/example.json__tmpl__ +4 -0
- package/src/generators/cypress-project/files/v9-and-under/src/integration/app.spec.ts__tmpl__ +13 -0
- package/src/generators/cypress-project/files/v9-and-under/src/plugins/index.js +22 -0
- package/src/generators/cypress-project/files/v9-and-under/src/support/app.po.ts__tmpl__ +1 -0
- package/src/generators/cypress-project/files/v9-and-under/src/support/commands.ts__tmpl__ +33 -0
- package/src/generators/cypress-project/files/v9-and-under/src/support/index.ts__tmpl__ +17 -0
- package/src/generators/cypress-project/files/v9-and-under/tsconfig.json +10 -0
- package/src/generators/cypress-project/schema.d.ts +15 -0
- package/src/generators/cypress-project/schema.json +79 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +47 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +5 -0
- package/src/generators/init/schema.json +16 -0
- package/src/generators/migrate-to-cypress-11/conversion.util.d.ts +34 -0
- package/src/generators/migrate-to-cypress-11/conversion.util.js +241 -0
- package/src/generators/migrate-to-cypress-11/conversion.util.js.map +1 -0
- package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.d.ts +3 -0
- package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.js +85 -0
- package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.js.map +1 -0
- package/src/generators/migrate-to-cypress-11/schema.json +15 -0
- package/src/migrations/update-12-8-0/remove-typescript-plugin.d.ts +2 -0
- package/src/migrations/update-12-8-0/remove-typescript-plugin.js +89 -0
- package/src/migrations/update-12-8-0/remove-typescript-plugin.js.map +1 -0
- package/src/migrations/update-14-6-1/update-cypress-configs-presets.d.ts +3 -0
- package/src/migrations/update-14-6-1/update-cypress-configs-presets.js +111 -0
- package/src/migrations/update-14-6-1/update-cypress-configs-presets.js.map +1 -0
- package/src/migrations/update-14-7-0/update-cypress-version-if-10.d.ts +3 -0
- package/src/migrations/update-14-7-0/update-cypress-version-if-10.js +33 -0
- package/src/migrations/update-14-7-0/update-cypress-version-if-10.js.map +1 -0
- package/src/migrations/update-15-0-0/add-cypress-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-cypress-inputs.js +48 -0
- package/src/migrations/update-15-0-0/add-cypress-inputs.js.map +1 -0
- package/src/migrations/update-15-0-0/update-cy-mount-usage.d.ts +5 -0
- package/src/migrations/update-15-0-0/update-cy-mount-usage.js +124 -0
- package/src/migrations/update-15-0-0/update-cy-mount-usage.js.map +1 -0
- package/src/migrations/update-15-1-0/cypress-11.d.ts +6 -0
- package/src/migrations/update-15-1-0/cypress-11.js +118 -0
- package/src/migrations/update-15-1-0/cypress-11.js.map +1 -0
- package/src/migrations/update-15-5-0/helpers.d.ts +3 -0
- package/src/migrations/update-15-5-0/helpers.js +40 -0
- package/src/migrations/update-15-5-0/helpers.js.map +1 -0
- package/src/migrations/update-15-5-0/update-to-cypress-12.d.ts +24 -0
- package/src/migrations/update-15-5-0/update-to-cypress-12.js +183 -0
- package/src/migrations/update-15-5-0/update-to-cypress-12.js.map +1 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/plugins/preprocessor-vite.d.ts +32 -0
- package/src/plugins/preprocessor-vite.js +96 -0
- package/src/plugins/preprocessor-vite.js.map +1 -0
- package/src/utils/add-linter.d.ts +21 -0
- package/src/utils/add-linter.js +90 -0
- package/src/utils/add-linter.js.map +1 -0
- package/src/utils/ct-helpers.d.ts +16 -0
- package/src/utils/ct-helpers.js +86 -0
- package/src/utils/ct-helpers.js.map +1 -0
- package/src/utils/cypress-version.d.ts +5 -0
- package/src/utils/cypress-version.js +34 -0
- package/src/utils/cypress-version.js.map +1 -0
- package/src/utils/find-target-options.d.ts +16 -0
- package/src/utils/find-target-options.js +115 -0
- package/src/utils/find-target-options.js.map +1 -0
- package/src/utils/project-name.d.ts +3 -0
- package/src/utils/project-name.js +20 -0
- package/src/utils/project-name.js.map +1 -0
- package/src/utils/versions.d.ts +9 -0
- package/src/utils/versions.js +13 -0
- package/src/utils/versions.js.map +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BANNED_COMMANDS = exports.isAlreadyCommented = void 0;
|
|
4
|
+
function isAlreadyCommented(node) {
|
|
5
|
+
return node.getFullText().includes('TODO(@nrwl/cypress)');
|
|
6
|
+
}
|
|
7
|
+
exports.isAlreadyCommented = isAlreadyCommented;
|
|
8
|
+
exports.BANNED_COMMANDS = [
|
|
9
|
+
'as',
|
|
10
|
+
'children',
|
|
11
|
+
'closest',
|
|
12
|
+
'contains',
|
|
13
|
+
'debug',
|
|
14
|
+
'document',
|
|
15
|
+
'eq',
|
|
16
|
+
'filter',
|
|
17
|
+
'find',
|
|
18
|
+
'first',
|
|
19
|
+
'focused',
|
|
20
|
+
'get',
|
|
21
|
+
'hash',
|
|
22
|
+
'its',
|
|
23
|
+
'last',
|
|
24
|
+
'location',
|
|
25
|
+
'next',
|
|
26
|
+
'nextAll',
|
|
27
|
+
'not',
|
|
28
|
+
'parent',
|
|
29
|
+
'parents',
|
|
30
|
+
'parentsUntil',
|
|
31
|
+
'prev',
|
|
32
|
+
'prevUntil',
|
|
33
|
+
'root',
|
|
34
|
+
'shadow',
|
|
35
|
+
'siblings',
|
|
36
|
+
'title',
|
|
37
|
+
'url',
|
|
38
|
+
'window',
|
|
39
|
+
];
|
|
40
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-15-5-0/helpers.ts"],"names":[],"mappings":";;;AAEA,SAAgB,kBAAkB,CAAC,IAAU;IAC3C,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAC5D,CAAC;AAFD,gDAEC;AAEY,QAAA,eAAe,GAAG;IAC7B,IAAI;IACJ,UAAU;IACV,SAAS;IACT,UAAU;IACV,OAAO;IACP,UAAU;IACV,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,OAAO;IACP,SAAS;IACT,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,UAAU;IACV,MAAM;IACN,SAAS;IACT,KAAK;IACL,QAAQ;IACR,SAAS;IACT,cAAc;IACd,MAAM;IACN,WAAW;IACX,MAAM;IACN,QAAQ;IACR,UAAU;IACV,OAAO;IACP,KAAK;IACL,QAAQ;CACT,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
export declare function updateToCypress12(tree: Tree): GeneratorCallback;
|
|
3
|
+
export declare function turnOffTestIsolation(tree: Tree, configPath: string): void;
|
|
4
|
+
/**
|
|
5
|
+
* Leave a comment on all apis that have been removed andsuperseded by cy.intercept
|
|
6
|
+
* stating they these API are now removed and need to update.
|
|
7
|
+
* cy.route, cy.server, Cypress.Server.defaults
|
|
8
|
+
**/
|
|
9
|
+
export declare function shouldUseCyIntercept(tree: Tree, filePath: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Leave a comment on all apis that have been removed and superseded by cy.session
|
|
12
|
+
* stating they these API are now removed and need to update.
|
|
13
|
+
* Cypress.Cookies.defaults & Cypress.Cookies.preserveOnce
|
|
14
|
+
**/
|
|
15
|
+
export declare function shouldUseCySession(tree: Tree, filePath: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* leave a comment about nested cy commands in a cy.should callback
|
|
18
|
+
* */
|
|
19
|
+
export declare function shouldNotUseCyInShouldCB(tree: Tree, filePath: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* leave a comment on all usages of overriding built-ins that are now banned
|
|
22
|
+
* */
|
|
23
|
+
export declare function shouldNotOverrideCommands(tree: Tree, filePath: string): void;
|
|
24
|
+
export default updateToCypress12;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldNotOverrideCommands = exports.shouldNotUseCyInShouldCB = exports.shouldUseCySession = exports.shouldUseCyIntercept = exports.turnOffTestIsolation = exports.updateToCypress12 = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const typescript_1 = require("typescript");
|
|
8
|
+
const cypress_version_1 = require("../../utils/cypress-version");
|
|
9
|
+
const helpers_1 = require("./helpers");
|
|
10
|
+
const JS_TS_FILE_MATCHER = /\.[jt]sx?$/;
|
|
11
|
+
function updateToCypress12(tree) {
|
|
12
|
+
if ((0, cypress_version_1.installedCypressVersion)() < 11) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
16
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/cypress:cypress', (options, projectName, targetName, configName) => {
|
|
17
|
+
if (!(options.cypressConfig && tree.exists(options.cypressConfig))) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const projectConfig = projects.get(projectName);
|
|
21
|
+
turnOffTestIsolation(tree, options.cypressConfig);
|
|
22
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
23
|
+
if (!JS_TS_FILE_MATCHER.test(filePath)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
shouldUseCyIntercept(tree, filePath);
|
|
27
|
+
shouldUseCySession(tree, filePath);
|
|
28
|
+
shouldNotUseCyInShouldCB(tree, filePath);
|
|
29
|
+
shouldNotOverrideCommands(tree, filePath);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
console.warn((0, devkit_1.stripIndents) `Cypress 12 has lots of breaking changes that might subtly break your tests.
|
|
33
|
+
This migration marked known issues that need to be manually migrated,
|
|
34
|
+
but there can still be runtime based errors that were not detected.
|
|
35
|
+
Please consult the offical Cypress v12 migration guide for more info on these changes and the next steps.
|
|
36
|
+
https://docs.cypress.io/guides/references/migration-guide
|
|
37
|
+
`);
|
|
38
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
39
|
+
json.devDependencies.cypress = '^12.2.0';
|
|
40
|
+
return json;
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.updateToCypress12 = updateToCypress12;
|
|
47
|
+
function turnOffTestIsolation(tree, configPath) {
|
|
48
|
+
const config = tree.read(configPath, 'utf-8');
|
|
49
|
+
const isTestIsolationSet = tsquery_1.tsquery.query(config, 'ExportAssignment ObjectLiteralExpression > PropertyAssignment:has(Identifier[name="testIsolation"])');
|
|
50
|
+
if (isTestIsolationSet.length > 0) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const testIsolationProperty = `/**
|
|
54
|
+
* TODO(@nrwl/cypress): In Cypress v12,the testIsolation option is turned on by default.
|
|
55
|
+
* This can cause tests to start breaking where not indended.
|
|
56
|
+
* You should consider enabling this once you verify tests do not depend on each other
|
|
57
|
+
* More Info: https://docs.cypress.io/guides/references/migration-guide#Test-Isolation
|
|
58
|
+
**/
|
|
59
|
+
testIsolation: false,`;
|
|
60
|
+
const updated = tsquery_1.tsquery.replace(config, 'ExportAssignment ObjectLiteralExpression > PropertyAssignment:has(Identifier[name="e2e"])', (node) => {
|
|
61
|
+
if ((0, typescript_1.isObjectLiteralExpression)(node.initializer)) {
|
|
62
|
+
const listOfProperties = node.initializer.properties
|
|
63
|
+
.map((j) => j.getText())
|
|
64
|
+
.join(',\n ');
|
|
65
|
+
return `e2e: {
|
|
66
|
+
${listOfProperties},
|
|
67
|
+
${testIsolationProperty}
|
|
68
|
+
}`;
|
|
69
|
+
}
|
|
70
|
+
return `e2e: {
|
|
71
|
+
...${node.initializer.getText()},
|
|
72
|
+
${testIsolationProperty}
|
|
73
|
+
}`;
|
|
74
|
+
});
|
|
75
|
+
tree.write(configPath, updated);
|
|
76
|
+
}
|
|
77
|
+
exports.turnOffTestIsolation = turnOffTestIsolation;
|
|
78
|
+
/**
|
|
79
|
+
* Leave a comment on all apis that have been removed andsuperseded by cy.intercept
|
|
80
|
+
* stating they these API are now removed and need to update.
|
|
81
|
+
* cy.route, cy.server, Cypress.Server.defaults
|
|
82
|
+
**/
|
|
83
|
+
function shouldUseCyIntercept(tree, filePath) {
|
|
84
|
+
const content = tree.read(filePath, 'utf-8');
|
|
85
|
+
const markedRemovedCommands = tsquery_1.tsquery.replace(content, ':matches(PropertyAccessExpression:has(Identifier[name="cy"]):has(Identifier[name="server"], Identifier[name="route"]), PropertyAccessExpression:has(Identifier[name="defaults"]):has(Identifier[name="Cypress"], Identifier[name="Server"]))', (node) => {
|
|
86
|
+
if ((0, helpers_1.isAlreadyCommented)(node)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const expression = node.expression.getText().trim();
|
|
90
|
+
// prevent extra chaining i.e. cy.route().as() will return 2 results
|
|
91
|
+
// cy.route and cy.route().as
|
|
92
|
+
// only need the first 1 so skip any extra chaining
|
|
93
|
+
if (expression === 'cy' || expression === 'Cypress.Server') {
|
|
94
|
+
return `// TODO(@nrwl/cypress): this command has been removed, use cy.intercept instead. https://docs.cypress.io/guides/references/migration-guide#cy-server-cy-route-and-Cypress-Server-defaults
|
|
95
|
+
${node.getText()}`;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
tree.write(filePath, markedRemovedCommands);
|
|
99
|
+
}
|
|
100
|
+
exports.shouldUseCyIntercept = shouldUseCyIntercept;
|
|
101
|
+
/**
|
|
102
|
+
* Leave a comment on all apis that have been removed and superseded by cy.session
|
|
103
|
+
* stating they these API are now removed and need to update.
|
|
104
|
+
* Cypress.Cookies.defaults & Cypress.Cookies.preserveOnce
|
|
105
|
+
**/
|
|
106
|
+
function shouldUseCySession(tree, filePath) {
|
|
107
|
+
const content = tree.read(filePath, 'utf-8');
|
|
108
|
+
const markedRemovedCommands = tsquery_1.tsquery.replace(content, ':matches(PropertyAccessExpression:has(Identifier[name="defaults"]):has(Identifier[name="Cypress"], Identifier[name="Cookies"]), PropertyAccessExpression:has(Identifier[name="preserveOnce"]):has(Identifier[name="Cypress"], Identifier[name="Cookies"]))', (node) => {
|
|
109
|
+
if ((0, helpers_1.isAlreadyCommented)(node)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const expression = node.expression.getText().trim();
|
|
113
|
+
// prevent grabbing other Cypress.<something>.defaults
|
|
114
|
+
if (expression === 'Cypress.Cookies') {
|
|
115
|
+
return `// TODO(@nrwl/cypress): this command has been removed, use cy.session instead. https://docs.cypress.io/guides/references/migration-guide#Command-Cypress-API-Changes
|
|
116
|
+
${node.getText()}`;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
tree.write(filePath, markedRemovedCommands);
|
|
120
|
+
}
|
|
121
|
+
exports.shouldUseCySession = shouldUseCySession;
|
|
122
|
+
/**
|
|
123
|
+
* leave a comment about nested cy commands in a cy.should callback
|
|
124
|
+
* */
|
|
125
|
+
function shouldNotUseCyInShouldCB(tree, filePath) {
|
|
126
|
+
const content = tree.read(filePath, 'utf-8');
|
|
127
|
+
const markedNestedCyCommands = tsquery_1.tsquery.replace(content, 'CallExpression > PropertyAccessExpression:has(Identifier[name="cy"]):has(Identifier[name="should"])', (node) => {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
if ((0, helpers_1.isAlreadyCommented)(node) ||
|
|
130
|
+
(node.parent && !(0, typescript_1.isCallExpression)(node.parent))) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const parentExpression = node.parent;
|
|
134
|
+
if (((_a = parentExpression === null || parentExpression === void 0 ? void 0 : parentExpression.arguments) === null || _a === void 0 ? void 0 : _a[0]) &&
|
|
135
|
+
((0, typescript_1.isArrowFunction)(parentExpression.arguments[0]) ||
|
|
136
|
+
(0, typescript_1.isFunctionExpression)(parentExpression.arguments[0]))) {
|
|
137
|
+
const isUsingNestedCyCommand = ((_b = tsquery_1.tsquery.query(parentExpression.arguments[0], 'CallExpression > PropertyAccessExpression:has(Identifier[name="cy"])')) === null || _b === void 0 ? void 0 : _b.length) > 0;
|
|
138
|
+
if (isUsingNestedCyCommand) {
|
|
139
|
+
return `/**
|
|
140
|
+
* TODO(@nrwl/cypress): Nesting Cypress commands in a should assertion now throws.
|
|
141
|
+
* You should use .then() to chain commands instead.
|
|
142
|
+
* More Info: https://docs.cypress.io/guides/references/migration-guide#-should
|
|
143
|
+
**/
|
|
144
|
+
${node.getText()}`;
|
|
145
|
+
}
|
|
146
|
+
return node.getText();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
tree.write(filePath, markedNestedCyCommands);
|
|
150
|
+
}
|
|
151
|
+
exports.shouldNotUseCyInShouldCB = shouldNotUseCyInShouldCB;
|
|
152
|
+
/**
|
|
153
|
+
* leave a comment on all usages of overriding built-ins that are now banned
|
|
154
|
+
* */
|
|
155
|
+
function shouldNotOverrideCommands(tree, filePath) {
|
|
156
|
+
const content = tree.read(filePath, 'utf-8');
|
|
157
|
+
const markedOverrideUsage = tsquery_1.tsquery.replace(content, 'PropertyAccessExpression:has(Identifier[name="overwrite"]):has(Identifier[name="Cypress"])', (node) => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
if ((0, helpers_1.isAlreadyCommented)(node)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const expression = node.expression.getText().trim();
|
|
163
|
+
// prevent grabbing other Cypress.<something>.defaults
|
|
164
|
+
if (expression === 'Cypress.Commands') {
|
|
165
|
+
// get value.
|
|
166
|
+
const overwriteExpression = node.parent;
|
|
167
|
+
const command = (_b = (_a = overwriteExpression.arguments) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text; // need string without quotes
|
|
168
|
+
if (helpers_1.BANNED_COMMANDS.includes(command)) {
|
|
169
|
+
// overwrite
|
|
170
|
+
return `/**
|
|
171
|
+
* TODO(@nrwl/cypress): This command can no longer be overridden
|
|
172
|
+
* Consider using a different name like 'custom_${command}'
|
|
173
|
+
* More info: https://docs.cypress.io/guides/references/migration-guide#Cypress-Commands-overwrite
|
|
174
|
+
**/
|
|
175
|
+
${node.getText()}`;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
tree.write(filePath, markedOverrideUsage);
|
|
180
|
+
}
|
|
181
|
+
exports.shouldNotOverrideCommands = shouldNotOverrideCommands;
|
|
182
|
+
exports.default = updateToCypress12;
|
|
183
|
+
//# sourceMappingURL=update-to-cypress-12.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-to-cypress-12.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-15-5-0/update-to-cypress-12.ts"],"names":[],"mappings":";;;AAAA,uCAQoB;AACpB,6FAA0F;AAC1F,uDAAoD;AACpD,2CAQoB;AAEpB,iEAAsE;AACtE,uCAAgE;AAEhE,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAExC,SAAgB,iBAAiB,CAAC,IAAU;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AAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;QACpD,sDAAsD;QAEtD,IAAI,UAAU,KAAK,kBAAkB,EAAE;YACrC,aAAa;YACb,MAAM,mBAAmB,GAAG,IAAI,CAAC,MAAwB,CAAC;YAE1D,MAAM,OAAO,GAAG,MAAC,MAAA,mBAAmB,CAAC,SAAS,0CAAG,CAAC,CAAS,0CAAE,IAAI,CAAC,CAAC,6BAA6B;YAChG,IAAI,yBAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACrC,YAAY;gBACZ,OAAO;;iDAEgC,OAAO;;;EAGtD,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;aACV;SACF;IACH,CAAC,CACF,CAAC;IAEF,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;AAC5C,CAAC;AA/BD,8DA+BC;AAED,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
+
function replacePackage(tree) {
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
yield (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/cypress', '@nx/cypress');
|
|
9
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
exports.default = replacePackage;
|
|
13
|
+
//# sourceMappingURL=update-16-0-0-add-nx-packages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-16-0-0-add-nx-packages.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,0EAAuF;AAEvF,SAA8B,cAAc,CAAC,IAAU;;QACrD,MAAM,IAAA,iDAA+B,EAAC,IAAI,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;QAE5E,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAJD,iCAIC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://github.com/mammadataei/cypress-vite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2022 Mohammad Ataei
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
9
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
10
|
+
* the Software without restriction, including without limitation the rights to
|
|
11
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
12
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
20
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
21
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
22
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
23
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
**/
|
|
25
|
+
type CypressPreprocessor = (file: Record<string, any>) => string | Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Use Vite as a file preprocess for Cypress test files.
|
|
28
|
+
* This preprocessor shouldn't be used directly.
|
|
29
|
+
* Instead, use the nxE2EPreset(__filename, { bundler: 'vite' }) function instead.
|
|
30
|
+
*/
|
|
31
|
+
declare function vitePreprocessor(userConfigPath?: string): CypressPreprocessor;
|
|
32
|
+
export default vitePreprocessor;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/mammadataei/cypress-vite
|
|
4
|
+
*
|
|
5
|
+
* MIT License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2022 Mohammad Ataei
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
10
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
11
|
+
* the Software without restriction, including without limitation the rights to
|
|
12
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
13
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
14
|
+
* subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
21
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
22
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
23
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
24
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
**/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const path_1 = require("path");
|
|
29
|
+
const cache = new Map();
|
|
30
|
+
/**
|
|
31
|
+
* Use Vite as a file preprocess for Cypress test files.
|
|
32
|
+
* This preprocessor shouldn't be used directly.
|
|
33
|
+
* Instead, use the nxE2EPreset(__filename, { bundler: 'vite' }) function instead.
|
|
34
|
+
*/
|
|
35
|
+
function vitePreprocessor(userConfigPath) {
|
|
36
|
+
return (file) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { outputPath, filePath, shouldWatch } = file;
|
|
38
|
+
if (cache.has(filePath)) {
|
|
39
|
+
return cache.get(filePath);
|
|
40
|
+
}
|
|
41
|
+
const fileName = (0, path_1.basename)(outputPath);
|
|
42
|
+
const filenameWithoutExtension = (0, path_1.basename)(outputPath, (0, path_1.extname)(outputPath));
|
|
43
|
+
const defaultConfig = {
|
|
44
|
+
logLevel: 'silent',
|
|
45
|
+
define: {
|
|
46
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
47
|
+
},
|
|
48
|
+
build: {
|
|
49
|
+
emptyOutDir: false,
|
|
50
|
+
minify: false,
|
|
51
|
+
outDir: (0, path_1.dirname)(outputPath),
|
|
52
|
+
sourcemap: true,
|
|
53
|
+
write: true,
|
|
54
|
+
watch: getWatcherConfig(shouldWatch),
|
|
55
|
+
lib: {
|
|
56
|
+
entry: filePath,
|
|
57
|
+
fileName: () => fileName,
|
|
58
|
+
formats: ['umd'],
|
|
59
|
+
name: filenameWithoutExtension,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
cache.set(filePath, outputPath);
|
|
64
|
+
const { build } = require('vite');
|
|
65
|
+
const watcher = (yield build(Object.assign({ configFile: userConfigPath }, defaultConfig)));
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
if (shouldWatch && isWatcher(watcher)) {
|
|
68
|
+
watcher.on('event', (event) => {
|
|
69
|
+
if (event.code === 'END') {
|
|
70
|
+
resolve(outputPath);
|
|
71
|
+
file.emit('rerun');
|
|
72
|
+
}
|
|
73
|
+
if (event.code === 'ERROR') {
|
|
74
|
+
console.error(event);
|
|
75
|
+
reject(new Error(event.error.message));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
file.on('close', () => {
|
|
79
|
+
cache.delete(filePath);
|
|
80
|
+
watcher.close();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
resolve(outputPath);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function isWatcher(maybeWatcher) {
|
|
90
|
+
return maybeWatcher.on !== undefined;
|
|
91
|
+
}
|
|
92
|
+
function getWatcherConfig(shouldWatch) {
|
|
93
|
+
return shouldWatch ? {} : null;
|
|
94
|
+
}
|
|
95
|
+
exports.default = vitePreprocessor;
|
|
96
|
+
//# sourceMappingURL=preprocessor-vite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocessor-vite.js","sourceRoot":"","sources":["../../../../../packages/cypress/src/plugins/preprocessor-vite.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;IAuBI;;;AAEJ,+BAAkD;AAUlD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;AAExC;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,cAAuB;IAC/C,OAAO,CAAO,IAAI,EAAE,EAAE;QACpB,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAEnD,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACvB,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,C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,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;qBACpB;oBAED,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;wBAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;wBACrB,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;qBACxC;gBACH,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;oBACpB,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACvB,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC,UAAU,CAAC,CAAC;aACrB;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,YAAiB;IAClC,OAAO,YAAY,CAAC,EAAE,KAAK,SAAS,CAAC;AACvC,CAAC;AAED,SAAS,gBAAgB,CAAC,WAAoB;IAC5C,OAAO,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,kBAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Linter } from '@nx/linter';
|
|
3
|
+
export interface CyLinterOptions {
|
|
4
|
+
project: string;
|
|
5
|
+
linter: Linter;
|
|
6
|
+
setParserOptionsProject?: boolean;
|
|
7
|
+
skipPackageJson?: boolean;
|
|
8
|
+
rootProject?: boolean;
|
|
9
|
+
js?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Directory from the project root, where the cypress files will be located.
|
|
12
|
+
* typically src/ or cypress/
|
|
13
|
+
**/
|
|
14
|
+
cypressDir: string;
|
|
15
|
+
/**
|
|
16
|
+
* overwrite existing eslint rules for the cypress defaults
|
|
17
|
+
* This is useful when adding linting to a brand new project vs an existing one
|
|
18
|
+
**/
|
|
19
|
+
overwriteExisting?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function addLinterToCyProject(tree: Tree, options: CyLinterOptions): Promise<GeneratorCallback>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addLinterToCyProject = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const linter_1 = require("@nx/linter");
|
|
7
|
+
const global_eslint_config_1 = require("@nx/linter/src/generators/init/global-eslint-config");
|
|
8
|
+
const cypress_version_1 = require("./cypress-version");
|
|
9
|
+
const versions_1 = require("./versions");
|
|
10
|
+
function addLinterToCyProject(tree, options) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
if (options.linter === linter_1.Linter.None) {
|
|
13
|
+
return () => { };
|
|
14
|
+
}
|
|
15
|
+
const tasks = [];
|
|
16
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
17
|
+
if (!tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, '.eslintrc.json'))) {
|
|
18
|
+
tasks.push(yield (0, linter_1.lintProjectGenerator)(tree, {
|
|
19
|
+
project: options.project,
|
|
20
|
+
linter: options.linter,
|
|
21
|
+
skipFormat: true,
|
|
22
|
+
tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
|
|
23
|
+
eslintFilePatterns: [
|
|
24
|
+
`${projectConfig.root}/**/*.${options.js ? 'js' : '{js,ts}'}`,
|
|
25
|
+
],
|
|
26
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
27
|
+
skipPackageJson: options.skipPackageJson,
|
|
28
|
+
rootProject: options.rootProject,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
if (!options.linter || options.linter !== linter_1.Linter.EsLint) {
|
|
32
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
33
|
+
}
|
|
34
|
+
tasks.push(!options.skipPackageJson
|
|
35
|
+
? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'eslint-plugin-cypress': versions_1.eslintPluginCypressVersion })
|
|
36
|
+
: () => { });
|
|
37
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectConfig.root, '.eslintrc.json'), (json) => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (options.rootProject) {
|
|
40
|
+
json.plugins = ['@nrwl/nx'];
|
|
41
|
+
json.extends = ['plugin:cypress/recommended'];
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
json.extends = ['plugin:cypress/recommended', ...json.extends];
|
|
45
|
+
}
|
|
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: {},
|
|
56
|
+
};
|
|
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
|
+
];
|
|
63
|
+
if (options.overwriteExisting) {
|
|
64
|
+
json.overrides = [...globals, override];
|
|
65
|
+
}
|
|
66
|
+
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
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return json;
|
|
85
|
+
});
|
|
86
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.addLinterToCyProject = addLinterToCyProject;
|
|
90
|
+
//# sourceMappingURL=add-linter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-linter.js","sourceRoot":"","sources":["../../../../../packages/cypress/src/utils/add-linter.ts"],"names":[],"mappings":";;;;AAAA,uCAQoB;AACpB,uCAA0D;AAC1D,8FAAgG;AAChG,uDAA4D;AAC5D,yCAAwD;AAqBxD,SAAsB,oBAAoB,CACxC,IAAU,EACV,OAAwB;;QAExB,IAAI,OAAO,CAAC,MAAM,KAAK,eAAM,CAAC,IAAI,EAAE;YAClC,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;SACjB;QAED,MAAM,KAAK,GAAwB,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAEtE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,aAAa,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,EAAE;YACzE,KAAK,CAAC,IAAI,CACR,MAAM,IAAA,6BAAoB,EAAC,IAAI,EAAE;gBAC/B,OAAO,EAAE,O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CAAC,CAAC;IACpC,CAAC;CAAA;AAlGD,oDAkGC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExecutorContext, ProjectGraph } from '@nx/devkit';
|
|
2
|
+
import { ProjectConfiguration, TargetConfiguration } from '@nx/devkit';
|
|
3
|
+
export declare const CY_FILE_MATCHER: RegExp;
|
|
4
|
+
/**
|
|
5
|
+
* return a path to a temp css file
|
|
6
|
+
* temp file is scoped to the project root
|
|
7
|
+
* i.e. <context.root>/tmp/<project-root>/ct-styles.css
|
|
8
|
+
*/
|
|
9
|
+
export declare function getTempTailwindPath(context: ExecutorContext): string;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the childProjectName is a descendent of the parentProjectName
|
|
12
|
+
* in the project graph
|
|
13
|
+
**/
|
|
14
|
+
export declare function isCtProjectUsingBuildProject(graph: ProjectGraph, parentProjectName: string, childProjectName: string): boolean;
|
|
15
|
+
export declare function getProjectConfigByPath(graph: ProjectGraph, configPath: string): ProjectConfiguration;
|
|
16
|
+
export declare function createExecutorContext(graph: ProjectGraph, targets: Record<string, TargetConfiguration>, projectName: string, targetName: string, configurationName: string): ExecutorContext;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createExecutorContext = exports.getProjectConfigByPath = exports.isCtProjectUsingBuildProject = exports.getTempTailwindPath = exports.CY_FILE_MATCHER = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
8
|
+
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
9
|
+
const file_utils_1 = require("nx/src/project-graph/file-utils");
|
|
10
|
+
exports.CY_FILE_MATCHER = new RegExp(/\.cy\.[tj]sx?$/);
|
|
11
|
+
/**
|
|
12
|
+
* return a path to a temp css file
|
|
13
|
+
* temp file is scoped to the project root
|
|
14
|
+
* i.e. <context.root>/tmp/<project-root>/ct-styles.css
|
|
15
|
+
*/
|
|
16
|
+
function getTempTailwindPath(context) {
|
|
17
|
+
var _a;
|
|
18
|
+
if (!context.projectName) {
|
|
19
|
+
throw new Error('No project name found in context');
|
|
20
|
+
}
|
|
21
|
+
const project = context === null || context === void 0 ? void 0 : context.projectGraph.nodes[context.projectName];
|
|
22
|
+
if (!project) {
|
|
23
|
+
throw new Error(`No project found in project graph for ${context.projectName}`);
|
|
24
|
+
}
|
|
25
|
+
if ((_a = project === null || project === void 0 ? void 0 : project.data) === null || _a === void 0 ? void 0 : _a.root) {
|
|
26
|
+
return (0, path_1.join)(context.root, 'tmp', project.data.root, 'ct-styles.css');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.getTempTailwindPath = getTempTailwindPath;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if the childProjectName is a descendent of the parentProjectName
|
|
32
|
+
* in the project graph
|
|
33
|
+
**/
|
|
34
|
+
function isCtProjectUsingBuildProject(graph, parentProjectName, childProjectName) {
|
|
35
|
+
const isProjectDirectDep = graph.dependencies[parentProjectName].some((p) => p.target === childProjectName);
|
|
36
|
+
if (isProjectDirectDep) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const maybeIntermediateProjects = graph.dependencies[parentProjectName].filter((p) => !graph.externalNodes[p.target]);
|
|
40
|
+
for (const maybeIntermediateProject of maybeIntermediateProjects) {
|
|
41
|
+
if (isCtProjectUsingBuildProject(graph, maybeIntermediateProject.target, childProjectName)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
exports.isCtProjectUsingBuildProject = isCtProjectUsingBuildProject;
|
|
48
|
+
function getProjectConfigByPath(graph, configPath) {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
var _d;
|
|
51
|
+
const configFileFromWorkspaceRoot = (0, path_1.relative)(devkit_1.workspaceRoot, configPath);
|
|
52
|
+
const normalizedPathFromWorkspaceRoot = (0, devkit_1.normalizePath)((0, fs_1.lstatSync)(configPath).isFile()
|
|
53
|
+
? configFileFromWorkspaceRoot.replace((0, path_1.extname)(configPath), '')
|
|
54
|
+
: configFileFromWorkspaceRoot);
|
|
55
|
+
const projectRootMappings = (0, find_project_for_path_1.createProjectRootMappings)(graph.nodes);
|
|
56
|
+
const componentTestingProjectName = (0, find_project_for_path_1.findProjectForPath)(normalizedPathFromWorkspaceRoot, projectRootMappings);
|
|
57
|
+
if (!componentTestingProjectName ||
|
|
58
|
+
!((_a = graph.nodes[componentTestingProjectName]) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
59
|
+
throw new Error((0, devkit_1.stripIndents) `Unable to find the project configuration that includes ${normalizedPathFromWorkspaceRoot}.
|
|
60
|
+
Found project name? ${componentTestingProjectName}.
|
|
61
|
+
Graph has data? ${!!((_b = graph.nodes[componentTestingProjectName]) === null || _b === void 0 ? void 0 : _b.data)}`);
|
|
62
|
+
}
|
|
63
|
+
// make sure name is set since it can be undefined
|
|
64
|
+
(_c = (_d = graph.nodes[componentTestingProjectName].data).name) !== null && _c !== void 0 ? _c : (_d.name = componentTestingProjectName);
|
|
65
|
+
return graph.nodes[componentTestingProjectName].data;
|
|
66
|
+
}
|
|
67
|
+
exports.getProjectConfigByPath = getProjectConfigByPath;
|
|
68
|
+
function createExecutorContext(graph, targets, projectName, targetName, configurationName) {
|
|
69
|
+
const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(graph);
|
|
70
|
+
const nxJsonConfiguration = (0, file_utils_1.readNxJson)();
|
|
71
|
+
return {
|
|
72
|
+
cwd: process.cwd(),
|
|
73
|
+
projectGraph: graph,
|
|
74
|
+
target: targets[targetName],
|
|
75
|
+
targetName,
|
|
76
|
+
configurationName,
|
|
77
|
+
root: devkit_1.workspaceRoot,
|
|
78
|
+
isVerbose: false,
|
|
79
|
+
projectName,
|
|
80
|
+
projectsConfigurations,
|
|
81
|
+
nxJsonConfiguration,
|
|
82
|
+
workspace: Object.assign(Object.assign({}, nxJsonConfiguration), projectsConfigurations),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
exports.createExecutorContext = createExecutorContext;
|
|
86
|
+
//# sourceMappingURL=ct-helpers.js.map
|