[Telemetry Tools] update lodash to 4.17 (#77317)
This commit is contained in:
parent
520d348bf8
commit
9dfa20acd0
|
@ -10,12 +10,12 @@
|
||||||
"kbn:watch": "yarn build --watch"
|
"kbn:watch": "yarn build --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"lodash": "npm:@elastic/lodash@3.10.1-kibana4",
|
"lodash": "^4.17.20",
|
||||||
"@kbn/dev-utils": "1.0.0",
|
"@kbn/dev-utils": "1.0.0",
|
||||||
"@kbn/utility-types": "1.0.0",
|
"@kbn/utility-types": "1.0.0",
|
||||||
"@types/normalize-path": "^3.0.0",
|
"@types/normalize-path": "^3.0.0",
|
||||||
"normalize-path": "^3.0.0",
|
"normalize-path": "^3.0.0",
|
||||||
"@types/lodash": "^3.10.1",
|
"@types/lodash": "^4.14.159",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"typescript": "4.0.2"
|
"typescript": "4.0.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import { uniq } from 'lodash';
|
import { uniqBy } from 'lodash';
|
||||||
import {
|
import {
|
||||||
getResolvedModuleSourceFile,
|
getResolvedModuleSourceFile,
|
||||||
getIdentifierDeclarationFromSource,
|
getIdentifierDeclarationFromSource,
|
||||||
|
@ -148,7 +148,7 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
|
||||||
.map((typeNode) => getDescriptor(typeNode, program))
|
.map((typeNode) => getDescriptor(typeNode, program))
|
||||||
.filter(discardNullOrUndefined);
|
.filter(discardNullOrUndefined);
|
||||||
|
|
||||||
const uniqueKinds = uniq(kinds, 'kind');
|
const uniqueKinds = uniqBy(kinds, 'kind');
|
||||||
|
|
||||||
if (uniqueKinds.length !== 1) {
|
if (uniqueKinds.length !== 1) {
|
||||||
throw Error('Mapping does not support conflicting union types.');
|
throw Error('Mapping does not support conflicting union types.');
|
||||||
|
|
|
@ -18,7 +18,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import { pick, isObject, each, isArray, reduce, isEmpty, merge, transform, isEqual } from 'lodash';
|
import {
|
||||||
|
pick,
|
||||||
|
pickBy,
|
||||||
|
isObject,
|
||||||
|
forEach,
|
||||||
|
isArray,
|
||||||
|
reduce,
|
||||||
|
isEmpty,
|
||||||
|
merge,
|
||||||
|
transform,
|
||||||
|
isEqual,
|
||||||
|
} from 'lodash';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import glob from 'glob';
|
import glob from 'glob';
|
||||||
import { readFile, writeFile } from 'fs';
|
import { readFile, writeFile } from 'fs';
|
||||||
|
@ -186,17 +197,17 @@ export function getPropertyValue(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pickDeep(collection: any, identity: any, thisArg?: any) {
|
export function pickDeep(collection: any, identity: any) {
|
||||||
const picked: any = pick(collection, identity, thisArg);
|
const picked: any = pick(collection, identity);
|
||||||
const collections = pick(collection, isObject, thisArg);
|
const collections = pickBy(collection, isObject);
|
||||||
|
|
||||||
each(collections, function (item, key) {
|
forEach(collections, function (item, key) {
|
||||||
let object;
|
let object;
|
||||||
if (isArray(item)) {
|
if (isArray(item)) {
|
||||||
object = reduce(
|
object = reduce(
|
||||||
item,
|
item,
|
||||||
function (result, value) {
|
function (result, value) {
|
||||||
const pickedDeep = pickDeep(value, identity, thisArg);
|
const pickedDeep = pickDeep(value, identity);
|
||||||
if (!isEmpty(pickedDeep)) {
|
if (!isEmpty(pickedDeep)) {
|
||||||
result.push(pickedDeep);
|
result.push(pickedDeep);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +216,7 @@ export function pickDeep(collection: any, identity: any, thisArg?: any) {
|
||||||
[] as any[]
|
[] as any[]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
object = pickDeep(item, identity, thisArg);
|
object = pickDeep(item, identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(object)) {
|
if (!isEmpty(object)) {
|
||||||
|
@ -230,33 +241,38 @@ export const flattenKeys = (obj: any, keyPath: any[] = []): any => {
|
||||||
return { [keyPath.join('.')]: obj };
|
return { [keyPath.join('.')]: obj };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type ObjectDict = Record<string, any>;
|
||||||
export function difference(actual: any, expected: any) {
|
export function difference(actual: any, expected: any) {
|
||||||
function changes(obj: { [key: string]: any }, base: { [key: string]: any }) {
|
function changes(obj: ObjectDict, base: ObjectDict) {
|
||||||
return transform(obj, function (result, value, key) {
|
return transform(
|
||||||
if (key && /@@INDEX@@/.test(`${key}`)) {
|
obj,
|
||||||
// The type definition is an Index Signature, fuzzy searching for similar keys
|
function (result, value, key) {
|
||||||
const regexp = new RegExp(`${key}`.replace(/@@INDEX@@/g, '(.+)?'));
|
if (key && /@@INDEX@@/.test(`${key}`)) {
|
||||||
const keysInBase = Object.keys(base)
|
// The type definition is an Index Signature, fuzzy searching for similar keys
|
||||||
.map((k) => {
|
const regexp = new RegExp(`${key}`.replace(/@@INDEX@@/g, '(.+)?'));
|
||||||
const match = k.match(regexp);
|
const keysInBase = Object.keys(base)
|
||||||
return match && match[0];
|
.map((k) => {
|
||||||
})
|
const match = k.match(regexp);
|
||||||
.filter((s): s is string => !!s);
|
return match && match[0];
|
||||||
|
})
|
||||||
|
.filter((s): s is string => !!s);
|
||||||
|
|
||||||
if (keysInBase.length === 0) {
|
if (keysInBase.length === 0) {
|
||||||
// Mark this key as wrong because we couldn't find any matching keys
|
// Mark this key as wrong because we couldn't find any matching keys
|
||||||
result[key] = value;
|
result[key] = value;
|
||||||
}
|
|
||||||
|
|
||||||
keysInBase.forEach((k) => {
|
|
||||||
if (!isEqual(value, base[k])) {
|
|
||||||
result[k] = isObject(value) && isObject(base[k]) ? changes(value, base[k]) : value;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else if (key && !isEqual(value, base[key])) {
|
keysInBase.forEach((k) => {
|
||||||
result[key] = isObject(value) && isObject(base[key]) ? changes(value, base[key]) : value;
|
if (!isEqual(value, base[k])) {
|
||||||
}
|
result[k] = isObject(value) && isObject(base[k]) ? changes(value, base[k]) : value;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} else if (key && !isEqual(value, base[key])) {
|
||||||
|
result[key] = isObject(value) && isObject(base[key]) ? changes(value, base[key]) : value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{} as ObjectDict
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return changes(actual, expected);
|
return changes(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
10
yarn.lock
10
yarn.lock
|
@ -4123,11 +4123,6 @@
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
"@types/webpack" "*"
|
"@types/webpack" "*"
|
||||||
|
|
||||||
"@types/lodash@^3.10.1":
|
|
||||||
version "3.10.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-3.10.3.tgz#aaddec6a3c93bf03b402db3acf5d4c77bce8bdff"
|
|
||||||
integrity sha512-b9zScBKmB/RJqETbxu3YRya61vJOik89/lR+NdxjZAFMDcMSjwX6IhQoP4terJkhsa9TE1C+l6XwxCkhhsaZXg==
|
|
||||||
|
|
||||||
"@types/lodash@^4.14.116", "@types/lodash@^4.14.159":
|
"@types/lodash@^4.14.116", "@types/lodash@^4.14.159":
|
||||||
version "4.14.159"
|
version "4.14.159"
|
||||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.159.tgz#61089719dc6fdd9c5cb46efc827f2571d1517065"
|
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.159.tgz#61089719dc6fdd9c5cb46efc827f2571d1517065"
|
||||||
|
@ -18971,11 +18966,6 @@ lodash@^3.10.1:
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
|
||||||
integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=
|
integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=
|
||||||
|
|
||||||
"lodash@npm:@elastic/lodash@3.10.1-kibana4":
|
|
||||||
version "3.10.1-kibana4"
|
|
||||||
resolved "https://registry.yarnpkg.com/@elastic/lodash/-/lodash-3.10.1-kibana4.tgz#d491228fd659b4a1b0dfa08ba9c67a4979b9746d"
|
|
||||||
integrity sha512-geQqXd9ZedRCL+kq5cpeahYWYaYRV0BMXhCwzq4DpnGCVs430FTMS3Wcot3XChZZhCvkwHm15bpNjB312vPxaA==
|
|
||||||
|
|
||||||
log-ok@^0.1.1:
|
log-ok@^0.1.1:
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/log-ok/-/log-ok-0.1.1.tgz#bea3dd36acd0b8a7240d78736b5b97c65444a334"
|
resolved "https://registry.yarnpkg.com/log-ok/-/log-ok-0.1.1.tgz#bea3dd36acd0b8a7240d78736b5b97c65444a334"
|
||||||
|
|
Loading…
Reference in a new issue