Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Unify Lodash (#1420)
Browse files Browse the repository at this point in the history
* Unify lodash at CLI

* Unify lodash at Lib

* Unify lodash at CLI

* Unify lodash at tests
  • Loading branch information
ylv-io authored Feb 4, 2020
1 parent 287243d commit 578e4f2
Show file tree
Hide file tree
Showing 62 changed files with 68 additions and 764 deletions.
78 changes: 0 additions & 78 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,45 +78,6 @@
"inquirer": "^6.4.1",
"is-url": "^1.2.4",
"lockfile": "^1.0.4",
"lodash.castarray": "^4.4.0",
"lodash.compact": "^3.0.1",
"lodash.concat": "^4.5.0",
"lodash.difference": "^4.5.0",
"lodash.every": "^4.6.0",
"lodash.filter": "^4.6.0",
"lodash.find": "^4.6.0",
"lodash.findindex": "^4.6.0",
"lodash.flatmap": "^4.5.0",
"lodash.flatten": "^4.4.0",
"lodash.flattendeep": "^4.4.0",
"lodash.foreach": "^4.5.0",
"lodash.frompairs": "^4.0.1",
"lodash.groupby": "^4.6.0",
"lodash.intersection": "^4.4.0",
"lodash.isempty": "^4.4.0",
"lodash.isequal": "^4.5.0",
"lodash.isnil": "^4.0.0",
"lodash.isnull": "^3.0.0",
"lodash.isstring": "^4.0.1",
"lodash.isundefined": "^3.0.1",
"lodash.map": "^4.6.0",
"lodash.mapvalues": "^4.6.0",
"lodash.max": "^4.0.1",
"lodash.maxby": "^4.6.0",
"lodash.merge": "^4.6.1",
"lodash.negate": "^3.0.2",
"lodash.omit": "^4.5.0",
"lodash.omitby": "^4.6.0",
"lodash.partition": "^4.6.0",
"lodash.pick": "^4.4.0",
"lodash.pickby": "^4.6.0",
"lodash.reverse": "^4.0.1",
"lodash.sortby": "^4.7.0",
"lodash.topairs": "^4.3.0",
"lodash.uniq": "^4.5.0",
"lodash.uniqby": "^4.7.0",
"lodash.uniqwith": "^4.5.0",
"lodash.zipwith": "^4.2.0",
"npm-programmatic": "0.0.12",
"rlp": "^2.2.3",
"semver": "^5.5.0",
Expand All @@ -139,44 +100,6 @@
"devDependencies": {
"@types/chai-as-promised": "^7.1.2",
"@types/lodash": "^4.14.119",
"@types/lodash.castarray": "^4.4.6",
"@types/lodash.compact": "^3.0.6",
"@types/lodash.concat": "^4.5.6",
"@types/lodash.difference": "^4.5.6",
"@types/lodash.every": "^4.6.6",
"@types/lodash.filter": "^4.6.6",
"@types/lodash.find": "^4.6.6",
"@types/lodash.findindex": "^4.6.6",
"@types/lodash.flatmap": "^4.5.6",
"@types/lodash.flatten": "^4.4.6",
"@types/lodash.flattendeep": "^4.4.6",
"@types/lodash.foreach": "^4.5.6",
"@types/lodash.frompairs": "^4.0.6",
"@types/lodash.groupby": "^4.6.6",
"@types/lodash.intersection": "^4.4.6",
"@types/lodash.isempty": "^4.4.6",
"@types/lodash.isequal": "^4.5.5",
"@types/lodash.isnil": "^4.0.6",
"@types/lodash.isstring": "^4.0.6",
"@types/lodash.isundefined": "^3.0.6",
"@types/lodash.map": "^4.6.13",
"@types/lodash.mapvalues": "^4.6.6",
"@types/lodash.max": "^4.0.6",
"@types/lodash.maxby": "^4.6.6",
"@types/lodash.merge": "^4.6.6",
"@types/lodash.negate": "^3.0.6",
"@types/lodash.omit": "^4.5.6",
"@types/lodash.omitby": "^4.6.6",
"@types/lodash.partition": "^4.6.6",
"@types/lodash.pick": "^4.4.6",
"@types/lodash.pickby": "^4.6.6",
"@types/lodash.reverse": "^4.0.6",
"@types/lodash.sortby": "^4.7.6",
"@types/lodash.topairs": "^4.3.6",
"@types/lodash.uniq": "^4.5.6",
"@types/lodash.uniqby": "^4.7.6",
"@types/lodash.uniqwith": "^4.5.6",
"@types/lodash.zipwith": "^4.2.6",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.12",
"@typescript-eslint/eslint-plugin": "^2.12.0",
Expand All @@ -189,7 +112,6 @@
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-prettier": "^3.1.0",
"ganache-cli": "^6.3.0",
"lodash.isnil": "^4.0.0",
"lodash.mapkeys": "^4.6.0",
"lodash.random": "^3.2.0",
"mocha": "^6.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/bin/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import program from 'commander';
import { Loggy } from '@openzeppelin/upgrades';
import commands from '../commands';
import sortBy from 'lodash.sortby';
import { sortBy } from 'lodash';

// Do not use import here or Typescript will create wrong build folder
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/call.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pickBy from 'lodash.pickby';
import { pickBy } from 'lodash';
import { ContractMethodMutability as Mutability } from '@openzeppelin/upgrades';

import call from '../scripts/call';
Expand All @@ -12,7 +12,7 @@ import {
InquirerQuestions,
} from '../prompts/prompt';
import ConfigManager from '../models/config/ConfigManager';
import { SendTxPropsParams, SendTxSelectionParams } from './interfaces';
import { SendTxSelectionParams } from './interfaces';
import promptForMethodParams from '../prompts/method-params';
import Telemetry from '../telemetry';

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CompileParams } from '../scripts/interfaces';
import { ProjectCompilerOptions } from '../models/compiler/ProjectCompilerOptions';
import Telemetry from '../telemetry';
import ProjectFile from '../models/files/ProjectFile';
import isundefined from 'lodash.isundefined';
import { isUndefined } from 'lodash';
import { promptIfNeeded } from '../prompts/prompt';
import { TypechainQuestions } from '../prompts/typechain';

Expand Down Expand Up @@ -66,7 +66,7 @@ async function action(options: CompileParams & { interactive: boolean }): Promis
if (
!projectFile.compilerOptions ||
!projectFile.compilerOptions.typechain ||
isundefined(projectFile.compilerOptions.typechain.enabled)
isUndefined(projectFile.compilerOptions.typechain.enabled)
) {
const { typechainEnabled, typechainTarget, typechainOutdir } = await promptIfNeeded(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pickBy from 'lodash.pickby';
import { pickBy } from 'lodash';
import { Loggy } from '@openzeppelin/upgrades';

import link from './link';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/create2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pickBy from 'lodash.pickby';
import { pickBy } from 'lodash';

import { TxParams } from '@openzeppelin/upgrades';

Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/push.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import omit from 'lodash.omit';
import isString from 'lodash.isstring';
import { omit, isString } from 'lodash';
import { ZWeb3 } from '@openzeppelin/upgrades';

import add from './add';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/send-tx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pickBy from 'lodash.pickby';
import { pickBy } from 'lodash';

import sendTx from '../scripts/send-tx';
import { SendTxParams } from '../scripts/interfaces';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/set-admin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pickBy from 'lodash.pickby';
import { pickBy } from 'lodash';
import { ZWeb3 } from '@openzeppelin/upgrades';

import { parseContractReference } from '../utils/contract';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/update.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pickBy from 'lodash.pickby';
import { pickBy } from 'lodash';

import push from './push';
import update from '../scripts/update';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/interface/ValidationLogger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import isEmpty from 'lodash.isempty';
import { isEmpty } from 'lodash';
import {
Loggy,
getStorageLayout,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/models/compiler/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ProjectCompilerOptions } from './ProjectCompilerOptions';
import findUp from 'find-up';
import ProjectFile from '../files/ProjectFile';
import { promisify } from 'util';
import merge from 'lodash.merge';
import { merge } from 'lodash';
import typechain from './Typechain';

const state = { alreadyCompiled: false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { mkdirp, readJson, writeJson } from 'fs-extra';
import axios from 'axios';
import solc, { CompilerOutput, Compiler, CompilerInput } from 'solc-wrapper';
import semver from 'semver';
import reverse from 'lodash.reverse';
import uniq from 'lodash.uniq';
import compact from 'lodash.compact';
import castArray from 'lodash.castarray';
import { compact, castArray, reverse, uniq } from 'lodash';
import { Loggy } from '@openzeppelin/upgrades';
import { homedir } from 'os';
import path from 'path';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import flatMap from 'lodash.flatmap';
import { flatMap } from 'lodash';
import semver from 'semver';
import { Loggy } from '@openzeppelin/upgrades';
import solc, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import path from 'path';
import max from 'lodash.max';
import maxBy from 'lodash.maxby';
import pick from 'lodash.pick';
import omitBy from 'lodash.omitby';
import isUndefined from 'lodash.isundefined';
import { max, maxBy, pick, omitBy, isUndefined } from 'lodash';
import { readJsonSync, ensureDirSync, readJSON, writeJson, unlink } from 'fs-extra';
import { statSync, existsSync, readdirSync, lstatSync } from 'fs';
import { Loggy, Contracts } from '@openzeppelin/upgrades';
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/src/models/config/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import TruffleConfig from './TruffleConfig';
import { default as Session, SessionOptions } from '../network/Session';
import NetworkConfig from './NetworkConfig';

import pick from 'lodash.pick';
import pickBy from 'lodash.pickby';
import isNil from 'lodash.isnil';
import { pick, pickBy, isNil } from 'lodash';

const ConfigManager = {
config: undefined,
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/src/models/config/NetworkConfig.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import fs from 'fs';
import path from 'path';
import pick from 'lodash.pick';
import omitBy from 'lodash.omitby';
import isUndefined from 'lodash.isundefined';
import { pick, omitBy, isUndefined } from 'lodash';

interface NetworkConfigInterface extends ConfigInterface {
artifactDefaults: ArtifactDefaults;
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/models/config/TruffleConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'fs';
import pickBy from 'lodash.pickby';
import pick from 'lodash.pick';
import { pickBy, pick } from 'lodash';
import npm from 'npm-programmatic';
import semver from 'semver';
import { Loggy } from '@openzeppelin/upgrades';
Expand Down
6 changes: 1 addition & 5 deletions packages/cli/src/models/dependency/Dependency.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import fs from 'fs';
import map from 'lodash.map';
import uniq from 'lodash.uniq';
import flatten from 'lodash.flatten';
import fromPairs from 'lodash.frompairs';
import toPairs from 'lodash.topairs';
import { map, uniq, flatten, fromPairs, toPairs } from 'lodash';
import semver from 'semver';
import npm from 'npm-programmatic';
import { exec } from 'child_process';
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/models/files/ManifestVersion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import isNull from 'lodash.isnull';
import isUndefined from 'lodash.isundefined';
import { isNull, isUndefined } from 'lodash';

const OPEN_ZEPPELIN = 'openzeppelin';
const CURRENT_MANIFEST_VERSION = ['2', '2'];
Expand Down
9 changes: 1 addition & 8 deletions packages/cli/src/models/files/NetworkFile.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import fs from 'fs-extra';
import path from 'path';
import findIndex from 'lodash.findindex';
import isEmpty from 'lodash.isempty';
import isEqual from 'lodash.isequal';
import difference from 'lodash.difference';
import flatMap from 'lodash.flatmap';
import map from 'lodash.map';
import filter from 'lodash.filter';
import find from 'lodash.find';
import { findIndex, isEmpty, isEqual, difference, flatMap, map, filter, find } from 'lodash';

import {
Loggy,
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/src/models/files/ProjectFile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import fs from 'fs-extra';
import path from 'path';
import pickBy from 'lodash.pickby';
import isEqual from 'lodash.isequal';
import isEmpty from 'lodash.isempty';
import { pickBy, isEqual, isEmpty } from 'lodash';

import { Loggy } from '@openzeppelin/upgrades';
import Dependency from '../dependency/Dependency';
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/models/local/LocalController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'fs-extra';
import every from 'lodash.every';
import map from 'lodash.map';
import { every, map } from 'lodash';
import {
Contracts,
Loggy,
Expand Down
11 changes: 1 addition & 10 deletions packages/cli/src/models/network/NetworkController.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import fs from 'fs-extra';
import isEmpty from 'lodash.isempty';
import intersection from 'lodash.intersection';
import difference from 'lodash.difference';
import uniq from 'lodash.uniq';
import filter from 'lodash.filter';
import every from 'lodash.every';
import partition from 'lodash.partition';
import map from 'lodash.map';
import concat from 'lodash.concat';
import toPairs from 'lodash.topairs';
import { isEmpty, intersection, difference, uniq, filter, every, partition, map, concat, toPairs } from 'lodash';
import toposort from 'toposort';

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/models/network/ProjectDeployer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import forEach from 'lodash.foreach';
import { forEach } from 'lodash';
import {
AppProject,
PackageProject,
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/src/models/network/Session.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import fs from 'fs-extra';
import omitBy from 'lodash.omitby';
import isEmpty from 'lodash.isempty';
import pick from 'lodash.pick';
import compact from 'lodash.compact';
import { omitBy, isEmpty, pick, compact } from 'lodash';
import path from 'path';

import { Loggy } from '@openzeppelin/upgrades';
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/src/models/network/TransactionController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import isEmpty from 'lodash.isempty';
import isUndefined from 'lodash.isundefined';
import isNull from 'lodash.isnull';
import { isEmpty, isUndefined, isNull } from 'lodash';

import { Contract, Transactions, Loggy, ZWeb3, TxParams, ABI } from '@openzeppelin/upgrades';
import { isValidUnit, prettifyTokenAmount, toWei, fromWei } from '../../utils/units';
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/prompts/choices.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Separator } from 'inquirer';

import difference from 'lodash.difference';
import flatten from 'lodash.flatten';
import { difference, flatten } from 'lodash';
import ProjectFile from '../models/files/ProjectFile';
import ContractManager from '../models/local/ContractManager';
import Dependency from '../models/dependency/Dependency';
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/src/prompts/method-params.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { ContractMethodMutability as Mutability } from '@openzeppelin/upgrades';
import pickBy from 'lodash.pickby';
import isUndefined from 'lodash.isundefined';
import negate from 'lodash.negate';
import { pickBy, isUndefined, negate } from 'lodash';

import { parseMethodParams, parseArg, getSampleInput } from '../utils/input';
import { promptIfNeeded, argsList, methodsList, InquirerQuestions, argLabel } from './prompt';
Expand Down
6 changes: 1 addition & 5 deletions packages/cli/src/prompts/prompt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import uniqBy from 'lodash.uniqby';
import flatten from 'lodash.flatten';
import isEmpty from 'lodash.isempty';
import groupBy from 'lodash.groupby';
import difference from 'lodash.difference';
import { uniqBy, flatten, isEmpty, groupBy } from 'lodash';
import inquirer from 'inquirer';
import { contractMethodsFromAbi, ContractMethodMutability as Mutability, ABI } from '@openzeppelin/upgrades';

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import uuid from 'uuid/v4';
import path from 'path';
import crypto from 'crypto';
import envPaths from 'env-paths';
import mapValues from 'lodash.mapvalues';
import { mapValues } from 'lodash';
import inquirer from 'inquirer';
import proc from 'child_process';
import process from 'process';
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/utils/async.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import map from 'lodash.map';
import isEmpty from 'lodash.isempty';
import { map, isEmpty } from 'lodash';

export async function allPromisesOrError(
promisesWithObjects: any[],
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/utils/input.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BN from 'bignumber.js';
import flattenDeep from 'lodash.flattendeep';
import { flattenDeep } from 'lodash';
import { encodeParams, Loggy, ZWeb3 } from '@openzeppelin/upgrades';
import { MethodArgType } from '../prompts/prompt';
import zipWith from 'lodash.zipwith';
import { zipWith } from 'lodash';
import { isAddress, isHex } from 'web3-utils';

// TODO: Deprecate in favor of a combination of parseArg and parseArray
Expand Down
Loading

0 comments on commit 578e4f2

Please sign in to comment.