Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@turbo/codemod): add support for custom NPM registries #9803

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";
import type { MigrateCommandOptions } from "../types";

const REGISTRY = "https://registry.npmjs.org";
const DEFAULT_REGISTRY = "https://registry.npmjs.org";

interface PackageDetailsResponse {
"dist-tags": {
Expand All @@ -12,9 +12,12 @@ interface PackageDetailsResponse {
}

async function getPackageDetails({ packageName }: { packageName: string }) {
const registry =
process.env.npm_config_registry?.replace(/\/$/, "") || DEFAULT_REGISTRY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the reason for this .replace here? grep.app doesn't show me any prior art for this, though without the regex does. I'm figuring there's something I'm missing, just can't tell what it is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is to convert https://registry.npmjs.org/ to https://registry.npmjs.org

Happy to remove it though.


try {
const result = await axios.get<PackageDetailsResponse>(
`${REGISTRY}/${packageName}`
`${registry}/${packageName}`
);
return result.data;
} catch (err) {
Expand Down
Loading