mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
SKA: Relocate Script v7.1 (#206233)
## Summary * Fix an issue with the `--list` command failing the 1st run. * Allow passing in no filters, and relocate "incorrect" modules (aka modules that are not in the correct folder) in that case.
This commit is contained in:
parent
82721b0c25
commit
3b42b80bce
2 changed files with 22 additions and 29 deletions
|
@ -11,14 +11,14 @@ import { sortBy } from 'lodash';
|
|||
import type { ToolingLog } from '@kbn/tooling-log';
|
||||
import { getPackages } from '@kbn/repo-packages';
|
||||
import { REPO_ROOT } from '@kbn/repo-info';
|
||||
import { join } from 'path';
|
||||
import type { Package } from './types';
|
||||
import { BASE_FOLDER, EXCLUDED_MODULES, KIBANA_FOLDER } from './constants';
|
||||
import { calculateModuleTargetFolder, isInTargetFolder } from './utils/relocate';
|
||||
import { createModuleTable } from './utils/logging';
|
||||
import { safeExec } from './utils/exec';
|
||||
|
||||
export const listModules = async (listFlag: string, log: ToolingLog) => {
|
||||
// get all modules
|
||||
const modules = getPackages(REPO_ROOT);
|
||||
const devOnly: Package[] = [];
|
||||
const test: Package[] = [];
|
||||
const examples: Package[] = [];
|
||||
|
@ -26,47 +26,38 @@ export const listModules = async (listFlag: string, log: ToolingLog) => {
|
|||
const incorrect: Package[] = [];
|
||||
const correct: Package[] = [];
|
||||
|
||||
// get all modules
|
||||
await safeExec('yarn kbn bootstrap');
|
||||
const modules = getPackages(REPO_ROOT);
|
||||
|
||||
// find modules selected by user filters
|
||||
sortBy(modules, 'directory')
|
||||
// explicit exclusions
|
||||
.filter(({ id }) => !EXCLUDED_MODULES.includes(id))
|
||||
.forEach((module) => {
|
||||
const directory = module.directory.startsWith(BASE_FOLDER)
|
||||
? module.directory
|
||||
: join(BASE_FOLDER, module.directory);
|
||||
|
||||
if (module.isDevOnly()) {
|
||||
devOnly.push(module);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
module.directory.includes(`/${KIBANA_FOLDER}/test/`) ||
|
||||
module.directory.includes(`/${KIBANA_FOLDER}/x-pack/test/`)
|
||||
} else if (
|
||||
directory.includes(`/${KIBANA_FOLDER}/test/`) ||
|
||||
directory.includes(`/${KIBANA_FOLDER}/x-pack/test/`)
|
||||
) {
|
||||
test.push(module);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
module.directory.includes(`/${KIBANA_FOLDER}/examples/`) ||
|
||||
module.directory.includes(`/${KIBANA_FOLDER}/x-pack/examples/`)
|
||||
} else if (
|
||||
directory.includes(`/${KIBANA_FOLDER}/examples/`) ||
|
||||
directory.includes(`/${KIBANA_FOLDER}/x-pack/examples/`)
|
||||
) {
|
||||
examples.push(module);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!module.group || module.group === 'common' || !module.visibility) {
|
||||
// log.warning(`The module ${module.id} does not specify 'group' or 'visibility'. Skipping`);
|
||||
} else if (!module.group || module.group === 'common' || !module.visibility) {
|
||||
uncategorised.push(module);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isInTargetFolder(module)) {
|
||||
} else if (!isInTargetFolder(module)) {
|
||||
incorrect.push(module);
|
||||
// log.warning(dedent`The module ${module.id} is not in the correct folder:
|
||||
// - ${module.directory}
|
||||
// - ${calculateModuleTargetFolder(module)}`);
|
||||
|
||||
return;
|
||||
} else {
|
||||
correct.push(module);
|
||||
}
|
||||
correct.push(module);
|
||||
});
|
||||
|
||||
if (listFlag === 'all') {
|
||||
|
|
|
@ -102,6 +102,7 @@ export interface RelocateModulesParams {
|
|||
const findModules = ({ teams, paths, included, excluded }: FindModulesParams, log: ToolingLog) => {
|
||||
// get all modules
|
||||
const modules = getPackages(REPO_ROOT);
|
||||
const moduleFilters = teams.length > 0 || paths.length > 0 || included.length > 0;
|
||||
|
||||
// find modules selected by user filters
|
||||
return (
|
||||
|
@ -121,6 +122,7 @@ const findModules = ({ teams, paths, included, excluded }: FindModulesParams, lo
|
|||
// the module is under the umbrella specified by the user
|
||||
.filter(
|
||||
(module) =>
|
||||
!moduleFilters ||
|
||||
included.includes(module.id) ||
|
||||
teams.some((team) => belongsTo(module, team)) ||
|
||||
paths.some((path) => module.directory.includes(path))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue