mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[kbn/bootstrap] validate that certain deps don't ship in production (#80549)
Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
parent
cd9381c118
commit
07c1284e9d
23 changed files with 842 additions and 709 deletions
|
@ -131,10 +131,7 @@
|
||||||
"@kbn/i18n": "1.0.0",
|
"@kbn/i18n": "1.0.0",
|
||||||
"@kbn/interpreter": "1.0.0",
|
"@kbn/interpreter": "1.0.0",
|
||||||
"@kbn/logging": "1.0.0",
|
"@kbn/logging": "1.0.0",
|
||||||
"@kbn/pm": "1.0.0",
|
|
||||||
"@kbn/std": "1.0.0",
|
"@kbn/std": "1.0.0",
|
||||||
"@kbn/telemetry-tools": "1.0.0",
|
|
||||||
"@kbn/test-subj-selector": "0.2.1",
|
|
||||||
"@kbn/ui-framework": "1.0.0",
|
"@kbn/ui-framework": "1.0.0",
|
||||||
"@kbn/ace": "1.0.0",
|
"@kbn/ace": "1.0.0",
|
||||||
"@kbn/monaco": "1.0.0",
|
"@kbn/monaco": "1.0.0",
|
||||||
|
@ -247,8 +244,11 @@
|
||||||
"@kbn/expect": "1.0.0",
|
"@kbn/expect": "1.0.0",
|
||||||
"@kbn/optimizer": "1.0.0",
|
"@kbn/optimizer": "1.0.0",
|
||||||
"@kbn/plugin-generator": "1.0.0",
|
"@kbn/plugin-generator": "1.0.0",
|
||||||
|
"@kbn/pm": "1.0.0",
|
||||||
"@kbn/release-notes": "1.0.0",
|
"@kbn/release-notes": "1.0.0",
|
||||||
|
"@kbn/telemetry-tools": "1.0.0",
|
||||||
"@kbn/test": "1.0.0",
|
"@kbn/test": "1.0.0",
|
||||||
|
"@kbn/test-subj-selector": "0.2.1",
|
||||||
"@kbn/utility-types": "1.0.0",
|
"@kbn/utility-types": "1.0.0",
|
||||||
"@microsoft/api-documenter": "7.7.2",
|
"@microsoft/api-documenter": "7.7.2",
|
||||||
"@microsoft/api-extractor": "7.7.0",
|
"@microsoft/api-extractor": "7.7.0",
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/elastic/kibana.git"
|
"url": "git+https://github.com/elastic/kibana.git"
|
||||||
},
|
},
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Spencer Alger <email@spalger.com>",
|
"author": "Spencer Alger <email@spalger.com>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
||||||
"@babel/plugin-proposal-export-namespace-from": "^7.10.4",
|
"@babel/plugin-proposal-export-namespace-from": "^7.10.4",
|
||||||
|
|
|
@ -12,10 +12,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@elastic/safer-lodash-set": "0.0.0",
|
"@elastic/safer-lodash-set": "0.0.0",
|
||||||
"@kbn/config-schema": "1.0.0",
|
"@kbn/config-schema": "1.0.0",
|
||||||
"@kbn/dev-utils": "1.0.0",
|
|
||||||
"@kbn/logging": "1.0.0",
|
"@kbn/logging": "1.0.0",
|
||||||
"@kbn/std": "1.0.0",
|
"@kbn/std": "1.0.0",
|
||||||
"@kbn/utility-types": "1.0.0",
|
|
||||||
"js-yaml": "^3.14.0",
|
"js-yaml": "^3.14.0",
|
||||||
"load-json-file": "^6.2.0",
|
"load-json-file": "^6.2.0",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
|
@ -24,6 +22,8 @@
|
||||||
"type-detect": "^4.0.8"
|
"type-detect": "^4.0.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@kbn/dev-utils": "1.0.0",
|
||||||
|
"@kbn/utility-types": "1.0.0",
|
||||||
"typescript": "4.0.2",
|
"typescript": "4.0.2",
|
||||||
"tsd": "^0.13.1"
|
"tsd": "^0.13.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
"kbn:bootstrap": "yarn build",
|
"kbn:bootstrap": "yarn build",
|
||||||
"kbn:watch": "yarn build --watch"
|
"kbn:watch": "yarn build --watch"
|
||||||
},
|
},
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.11.6",
|
"@babel/core": "^7.11.6",
|
||||||
"@kbn/utils": "1.0.0",
|
"@kbn/utils": "1.0.0",
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "target/index.js",
|
"main": "target/index.js",
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"kbn:bootstrap": "rm -rf target && tsc",
|
"kbn:bootstrap": "rm -rf target && tsc",
|
||||||
"kbn:watch": "rm -rf target && tsc --watch"
|
"kbn:watch": "rm -rf target && tsc --watch"
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"kbn:bootstrap": "node scripts/build",
|
"kbn:bootstrap": "node scripts/build",
|
||||||
"kbn:watch": "node scripts/build --watch"
|
"kbn:watch": "node scripts/build --watch"
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"main": "import_resolver_kibana.js",
|
"main": "import_resolver_kibana.js",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/elastic/kibana/tree/master/packages/kbn-eslint-import-resolver-kibana"
|
"url": "https://github.com/elastic/kibana/tree/master/packages/kbn-eslint-import-resolver-kibana"
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "6.8.0",
|
"eslint": "6.8.0",
|
||||||
"babel-eslint": "^10.0.3"
|
"babel-eslint": "^10.0.3"
|
||||||
|
|
|
@ -3,5 +3,8 @@
|
||||||
"main": "./expect.js",
|
"main": "./expect.js",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true
|
"private": true,
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
1428
packages/kbn-pm/dist/index.js
vendored
1428
packages/kbn-pm/dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -4,6 +4,9 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"kbn:watch": "webpack --watch --progress",
|
"kbn:watch": "webpack --watch --progress",
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { ICommand } from './';
|
||||||
import { getAllChecksums } from '../utils/project_checksums';
|
import { getAllChecksums } from '../utils/project_checksums';
|
||||||
import { BootstrapCacheFile } from '../utils/bootstrap_cache_file';
|
import { BootstrapCacheFile } from '../utils/bootstrap_cache_file';
|
||||||
import { readYarnLock } from '../utils/yarn_lock';
|
import { readYarnLock } from '../utils/yarn_lock';
|
||||||
import { validateYarnLock } from '../utils/validate_yarn_lock';
|
import { validateDependencies } from '../utils/validate_dependencies';
|
||||||
|
|
||||||
export const BootstrapCommand: ICommand = {
|
export const BootstrapCommand: ICommand = {
|
||||||
description: 'Install dependencies and crosslink projects',
|
description: 'Install dependencies and crosslink projects',
|
||||||
|
@ -59,7 +59,7 @@ export const BootstrapCommand: ICommand = {
|
||||||
const yarnLock = await readYarnLock(kbn);
|
const yarnLock = await readYarnLock(kbn);
|
||||||
|
|
||||||
if (options.validate) {
|
if (options.validate) {
|
||||||
await validateYarnLock(kbn, yarnLock);
|
await validateDependencies(kbn, yarnLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
await linkProjectExecutables(projects, projectGraph);
|
await linkProjectExecutables(projects, projectGraph);
|
||||||
|
|
|
@ -153,6 +153,10 @@ export class Project {
|
||||||
return (this.json.kibana && this.json.kibana.clean) || {};
|
return (this.json.kibana && this.json.kibana.clean) || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isFlaggedAsDevOnly() {
|
||||||
|
return !!(this.json.kibana && this.json.kibana.devOnly);
|
||||||
|
}
|
||||||
|
|
||||||
public hasScript(name: string) {
|
public hasScript(name: string) {
|
||||||
return name in this.scripts;
|
return name in this.scripts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ export function renderProjectsTree(rootPath: string, projects: Map<string, Proje
|
||||||
return treeToString(createTreeStructure(projectsTree));
|
return treeToString(createTreeStructure(projectsTree));
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ITree {
|
export interface ITree {
|
||||||
name?: string;
|
name?: string;
|
||||||
children?: ITreeChildren;
|
children?: ITreeChildren;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ type DirOrProjectName = string | typeof projectKey;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||||
interface IProjectsTree extends Map<DirOrProjectName, string | IProjectsTree> {}
|
interface IProjectsTree extends Map<DirOrProjectName, string | IProjectsTree> {}
|
||||||
|
|
||||||
function treeToString(tree: ITree) {
|
export function treeToString(tree: ITree) {
|
||||||
return [tree.name].concat(childrenToStrings(tree.children, '')).join('\n');
|
return [tree.name].concat(childrenToStrings(tree.children, '')).join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,16 @@
|
||||||
// @ts-expect-error published types are useless
|
// @ts-expect-error published types are useless
|
||||||
import { stringify as stringifyLockfile } from '@yarnpkg/lockfile';
|
import { stringify as stringifyLockfile } from '@yarnpkg/lockfile';
|
||||||
import dedent from 'dedent';
|
import dedent from 'dedent';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
|
||||||
import { writeFile } from './fs';
|
import { writeFile } from './fs';
|
||||||
import { Kibana } from './kibana';
|
import { Kibana } from './kibana';
|
||||||
import { YarnLock } from './yarn_lock';
|
import { YarnLock } from './yarn_lock';
|
||||||
import { log } from './log';
|
import { log } from './log';
|
||||||
import { Project } from './project';
|
import { Project } from './project';
|
||||||
|
import { ITree, treeToString } from './projects_tree';
|
||||||
|
|
||||||
export async function validateYarnLock(kbn: Kibana, yarnLock: YarnLock) {
|
export async function validateDependencies(kbn: Kibana, yarnLock: YarnLock) {
|
||||||
// look through all of the packages in the yarn.lock file to see if
|
// look through all of the packages in the yarn.lock file to see if
|
||||||
// we have accidentally installed multiple lodash v4 versions
|
// we have accidentally installed multiple lodash v4 versions
|
||||||
const lodash4Versions = new Set<string>();
|
const lodash4Versions = new Set<string>();
|
||||||
|
@ -157,5 +159,45 @@ export async function validateYarnLock(kbn: Kibana, yarnLock: YarnLock) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// look for packages that have the the `kibana.devOnly` flag in their package.json
|
||||||
|
// and make sure they aren't included in the production dependencies of Kibana
|
||||||
|
const devOnlyProjectsInProduction = getDevOnlyProductionDepsTree(kbn, 'kibana');
|
||||||
|
if (devOnlyProjectsInProduction) {
|
||||||
|
log.error(dedent`
|
||||||
|
Some of the packages in the production dependency chain for Kibana and X-Pack are
|
||||||
|
flagged with "kibana.devOnly" in their package.json. Please check changes made to
|
||||||
|
packages and their dependencies to ensure they don't end up in production.
|
||||||
|
|
||||||
|
The devOnly dependencies that are being dependend on in production are:
|
||||||
|
|
||||||
|
${treeToString(devOnlyProjectsInProduction).split('\n').join('\n ')}
|
||||||
|
`);
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
log.success('yarn.lock analysis completed without any issues');
|
log.success('yarn.lock analysis completed without any issues');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDevOnlyProductionDepsTree(kbn: Kibana, projectName: string) {
|
||||||
|
const project = kbn.getProject(projectName);
|
||||||
|
const childProjectNames = [
|
||||||
|
...Object.keys(project.productionDependencies).filter((name) => kbn.hasProject(name)),
|
||||||
|
...(projectName === 'kibana' ? ['x-pack'] : []),
|
||||||
|
];
|
||||||
|
|
||||||
|
const children = childProjectNames
|
||||||
|
.map((n) => getDevOnlyProductionDepsTree(kbn, n))
|
||||||
|
.filter((t): t is ITree => !!t);
|
||||||
|
|
||||||
|
if (!children.length && !project.isFlaggedAsDevOnly()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tree: ITree = {
|
||||||
|
name: project.isFlaggedAsDevOnly() ? chalk.red.bold(projectName) : projectName,
|
||||||
|
children,
|
||||||
|
};
|
||||||
|
|
||||||
|
return tree;
|
||||||
|
}
|
|
@ -3,6 +3,9 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "target/index.js",
|
"main": "target/index.js",
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"kbn:bootstrap": "tsc",
|
"kbn:bootstrap": "tsc",
|
||||||
"kbn:watch": "tsc --watch"
|
"kbn:watch": "tsc --watch"
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"kbn:bootstrap": "yarn build"
|
"kbn:bootstrap": "yarn build"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"lodash": "^4.17.20"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@kbn/utility-types": "1.0.0",
|
||||||
"typescript": "4.0.2",
|
"typescript": "4.0.2",
|
||||||
"tsd": "^0.13.1"
|
"tsd": "^0.13.1"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@kbn/utility-types": "1.0.0",
|
|
||||||
"lodash": "^4.17.20"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "./target/index.js",
|
"main": "./target/index.js",
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kbn/dev-utils": "1.0.0",
|
"@kbn/dev-utils": "1.0.0",
|
||||||
"@storybook/addon-actions": "^6.0.16",
|
"@storybook/addon-actions": "^6.0.16",
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "./target/index.js",
|
"main": "./target/index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel src --out-dir target --delete-dir-on-start --extensions .ts --source-maps=inline",
|
"build": "babel src --out-dir target --delete-dir-on-start --extensions .ts --source-maps=inline",
|
||||||
"kbn:bootstrap": "yarn build",
|
"kbn:bootstrap": "yarn build",
|
||||||
|
|
|
@ -5,5 +5,8 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Spencer Alger <email@spalger.com>",
|
"author": "Spencer Alger <email@spalger.com>",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0",
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
"kbn:bootstrap": "yarn build",
|
"kbn:bootstrap": "yarn build",
|
||||||
"kbn:watch": "yarn build --watch"
|
"kbn:watch": "yarn build --watch"
|
||||||
},
|
},
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.10.5",
|
"@babel/cli": "^7.10.5",
|
||||||
"@jest/types": "^26.5.2",
|
"@jest/types": "^26.5.2",
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "target",
|
"main": "target",
|
||||||
"types": "target/index.d.ts",
|
"types": "target/index.d.ts",
|
||||||
|
"kibana": {
|
||||||
|
"devOnly": true
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"kbn:bootstrap": "tsc",
|
"kbn:bootstrap": "tsc",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue