[SIEM][Lists] Adds circular dependency checker for lists plugin

## Summary

* Added dependency checker for the public and common folders for lists
This commit is contained in:
Frank Hassanabad 2020-05-28 16:45:29 -06:00 committed by GitHub
parent 7f2e32475a
commit 957915b7e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 0 deletions

View file

@ -21,6 +21,12 @@ if [[ -z "$CODE_COVERAGE" ]] ; then
echo ""
echo ""
echo " -> Running List cyclic dependency test"
cd "$XPACK_DIR"
checks-reporter-with-killswitch "X-Pack List cyclic dependency test" node plugins/lists/scripts/check_circular_deps
echo ""
echo ""
# echo " -> Running jest integration tests"
# cd "$XPACK_DIR"
# node scripts/jest_integration --ci --verbose

View file

@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
require('../../../../src/setup_node_env');
require('./check_circular_deps/run_check_circular_deps_cli');

View file

@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { resolve } from 'path';
// @ts-ignore
import madge from 'madge';
import { createFailError, run } from '@kbn/dev-utils';
run(
async ({ log }) => {
const result = await madge(
[resolve(__dirname, '../../public'), resolve(__dirname, '../../common')],
{
excludeRegExp: [
'test.ts$',
'test.tsx$',
'src/core/server/types.ts$',
'src/core/server/saved_objects/types.ts$',
'src/core/public/chrome/chrome_service.tsx$',
'src/core/public/overlays/banners/banners_service.tsx$',
'src/core/public/saved_objects/saved_objects_client.ts$',
'src/plugins/data/public',
'src/plugins/ui_actions/public',
],
fileExtensions: ['ts', 'js', 'tsx'],
}
);
const circularFound = result.circular();
if (circularFound.length !== 0) {
throw createFailError(
`Lists circular dependencies of imports has been found:\n - ${circularFound.join('\n - ')}`
);
} else {
log.success('No circular deps 👍');
}
},
{
description: 'Check the Lists plugin for circular deps',
}
);