Skip to content

hackycy-collection/ossx-cli

Repository files navigation

ossx-cli

npm version npm downloads bundle License

Feb-06-2026 20-58-49

将本地构建产物一键上传到对象存储或服务器目录,用于前端/静态站点/资源文件自动化部署流程。

平台 状态 说明
阿里云 OSS 直传签名(HMAC-SHA1)PUT 上传
腾讯云 COS 临时签名(q-sign-*)PUT 上传
七牛云 规划中
SSH 基于 ssh2 / node-ssh 直接传输文件
FTP 规划中
自定义 提供 upload(ctx) 钩子自行实现

安装

pnpm add -D ossx-cli

配置

默认读取项目根目录的 ossx.config.*(支持 ts/js/json)。

示例配置:

import { defineConfig } from 'ossx-cli'

export default defineConfig({
  provider: {
    name: 'aliyun-oss',
    endpoint: 'oss-cn-shenzhen.aliyuncs.com',
    accessKeyId: 'xxxxxxx',
    accessKeySecret: 'xxxxxxx',
    bucket: 'bucket-xxx',
  },
  target: 'dist',
  ignoreFiles: ['*.zip', 'index.html'],
  destination: 'remote-path',
  maxLogfiles: 1,
})

支持多provider

import { defineConfig } from 'ossx-cli'

export default defineConfig({
  providers: [
    {
      tag: 'config1',
      provider: {
        name: 'aliyun-oss',
        endpoint: 'oss-cn-shenzhen.aliyuncs.com',
        accessKeyId: 'xxxxxxx',
        accessKeySecret: 'xxxxxxx',
        bucket: 'bucket-xxx',
      }
    },
    {
      tag: 'config2',
      provider: {
        name: 'aliyun-oss',
        endpoint: 'oss-cn-shenzhen.aliyuncs.com',
        accessKeyId: 'xxxxxxx',
        accessKeySecret: 'xxxxxxx',
        bucket: 'bucket-xxx',
      }
    }
  ],
  target: 'dist',
  ignoreFiles: ['*.zip', 'index.html'],
  destination: 'remote-path',
  maxLogfiles: 1,
})

CI环境下可配置OSSX_CI_PROVIDER_TAG环境变量用于设置默认provider

使用

运行命令

npx ossx

指定配置文件:

npx ossx -c ./ossx.config.ts

License

MIT License © hackycy

About

🤖 ossx-cli is a cli tool for upload file to oss

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors