mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
test: use ng-dev to detect circular dependencies
With this change we use `ng-dev ts-circular-deps` to detect circular dependencies so that all repos in Angular org use the same tool.
This commit is contained in:
parent
37a06a7c37
commit
eb81121261
1
goldens/circular-deps/packages.json
Normal file
1
goldens/circular-deps/packages.json
Normal file
@ -0,0 +1 @@
|
||||
[]
|
@ -34,7 +34,9 @@
|
||||
"postinstall": "yarn webdriver-update && yarn ngcc && yarn husky install",
|
||||
"//webdriver-update-README": "ChromeDriver version must match Puppeteer Chromium version, see https://github.com/GoogleChrome/puppeteer/releases http://chromedriver.chromium.org/downloads",
|
||||
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 91.0.4472.19",
|
||||
"ngcc": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
|
||||
"ngcc": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points",
|
||||
"ts-circular-deps:check": "ng-dev ts-circular-deps check --config ./packages/circular-deps-test.conf.js",
|
||||
"ts-circular-deps:approve": "ng-dev ts-circular-deps approve --config ./packages/circular-deps-test.conf.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -218,7 +220,6 @@
|
||||
"ts-node": "^9.0.0",
|
||||
"tslib": "^2.0.0",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-no-circular-imports": "^0.7.0",
|
||||
"typescript": "4.2.4",
|
||||
"verdaccio": "5.0.4",
|
||||
"verdaccio-auth-memory": "^10.0.0",
|
||||
|
71
packages/circular-deps-test.conf.js
Normal file
71
packages/circular-deps-test.conf.js
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
baseDir: '../',
|
||||
goldenFile: '../goldens/circular-deps/packages.json',
|
||||
glob: './**/*.ts',
|
||||
// Command that will be displayed if the golden needs to be updated.
|
||||
approveCommand: 'yarn ts-circular-deps:approve',
|
||||
resolveModule: resolveModule,
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom module resolver that maps specifiers for local packages folder.
|
||||
* This ensures that cross package/entry-point dependencies can be detected.
|
||||
*/
|
||||
|
||||
const LOCAL_MAPPINGS = [
|
||||
['@angular-devkit/build-angular', 'angular_devkit/build_angular'],
|
||||
['@angular-devkit/architect', 'angular_devkit/architect'],
|
||||
['@angular-devkit/architect-cli', 'angular_devkit/architect_cli'],
|
||||
['@angular-devkit/benchmark', 'angular_devkit/benchmark'],
|
||||
['@angular-devkit/build-optimizer', 'angular_devkit/build_optimizer'],
|
||||
['@angular-devkit/build-webpack', 'angular_devkit/build_webpack'],
|
||||
['@angular-devkit/core', 'angular_devkit/core'],
|
||||
['@angular-devkit/schematics', 'angular_devkit/schematics'],
|
||||
['@angular-devkit/schematics_cli', 'angular_devkit/schematics_cli'],
|
||||
['@angular/cli', 'angular/cli'],
|
||||
['@schematics/angular', 'schematics/angular'],
|
||||
['@ngtools/webpack', 'ngtools/webpack'],
|
||||
];
|
||||
|
||||
function resolveModule(specifier) {
|
||||
let localSpecifierPath;
|
||||
|
||||
for (const [key, value] of LOCAL_MAPPINGS) {
|
||||
if (specifier.startsWith(key)) {
|
||||
localSpecifierPath = path.join(__dirname, specifier.replace(key, value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!localSpecifierPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const lookups = [
|
||||
localSpecifierPath,
|
||||
`${localSpecifierPath}.ts`,
|
||||
path.join(localSpecifierPath, 'src/index.ts'),
|
||||
path.join(localSpecifierPath, 'index.ts'),
|
||||
];
|
||||
|
||||
for (const lookup of lookups) {
|
||||
try {
|
||||
if (fs.statSync(lookup).isFile()) {
|
||||
return lookup;
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
// Consider using no-identical-functions and disabling in faulty tests
|
||||
// Consider using cognitive-complexity and refactor
|
||||
// Consider using no-useless-cast but it's annoying
|
||||
"extends": ["tslint-no-circular-imports"],
|
||||
"linterOptions": {
|
||||
"format": "codeFrame",
|
||||
"exclude": ["dist-schema/**", "**/third_party/**"]
|
||||
|
@ -10861,11 +10861,6 @@ tslib@^1.10.0, tslib@^1.13.0, tslib@^1.8.1, tslib@^1.9.0:
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
|
||||
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
|
||||
|
||||
tslint-no-circular-imports@^0.7.0:
|
||||
version "0.7.0"
|
||||
resolved "https://registry.yarnpkg.com/tslint-no-circular-imports/-/tslint-no-circular-imports-0.7.0.tgz#9df0a15654d66b172e0b7843eed073fa5ae99b5f"
|
||||
integrity sha512-k3wxpeMC4ef40UbpfBVHEHIzKfNZq5/SCtAO1YjGsaNTklo+K53/TWLrym+poA65RJFDiYgYNWvkeIIkJNA0Vw==
|
||||
|
||||
tslint@^6.1.3:
|
||||
version "6.1.3"
|
||||
resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.3.tgz#5c23b2eccc32487d5523bd3a470e9aa31789d904"
|
||||
|
Loading…
x
Reference in New Issue
Block a user