Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Yarn Berry plugin that resolves authentication for AWS CodeArtifact NPM registries

NotificationsYou must be signed in to change notification settings

MaintainX/yarn-plugin-aws-codeartifact

 
 

Repository files navigation

This is a Yarn v4 plugin that resolves authentication for AWS CodeArtifact NPM registries.

For Yarn v3 support, installv0.16.1 or earlier(down tov0.8.0).

For Yarn v2 support, installv0.7.6 or earlier.

Install

yarn plugin import https://raw.githubusercontent.com/mhassan1/yarn-plugin-aws-codeartifact/v0.22.0/bundles/@yarnpkg/plugin-aws-codeartifact.js

Usage

  1. ConfigureAWS SDK credentials.
  2. Put the AWS CodeArtifact Registry URL in.yarnrc.yml:
# .yarnrc.ymlnpmRegistryServer:https://domain-test-000000000000.d.codeartifact.us-east-1.amazonaws.com/npm/repo-test/npmPublishRegistry:https://domain-test-000000000000.d.codeartifact.us-east-1.amazonaws.com/npm/repo-test/npmAlwaysAuth:true# ORnpmRegistries://domain-test-000000000000.d.codeartifact.us-east-1.amazonaws.com/npm/repo-test/:npmAlwaysAuth:true# ORnpmScopes:my-scope:npmRegistryServer:https://domain-test-000000000000.d.codeartifact.us-east-1.amazonaws.com/npm/repo-test/npmPublishRegistry:https://domain-test-000000000000.d.codeartifact.us-east-1.amazonaws.com/npm/repo-test/npmAlwaysAuth:true

IMPORTANT:npmAlwaysAuth: true must be specified wherever a registry is defined.

NOTE: IfpublishConfig.registry is specified inpackage.json,you must also specify that registry innpmRegistries in.yarnrc.yml.

  1. Runyarn commands.

AWS Profiles

If you have configured multipleAWS Profiles,(e.g. in an AWS credentials file like~/.aws/credentials (Linux & Mac) or%USERPROFILE%\.aws\credentials (Windows))you can specify the profile to use by specifying theAWS_PROFILE environment variable.

For more fine-grained control, you can add a.yarn-plugin-aws-codeartifact.yml configuration filein your project directory, any parent directory, or the home directory (similar to.yarnrc.yml):

# .yarn-plugin-aws-codeartifact.ymlnpmRegistryServerConfig:PluginRegistryConfig# ORnpmPublishRegistryConfig:PluginRegistryConfig# ORnpmRegistries://domain-test-000000000000.d.codeartifact.us-east-1.amazonaws.com/npm/repo-test/:PluginRegistryConfig# ORnpmScopes:my-scope:npmRegistryServerConfig:PluginRegistryConfig# ORnpmPublishRegistryConfig:PluginRegistryConfig

wherePluginRegistryConfig contains the following properties:

  • awsProfile - Name of the AWS Profile to use for this registry
    • AnawsProfile value (including'', which is equivalent to'default') will override theAWS_PROFILE environment variable;otherwise, theAWS_PROFILE environment variable will be used (or if it is unset, the default profile will be used).
  • preferAwsEnvironmentCredentials - Whether to prefer AWS credentials provided by environment variables, i.e.AWS_ACCESS_KEY_ID (defaultfalse)
    • By default, ifawsProfile is provided, AWS SDK v3 will look for that profile only and fail if it doesn't exist on the machine.
    • Set this flag to check for environment variable credentials first, and only attempt to use the profile if credentials are not provided by environment variables.
    • This flag is useful in the scenario where developers will use profiles but CI environments will use environment variables.
  • skipCommand - Command to run when deciding whether to authenticate to AWS; if the command exits zero, skip authentication (optional)
    • The command will run relative to the directory where it's defined
  • preAuthCommand - Command to run before authenticating to AWS (optional)
    • The command will run relative to the directory where it's defined
# PluginRegistryConfig# Name of the AWS Profile to use for this registry.#awsProfile:aws-profile# By default, if `awsProfile` is provided, AWS SDK v3 will look for that profile and fail if it doesn't exist on the machine.# Set this to `true` to first check for AWS credentials provided by environment variables (i.e. `AWS_ACCESS_KEY_ID`);#preferAwsEnvironmentCredentials:true# Command to run when deciding whether to authenticate to AWS, relative to the directory where it's defined;# if the command exits zero, skip authentication (optional)#skipCommand:|-  node -e "process.exitCode = process.env.MY_SKIP_ENV_VAR === 'true' ? 0 : 1"# Command to run before authenticating to AWS, relative to the directory where it's defined (optional)#preAuthCommand:log-me-in

How It Works

This plugin hooks into Yarn Berry so that anyyarn commands that may require fetching or publishing packagesto an AWS CodeArtifact registry will have an AWS CodeArtifact token generated right before.

It uses thegetNpmAuthenticationHeader hook.

Seesrc/registryCommands.ts for the list of supportedyarn commands and the type of registry they require.NOTE:lerna commands are also supported, as long as they are run withyarn lerna ....

More info:

Debugging

_YARN_PLUGIN_AWS_CODEARTIFACT_DEBUG=* yarn

Testing

yarn test

NOTE: Integration tests requireyarn build first.

Publishing

npm version <version>

License

MIT

About

Yarn Berry plugin that resolves authentication for AWS CodeArtifact NPM registries

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript98.1%
  • JavaScript1.9%

[8]ページ先頭

©2009-2025 Movatter.jp