Skip to content

Commit 200266a

Browse files
committed
deps: drop another-npm-registry-client
`another-npm-registry-client` is a fork of `npm-registry-client` which is a, now deprecated, library for interacting with npm registries. At this point, the project does not use any runtime code from the library (see 893a67e and a678e14). The only part of it we still used was the NpmAuth type which represents npm authentication data. But there is already a type for this as part of the `npm-registry-fetch` libary. Therefore the dependency can now safely be removed.
1 parent d9a02f9 commit 200266a

9 files changed

+64
-696
lines changed

package-lock.json

+49-590
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"dependencies": {
6969
"@commander-js/extra-typings": "^9.5.0",
7070
"@iarna/toml": "^2.2.5",
71-
"another-npm-registry-client": "^8.7.0",
7271
"chalk": "^4.1.2",
7372
"cli-table": "^0.3.11",
7473
"commander": "^9.5.0",

src/app/get-registry-auth.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NpmAuth } from "another-npm-registry-client";
1+
import type { AuthOptions } from "npm-registry-fetch";
22
import { decodeBase64 } from "../domain/base64";
33
import { partialApply } from "../domain/fp-utils";
44
import { DebugLog } from "../domain/logging";
@@ -31,7 +31,7 @@ export function isNonAuthUrl(url: RegistryUrl): boolean {
3131
* @returns The converted auth object.
3232
* @throws {Error} If auth contained bad base64 string.
3333
*/
34-
export function importNpmAuth(entry: UpmConfigEntry): NpmAuth {
34+
export function importNpmAuth(entry: UpmConfigEntry): AuthOptions {
3535
// Basic auth
3636
if ("_auth" in entry) {
3737
const decoded = decodeBase64(entry._auth);
@@ -61,7 +61,7 @@ export function importNpmAuth(entry: UpmConfigEntry): NpmAuth {
6161
export function tryGetAuthEntry(
6262
upmConfig: UpmConfig,
6363
url: RegistryUrl
64-
): NpmAuth | null {
64+
): AuthOptions | null {
6565
const entry =
6666
upmConfig.npmAuth?.[url] ?? upmConfig.npmAuth?.[url + "/"] ?? null;
6767
if (entry === null) {

src/app/login.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NpmAuth } from "another-npm-registry-client";
1+
import type { AuthOptions } from "npm-registry-fetch";
22
import { partialApply } from "../domain/fp-utils";
33
import { DebugLog } from "../domain/logging";
44
import { RegistryUrl } from "../domain/registry-url";
@@ -51,15 +51,15 @@ export async function loginUsing(
5151
);
5252

5353
if (authMode === "basic") {
54-
const auth: NpmAuth = { username, password, email, alwaysAuth };
54+
const auth: AuthOptions = { username, password, email, alwaysAuth };
5555
return await putRegistryAuth(configPath, registry, auth);
5656
}
5757

5858
// npm login
5959
const token = await getAuthToken(registry, username, email, password);
6060
await debugLog(`npm login successful`);
6161

62-
const auth: NpmAuth = { token, email, alwaysAuth };
62+
const auth: AuthOptions = { token, email, alwaysAuth };
6363
await putRegistryAuth(configPath, registry, auth);
6464

6565
const npmrcPath = await putNpmAuthToken(homePath, registry, token);

src/app/put-registry-auth.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NpmAuth } from "another-npm-registry-client";
1+
import type { AuthOptions } from "npm-registry-fetch";
22
import { encodeBase64 } from "../domain/base64";
33
import { partialApply } from "../domain/fp-utils";
44
import { RegistryUrl } from "../domain/registry-url";
@@ -10,7 +10,7 @@ import { saveUpmConfigFileUsing } from "./write-upm-config";
1010

1111
function mergeEntries(
1212
oldEntry: UpmConfigEntry | null,
13-
newEntry: NpmAuth
13+
newEntry: AuthOptions
1414
): UpmConfigEntry {
1515
const alwaysAuth = newEntry.alwaysAuth ?? oldEntry?.alwaysAuth;
1616

@@ -41,7 +41,7 @@ function mergeEntries(
4141
export function putRegistryAuthIntoUpmConfig(
4242
currentContent: UpmConfig | null,
4343
registry: RegistryUrl,
44-
auth: NpmAuth
44+
auth: AuthOptions
4545
): UpmConfig {
4646
const oldEntries = currentContent?.npmAuth ?? {};
4747
// Search the entry both with and without trailing slash
@@ -70,7 +70,7 @@ export async function putRegistryAuthUsing(
7070
writeTextFile: WriteTextFile,
7171
configPath: string,
7272
registry: RegistryUrl,
73-
auth: NpmAuth
73+
auth: AuthOptions
7474
): Promise<void> {
7575
const loadUpmConfig = partialApply(loadUpmConfigUsing, readTextFile);
7676
const saveUpmConfig = partialApply(saveUpmConfigFileUsing, writeTextFile);

src/domain/registry.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { NpmAuth } from "another-npm-registry-client";
2-
import npmFetch from "npm-registry-fetch";
1+
import npmFetch, { type AuthOptions } from "npm-registry-fetch";
32
import { RegistryUrl, unityRegistryUrl } from "./registry-url";
43

54
/**
@@ -14,7 +13,7 @@ export type Registry = Readonly<{
1413
* The authentication information used for this registry. Null if the registry
1514
* does not require authentication.
1615
*/
17-
auth: NpmAuth | null;
16+
auth: AuthOptions | null;
1817
}>;
1918

2019
/**

src/types/another-npm-registry-client.d.ts

-51
This file was deleted.

test/integration/io/registry-client.mock.ts

-38
This file was deleted.

test/unit/domain/registry.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NpmAuth } from "another-npm-registry-client";
1+
import type { AuthOptions } from "npm-registry-fetch";
22
import { makeNpmFetchOptions, Registry } from "../../../src/domain/registry";
33
import { someRegistryUrl } from "../../common/data-registry";
44

@@ -31,7 +31,7 @@ describe("npm registry", () => {
3131
});
3232

3333
it("should use token auth info", () => {
34-
const auth: NpmAuth = { token: "Some token", alwaysAuth: true };
34+
const auth: AuthOptions = { token: "Some token", alwaysAuth: true };
3535
const registry: Registry = {
3636
url: someRegistryUrl,
3737
auth,
@@ -47,7 +47,7 @@ describe("npm registry", () => {
4747
});
4848

4949
it("should use basic auth info", () => {
50-
const auth: NpmAuth = {
50+
const auth: AuthOptions = {
5151
username: "user",
5252
password: "pass",
5353

0 commit comments

Comments
 (0)