config-upload
📦 Upload files to storage with only one command.
Install
$ yarn add dev config-upload
or install globally
$ yarn global add config-upload
If you prefer using npm:
$ npm install --dev config-upload
Usage
- Run
config-update --init
to create a config file with prompt. Or simply putting config in.config-upload.json
.
- Upload files to storage with the following command
$ config-upload
CLI
$ config-upload --help
Usage
$ config-upload [options]
Options
--init Initialize a configuration file.
--no-fail-fast Upload all files no matter what. Default will exiting on first failure.
--config Config file path. Default is ".config-upload.json".
--context Additional context provided to config.
Examples
$ config-upload --init
$ config-upload
$ config-upload --config path/to/config.json
$ config-upload --context '{"revision": "v1.2.3"}'
Config
Need to configure some options by putting it in .config-upload.json
dists
dist name
Type: String
Name the distination
type
Type: String
The way to upload. If not specify, it will use dist name
as default.
Currently support types:
s3
qiniu
bucket
Type: String
Storage's bucket name.
folder
Type: String
Default: ''
Folder's path.
filename
Type: String
Default: [name].[ext]
File name in storage. Default is original file name.
folder
and filename
enable you to replace value with [name] [ext] or other injected context. For example, if uploaded file is image1.jpg
, folder/to/[ext]/
will replaced to folder/to/jpg
.
Provide context example:
command: $ config-upload --context '{"revision": "v4", "prefix": "a"}'
source: "bird.png"
folder: "/folder/[revision]"
filename: "[prefix]_[name].[ext]"
file path in storage: /folder/v4/a_bird.png
sources
Type: Array<Object>
Files prepared to upload by the defined array of object.
dist
Type: String
An upload destination defined in the dists
section. Specify dist name
as it's value.
include
Type: String
Includes files that matching pattern. Using glob.
exclude
Type: String
Excludes files that matching pattern. It takes priority over include
. Using glob.
folder
Override folder settings.
filename
Override filename settings.
Config Example
Basic example - Upload to S3
Custom Distination Name - Use s3 uploader
Exclude file - Without .txt file
Provide context - Git revision in folder path
command:
$ config-upload --context "{\"revision\": \"`git rev-parse HEAD`\"}"
config:
TODO
- Support YAML format
- AWS S3 permission group
- More uploaders
LICENSE
MIT