mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
chore(NA): adds @kbn/whereis-pkg-cli to quickly find a pkg location (#148696)
This PR ads a new cli package to allow us to search for package locations by providing their IDs. I see this as useful as we start adding more and more packages across different locations. Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
99013bdab8
commit
548da835a2
13 changed files with 120 additions and 2 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -1025,6 +1025,7 @@ packages/kbn-utility-types @elastic/kibana-core
|
|||
packages/kbn-utility-types-jest @elastic/kibana-operations
|
||||
packages/kbn-utils @elastic/kibana-operations
|
||||
packages/kbn-web-worker-stub @elastic/kibana-operations
|
||||
packages/kbn-whereis-pkg-cli @elastic/kibana-operations
|
||||
packages/kbn-yarn-lock-validator @elastic/kibana-operations
|
||||
packages/shared-ux/avatar/solution @elastic/kibana-global-experience
|
||||
packages/shared-ux/avatar/user_profile/impl @elastic/kibana-global-experience
|
||||
|
|
|
@ -821,6 +821,7 @@
|
|||
"@kbn/ts-projects": "link:packages/kbn-ts-projects",
|
||||
"@kbn/ts-type-check-cli": "link:packages/kbn-ts-type-check-cli",
|
||||
"@kbn/web-worker-stub": "link:packages/kbn-web-worker-stub",
|
||||
"@kbn/whereis-pkg-cli": "link:packages/kbn-whereis-pkg-cli",
|
||||
"@kbn/yarn-lock-validator": "link:packages/kbn-yarn-lock-validator",
|
||||
"@loaders.gl/polyfills": "^2.3.5",
|
||||
"@mapbox/vector-tile": "1.3.1",
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
/** @typedef {import('./modern/types').PluginTypeInfo} PluginTypeInfo */
|
||||
/** @typedef {Map<string, string>} PackageMap */
|
||||
|
||||
const { getPackages, findPackageInfoForPath } = require('./modern/get_packages');
|
||||
const { getPackages, findPackageInfoForPath, getPkgMap } = require('./modern/get_packages');
|
||||
const {
|
||||
parsePackageManifest,
|
||||
readPackageManifest,
|
||||
|
@ -38,6 +38,7 @@ module.exports = {
|
|||
readPackageMap,
|
||||
getPackages,
|
||||
findPackageInfoForPath,
|
||||
getPkgMap,
|
||||
parsePackageManifest,
|
||||
readPackageManifest,
|
||||
validatePackageManifest,
|
||||
|
|
|
@ -95,4 +95,4 @@ function findPackageInfoForPath(repoRoot, path) {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = { getPackages, findPackageInfoForPath };
|
||||
module.exports = { getPackages, findPackageInfoForPath, getPkgMap };
|
||||
|
|
3
packages/kbn-whereis-pkg-cli/README.md
Normal file
3
packages/kbn-whereis-pkg-cli/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# @kbn/whereis-pkg-cli
|
||||
|
||||
CLI for finding package locations by providing their IDs.
|
13
packages/kbn-whereis-pkg-cli/jest.config.js
Normal file
13
packages/kbn-whereis-pkg-cli/jest.config.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../..',
|
||||
roots: ['<rootDir>/packages/kbn-whereis-pkg-cli'],
|
||||
};
|
6
packages/kbn-whereis-pkg-cli/kibana.jsonc
Normal file
6
packages/kbn-whereis-pkg-cli/kibana.jsonc
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"type": "shared-common",
|
||||
"id": "@kbn/whereis-pkg-cli",
|
||||
"owner": "@elastic/kibana-operations",
|
||||
"devOnly": true
|
||||
}
|
7
packages/kbn-whereis-pkg-cli/package.json
Normal file
7
packages/kbn-whereis-pkg-cli/package.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "@kbn/whereis-pkg-cli",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0",
|
||||
"main": "./run_whereis_pkg_cli"
|
||||
}
|
48
packages/kbn-whereis-pkg-cli/run_whereis_pkg_cli.ts
Normal file
48
packages/kbn-whereis-pkg-cli/run_whereis_pkg_cli.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { run } from '@kbn/dev-cli-runner';
|
||||
import { createFailError } from '@kbn/dev-cli-errors';
|
||||
import { getPkgMap } from '@kbn/repo-packages';
|
||||
import type { ToolingLog } from '@kbn/tooling-log';
|
||||
|
||||
const locatePkgsByID = function (inputFilters: string[], log: ToolingLog) {
|
||||
const packagesMap = getPkgMap();
|
||||
let missingPkgsCount = 0;
|
||||
|
||||
inputFilters.forEach((filterInput) => {
|
||||
const pkgId = filterInput.toLowerCase();
|
||||
|
||||
if (packagesMap.has(pkgId)) {
|
||||
const pkgLocation = packagesMap.get(pkgId);
|
||||
log.success(`pkg ${pkgId} location => ${pkgLocation}`);
|
||||
} else {
|
||||
missingPkgsCount++;
|
||||
// fail
|
||||
log.error(`pkg ${pkgId} NOT FOUND`);
|
||||
}
|
||||
});
|
||||
|
||||
return missingPkgsCount;
|
||||
};
|
||||
|
||||
run(
|
||||
async ({ log, flagsReader }) => {
|
||||
const missingPackagesCount = locatePkgsByID(flagsReader.getPositionals(), log);
|
||||
|
||||
if (!missingPackagesCount) {
|
||||
log.success('All packages were found successfully');
|
||||
} else {
|
||||
throw createFailError('see above errors');
|
||||
}
|
||||
},
|
||||
{
|
||||
usage: `node scripts/whereis_pkg [...packages]`,
|
||||
description: 'Logs where a given package(s) ID is located in the repository',
|
||||
}
|
||||
);
|
22
packages/kbn-whereis-pkg-cli/tsconfig.json
Normal file
22
packages/kbn-whereis-pkg-cli/tsconfig.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "target/types",
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*"
|
||||
],
|
||||
"kbn_references": [
|
||||
"@kbn/dev-cli-runner",
|
||||
"@kbn/dev-cli-errors",
|
||||
"@kbn/repo-packages",
|
||||
"@kbn/tooling-log"
|
||||
]
|
||||
}
|
10
scripts/whereis_pkg.js
Normal file
10
scripts/whereis_pkg.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('@kbn/whereis-pkg-cli');
|
|
@ -1296,6 +1296,8 @@
|
|||
"@kbn/watcher-plugin/*": ["x-pack/plugins/watcher/*"],
|
||||
"@kbn/web-worker-stub": ["packages/kbn-web-worker-stub"],
|
||||
"@kbn/web-worker-stub/*": ["packages/kbn-web-worker-stub/*"],
|
||||
"@kbn/whereis-pkg-cli": ["packages/kbn-whereis-pkg-cli"],
|
||||
"@kbn/whereis-pkg-cli/*": ["packages/kbn-whereis-pkg-cli/*"],
|
||||
"@kbn/yarn-lock-validator": ["packages/kbn-yarn-lock-validator"],
|
||||
"@kbn/yarn-lock-validator/*": ["packages/kbn-yarn-lock-validator/*"],
|
||||
// END AUTOMATED PACKAGE LISTING
|
||||
|
|
|
@ -4309,6 +4309,10 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/whereis-pkg-cli@link:packages/kbn-whereis-pkg-cli":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/yarn-lock-validator@link:packages/kbn-yarn-lock-validator":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue