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 oss #69701

Closed
wants to merge 1 commit into from
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@
"leaflet.heat": "0.2.0",
"less": "npm:@elastic/[email protected]",
"less-loader": "5.0.0",
"lodash4": "npm:lodash@^4.17.15",
"lodash3": "npm:@elastic/[email protected]",
"lodash": "npm:@elastic/[email protected]",
"lodash.clonedeep": "^4.5.0",
"lru-cache": "4.1.5",
Expand Down Expand Up @@ -354,6 +356,8 @@
"@types/json5": "^0.0.30",
"@types/license-checker": "15.0.0",
"@types/listr": "^0.14.0",
"@types/lodash4": "npm:@types/lodash@^4.14.155",
"@types/lodash3": "npm:@types/lodash@^3.10.1",
"@types/lodash": "^3.10.1",
"@types/lodash.clonedeep": "^4.5.4",
"@types/lru-cache": "^5.1.0",
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": {
"lodash3": "npm:@elastic/[email protected]",
"joi": "^13.5.2",
"moment": "^2.24.0",
"type-detect": "^4.0.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ValidationErrorItem,
ValidationOptions,
} from 'joi';
import { isPlainObject } from 'lodash';
import { isPlainObject } from 'lodash3';
import { isDuration } from 'moment';
import { Stream } from 'stream';
import { ByteSizeValue, ensureByteSizeValue } from '../byte_size_value';
Expand Down
16 changes: 16 additions & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,22 @@
'@types/lodash.clonedeepwith',
],
},
{
groupSlug: 'lodash3',
groupName: 'lodash3 related packages',
packageNames: [
'lodash3',
'@types/lodash3',
],
},
{
groupSlug: 'lodash4',
groupName: 'lodash4 related packages',
packageNames: [
'lodash4',
'@types/lodash4',
],
},
{
groupSlug: 'log-symbols',
groupName: 'log-symbols related packages',
Expand Down
2 changes: 1 addition & 1 deletion src/apm.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
const { join } = require('path');
const { readFileSync } = require('fs');
const { execSync } = require('child_process');
const merge = require('lodash.merge');
const merge = require('lodash4/merge');
const { name, version, build } = require('../package.json');

const ROOT_DIR = join(__dirname, '..');
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { pkg } from '../core/server/utils';
import Command from './command';
import serveCommand from './serve/serve';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cluster/cluster.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// eslint-disable-next-line max-classes-per-file
import EventEmitter from 'events';
import { assign, random } from 'lodash';
import { assign, random } from 'lodash4';
import { delay } from 'bluebird';

class MockClusterFork extends EventEmitter {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/cluster/cluster_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const mockConfig: any = {
},
};

import { sample } from 'lodash';
import { sample } from 'lodash4';

import { ClusterManager } from './cluster_manager';
import { Worker } from './worker';
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('CLI cluster manager', () => {
}

const football = {};
const messenger = sample(manager.workers);
const messenger = sample(manager.workers) as any;

messenger.emit('broadcast', football);
for (const worker of manager.workers) {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/cluster/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import cluster from 'cluster';
import { EventEmitter } from 'events';

Expand Down Expand Up @@ -177,7 +177,7 @@ export class Worker extends EventEmitter {
}

flushChangeBuffer() {
const files = _.unique(this.changes.splice(0));
const files = _.uniq(this.changes.splice(0));
const prefix = files.length > 1 ? '\n - ' : '';
return files.reduce(function (list, file) {
return `${list || ''}${prefix}"${file}"`;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import Chalk from 'chalk';

import help from './help';
Expand Down
4 changes: 2 additions & 2 deletions src/cli/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';

export default function help(command, spaces) {
if (!_.size(command.commands)) {
Expand Down Expand Up @@ -72,7 +72,7 @@ function commandsSummary(program) {
}, 0);

return cmds.reduce(function (help, cmd) {
return `${help || ''}${_.padRight(cmd[0], cmdLColWidth)} ${cmd[1] || ''}\n`;
return `${help || ''}${_.padEnd(cmd[0], cmdLColWidth)} ${cmd[1] || ''}\n`;
}, '');
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/serve/read_keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import path from 'path';
import { set } from 'lodash';
import { set } from 'lodash4';

import { Keystore } from '../../legacy/server/keystore';
import { getDataPath } from '../../core/server/path';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { statSync } from 'fs';
import { resolve } from 'path';
import url from 'url';
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/cli_keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { join } from 'path';

import { pkg } from '../core/server/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { pkg } from '../core/server/utils';
import Command from '../cli/command';
import listCommand from './list';
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { rename } from 'fs';
import { delay } from 'lodash';
import { delay } from 'lodash4';

export function renamePlugin(workingPath, finalPath) {
return new Promise(function (resolve, reject) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import yauzl from 'yauzl';
import path from 'path';
import { createWriteStream, mkdir } from 'fs';
import { get } from 'lodash';
import { get } from 'lodash4';

/**
* Returns an array of package objects. There will be one for each of
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/doc_title/doc_title_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { compact, flattenDeep, isString } from 'lodash';
import { compact, flattenDeep, isString } from 'lodash4';

interface StartDeps {
document: { title: string };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { sortBy } from 'lodash';
import { sortBy } from 'lodash4';
import { BehaviorSubject, ReplaySubject, Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { MountPoint } from '../../types';
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/nav_links/nav_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { sortBy } from 'lodash';
import { sortBy } from 'lodash4';
import { BehaviorSubject, combineLatest, Observable, ReplaySubject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';

Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/recently_accessed/persisted_log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { cloneDeep, isEqual, take } from 'lodash';
import { cloneDeep, isEqual, take } from 'lodash4';
import * as Rx from 'rxjs';
import { map } from 'rxjs/operators';

Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/ui/header/collapsible_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { groupBy, sortBy } from 'lodash';
import { groupBy, sortBy } from 'lodash4';
import React, { useRef } from 'react';
import { useObservable } from 'react-use';
import * as Rx from 'rxjs';
Expand Down
4 changes: 3 additions & 1 deletion src/core/public/http/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { merge } from 'lodash';
import { merge } from 'lodash3';
import { format } from 'url';
import { BehaviorSubject } from 'rxjs';

Expand Down Expand Up @@ -111,6 +111,7 @@ export class Fetch {
});
};

// TODO: need to migrate this to lodash4
private createRequest(options: HttpFetchOptionsWithPath): Request {
// Merge and destructure options out that are not applicable to the Fetch API.
const {
Expand All @@ -134,6 +135,7 @@ export class Fetch {
},
}
);

const url = format({
pathname: shouldPrependBasePath ? this.params.basePath.prepend(options.path) : options.path,
query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { get } from 'lodash';
import { get } from 'lodash4';
import { DiscoveredPlugin, PluginName } from '../../server';
import {
EnvironmentMode,
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/overlays/banners/priority_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { sortBy } from 'lodash';
import { sortBy } from 'lodash4';

interface PriorityValue {
readonly priority: number;
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/plugins/plugin_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { omit } from 'lodash';
import { omit } from 'lodash4';
import { DiscoveredPlugin } from '../../server';
import { PluginOpaqueId, PackageInfo, EnvironmentMode } from '../../server/types';
import { CoreContext } from '../core_system';
Expand Down
12 changes: 9 additions & 3 deletions src/core/public/plugins/plugins_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { omit, pick } from 'lodash';
import { omit, pick } from 'lodash4';

import {
MockedPluginInitializer,
Expand Down Expand Up @@ -92,7 +92,10 @@ describe('PluginsService', () => {
docLinks: docLinksServiceMock.createSetupContract(),
fatalErrors: fatalErrorsServiceMock.createSetupContract(),
http: httpServiceMock.createSetupContract(),
injectedMetadata: pick(injectedMetadataServiceMock.createStartContract(), 'getInjectedVar'),
injectedMetadata: pick(
injectedMetadataServiceMock.createStartContract(),
'getInjectedVar'
) as any,
notifications: notificationServiceMock.createSetupContract(),
uiSettings: uiSettingsServiceMock.createSetupContract(),
};
Expand All @@ -107,7 +110,10 @@ describe('PluginsService', () => {
http: httpServiceMock.createStartContract(),
chrome: chromeServiceMock.createStartContract(),
i18n: i18nServiceMock.createStartContract(),
injectedMetadata: pick(injectedMetadataServiceMock.createStartContract(), 'getInjectedVar'),
injectedMetadata: pick(
injectedMetadataServiceMock.createStartContract(),
'getInjectedVar'
) as any,
notifications: notificationServiceMock.createStartContract(),
overlays: overlayServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
Expand Down
6 changes: 4 additions & 2 deletions src/core/public/saved_objects/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { cloneDeep, pick, throttle } from 'lodash';
import { cloneDeep, pick, throttle } from 'lodash4';
import { resolve as resolveUrl } from 'url';

import {
Expand Down Expand Up @@ -162,7 +162,9 @@ export class SavedObjectsClient {
});

if (!foundObject) {
return queueItem.resolve(this.createSavedObject(pick(queueItem, ['id', 'type'])));
return queueItem.resolve(
this.createSavedObject(pick(queueItem, ['id', 'type']) as SavedObject)
);
}

queueItem.resolve(foundObject);
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/saved_objects/simple_saved_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { get, has, set } from 'lodash';
import { get, has, set } from 'lodash4';
import { SavedObject as SavedObjectType } from '../../server';
import { SavedObjectsClientContract } from './saved_objects_client';

Expand Down Expand Up @@ -60,7 +60,7 @@ export class SimpleSavedObject<T = unknown> {
}

public set(key: string, value: any): T {
return set(this.attributes, key, value);
return set(this.attributes as any, key, value) as any;
}

public has(key: string): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/ui_settings/ui_settings_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { cloneDeep, defaultsDeep } from 'lodash';
import { cloneDeep, defaultsDeep } from 'lodash4';
import { Observable, Subject, concat, defer, of } from 'rxjs';
import { filter, map } from 'rxjs/operators';

Expand Down
4 changes: 2 additions & 2 deletions src/core/server/capabilities/merge_capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

import { merge } from 'lodash';
import { mergeWith } from 'lodash4';
import { Capabilities } from './types';

export const mergeCapabilities = (...sources: Array<Partial<Capabilities>>): Capabilities =>
merge({}, ...sources, (a: any, b: any) => {
mergeWith({}, ...sources, (a: any, b: any) => {
if (
(typeof a === 'boolean' && typeof b === 'object') ||
(typeof a === 'object' && typeof b === 'boolean')
Expand Down
Loading