-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
7,381 additions
and
6,774 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
dist | ||
pnpm-lock.yaml | ||
coverage | ||
docs |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
@@ -37,7 +37,8 @@ plugins: | |
custom: | ||
syncCloudStorage: | ||
- name: my-bucket | ||
localPath: ./assets | ||
patterns: | ||
- assets/* | ||
actions: | ||
- upload | ||
- delete | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ coverage: | |
status: | ||
project: | ||
default: | ||
target: 100% | ||
threshold: 40% | ||
target: 90% | ||
threshold: 20% |
Oops, something went wrong.