- Notifications
You must be signed in to change notification settings - Fork0
MaintainX/yarn-plugin-aws-codeartifact
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
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.
yarn plugin import https://raw.githubusercontent.com/mhassan1/yarn-plugin-aws-codeartifact/v0.22.0/bundles/@yarnpkg/plugin-aws-codeartifact.js- ConfigureAWS SDK credentials.
- 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.
- Run
yarncommands.
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- An
awsProfilevalue (including'', which is equivalent to'default') will override theAWS_PROFILEenvironment variable;otherwise, theAWS_PROFILEenvironment variable will be used (or if it is unset, the default profile will be used).
- An
preferAwsEnvironmentCredentials- Whether to prefer AWS credentials provided by environment variables, i.e.AWS_ACCESS_KEY_ID(defaultfalse)- By default, if
awsProfileis 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.
- By default, if
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
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:
_YARN_PLUGIN_AWS_CODEARTIFACT_DEBUG=* yarn
yarn test
NOTE: Integration tests requireyarn build first.
npm version <version>
MIT
About
Yarn Berry plugin that resolves authentication for AWS CodeArtifact NPM registries
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- TypeScript98.1%
- JavaScript1.9%