Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-rc.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
msudgh committed Aug 18, 2024
2 parents 3101edb + 39e0b31 commit a977d24
Show file tree
Hide file tree
Showing 44 changed files with 7,381 additions and 6,774 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ updates:
allow:
- dependency-type: 'production'
groups:
production-dependencies:
security-update-for-dependencies:
applies-to: 'security-updates'
dependency-type: 'production'
target-branch: 'develop'
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dist
pnpm-lock.yaml
coverage
docs
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

11 changes: 11 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import("prettier").Config} */
const config = {
trailingComma: 'es5',
useTabs: false,
tabWidth: 2,
semi: false,
singleQuote: true,
printWidth: 80,
}

export default config
102 changes: 85 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# Sync Cloud Storage
# sync-cloud-storage

[![NPM](https://img.shields.io/npm/v/sync-cloud-storage)](https://www.npmjs.com/package/sync-cloud-storage)
[![Pipeline Status](https://github.com/msudgh/sync-cloud-storage/actions/workflows/ci.yml/badge.svg?branch=main)](./.github/workflows/ci.yml)
[![Codecov Status](https://codecov.io/gh/msudgh/sync-cloud-storage/branch/main/graph/badge.svg?token=2BY6063VOY)](https://codecov.io/gh/msudgh/sync-cloud-storage)
[![License](https://img.shields.io/github/license/msudgh/sync-cloud-storage)](LICENSE)

A simple way to sync folders & files between a remote machine and a cloud provider's storage.
Synchronize files and directories between a remote machine and a cloud storage via cloud frameworks and stacks consisting of [AWS SAM (Serverless)](https://www.serverless.com/) and [AWS Cloud Development Kit (CDK)](https://aws.amazon.com/cdk/). This package supports the following cloud storage providers: [AWS S3](https://aws.amazon.com/s3/).

Available for following cloud frameworks:
## Features

- [Serverless](https://serverless.com/)

> **Note**: This plugin is still in development and may not be stable. Use with caution.
- Sync multiple storages at once and flexible file matching (single or multiple file/dir sync) by defining patterns of [`glob`](<https://en.wikipedia.org/wiki/Glob_(programming)>) to include or exclude
- Supports a set of options as following for each file based on storage: `Prefix`, `Access Control List (ACL)`, `Tags`, `Metadata`
- Select a list of specific sync actions for each storage: `uploading`, `deleting`
- Modern and uses the latest official cloud provider's SDK
- AWS S3: [`[email protected]`](https://www.npmjs.com/package/@aws-sdk/client-s3)

## Installation

1. [**ni**](https://github.com/antfu/ni): `ni sync-cloud-storage -D`
2. [**npm**](https://npmjs.com/): `npm i sync-cloud-storage -D`
3. [**yarn**](https://yarnpkg.com/): `yarn add sync-cloud-storage -D`
4. [**pnpm**](https://pnpm.io/): `pnpm add sync-cloud-storage -D`
- [**npm**](https://npmjs.com/): `npm i sync-cloud-storage`
- [**yarn**](https://yarnpkg.com/): `yarn add sync-cloud-storage`
- [**pnpm**](https://pnpm.io/): `pnpm add sync-cloud-storage`
- [**ni**](https://github.com/antfu/ni): `ni sync-cloud-storage`

## Why
## Usage

- Uses the latest official cloud provider's SDK.
- Sync multiple storages at once.
- Sync tags and metadata of each storage.
### AWS S3

## Usage
#### Serverless

### Serverless
Sync storages action as a pre-deploy hook in the `serverless.yml`:

```yaml
plugins:
Expand All @@ -37,7 +37,8 @@ plugins:
custom:
syncCloudStorage:
- name: my-bucket
localPath: ./assets
patterns:
- assets/*
actions:
- upload
- delete
Expand All @@ -47,3 +48,70 @@ custom:
foo: bar
bar: foo
```
#### CDK
Call sync storages action after setting up a CDK App:
```typescript
import { Stack, App } from '@aws-cdk/core'
import SyncCloudStorage from 'sync-cloud-storage'

const app = new App()
const stack = new Stack(app, 'MyStack')
const syncCloudStorage = new SyncCloudStorage(stack, {
storages: [
{
name: 'my-bucket',
patterns: ['assets/*'],
actions: ['upload', 'delete'],
prefix: 'assets',
acl: 'public-read',
metadata: {
foo: 'bar',
bar: 'foo',
},
},
],
})

// Sync storages
syncCloudStorage.storages()

// Sync tags
syncCloudStorage.tags()

// Sync metadata
syncCloudStorage.metadata()
```

## Options

### General

| Option | Notes | Type | Required | Default |
| -------- | ---------------------------------- | -------------------------------- | -------- | ---------------------------------------------------- |
| storages | List of storages, Minimum items: 1 | `array` of [`storage`](#storage) | true | undefined |
| region | Cloud (AWS) region | `string` | false | undefined or `AWS_REGION` environment variable |
| endpoint | Cloud (AWS) Endpoint URL | `string` | false | undefined or `AWS_ENDPOINT_URL` environment variable |
| offline | Offline mode | `boolean` | false | false or `IS_OFFLINE` environment variable |
| disabled | Disable sync | `boolean` | false | false |
| silent | Silent output logs | `boolean` | false | false |

### Storage

| Option | Notes | Type | Required | Default |
| ----------- | ----------------------------------------------------------------------------------------------------------- | ------------------- | -------- | ------------------ |
| name | Name of storage (AWS S3 Bucket), Minimum length: 1 | `string` | true | undefined |
| patterns | Patterns of [`glob`][glob] paths to include or exclude on sync action, Minimum items: 1 | `array` of `string` | true | undefined |
| actions | Sync actions, Valid values: `upload`, `delete` | `array` of `string` | false | `upload`, `delete` |
| prefix | Prefix for the storage files and folders | `string` | false | `''` |
| enabled | Enable or disable the storage on sync action | `boolean` | false | `true` |
| acl | [AWS S3 Canned ACL][acl], Valid values: `private`, `public-read`, `public-read-write`, `authenticated-read` | `string` | false | undefined |
| metadata | A set of metadata key/value pair to be set or unset on the object | `object` | false | undefined |
| tags | A set of tag key/value pair to be set or unset on the object | `object` | false | `{}` |
| gitignore | Use .gitignore file to exclude files and directories | `boolean` | false | false |
| ignoreFiles | Ignore files and directories to exclude from sync action | `array` of `string` | false | undefined |

[glob]: https://en.wikipedia.org/wiki/Glob_(programming)
[acl]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
4 changes: 2 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ coverage:
status:
project:
default:
target: 100%
threshold: 40%
target: 90%
threshold: 20%
Loading

0 comments on commit a977d24

Please sign in to comment.