super-cp

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 13 Imported by: 0

README

super-cp

super-cp 是一个基于 Golang 实现的静态资源发布工具。

他针对将静态资源部署到 s3 的场景,提供了缓存控制和发布顺序管理能力

$ super-cp --help

Copy files to object storage as a static website

Usage:
  super-cp [flags] [job-names...]

Flags:
  -a, --analyze           print analyze output (default true)
  -j, --concurrency int   concurrency level (default 8)
  -c, --config string     config file path (default ".super-cp.yml")
      --dry-run           print all actions without actually do
  -h, --help              help for super-cp
  -v, --verbose           print verbose output

核心概念

1. jobs

表示不同的传输任务,使用命令行的 args 指定实际使用哪一个, 默认是 default

jobs:
  test:
  prod:
2. job.source

文件源的过滤规则,使用 Unix Shell 风格的 glob 语法,支持 ** 通配符

可以使用 strip 去除一部分前缀,下例的 dist/index.html 会被传输到目标存储的 index.html 中。

source: # 源文件(可以有多个)
  pattern: "dist/**/*" # 匹配 dist 目录下的所有文件
  strip: "dist" # 去掉 dist 前缀
3. job.dist

目标存储 DSN

dist:
  type: "s3"
  dsn: "s3://-/mybucket/mypath/"
4. job.rules

对待发布文件应用规则,参考 .example.yml 中的示例。

rules:
    # glob 匹配
  - pattern: "{icons/**,favicon.ico}"
    
    # 添加 header
    headers:
      "Cache-Control": "public, max-age=300"

    # 标记文件为排除
    exclude: true

    # 设置上传顺序,默认是 0,先小后大
    index: 1

Development

go build -o super-cp main.go
./super-cp -config .super-cp.yml test

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
uploaders
s3

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL