mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [SKA: Misc cleanup and enhancements (#212207)](https://github.com/elastic/kibana/pull/212207) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Gerard Soldevila","email":"gerard.soldevila@elastic.co"},"sourceCommit":{"committedDate":"2025-02-24T13:31:00Z","message":"SKA: Misc cleanup and enhancements (#212207)\n\n## Summary\n\n* Remove some old paths pointing to `packages/kbn-pm` (no longer\nexists).\n* ~Fix group and visibility for `@kbn/streams-app-wrapper-plugin`~.\n(done in https://github.com/elastic/kibana/pull/212210)\n* Update `scripts/relocate` logic with latest enhancements.\n* Convert `@kbn/observability-synthetics-test-data` folder name to\ncamel-case (messes up with pre-commit hook).","sha":"a41badf96496c81587fca3d56c1c891abeb1a3a9","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"SKA: Misc cleanup and enhancements","number":212207,"url":"https://github.com/elastic/kibana/pull/212207","mergeCommit":{"message":"SKA: Misc cleanup and enhancements (#212207)\n\n## Summary\n\n* Remove some old paths pointing to `packages/kbn-pm` (no longer\nexists).\n* ~Fix group and visibility for `@kbn/streams-app-wrapper-plugin`~.\n(done in https://github.com/elastic/kibana/pull/212210)\n* Update `scripts/relocate` logic with latest enhancements.\n* Convert `@kbn/observability-synthetics-test-data` folder name to\ncamel-case (messes up with pre-commit hook).","sha":"a41badf96496c81587fca3d56c1c891abeb1a3a9"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212207","number":212207,"mergeCommit":{"message":"SKA: Misc cleanup and enhancements (#212207)\n\n## Summary\n\n* Remove some old paths pointing to `packages/kbn-pm` (no longer\nexists).\n* ~Fix group and visibility for `@kbn/streams-app-wrapper-plugin`~.\n(done in https://github.com/elastic/kibana/pull/212210)\n* Update `scripts/relocate` logic with latest enhancements.\n* Convert `@kbn/observability-synthetics-test-data` folder name to\ncamel-case (messes up with pre-commit hook).","sha":"a41badf96496c81587fca3d56c1c891abeb1a3a9"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
This commit is contained in:
parent
e3b2b50939
commit
221205c0ee
27 changed files with 88 additions and 72 deletions
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
|
@ -687,7 +687,7 @@ x-pack/solutions/observability/plugins/observability_logs_explorer @elastic/obs-
|
|||
x-pack/solutions/observability/plugins/observability_onboarding @elastic/obs-ux-logs-team
|
||||
x-pack/solutions/observability/plugins/observability @elastic/obs-ux-management-team
|
||||
x-pack/solutions/observability/plugins/observability_shared @elastic/observability-ui
|
||||
x-pack/solutions/observability/packages/synthetics_test_data @elastic/obs-ux-management-team
|
||||
x-pack/solutions/observability/packages/synthetics-test-data @elastic/obs-ux-management-team
|
||||
x-pack/solutions/observability/packages/utils-browser @elastic/observability-ui
|
||||
x-pack/solutions/observability/packages/utils-common @elastic/observability-ui
|
||||
x-pack/solutions/observability/packages/utils-server @elastic/observability-ui
|
||||
|
|
|
@ -1476,7 +1476,7 @@
|
|||
"@kbn/manifest": "link:packages/kbn-manifest",
|
||||
"@kbn/mock-idp-plugin": "link:packages/kbn-mock-idp-plugin",
|
||||
"@kbn/mock-idp-utils": "link:packages/kbn-mock-idp-utils",
|
||||
"@kbn/observability-synthetics-test-data": "link:x-pack/solutions/observability/packages/synthetics_test_data",
|
||||
"@kbn/observability-synthetics-test-data": "link:x-pack/solutions/observability/packages/synthetics-test-data",
|
||||
"@kbn/openapi-bundler": "link:packages/kbn-openapi-bundler",
|
||||
"@kbn/openapi-generator": "link:packages/kbn-openapi-generator",
|
||||
"@kbn/optimizer": "link:packages/kbn-optimizer",
|
||||
|
|
|
@ -38,7 +38,6 @@ export const MANAGED_CONFIG_KEYS: ManagedConfigKey[] = [
|
|||
{
|
||||
key: 'search.exclude',
|
||||
value: {
|
||||
['**/packages/kbn-pm/dist/index.js']: true,
|
||||
['**/api_docs']: true,
|
||||
['**/tsconfig.tsbuildinfo']: true,
|
||||
['**/*.map']: true,
|
||||
|
|
|
@ -12,8 +12,7 @@ import fs from 'fs';
|
|||
import path, { join } from 'path';
|
||||
import { getPackages } from '@kbn/repo-packages';
|
||||
import { REPO_ROOT } from '@kbn/repo-info';
|
||||
import { EXCLUDED_FOLDERS, EXCLUDED_FOLDER_NAMES, EXTENSIONS } from './constants';
|
||||
import { BASE_FOLDER } from './constants';
|
||||
import { EXCLUDED_FOLDERS, EXCLUDED_FOLDER_NAMES, EXTENSIONS, BASE_FOLDER } from './constants';
|
||||
|
||||
const findPaths = (content: string): string[] => {
|
||||
const regex = /([\.]{1,2}(\/[^\s)\]\['`#"]+)+)/g;
|
||||
|
|
|
@ -39,9 +39,7 @@ export const listModules = async (listFlag: string, log: ToolingLog) => {
|
|||
? module.directory
|
||||
: join(BASE_FOLDER, module.directory);
|
||||
|
||||
if (module.isDevOnly()) {
|
||||
devOnly.push(module);
|
||||
} else if (
|
||||
if (
|
||||
directory.includes(`/${KIBANA_FOLDER}/test/`) ||
|
||||
directory.includes(`/${KIBANA_FOLDER}/x-pack/test/`)
|
||||
) {
|
||||
|
|
|
@ -36,6 +36,8 @@ import {
|
|||
getManualCommits,
|
||||
} from './utils/git';
|
||||
|
||||
const SKIP_RESET = false;
|
||||
|
||||
const moveModule = async (module: Package, log: ToolingLog) => {
|
||||
const destination = calculateModuleTargetFolder(module);
|
||||
log.info(`Moving ${module.directory} to ${destination}`);
|
||||
|
@ -107,8 +109,6 @@ const findModules = ({ teams, paths, included, excluded }: FindModulesParams, lo
|
|||
// find modules selected by user filters
|
||||
return (
|
||||
sortBy(modules, ['directory'])
|
||||
// exclude devOnly modules (they will remain in /packages)
|
||||
.filter(({ manifest }) => !manifest.devOnly)
|
||||
// explicit exclusions
|
||||
.filter(({ id }) => !EXCLUDED_MODULES.includes(id) && !excluded.includes(id))
|
||||
// we don't want to move test and example modules (just yet)
|
||||
|
@ -181,55 +181,57 @@ export const findAndRelocateModules = async (params: RelocateModulesParams, log:
|
|||
return;
|
||||
}
|
||||
|
||||
if (prNumber) {
|
||||
pr = await findPr(prNumber);
|
||||
if (!SKIP_RESET) {
|
||||
if (prNumber) {
|
||||
pr = await findPr(prNumber);
|
||||
|
||||
if (getManualCommits(pr.commits).length > 0) {
|
||||
const resOverride = await inquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'overrideManualCommits',
|
||||
message:
|
||||
'Manual commits detected in the PR. The script will try to cherry-pick them, but it might require manual intervention to resolve conflicts. Continue?',
|
||||
});
|
||||
if (!resOverride.overrideManualCommits) {
|
||||
log.info('Aborting');
|
||||
return;
|
||||
if (getManualCommits(pr.commits).length > 0) {
|
||||
const resOverride = await inquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'overrideManualCommits',
|
||||
message:
|
||||
'Manual commits detected in the PR. The script will try to cherry-pick them, but it might require manual intervention to resolve conflicts. Continue?',
|
||||
});
|
||||
if (!resOverride.overrideManualCommits) {
|
||||
log.info('Aborting');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const resConfirmReset = await inquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'confirmReset',
|
||||
message: `The script will RESET CHANGES in this repository. Proceed?`,
|
||||
});
|
||||
const resConfirmReset = await inquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'confirmReset',
|
||||
message: `The script will RESET CHANGES in this repository. Proceed?`,
|
||||
});
|
||||
|
||||
if (!resConfirmReset.confirmReset) {
|
||||
log.info('Aborting');
|
||||
return;
|
||||
}
|
||||
|
||||
// start with a clean repo
|
||||
await safeExec(`git restore --staged .`);
|
||||
await safeExec(`git restore .`);
|
||||
await safeExec(`git clean -f -d`);
|
||||
await safeExec(`git checkout ${baseBranch} && git pull ${upstream} ${baseBranch}`);
|
||||
|
||||
if (pr) {
|
||||
// checkout existing PR, reset all commits, rebase from baseBranch
|
||||
try {
|
||||
await checkoutResetPr(pr, baseBranch);
|
||||
} catch (error) {
|
||||
log.error(`Error checking out / resetting PR #${prNumber}:`);
|
||||
log.error(error);
|
||||
if (!resConfirmReset.confirmReset) {
|
||||
log.info('Aborting');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// checkout new branch
|
||||
await checkoutBranch(NEW_BRANCH);
|
||||
}
|
||||
|
||||
await safeExec(`yarn kbn bootstrap`);
|
||||
// start with a clean repo
|
||||
await safeExec(`git restore --staged .`);
|
||||
await safeExec(`git restore .`);
|
||||
await safeExec(`git clean -f -d`);
|
||||
await safeExec(`git checkout ${baseBranch} && git pull ${upstream} ${baseBranch}`);
|
||||
|
||||
if (pr) {
|
||||
// checkout existing PR, reset all commits, rebase from baseBranch
|
||||
try {
|
||||
await checkoutResetPr(pr, baseBranch);
|
||||
} catch (error) {
|
||||
log.error(`Error checking out / resetting PR #${prNumber}:`);
|
||||
log.error(error);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// checkout new branch
|
||||
await checkoutBranch(NEW_BRANCH);
|
||||
}
|
||||
|
||||
await safeExec(`yarn kbn bootstrap`);
|
||||
}
|
||||
await inquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'readyRelocate',
|
||||
|
|
|
@ -11,7 +11,7 @@ import { basename, join } from 'path';
|
|||
import type { ToolingLog } from '@kbn/tooling-log';
|
||||
import { orderBy } from 'lodash';
|
||||
import type { Package } from '../types';
|
||||
import { applyTransforms } from './transforms';
|
||||
import { HARDCODED_MODULE_PATHS, applyTransforms } from './transforms';
|
||||
import {
|
||||
BASE_FOLDER,
|
||||
BASE_FOLDER_DEPTH,
|
||||
|
@ -42,7 +42,12 @@ export const calculateModuleTargetFolder = (module: Package): string => {
|
|||
: join(BASE_FOLDER, module.directory);
|
||||
|
||||
let moduleDelimiter: string;
|
||||
if (!fullPath.includes('/plugins/') && !fullPath.includes('/packages/')) {
|
||||
if (HARDCODED_MODULE_PATHS[module.id]) {
|
||||
return join(BASE_FOLDER, HARDCODED_MODULE_PATHS[module.id]);
|
||||
} else if (module.isDevOnly()) {
|
||||
// only packages can be devOnly
|
||||
moduleDelimiter = '/packages/';
|
||||
} else if (!fullPath.includes('/plugins/') && !fullPath.includes('/packages/')) {
|
||||
throw new Error(
|
||||
`The module ${module.id} is not located under a '*/plugins/*' or '*/packages/*' folder`
|
||||
);
|
||||
|
@ -63,6 +68,15 @@ export const calculateModuleTargetFolder = (module: Package): string => {
|
|||
chunks.shift(); // remove the base path up to '/packages/' or '/plugins/'
|
||||
const moduleFolder = chunks.join(moduleDelimiter); // in case there's an extra /packages/ or /plugins/ folder
|
||||
|
||||
if (
|
||||
module.isDevOnly() &&
|
||||
(!module.group || module.group === 'common') &&
|
||||
fullPath.includes(`/${KIBANA_FOLDER}/packages/`) &&
|
||||
!fullPath.includes(`/${KIBANA_FOLDER}/packages/core/`)
|
||||
) {
|
||||
// relocate all dev modules under /packages to /src/dev/packages
|
||||
return applyTransforms(module, join(BASE_FOLDER, 'src', 'dev', 'packages', moduleFolder));
|
||||
}
|
||||
let path: string;
|
||||
|
||||
if (group === 'platform') {
|
||||
|
@ -85,7 +99,7 @@ export const calculateModuleTargetFolder = (module: Package): string => {
|
|||
moduleFolder
|
||||
);
|
||||
}
|
||||
} else {
|
||||
} else if (group === 'observability' || group === 'security' || group === 'search') {
|
||||
path = join(
|
||||
BASE_FOLDER,
|
||||
'x-pack', // all solution modules are 'x-pack'
|
||||
|
@ -94,6 +108,8 @@ export const calculateModuleTargetFolder = (module: Package): string => {
|
|||
isPlugin ? 'plugins' : 'packages',
|
||||
moduleFolder
|
||||
);
|
||||
} else {
|
||||
path = fullPath;
|
||||
}
|
||||
|
||||
// after-creation transforms
|
||||
|
@ -113,6 +129,13 @@ export const replaceReferences = async (module: Package, destination: string, lo
|
|||
const relativeSource = source.replace(BASE_FOLDER, '');
|
||||
const relativeDestination = destination.replace(BASE_FOLDER, '');
|
||||
|
||||
if (relativeSource.split('/').length === 1) {
|
||||
log.warning(
|
||||
`Cannot replace references of a 1-level relative path '${relativeSource}'. Skipping.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(relativeSource.startsWith('src') && relativeDestination.startsWith('src')) ||
|
||||
(relativeSource.startsWith('x-pack') && relativeDestination.startsWith('x-pack'))
|
||||
|
|
|
@ -9,21 +9,16 @@
|
|||
|
||||
import type { Package } from '../types';
|
||||
|
||||
export const HARDCODED_MODULE_PATHS: Record<string, string> = {
|
||||
'@kbn/apm-ftr-e2e': 'x-pack/solutions/observability/plugins/apm/ftr_e2e',
|
||||
'@kbn/core-test-helpers-kbn-server': 'src/core/test-helpers/kbn-server',
|
||||
'@kbn/core-test-helpers-model-versions': 'src/core/test-helpers/model-versions',
|
||||
'@kbn/synthetics-e2e': 'x-pack/solutions/observability/plugins/synthetics/e2e',
|
||||
'@kbn/test-suites-src': 'src/platform/test',
|
||||
};
|
||||
|
||||
type TransformFunction = (param: string) => string;
|
||||
const TRANSFORMS: Record<string, string | TransformFunction> = {
|
||||
'x-pack/platform/packages/shared/observability/': 'x-pack/platform/packages/shared/',
|
||||
'src/platform/packages/shared/chart_expressions/common':
|
||||
'src/platform/packages/shared/chart-expressions-common',
|
||||
'x-pack/solutions/search/packages/shared_ui': 'x-pack/solutions/search/packages/shared_ui',
|
||||
'x-pack/solutions/security/packages/security-solution/': 'x-pack/solutions/security/packages/',
|
||||
'x-pack/platform/plugins/shared/observability_ai_assistant':
|
||||
'x-pack/platform/plugins/shared/observability_ai_assistant',
|
||||
'x-pack/solutions/observability/plugins/observability_solution/':
|
||||
'x-pack/solutions/observability/plugins/',
|
||||
'x-pack/solutions/observability/packages/observability/observability_utils/observability_':
|
||||
'x-pack/solutions/observability/packages/',
|
||||
'x-pack/solutions/observability/packages/observability/':
|
||||
'x-pack/solutions/observability/packages/',
|
||||
'src/core/packages/core/': (path: string) => {
|
||||
const relativePath = path.split('src/core/packages/')[1];
|
||||
const relativeChunks = relativePath.split('/');
|
||||
|
@ -40,6 +35,7 @@ const TRANSFORMS: Record<string, string | TransformFunction> = {
|
|||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const applyTransforms = (module: Package, path: string): string => {
|
||||
const transform = Object.entries(TRANSFORMS).find(([what]) => path.includes(what));
|
||||
if (!transform) {
|
||||
|
|
|
@ -128,7 +128,6 @@ export const IGNORE_DIRECTORY_GLOBS = [
|
|||
'src/babel-*',
|
||||
'packages/*',
|
||||
'x-pack/packages/ai-infra/*',
|
||||
'packages/kbn-pm/src/utils/__fixtures__/*',
|
||||
'packages/kbn-check-prod-native-modules-cli/integration_tests/__fixtures__/*/node_modules/*',
|
||||
'x-pack/dev-tools',
|
||||
'packages/kbn-optimizer/src/__fixtures__/mock_repo/x-pack',
|
||||
|
|
|
@ -1368,8 +1368,8 @@
|
|||
"@kbn/observability-plugin/*": ["x-pack/solutions/observability/plugins/observability/*"],
|
||||
"@kbn/observability-shared-plugin": ["x-pack/solutions/observability/plugins/observability_shared"],
|
||||
"@kbn/observability-shared-plugin/*": ["x-pack/solutions/observability/plugins/observability_shared/*"],
|
||||
"@kbn/observability-synthetics-test-data": ["x-pack/solutions/observability/packages/synthetics_test_data"],
|
||||
"@kbn/observability-synthetics-test-data/*": ["x-pack/solutions/observability/packages/synthetics_test_data/*"],
|
||||
"@kbn/observability-synthetics-test-data": ["x-pack/solutions/observability/packages/synthetics-test-data"],
|
||||
"@kbn/observability-synthetics-test-data/*": ["x-pack/solutions/observability/packages/synthetics-test-data/*"],
|
||||
"@kbn/observability-utils-browser": ["x-pack/solutions/observability/packages/utils-browser"],
|
||||
"@kbn/observability-utils-browser/*": ["x-pack/solutions/observability/packages/utils-browser/*"],
|
||||
"@kbn/observability-utils-common": ["x-pack/solutions/observability/packages/utils-common"],
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../../..',
|
||||
roots: ['<rootDir>/x-pack/solutions/observability/packages/synthetics_test_data'],
|
||||
roots: ['<rootDir>/x-pack/solutions/observability/packages/synthetics-test-data'],
|
||||
};
|
|
@ -6590,7 +6590,7 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/observability-synthetics-test-data@link:x-pack/solutions/observability/packages/synthetics_test_data":
|
||||
"@kbn/observability-synthetics-test-data@link:x-pack/solutions/observability/packages/synthetics-test-data":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue