-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use PAT due to branch protection (#17)
Also some more logging
- Loading branch information
Showing
5 changed files
with
87 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,69 @@ | ||
import type { PackageJson } from "read-pkg"; | ||
import { DEFAULT_NPM_REGISTRY } from "./definitions/constants.js"; | ||
import { | ||
DEFAULT_NPM_REGISTRY, | ||
YARNRC_FILENAME, | ||
} from "./definitions/constants.js"; | ||
import type { CommonContext } from "./definitions/context.js"; | ||
import type { Yarnrc } from "./definitions/yarnrc.js"; | ||
|
||
export function getRegistry( | ||
{ publishConfig }: PackageJson, | ||
{ npmRegistryServer, npmPublishRegistry }: Yarnrc, | ||
{ env }: { env?: CommonContext["env"] } | ||
{ | ||
env, | ||
logger, | ||
}: { env: CommonContext["env"]; logger: CommonContext["logger"] } | ||
) { | ||
const publishConfigRegistry = publishConfig?.["registry"] as | ||
| string | ||
| undefined; | ||
|
||
return ( | ||
publishConfigRegistry || | ||
env?.["YARN_NPM_PUBLISH_REGISTRY"] || | ||
npmPublishRegistry || | ||
env?.["YARN_NPM_REGISTRY_SERVER"] || | ||
npmRegistryServer || | ||
DEFAULT_NPM_REGISTRY | ||
); | ||
if (publishConfigRegistry) { | ||
logger.log( | ||
`Using registry "%s" from "package.json: publishConfig.registry"`, | ||
publishConfigRegistry | ||
); | ||
|
||
return publishConfigRegistry; | ||
} | ||
|
||
if (env["YARN_NPM_PUBLISH_REGISTRY"]) { | ||
logger.log( | ||
`Using registry "%s" from environment variable YARN_NPM_PUBLISH_REGISTRY`, | ||
env["YARN_NPM_PUBLISH_REGISTRY"] | ||
); | ||
|
||
return env["YARN_NPM_PUBLISH_REGISTRY"]; | ||
} | ||
|
||
if (npmPublishRegistry) { | ||
logger.log( | ||
`Using registry "%s" from "${YARNRC_FILENAME}: npmPublishRegistry"`, | ||
npmPublishRegistry | ||
); | ||
|
||
return npmPublishRegistry; | ||
} | ||
|
||
if (env["YARN_NPM_REGISTRY_SERVER"]) { | ||
logger.log( | ||
`Using registry "%s" from environment variable YARN_NPM_REGISTRY_SERVER`, | ||
env["YARN_NPM_REGISTRY_SERVER"] | ||
); | ||
|
||
return env["YARN_NPM_REGISTRY_SERVER"]; | ||
} | ||
|
||
if (npmRegistryServer) { | ||
logger.log( | ||
`Using registry "%s" from "${YARNRC_FILENAME}: npmRegistryServer"`, | ||
npmRegistryServer | ||
); | ||
|
||
return npmRegistryServer; | ||
} | ||
|
||
logger.log(`Using default registry "%s"`, DEFAULT_NPM_REGISTRY); | ||
|
||
return DEFAULT_NPM_REGISTRY; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters