* feat(testing): add generator to aid in the migration to cypress 10 cypress 10 introduces a new configuration format and new layout that requires update settings and files for e2e projects * feat(testing): cypress component tests for react/next initial work for cypress component tests for react and next * feat(testing): add support for v10 e2e cypress projects create the correct files for cypress projects >v10 and reorganize tests based on version to allow easier parsing of tests * feat(testing): add utils for modifying cypress v10 config provide ts transformers to take in an existing cypress config and update/add properties within the given configuration * fix(testing): fix tests affected by the cypress v10 changes update tests to assert the correct files/folders/file contents due to the cypress changes in v10 * cleanup(testing): move cypress component testing plugins into the respective packages move the plugins into out of cypress plugins into the specific vertical plugin to prevent issues with circular refs * cleanup(testing): bump cypress version bump to latest cypress v10 release * docs(testing): update docs for cypress 10 update cypress docs to include info about component testing and migration to cypress v10 * fix(repo): revert cypress version bump keep v9 of cypress installed for nx repo until v10 release * fix(testing): update cypress gen tsconfig and infer targets with converter * fix(testing): make sure tests use the cypress v10 (for the intermediate) * fix(testing): update target name after feedback * fix(testing): support multiple target w/custom configs for cypress v10 migration * fix(testing): refactor cy component tests into seperate verticals * feat(testing): create storybook cypress preset * fix(testing): clean up cy v10 migration * fix(testing): don't branch for cypress executor testingType * fix(testing): move cy comp test generator to next * fix(testing): bump cypress deps * fix(testing): clean up cy component testing generators * fix(testing): update cy component testing docs * fix(testign): dep check. runtime plugin pulls from @nrwl/react * fix(testing): move e2e into verticals * fix(testing): address PR feedback * fix(testing): clean up unit tests * feat(angular): support migrating angular cli workspaces using cypress v10 * chore(testing): update e2e tests * fix(testing): address pr feedback * chore(testing): remove cypress component testing for next.js * fix(testing): address pr feedback Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
201 lines
5.1 KiB
TypeScript
201 lines
5.1 KiB
TypeScript
import * as depcheck from 'depcheck';
|
|
|
|
// Ignore packages that are defined here per package
|
|
const IGNORE_MATCHES = {
|
|
'*': [
|
|
'nx',
|
|
'@nrwl/cli',
|
|
'@nrwl/workspace',
|
|
'prettier',
|
|
'typescript',
|
|
'dotenv',
|
|
'rxjs',
|
|
],
|
|
angular: [
|
|
'@angular-devkit/architect',
|
|
'@angular-devkit/build-angular',
|
|
'@angular-devkit/core',
|
|
'@angular/compiler',
|
|
'@angular/compiler-cli',
|
|
'@angular/core',
|
|
'@angular/router',
|
|
'@ngrx/effects',
|
|
'@ngrx/router-store',
|
|
'@ngrx/store',
|
|
'@storybook/angular',
|
|
'rxjs',
|
|
'semver',
|
|
// installed dynamically by the library generator
|
|
'ng-packagr',
|
|
// ng-packagr deps, some are handled if not installed
|
|
'injection-js',
|
|
'browserslist',
|
|
'cacache',
|
|
'find-cache-dir',
|
|
'less',
|
|
'node-sass',
|
|
'node-sass-tilde-importer',
|
|
'ora',
|
|
'postcss',
|
|
'postcss-import',
|
|
'postcss-preset-env',
|
|
'postcss-url',
|
|
'sass',
|
|
'stylus',
|
|
'tailwindcss',
|
|
],
|
|
cli: ['nx'],
|
|
cypress: ['cypress', '@angular-devkit/schematics', '@nrwl/cypress'],
|
|
devkit: ['@angular-devkit/architect', 'rxjs'],
|
|
'eslint-plugin-nx': ['@angular-eslint/eslint-plugin'],
|
|
jest: [
|
|
'jest',
|
|
'@jest/types',
|
|
'identity-obj-proxy',
|
|
'@angular-devkit/schematics',
|
|
],
|
|
linter: [
|
|
'eslint',
|
|
'@angular-devkit/schematics',
|
|
'@angular-devkit/architect',
|
|
// Installed and uninstalled dynamically when the conversion generator runs
|
|
'tslint-to-eslint-config',
|
|
// Resolved from the end user's own workspace installation dynamically
|
|
'@typescript-eslint/eslint-plugin',
|
|
],
|
|
next: [
|
|
'@angular-devkit/architect',
|
|
'@nrwl/devkit',
|
|
'express',
|
|
'http-proxy-middleware',
|
|
'next',
|
|
'rxjs',
|
|
'tsconfig-paths-webpack-plugin',
|
|
'webpack',
|
|
],
|
|
react: [
|
|
'babel-plugin-emotion',
|
|
'babel-plugin-styled-components',
|
|
'rollup',
|
|
'webpack',
|
|
'@swc/jest',
|
|
'babel-jest',
|
|
'@angular-devkit/core',
|
|
'@angular-devkit/schematics',
|
|
// TODO(caleb): remove when refactoring plugin to use @nrwl/web
|
|
// webpack plugins for cypress component testing dev server
|
|
'babel-loader',
|
|
'css-loader',
|
|
'less-loader',
|
|
'sass',
|
|
'sass-loader',
|
|
'style-loader',
|
|
'stylus-loader',
|
|
'swc-loader',
|
|
'tsconfig-paths-webpack-plugin',
|
|
],
|
|
storybook: [
|
|
'@angular-devkit/architect',
|
|
'@angular-devkit/core',
|
|
'@angular-devkit/schematics',
|
|
'@storybook/addon-knobs',
|
|
'@storybook/addon-essentials',
|
|
'@storybook/core',
|
|
'@storybook/core-server',
|
|
'rxjs',
|
|
],
|
|
nx: [
|
|
'@angular-devkit/build-angular',
|
|
'@angular-devkit/schematics',
|
|
'@angular-devkit/core',
|
|
'@angular-devkit/architect',
|
|
'@angular/cli',
|
|
'ts-node', // We *may* fall back on ts-node, but we want to encourage the use of @swc-node instead so we don't explicitly list ts-node as an optional dep
|
|
],
|
|
web: [
|
|
// we don't want to bloat the install of @nrwl/web by including @swc/core and swc-loader as a dependency.
|
|
'@swc/core',
|
|
'swc-loader',
|
|
|
|
'fibers',
|
|
'node-sass',
|
|
],
|
|
workspace: [
|
|
'tslint',
|
|
'@angular-devkit/architect',
|
|
'@angular-devkit/core',
|
|
'@angular-devkit/schematics',
|
|
'webpack',
|
|
'webpack-dev-server',
|
|
'@nrwl/cli',
|
|
'@nrwl/jest',
|
|
'@nrwl/linter',
|
|
'tsconfig-paths',
|
|
],
|
|
nest: ['semver'],
|
|
'make-angular-cli-faster': ['@angular/core'],
|
|
};
|
|
|
|
export default async function getMissingDependencies(
|
|
name: string,
|
|
path: string,
|
|
dependencies: JSON,
|
|
verbose: boolean
|
|
) {
|
|
const options: any = {
|
|
/**
|
|
* If a dependency is exclusively used via a TypeScript type import
|
|
* e.g. `import type { Foo } from 'bar';`
|
|
* ...then we do not want it to trigger a missing dependency warning
|
|
* because it is not required at runtime.
|
|
*
|
|
* We can achieve this by overriding the default detector for
|
|
* ImportDeclaration nodes to check the `importKind` value.
|
|
*/
|
|
detectors: [
|
|
...Object.entries(depcheck.detector).map(([detectorName, detectorFn]) => {
|
|
// Use all the default detectors, apart from 'importDeclaration'
|
|
if (detectorName !== 'importDeclaration') {
|
|
return detectorFn;
|
|
}
|
|
const customImportDeclarationDetector: depcheck.Detector = (node) => {
|
|
return node.type === 'ImportDeclaration' &&
|
|
node.source &&
|
|
node.source.value &&
|
|
node.importKind !== 'type'
|
|
? [node.source.value]
|
|
: [];
|
|
};
|
|
return customImportDeclarationDetector;
|
|
}),
|
|
],
|
|
skipMissing: false, // skip calculation of missing dependencies
|
|
ignorePatterns: [
|
|
'*.d.ts',
|
|
'.eslintrc.json',
|
|
'*.spec*',
|
|
'src/schematics/**/files/**',
|
|
'src/migrations/**',
|
|
],
|
|
};
|
|
let { missing } = await depcheck(path, {
|
|
...options,
|
|
package: { dependencies },
|
|
});
|
|
|
|
const packagesMissing = Object.keys(missing).filter(
|
|
(m) =>
|
|
!IGNORE_MATCHES['*'].includes(m) &&
|
|
!(IGNORE_MATCHES[name] || []).includes(m)
|
|
);
|
|
|
|
if (verbose) {
|
|
console.log(`> ${name}`);
|
|
packagesMissing.map((p) => {
|
|
console.log(p, missing[p]);
|
|
});
|
|
}
|
|
|
|
return packagesMissing;
|
|
}
|