Skip to content

Commit

Permalink
remove memize dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Jul 29, 2024
1 parent f381e3c commit 91588c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
17 changes: 7 additions & 10 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S node --import @swc-node/register/esm-register
import ansiRegex from "ansi-regex";
import minimist from "minimist";
import rat from "registry-auth-token";
import registryAuthToken from "registry-auth-token";
import rc from "rc";
import {parse, coerce, diff, gt, gte, lt, neq, valid, validRange} from "semver";
import {cwd, stdout, argv, env, exit} from "node:process";
Expand All @@ -13,7 +13,6 @@ import supportsColor from "supports-color";
import {magenta, red, green, disableColor} from "glowie";
import {getProperty} from "dot-prop";
import pAll from "p-all";
import memize from "memize";
import picomatch from "picomatch";
import pkg from "./package.json" with {type: "json"};
import type {AuthOptions} from "registry-auth-token";
Expand Down Expand Up @@ -77,9 +76,7 @@ const partsRe = /^([^/]+)\/([^/#]+)?.*?\/([0-9a-f]+|v?[0-9]+\.[0-9]+\.[0-9]+)$/i
const hashRe = /^[0-9a-f]{7,}$/i;
const versionRe = /[0-9]+(\.[0-9]+)?(\.[0-9]+)?/g;
const esc = (str: string) => str.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&");
const gitInfo = memize(hostedGitInfo.fromUrl);
const registryAuthToken = memize(rat);
const normalizeUrl = memize((url: string) => url.endsWith("/") ? url.substring(0, url.length - 1) : url);
const normalizeUrl = (url: string) => url.endsWith("/") ? url.substring(0, url.length - 1) : url;
const packageVersion = pkg.version || "0.0.0";
const sep = "\0";

Expand Down Expand Up @@ -165,10 +162,10 @@ function matchesAny(str: string, set: PackageArg) {
return false;
}

const registryUrl = memize((scope: string, npmrc: Npmrc) => {
function registryUrl(scope: string, npmrc: Npmrc) {
const url = npmrc[`${scope}:registry`] || npmrc.registry;
return url.endsWith("/") ? url : `${url}/`;
});
}

function makeGoProxies(): string[] {
if (env.GOPROXY) {
Expand Down Expand Up @@ -201,15 +198,15 @@ function getAuthAndRegistry(name: string, registry: string, authTokenOpts: AuthO
}
}

const getFetchOpts = memize((agentOpts: AgentOptions, authType?: string, authToken?: string) => {
function getFetchOpts(agentOpts: AgentOptions, authType?: string, authToken?: string) {
return {
...(Object.keys(agentOpts).length && {agentOpts}),
headers: {
"user-agent": `updates/${packageVersion}`,
...(authToken && {Authorization: `${authType} ${authToken}`}),
}
};
});
}

async function doFetch(url: string, opts: RequestInit) {
if (args.verbose) console.error(`${magenta("fetch")} ${url}`);
Expand Down Expand Up @@ -299,7 +296,7 @@ function getInfoUrl({repository, homepage, info}: {repository: string | {[other:
return `https://github.com/${name.replace(/^@/, "")}`;
} else if (repository) {
const url: string = typeof repository === "string" ? repository : repository.url;
const info = gitInfo(url);
const info = hostedGitInfo.fromUrl(url);
const browse = info?.browse?.();
if (browse) {
infoUrl = browse;
Expand Down
8 changes: 0 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"execa": "8.0.1",
"glowie": "1.3.2",
"hosted-git-info": "7.0.2",
"memize": "2.1.0",
"minimist": "1.2.8",
"p-all": "5.0.0",
"picomatch": "4.0.2",
Expand Down

0 comments on commit 91588c4

Please sign in to comment.