Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[poc] chore(NA): migrate to lodash@4 on packages and x-pack #69689

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"**/@types/hoist-non-react-statics": "^3.3.1",
"**/@types/chai": "^4.2.11",
"**/typescript": "3.9.5",
"**/graphql-toolkit/lodash": "^4.17.13",
"**/hoist-non-react-statics": "^3.3.2",
"**/isomorphic-git/**/base64-js": "^1.2.1",
"**/image-diff/gm/debug": "^2.6.9",
Expand Down Expand Up @@ -213,8 +212,8 @@
"leaflet.heat": "0.2.0",
"less": "npm:@elastic/[email protected]",
"less-loader": "5.0.0",
"lodash": "npm:@elastic/[email protected]",
"lodash.clonedeep": "^4.5.0",
"lodash": "^4.17.15",
"lodash3": "npm:@elastic/[email protected]",
"lru-cache": "4.1.5",
"markdown-it": "^10.0.0",
"mini-css-extract-plugin": "0.8.0",
Expand Down Expand Up @@ -354,8 +353,8 @@
"@types/json5": "^0.0.30",
"@types/license-checker": "15.0.0",
"@types/listr": "^0.14.0",
"@types/lodash": "^3.10.1",
"@types/lodash.clonedeep": "^4.5.4",
"@types/lodash": "^4.14.155",
"@types/lodash3": "npm:@types/lodash@^3.10.1",
"@types/lru-cache": "^5.1.0",
"@types/markdown-it": "^0.0.7",
"@types/minimatch": "^2.0.29",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-config-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"tsd": "^0.7.4"
},
"peerDependencies": {
"lodash": "^4.17.15",
"joi": "^13.5.2",
"moment": "^2.24.0",
"type-detect": "^4.0.8"
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-interpreter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"dependencies": {
"@babel/runtime": "^7.10.2",
"@kbn/i18n": "1.0.0",
"lodash": "npm:@elastic/[email protected]",
"lodash.clone": "^4.5.0",
"lodash": "^4.17.15",
"uuid": "3.3.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-interpreter/src/common/lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import clone from 'lodash.clone';
import { clone } from 'lodash';

export class Registry {
constructor(prop = 'name') {
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-plugin-generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const dedent = require('dedent');
const sao = require('sao');
const chalk = require('chalk');
const getopts = require('getopts');
const snakeCase = require('lodash.snakecase');
const { snakeCase } = require('lodash');

exports.run = function run(argv) {
const options = getopts(argv, {
Expand All @@ -41,7 +41,7 @@ exports.run = function run(argv) {
if (options.help) {
console.log(
dedent(chalk`
# {dim Usage:}
# {dim Usage:}
node scripts/generate-plugin {bold [name]}
Generate a fresh Kibana plugin in the plugins/ directory
`) + '\n'
Expand Down
5 changes: 1 addition & 4 deletions packages/kbn-plugin-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
"dedent": "^0.7.0",
"execa": "^4.0.2",
"getopts": "^2.2.4",
"lodash.camelcase": "^4.3.0",
"lodash.kebabcase": "^4.1.1",
"lodash.snakecase": "^4.1.1",
"lodash.startcase": "^4.4.0",
"lodash": "^4.17.15",
"sao": "^0.22.12"
}
}
4 changes: 1 addition & 3 deletions packages/kbn-plugin-generator/sao_template/sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
const { relative, resolve } = require('path');
const fs = require('fs');

const startCase = require('lodash.startcase');
const camelCase = require('lodash.camelcase');
const snakeCase = require('lodash.snakecase');
const { camelCase, startCase, snakeCase } = require('lodash');
const chalk = require('chalk');
const execa = require('execa');

Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/glob": "^5.0.35",
"@types/globby": "^6.1.0",
"@types/has-ansi": "^3.0.0",
"@types/lodash.clonedeepwith": "^4.5.3",
"@types/lodash": "^4.14.155",
"@types/log-symbols": "^2.0.0",
"@types/ncp": "^2.0.1",
"@types/node": ">=10.17.17 <10.20.0",
Expand All @@ -46,7 +46,7 @@
"globby": "^8.0.1",
"has-ansi": "^3.0.0",
"is-path-inside": "^3.0.2",
"lodash.clonedeepwith": "^4.5.0",
"lodash": "^4.17.15",
"log-symbols": "^2.2.0",
"multimatch": "^4.0.0",
"ncp": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import cloneDeepWith from 'lodash.clonedeepwith';
import { cloneDeepWith } from 'lodash';
import { resolve, sep as pathSep } from 'path';

const repoRoot = resolve(__dirname, '../../../../');
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@babel/cli": "^7.10.1",
"@kbn/babel-preset": "1.0.0",
"@kbn/dev-utils": "1.0.0",
"@types/lodash": "^4.14.155",
"@types/parse-link-header": "^1.0.0",
"@types/puppeteer": "^3.0.0",
"@types/strip-ansi": "^5.2.1",
Expand All @@ -25,6 +26,7 @@
"del": "^5.1.0",
"getopts": "^2.2.4",
"glob": "^7.1.2",
"lodash": "^4.17.15",
"parse-link-header": "^1.0.1",
"puppeteer": "^3.3.0",
"strip-ansi": "^5.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
*/

import { Schema } from 'joi';
import { cloneDeep, get, has } from 'lodash';

// @ts-ignore internal lodash module is not typed
import toPath from 'lodash/internal/toPath';
import { cloneDeepWith, get, has, toPath } from 'lodash';

import { schema } from './schema';

Expand Down Expand Up @@ -114,15 +111,15 @@ export class Config {
throw new Error(`Unknown config key "${key}"`);
}

return cloneDeep(get(this[$values], key, defaultValue), (v) => {
return cloneDeepWith(get(this[$values], key, defaultValue), (v) => {
if (typeof v === 'function') {
return v;
}
});
}

public getAll() {
return cloneDeep(this[$values], (v) => {
return cloneDeepWith(this[$values], (v) => {
if (typeof v === 'function') {
return v;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-test/src/legacy_es/legacy_es_test_cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

import { resolve } from 'path';
import { format } from 'url';
import { get } from 'lodash';
import toPath from 'lodash/internal/toPath';
import { get, toPath } from 'lodash';
import { Cluster } from '@kbn/es';
import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix';
import { esTestConfig } from './es_test_config';
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-test/src/page_load_metrics/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import Fs from 'fs';
import Url from 'url';
import _ from 'lodash';
import puppeteer from 'puppeteer';
import { resolve } from 'path';
import { ToolingLog } from '@kbn/dev-utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-framework/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const sass = require('node-sass');
const postcss = require('postcss');
const postcssConfig = require('../../src/optimize/postcss.config');
const chokidar = require('chokidar');
const debounce = require('lodash/function/debounce');
const debounce = require('lodash/debounce');

const platform = require('os').platform();
const isPlatformWindows = /^win/.test(platform);
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"classnames": "2.2.6",
"focus-trap-react": "^3.1.1",
"lodash": "npm:@elastic/[email protected]",
"lodash": "^4.17.15",
"prop-types": "15.6.0",
"react": "^16.12.0",
"react-ace": "^5.9.0",
Expand Down
16 changes: 4 additions & 12 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -550,19 +550,11 @@
],
},
{
groupSlug: 'lodash.clonedeep',
groupName: 'lodash.clonedeep related packages',
groupSlug: 'lodash3',
groupName: 'lodash3 related packages',
packageNames: [
'lodash.clonedeep',
'@types/lodash.clonedeep',
],
},
{
groupSlug: 'lodash.clonedeepwith',
groupName: 'lodash.clonedeepwith related packages',
packageNames: [
'lodash.clonedeepwith',
'@types/lodash.clonedeepwith',
'lodash3',
'@types/lodash3',
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ElasticsearchBeatsAdapter implements CMBeatsAdapter {
if (!response.found) {
return null;
}
const beat = _get<CMBeat>(response, '_source.beat');
const beat = _get(response, '_source.beat') as CMBeat;
beat.tags = beat.tags || [];
return beat;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ export class ElasticsearchBeatsAdapter implements CMBeatsAdapter {

const response = await this.database.search(user, params);

const beats = _get<CMBeat[]>(response, 'hits.hits', []);
const beats = _get(response, 'hits.hits', []) as CMBeat[];

if (beats.length === 0) {
return [];
Expand All @@ -127,14 +127,12 @@ export class ElasticsearchBeatsAdapter implements CMBeatsAdapter {

const response = await this.database.search(user, params);

const beats = _get<CMBeat[]>(response, 'hits.hits', []);
const beats = _get(response, 'hits.hits', []) as CMBeat[];

if (beats.length === 0) {
return null;
}
return omit<CMBeat, {}>(_get<CMBeat>(formatWithTags(beats[0]), '_source.beat'), [
'access_token',
]);
return omit(_get(formatWithTags(beats[0]), '_source.beat'), ['access_token']) as CMBeat;
}

public async getAll(user: FrameworkUser, ESQuery?: any) {
Expand Down Expand Up @@ -171,7 +169,7 @@ export class ElasticsearchBeatsAdapter implements CMBeatsAdapter {
if (!response) {
return [];
}
const beats = _get<any>(response, 'hits.hits', []);
const beats = _get(response, 'hits.hits', []) as any;

return beats.map((beat: any) =>
formatWithTags(omit(beat._source.beat as CMBeat, ['access_token']) as CMBeat)
Expand Down Expand Up @@ -202,7 +200,7 @@ export class ElasticsearchBeatsAdapter implements CMBeatsAdapter {
index: INDEX_NAMES.BEATS,
refresh: 'wait_for',
});
return _get<any>(response, 'items', []).map((item: any, resultIdx: number) => ({
return (_get(response, 'items', []) as any).map((item: any, resultIdx: number) => ({
idxInRequest: removals[resultIdx].idxInRequest,
result: item.update.result,
status: item.update.status,
Expand Down Expand Up @@ -237,7 +235,7 @@ export class ElasticsearchBeatsAdapter implements CMBeatsAdapter {
refresh: 'wait_for',
});
// console.log(response.items[0].update.error);
return _get<any>(response, 'items', []).map((item: any, resultIdx: any) => ({
return (_get(response, 'items', []) as any).map((item: any, resultIdx: any) => ({
idxInRequest: assignments[resultIdx].idxInRequest,
result: item.update.result,
status: item.update.status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class MemoryBeatsAdapter implements CMBeatsAdapter {
}

public async getAll(user: FrameworkUser) {
return this.beatsDB.map<CMBeat>((beat: any) => omit(beat, ['access_token']));
return this.beatsDB.map((beat: any) => omit(beat, ['access_token'])) as CMBeat[];
}

public async removeTagsFromBeats(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ElasticsearchConfigurationBlockAdapter implements ConfigurationBloc
};

const response = await this.database.search(user, params);
const configs = get<any>(response, 'hits.hits', []);
const configs = get(response, 'hits.hits', []);

return configs.map((tag: any) => ({ ...tag._source.tag, config: JSON.parse(tag._source.tag) }));
}
Expand Down Expand Up @@ -71,7 +71,7 @@ export class ElasticsearchConfigurationBlockAdapter implements ConfigurationBloc
} else {
response = await this.database.search(user, params);
}
const configs = get<any>(response, 'hits.hits', []);
const configs = get(response, 'hits.hits', []);

return {
blocks: configs.map((block: any) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ElasticsearchTagsAdapter implements CMTagsAdapter {
};
}
const response = await this.database.search(user, params);
const tags = get<any>(response, 'hits.hits', []);
const tags = get(response, 'hits.hits', []) as any;

return tags.map((tag: any) => ({ hasConfigurationBlocksTypes: [], ...tag._source.tag }));
}
Expand All @@ -63,7 +63,7 @@ export class ElasticsearchTagsAdapter implements CMTagsAdapter {

const beatsResponse = await this.database.search(user, params);

const beats = get<BeatTag[]>(beatsResponse, 'hits.hits', []).map(
const beats = (get(beatsResponse, 'hits.hits', []) as BeatTag[]).map(
(beat: any) => beat._source.beat
);

Expand Down Expand Up @@ -142,7 +142,7 @@ export class ElasticsearchTagsAdapter implements CMTagsAdapter {
};
const response = await this.database.index(user, params);

return get<string>(response, 'result');
return get(response, 'result') as string;
}

public async getWithoutConfigTypes(
Expand Down Expand Up @@ -172,7 +172,7 @@ export class ElasticsearchTagsAdapter implements CMTagsAdapter {
size: 10000,
};
const response = await this.database.search(user, params);
const tags = get<any>(response, 'hits.hits', []);
const tags = get(response, 'hits.hits', []) as any;

return tags.map((tag: any) => ({ hasConfigurationBlocksTypes: [], ...tag._source.tag }));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export class ElasticsearchTokensAdapter implements CMTokensAdapter {

const response = await this.database.get(user, params);

const tokenDetails = get<TokenEnrollmentData>(response, '_source.enrollment_token', {
const tokenDetails = get(response, '_source.enrollment_token', {
expires_on: '0',
token: null,
});
}) as TokenEnrollmentData;

// Elasticsearch might return fast if the token is not found. OR it might return fast
// if the token *is* found. Either way, an attacker could using a timing attack to figure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { CMServerLibs } from '../types';
export function compose(server: any): CMServerLibs {
const framework = new BackendFrameworkLib(new HapiBackendFrameworkAdapter(undefined, server));

const beatsAdapter = new MemoryBeatsAdapter(server.beatsDB || []);
const beatsAdapter = new MemoryBeatsAdapter(server.beatsDB || []) as any;
const configAdapter = new MemoryConfigurationBlockAdapter(server.configsDB || []);
const tags = new CMTagsDomain(
new MemoryTagsAdapter(server.tagsDB || []),
Expand Down
8 changes: 2 additions & 6 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@types/jsdom": "^12.2.4",
"@types/json-stable-stringify": "^1.0.32",
"@types/jsonwebtoken": "^7.2.8",
"@types/lodash": "^3.10.1",
"@types/lodash": "^4.14.155",
"@types/mapbox-gl": "^1.9.1",
"@types/memoize-one": "^4.1.0",
"@types/mime": "^2.0.1",
Expand Down Expand Up @@ -275,11 +275,7 @@
"json-stable-stringify": "^1.0.1",
"jsonwebtoken": "^8.5.1",
"jsts": "^1.6.2",
"lodash": "npm:@elastic/[email protected]",
"lodash.keyby": "^4.6.0",
"lodash.mean": "^4.1.0",
"lodash.topath": "^4.5.2",
"lodash.uniqby": "^4.7.0",
"lodash": "^4.17.15",
"lz-string": "^1.4.4",
"mapbox-gl": "^1.10.0",
"mapbox-gl-draw-rectangle-mode": "^1.0.4",
Expand Down
Loading