├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── my-app ├── .npmrc ├── index.js └── package.json └── my-package ├── .npmrc ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 11 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS CodeArtifact NPM Example 2 | 3 | An example repository for creating, publishing, and installing npm packages 4 | using [AWS CodeArtifact](https://aws.amazon.com/codeartifact/) 5 | 6 | ## Prerequisites 7 | 8 | 1. [Create an AWS account](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/) 9 | 2. [Install and configure the AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html) 10 | 3. [Create a CodeArtifact repository](https://docs.aws.amazon.com/codeartifact/latest/ug/create-repo.html) 11 | 12 | ## Getting Started 13 | 14 | ### Find and replace the following 15 | 16 | 1. `my-repo` with your CodeArtifact repository name 17 | 2. `my-domain` with your CodeArtifact domain 18 | 3. `us-east-1` with the region of your CodeArtifact repository 19 | 4. `` with your AWS account ID 20 | 5. `@myorg` with your org name 21 | 22 | ### Publish `my-package` 23 | 24 | To publish `my-package`, change your working directory to [./my-package](./my-package) 25 | and run `npm publish` 26 | 27 | ### Install from `my-app` 28 | 29 | To install your new package, change your working directory to [./my-app](./my-app) 30 | and run `npm install` 31 | 32 | ## Security 33 | 34 | See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. 35 | 36 | ## License 37 | 38 | This library is licensed under the MIT-0 License. See the LICENSE file. 39 | -------------------------------------------------------------------------------- /my-app/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /my-app/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. and its affiliates. All Rights Reserved. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Licensed under the MIT License. See the LICENSE accompanying this file 6 | * for the specific language governing permissions and limitations under 7 | * the License. 8 | */ 9 | 10 | const { helloWorld } = require("@myorg/my-package"); 11 | 12 | helloWorld(); 13 | -------------------------------------------------------------------------------- /my-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-app", 3 | "version": "1.0.0", 4 | "description": "A sample application consuming a private scoped npm package", 5 | "main": "index.js", 6 | "engines": { 7 | "npm": "<=6" 8 | }, 9 | "scripts": { 10 | "preinstall": "npm run co:login", 11 | "co:login": "aws codeartifact login --tool npm --repository my-repo --domain my-domain" 12 | }, 13 | "dependencies": { 14 | "@myorg/my-package": "^1.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /my-package/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /my-package/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. and its affiliates. All Rights Reserved. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Licensed under the MIT License. See the LICENSE accompanying this file 6 | * for the specific language governing permissions and limitations under 7 | * the License. 8 | */ 9 | 10 | module.exports.helloWorld = function () { 11 | console.log("Hello world!"); 12 | }; 13 | -------------------------------------------------------------------------------- /my-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@myorg/my-package", 3 | "version": "1.0.0", 4 | "description": "A sample private scoped npm package", 5 | "main": "index.js", 6 | "engines": { 7 | "npm": "<=6" 8 | }, 9 | "scripts": { 10 | "prepare": "npm run co:login", 11 | "co:login": "aws codeartifact login --tool npm --repository my-repo --domain my-domain" 12 | } 13 | } 14 | --------------------------------------------------------------------------------