diff --git a/package-lock.json b/package-lock.json index 7fb93cb8..9aa939c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,6 @@ "fs-extra": "^10.1.0", "is-wsl": "^2.2.0", "libnpmsearch": "^5.0.3", - "lodash": "^4.17.21", "mkdirp": "^3.0.1", "npm-registry-fetch": "^13.1.1", "npmlog": "^6.0.2", @@ -43,7 +42,6 @@ "@types/cli-table": "^0.3.2", "@types/fs-extra": "^11.0.3", "@types/libnpmsearch": "^2.0.4", - "@types/lodash": "^4.14.199", "@types/mocha": "^10.0.3", "@types/node": "^16.18.68", "@types/node-fetch": "^2.6.9", @@ -1410,11 +1408,6 @@ "@types/npm-registry-fetch": "*" } }, - "node_modules/@types/lodash": { - "version": "4.14.199", - "dev": true, - "license": "MIT" - }, "node_modules/@types/minimist": { "version": "1.2.2", "dev": true, @@ -4819,6 +4812,7 @@ }, "node_modules/lodash": { "version": "4.17.21", + "dev": true, "license": "MIT" }, "node_modules/lodash.capitalize": { @@ -11419,10 +11413,6 @@ "@types/npm-registry-fetch": "*" } }, - "@types/lodash": { - "version": "4.14.199", - "dev": true - }, "@types/minimist": { "version": "1.2.2", "dev": true @@ -13560,7 +13550,8 @@ } }, "lodash": { - "version": "4.17.21" + "version": "4.17.21", + "dev": true }, "lodash.capitalize": { "version": "4.2.1", diff --git a/package.json b/package.json index ede3a7b0..5dba53ad 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "@types/cli-table": "^0.3.2", "@types/fs-extra": "^11.0.3", "@types/libnpmsearch": "^2.0.4", - "@types/lodash": "^4.14.199", "@types/mocha": "^10.0.3", "@types/node": "^16.18.68", "@types/node-fetch": "^2.6.9", @@ -78,7 +77,6 @@ "fs-extra": "^10.1.0", "is-wsl": "^2.2.0", "libnpmsearch": "^5.0.3", - "lodash": "^4.17.21", "mkdirp": "^3.0.1", "npm-registry-fetch": "^13.1.1", "npmlog": "^6.0.2", diff --git a/src/cmd-login.ts b/src/cmd-login.ts index 573ff4e5..39192e0a 100644 --- a/src/cmd-login.ts +++ b/src/cmd-login.ts @@ -1,6 +1,5 @@ import fs from "fs"; import path from "path"; -import _ from "lodash"; import { assertIsNpmClientError, getNpmClient } from "./registry-client"; import log from "./logger"; import { @@ -106,8 +105,7 @@ const npmLogin = async function ( email, }, }); - if (_.isString(data.ok)) log.notice("auth", data.ok); - else if (data.ok) { + if (data.ok) { log.notice("auth", `you are authenticated as '${username}'`); const token = data.token; return { code: 0, token }; @@ -170,7 +168,7 @@ export const generateNpmrcLines = function ( let registryUrl = registry.slice(registry.search(/:\/\//) + 1); // add trailing slash if (!registryUrl.endsWith("/")) registryUrl = registryUrl + "/"; - const index = _.findIndex(lines, function (element, index) { + const index = lines.findIndex(function (element, index) { if (element.indexOf(registryUrl + ":_authToken=") !== -1) { // If an entry for the auth token is found, replace it lines[index] = element.replace( diff --git a/src/registry-client.ts b/src/registry-client.ts index dab21530..b6114c3e 100644 --- a/src/registry-client.ts +++ b/src/registry-client.ts @@ -9,7 +9,6 @@ import RegClient, { import log from "./logger"; import request from "request"; import assert, { AssertionError } from "assert"; -import _ from "lodash"; import { tryGetLatestVersion, UnityPackument } from "./types/packument"; import { DomainName, isInternalPackage } from "./types/domain-name"; import { SemanticVersion } from "./types/semantic-version"; @@ -156,7 +155,7 @@ export const fetchPackageDependencies = async function ( // a list of pending dependency {name, version} const pendingList: NameVersionPair[] = [{ name, version }]; // a list of processed dependency {name, version} - const processedList = []; + const processedList = Array.of(); // a list of dependency entry exists on the registry const depsValid = []; // a list of dependency entry doesn't exist on the registry @@ -169,7 +168,10 @@ export const fetchPackageDependencies = async function ( while (pendingList.length > 0) { // NOTE: Guaranteed defined because of while loop logic const entry = pendingList.shift() as NameVersionPair; - if (processedList.find((x) => _.isEqual(x, entry)) === undefined) { + const isProcessed = processedList.some( + (x) => x.name === entry.name && x.version === entry.version + ); + if (!isProcessed) { // add entry to processed list processedList.push(entry); // create valid dependency structure @@ -188,10 +190,10 @@ export const fetchPackageDependencies = async function ( }; if (!depObj.internal) { // try fetching package info from cache - const getResult = _.get(cachedPackageInfoDict, entry.name, { + const getResult = cachedPackageInfoDict[entry.name] ?? { packument: null, upstream: false, - }); + }; let packument = getResult.packument; const upstream = getResult.upstream; if (packument !== null) { @@ -252,10 +254,9 @@ export const fetchPackageDependencies = async function ( // add dependencies to pending list if (depObj.self || deep) { const deps: NameVersionPair[] = ( - _.toPairs(packument.versions[entry.version]!["dependencies"]) as [ - DomainName, - SemanticVersion - ][] + Object.entries( + packument.versions[entry.version]!["dependencies"] || {} + ) as [DomainName, SemanticVersion][] ).map((x): NameVersionPair => { return { name: x[0],