Skip to content

Commit

Permalink
deps: drop another-npm-registry-client
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
ComradeVanti committed Sep 28, 2024
1 parent 893a67e commit b024c6e
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 696 deletions.
639 changes: 49 additions & 590 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"dependencies": {
"@commander-js/extra-typings": "^9.5.0",
"@iarna/toml": "^2.2.5",
"another-npm-registry-client": "^8.7.0",
"chalk": "^4.1.2",
"cli-table": "^0.3.11",
"commander": "^9.5.0",
Expand Down
6 changes: 3 additions & 3 deletions src/app/get-registry-auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NpmAuth } from "another-npm-registry-client";
import type { AuthOptions } from "npm-registry-fetch";
import { decodeBase64 } from "../domain/base64";
import { partialApply } from "../domain/fp-utils";
import { DebugLog } from "../domain/logging";
Expand Down Expand Up @@ -31,7 +31,7 @@ export function isNonAuthUrl(url: RegistryUrl): boolean {
* @returns The converted auth object.
* @throws {Error} If auth contained bad base64 string.
*/
export function importNpmAuth(entry: UpmConfigEntry): NpmAuth {
export function importNpmAuth(entry: UpmConfigEntry): AuthOptions {
// Basic auth
if ("_auth" in entry) {
const decoded = decodeBase64(entry._auth);
Expand Down Expand Up @@ -61,7 +61,7 @@ export function importNpmAuth(entry: UpmConfigEntry): NpmAuth {
export function tryGetAuthEntry(
upmConfig: UpmConfig,
url: RegistryUrl
): NpmAuth | null {
): AuthOptions | null {
const entry =
upmConfig.npmAuth?.[url] ?? upmConfig.npmAuth?.[url + "/"] ?? null;
if (entry === null) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/login.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NpmAuth } from "another-npm-registry-client";
import type { AuthOptions } from "npm-registry-fetch";
import { partialApply } from "../domain/fp-utils";
import { DebugLog } from "../domain/logging";
import { RegistryUrl } from "../domain/registry-url";
Expand Down Expand Up @@ -51,15 +51,15 @@ export async function loginUsing(
);

if (authMode === "basic") {
const auth: NpmAuth = { username, password, email, alwaysAuth };
const auth: AuthOptions = { username, password, email, alwaysAuth };
return await putRegistryAuth(configPath, registry, auth);
}

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

const auth: NpmAuth = { token, email, alwaysAuth };
const auth: AuthOptions = { token, email, alwaysAuth };
await putRegistryAuth(configPath, registry, auth);

const npmrcPath = await putNpmAuthToken(homePath, registry, token);
Expand Down
8 changes: 4 additions & 4 deletions src/app/put-registry-auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NpmAuth } from "another-npm-registry-client";
import type { AuthOptions } from "npm-registry-fetch";
import { encodeBase64 } from "../domain/base64";
import { partialApply } from "../domain/fp-utils";
import { RegistryUrl } from "../domain/registry-url";
Expand All @@ -10,7 +10,7 @@ import { saveUpmConfigFileUsing } from "./write-upm-config";

function mergeEntries(
oldEntry: UpmConfigEntry | null,
newEntry: NpmAuth
newEntry: AuthOptions
): UpmConfigEntry {
const alwaysAuth = newEntry.alwaysAuth ?? oldEntry?.alwaysAuth;

Expand Down Expand Up @@ -41,7 +41,7 @@ function mergeEntries(
export function putRegistryAuthIntoUpmConfig(
currentContent: UpmConfig | null,
registry: RegistryUrl,
auth: NpmAuth
auth: AuthOptions
): UpmConfig {
const oldEntries = currentContent?.npmAuth ?? {};
// Search the entry both with and without trailing slash
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function putRegistryAuthUsing(
writeTextFile: WriteTextFile,
configPath: string,
registry: RegistryUrl,
auth: NpmAuth
auth: AuthOptions
): Promise<void> {
const loadUpmConfig = partialApply(loadUpmConfigUsing, readTextFile);
const saveUpmConfig = partialApply(saveUpmConfigFileUsing, writeTextFile);
Expand Down
5 changes: 2 additions & 3 deletions src/domain/registry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NpmAuth } from "another-npm-registry-client";
import npmFetch from "npm-registry-fetch";
import npmFetch, { type AuthOptions } from "npm-registry-fetch";
import { RegistryUrl, unityRegistryUrl } from "./registry-url";

/**
Expand All @@ -14,7 +13,7 @@ export type Registry = Readonly<{
* The authentication information used for this registry. Null if the registry
* does not require authentication.
*/
auth: NpmAuth | null;
auth: AuthOptions | null;
}>;

/**
Expand Down
51 changes: 0 additions & 51 deletions src/types/another-npm-registry-client.d.ts

This file was deleted.

38 changes: 0 additions & 38 deletions test/integration/io/registry-client.mock.ts

This file was deleted.

6 changes: 3 additions & 3 deletions test/unit/domain/registry.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NpmAuth } from "another-npm-registry-client";
import type { AuthOptions } from "npm-registry-fetch";
import { makeNpmFetchOptions, Registry } from "../../../src/domain/registry";
import { someRegistryUrl } from "../../common/data-registry";

Expand Down Expand Up @@ -31,7 +31,7 @@ describe("npm registry", () => {
});

it("should use token auth info", () => {
const auth: NpmAuth = { token: "Some token", alwaysAuth: true };
const auth: AuthOptions = { token: "Some token", alwaysAuth: true };
const registry: Registry = {
url: someRegistryUrl,
auth,
Expand All @@ -47,7 +47,7 @@ describe("npm registry", () => {
});

it("should use basic auth info", () => {
const auth: NpmAuth = {
const auth: AuthOptions = {
username: "user",
password: "pass",
email: "[email protected]",
Expand Down

0 comments on commit b024c6e

Please sign in to comment.