refactor: consolidate lodash dependencies (#1464)

This commit is contained in:
Mark Lee 2020-02-03 13:09:31 -08:00 коммит произвёл GitHub
Родитель 0193c27753
Коммит 8693a1eff4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 21 добавлений и 36 удалений

Просмотреть файл

@ -70,8 +70,7 @@
"global": "^4.3.2",
"html-webpack-plugin": "^3.2.0",
"inquirer": "^7.0.4",
"lodash.merge": "^4.6.2",
"lodash.template": "^4.5.0",
"lodash": "^4.17.15",
"log-symbols": "^3.0.0",
"mime-types": "^2.1.25",
"node-fetch": "^2.6.0",
@ -116,8 +115,7 @@
"@types/html-webpack-plugin": "^3.2.1",
"@types/inquirer": "^6.5.0",
"@types/listr": "^0.14.2",
"@types/lodash.merge": "^4.6.4",
"@types/lodash.template": "^4.4.4",
"@types/lodash": "^4.14.149",
"@types/mime-types": "^2.1.0",
"@types/minimist": "^1.2.0",
"@types/mocha": "^7.0.1",

Просмотреть файл

@ -51,8 +51,7 @@
"find-up": "^4.1.0",
"fs-extra": "^8.1.0",
"glob": "^7.1.5",
"lodash.merge": "^4.6.2",
"lodash.template": "^4.5.0",
"lodash": "^4.17.15",
"log-symbols": "^3.0.0",
"node-fetch": "^2.6.0",
"nugget": "^2.0.1",

Просмотреть файл

@ -1,4 +1,4 @@
import _merge from 'lodash.merge';
import { merge } from 'lodash';
import { asyncOra } from '@electron-forge/async-ora';
import baseTemplate from '@electron-forge/template-base';
import debug from 'debug';
@ -196,7 +196,7 @@ export default async ({
const templatePackageJSON = await readRawPackageJson(baseTemplate.templateDir);
if (packageJSON.config.forge) {
if (typeof packageJSON.config.forge !== 'string') {
packageJSON.config.forge = _merge(templatePackageJSON.config.forge, packageJSON.config.forge);
packageJSON.config.forge = merge(templatePackageJSON.config.forge, packageJSON.config.forge);
}
} else {
packageJSON.config.forge = templatePackageJSON.config.forge;

Просмотреть файл

@ -1,7 +1,7 @@
import { ForgeConfig } from '@electron-forge/shared-types';
import fs from 'fs-extra';
import path from 'path';
import _template from 'lodash.template';
import { template } from 'lodash';
import { readRawPackageJson } from './read-package-json';
import PluginInterface from './plugin-interface';
@ -94,7 +94,7 @@ export function renderConfigTemplate(dir: string, templateObj: any, obj: any) {
if (typeof value === 'object' && value !== null) {
renderConfigTemplate(dir, templateObj, value);
} else if (typeof value === 'string') {
obj[key] = _template(value)(templateObj);
obj[key] = template(value)(templateObj);
if (obj[key].startsWith('require:')) {
// eslint-disable-next-line global-require, import/no-dynamic-require
obj[key] = require(path.resolve(dir, obj[key].substr(8)));

Просмотреть файл

@ -1,6 +1,6 @@
import _merge from 'lodash.merge';
import { IForgeResolvableMaker, IForgeResolvablePublisher } from '@electron-forge/shared-types';
import { expect } from 'chai';
import { merge } from 'lodash';
import upgradeForgeConfig, { updateUpgradedForgeDevDeps } from '../../src/util/upgrade-forge-config';
@ -20,7 +20,7 @@ describe('upgradeForgeConfig', () => {
it('converts electron-rebuild config', () => {
const rebuildConfig = { types: ['prod'] };
const oldConfig = { electronRebuildConfig: _merge({}, rebuildConfig) };
const oldConfig = { electronRebuildConfig: { ...rebuildConfig } };
const newConfig = upgradeForgeConfig(oldConfig);
expect(newConfig.electronRebuildConfig).to.deep.equal(rebuildConfig);
@ -123,13 +123,13 @@ describe('updateUpgradedForgeDevDeps', () => {
};
it('removes unused makers from devDependencies', () => {
const packageJSON = _merge({}, skeletonPackageJSON);
const packageJSON = merge({}, skeletonPackageJSON);
const devDeps = updateUpgradedForgeDevDeps(packageJSON, ['@electron-forge/maker-squirrel']);
expect(devDeps).to.deep.equal([]);
});
it('adds makers to devDependencies', () => {
const packageJSON = _merge({}, skeletonPackageJSON);
const packageJSON = merge({}, skeletonPackageJSON);
packageJSON.config.forge.makers = [
{
name: '@electron-forge/maker-zip',
@ -149,7 +149,7 @@ describe('updateUpgradedForgeDevDeps', () => {
});
it('adds publishers to devDependencies', () => {
const packageJSON = _merge({}, skeletonPackageJSON);
const packageJSON = merge({}, skeletonPackageJSON);
packageJSON.config.forge.publishers = [
{ name: '@electron-forge/publisher-github' },
{ name: '@electron-forge/publisher-snapcraft' },
@ -162,8 +162,10 @@ describe('updateUpgradedForgeDevDeps', () => {
});
it('adds electron-compile plugin to devDependencies when electron-prebuilt-compile is in devDependencies', () => {
const packageJSON = _merge({}, skeletonPackageJSON, {
devDependencies: { 'electron-prebuilt-compile': '2.0.0' },
const packageJSON = merge({}, skeletonPackageJSON, {
devDependencies: {
'electron-prebuilt-compile': '2.0.0',
},
});
const actual = updateUpgradedForgeDevDeps(packageJSON, []);

Просмотреть файл

@ -22,7 +22,7 @@
"@electron-forge/shared-types": "6.0.0-beta.47",
"@octokit/rest": "^16.42.2",
"fs-extra": "^8.1.0",
"lodash.merge": "^4.6.2",
"lodash": "^4.17.15",
"mime-types": "^2.1.25"
}
}

Просмотреть файл

@ -1,5 +1,5 @@
import GitHubAPI from '@octokit/rest';
import merge from 'lodash.merge';
import { merge } from 'lodash';
export default class GitHub {
private options: GitHubAPI.Options;

Просмотреть файл

@ -1205,21 +1205,7 @@
"@types/node" "*"
rxjs "^6.5.1"
"@types/lodash.merge@^4.6.4":
version "4.6.6"
resolved "https://registry.yarnpkg.com/@types/lodash.merge/-/lodash.merge-4.6.6.tgz#b84b403c1d31bc42d51772d1cd5557fa008cd3d6"
integrity sha512-IB90krzMf7YpfgP3u/EvZEdXVvm4e3gJbUvh5ieuI+o+XqiNEt6fCzqNRaiLlPVScLI59RxIGZMQ3+Ko/DJ8vQ==
dependencies:
"@types/lodash" "*"
"@types/lodash.template@^4.4.4":
version "4.4.6"
resolved "https://registry.yarnpkg.com/@types/lodash.template/-/lodash.template-4.4.6.tgz#d28a380a0cd152e6846324bf8f68b93318f09bc0"
integrity sha512-nBw8J73e8AsYlS/ZoYRKDCQPHqm4F9xAeDLVe4M6xKDo4+1W0pruQ9egw5zgwxveb3C8kzSOetXalCzz3A1cTQ==
dependencies:
"@types/lodash" "*"
"@types/lodash@*":
"@types/lodash@^4.14.149":
version "4.14.149"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.149.tgz#1342d63d948c6062838fbf961012f74d4e638440"
integrity sha512-ijGqzZt/b7BfzcK9vTrS6MFljQRPn5BFWOx8oE0GYxribu6uV+aA9zZuXI1zc/etK9E8nrgdoF2+LgUw7+9tJQ==
@ -5946,7 +5932,7 @@ lodash.map@^4.5.1:
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
integrity sha1-dx7Hg540c9nEzeKLGTlMNWL09tM=
lodash.merge@^4.6.1, lodash.merge@^4.6.2:
lodash.merge@^4.6.1:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
@ -5961,7 +5947,7 @@ lodash.sortby@^4.7.0:
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
lodash.template@^4.2.2, lodash.template@^4.5.0:
lodash.template@^4.2.2:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab"
integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==