Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Feb 7, 2022
1 parent 65f42fb commit 7b65862
Show file tree
Hide file tree
Showing 17 changed files with 572 additions and 38 deletions.
182 changes: 159 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,167 @@
# typescript-library-skeleton
# @jcoreio/aws-ecr-utils

[![CircleCI](https://circleci.com/gh/jedwards1211/typescript-library-skeleton.svg?style=svg)](https://circleci.com/gh/jedwards1211/typescript-library-skeleton)
[![Coverage Status](https://codecov.io/gh/jedwards1211/typescript-library-skeleton/branch/master/graph/badge.svg)](https://codecov.io/gh/jedwards1211/typescript-library-skeleton)
[![CircleCI](https://circleci.com/gh/jcoreio/aws-ecr-utils.svg?style=svg)](https://circleci.com/gh/jcoreio/aws-ecr-utils)
[![Coverage Status](https://codecov.io/gh/jcoreio/aws-ecr-utils/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/aws-ecr-utils)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![npm version](https://badge.fury.io/js/typescript-library-skeleton.svg)](https://badge.fury.io/js/typescript-library-skeleton)
[![npm version](https://badge.fury.io/js/%40jcoreio%2Faws-ecr-utils.svg)](https://badge.fury.io/js/%40jcoreio%2Faws-ecr-utils)

This is my personal skeleton for creating an typescript library npm package. You are welcome to use it.
# Table of Contents

## Quick start
- [@jcoreio/aws-ecr-utils](#jcoreioaws-ecr-utils)
- [Table of Contents](#table-of-contents)
- [`copyECRImage(options)`](#copyecrimageoptions)
- [Options](#options)
- [`options.from.imageUri`, `options.to.imageUri` (`string`, **required**)](#optionsfromimageuri-optionstoimageuri-string-required)
- [`options.from.ecr`, `options.to.ecr` (`AWS.ECR`, _optional_)](#optionsfromecr-optionstoecr-awsecr-optional)
- [`options.from.awsConfig`, `options.to.awsConfig` (`AWS.ConfigurationOptions`, _optional_)](#optionsfromawsconfig-optionstoawsconfig-awsconfigurationoptions-optional)
- [Returns (`Promise<void>`)](#returns-promisevoid)
- [`ecrImageExists(options)`](#ecrimageexistsoptions)
- [Options](#options-1)
- [`options.ecr` (`AWS.ECR`, _optional_)](#optionsecr-awsecr-optional)
- [`options.awsConfig` (`AWS.ConfigurationOptions`, _optional_)](#optionsawsconfig-awsconfigurationoptions-optional)
- [`options.imageUri` (`string`, _optional_)](#optionsimageuri-string-optional)
- [`options.registryId` (`string`, _optional_)](#optionsregistryid-string-optional)
- [`options.repositoryName` (`string`, _optional_)](#optionsrepositoryname-string-optional)
- [`options.imageTag` (`string`, _optional_)](#optionsimagetag-string-optional)
- [Returns (`Promise<boolean>`)](#returns-promiseboolean)
- [`loginToECR(options)`](#logintoecroptions)
- [Options](#options-2)
- [`options.ecr` (`AWS.ECR`, _optional_)](#optionsecr-awsecr-optional-1)
- [`options.awsConfig` (`AWS.ConfigurationOptions`, _optional_)](#optionsawsconfig-awsconfigurationoptions-optional-1)
- [Returns (`Promise<void>`)](#returns-promisevoid-1)
- [`parseECRImageUri(imageUri)`](#parseecrimageuriimageuri)
- [Options](#options-3)
- [`imageUri` (`string`, **required**)](#imageuri-string-required)
- [Returns (`object`)](#returns-object)
- [`tagECRImage(options)`](#tagecrimageoptions)
- [Options](#options-4)
- [`options.ecr` (`AWS.ECR`, _optional_)](#optionsecr-awsecr-optional-2)
- [`options.awsConfig` (`AWS.ConfigurationOptions`, _optional_)](#optionsawsconfig-awsconfigurationoptions-optional-2)
- [`options.imageUri` (`string`, **required**)](#optionsimageuri-string-required)
- [`options.tags` (`string[]`, **required**)](#optionstags-string-required)
- [Returns (`Promise<void>`)](#returns-promisevoid-2)

```sh
npx 0-60 clone https://github.com/jedwards1211/typescript-library-skeleton.git
## `copyECRImage(options)`

Copies an image between ECRs (potentially between accounts). Requires Docker to be installed and the `docker` command to be on your path.

### Options

#### `options.from.imageUri`, `options.to.imageUri` (`string`, **required**)

The URIs of the source and destination ECR images

#### `options.from.ecr`, `options.to.ecr` (`AWS.ECR`, _optional_)

The ECR clients to use for the source and destination images

#### `options.from.awsConfig`, `options.to.awsConfig` (`AWS.ConfigurationOptions`, _optional_)

The AWS service options to use if `options.from.ecr` and `options.to.ecr` aren't provided

### Returns (`Promise<void>`)

A promise that will resolve once the image has been pulled from the source repository and pushed to the destination repository.

## `ecrImageExists(options)`

Determines if an ECR image exists.

### Options

#### `options.ecr` (`AWS.ECR`, _optional_)

The ECR client to use

#### `options.awsConfig` (`AWS.ConfigurationOptions`, _optional_)

The AWS service options to use if `options.ecr` isn't provided

#### `options.imageUri` (`string`, _optional_)

The URI of the image to look for. You must provide either this or `options.registryId`,
`options.repositoryName`, or `imageTag`.

#### `options.registryId` (`string`, _optional_)

The ID of the ECR (same as your AWS account number?)

#### `options.repositoryName` (`string`, _optional_)

The name of the ECR repository

#### `options.imageTag` (`string`, _optional_)

The ECR image tag

### Returns (`Promise<boolean>`)

A promise that will resolve to true if the image exists and false otherwise.

## `loginToECR(options)`

Logs the local Docker client into the given ECR. Requires Docker to be installed and the `docker` command to be on your path.

### Options

#### `options.ecr` (`AWS.ECR`, _optional_)

The ECR client to use

#### `options.awsConfig` (`AWS.ConfigurationOptions`, _optional_)

The AWS service options to use if `options.ecr` isn't provided

### Returns (`Promise<void>`)

A promise that will resolve once logged in.

## `parseECRImageUri(imageUri)`

Parses the given ECR image URI.

### Options

#### `imageUri` (`string`, **required**)

The URI of the ECR image to parse.

### Returns (`object`)

An object with the following properties:

```ts
{
registryId: string
region: string
repositoryName: string
imageTag: string
}
```

## Tools used

- babel 7
- typescript
- mocha
- chai
- istanbul
- nyc
- eslint
- prettier
- husky
- semantic-release
- renovate
- Circle CI
- Codecov.io
## `tagECRImage(options)`

Adds additional tags to an existing ECR image.

### Options

#### `options.ecr` (`AWS.ECR`, _optional_)

The ECR client to use

#### `options.awsConfig` (`AWS.ConfigurationOptions`, _optional_)

The AWS service options to use if `options.ecr` isn't provided

#### `options.imageUri` (`string`, **required**)

The URI of the ECR image to add tags to

#### `options.tags` (`string[]`, **required**)

The tags to add to the ECR image

### Returns (`Promise<void>`)

A promise that will resolve once the tags have been added.
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typescript-library-skeleton",
"name": "@jcoreio/aws-ecr-utils",
"version": "0.0.0-development",
"description": "my personal ES2015 library project skeleton",
"description": "utilities for working with AWS Elastic Container Registry",
"main": "index.js",
"sideEffects": false,
"scripts": {
Expand Down Expand Up @@ -68,17 +68,19 @@
},
"repository": {
"type": "git",
"url": "https://github.com/jedwards1211/typescript-library-skeleton.git"
"url": "https://github.com/jcoreio/aws-ecr-utils.git"
},
"keywords": [
"typescript"
"aws",
"ecr",
"aws-sdk"
],
"author": "Andy Edwards",
"license": "MIT",
"bugs": {
"url": "https://github.com/jedwards1211/typescript-library-skeleton/issues"
"url": "https://github.com/jcoreio/aws-ecr-utils/issues"
},
"homepage": "https://github.com/jedwards1211/typescript-library-skeleton#readme",
"homepage": "https://github.com/jcoreio/aws-ecr-utils#readme",
"devDependencies": {
"@babel/cli": "^7.15.7",
"@babel/core": "^7.15.5",
Expand Down Expand Up @@ -118,6 +120,9 @@
"typescript": "^4.4.3"
},
"dependencies": {
"@babel/runtime": "^7.15.4"
"@babel/runtime": "^7.15.4",
"aws-sdk": "^2.1070.0",
"base64-js": "^1.5.1",
"promisify-child-process": "^4.1.1"
}
}
Loading

0 comments on commit 7b65862

Please sign in to comment.