@becrafter/sail 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/bin/sail.js +37 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @becrafter/sail
|
|
2
|
+
|
|
3
|
+
> S3 协议对象存储 CLI —— 单个静态二进制,零运行时依赖。
|
|
4
|
+
|
|
5
|
+
`sail` 面向任何兼容 S3 协议的对象存储服务(AWS S3、MinIO、阿里云 OSS 及各类自建 S3 兼容服务),提供上传/下载、列举、删除、复制/移动、内容查看、预签名 URL 等日常操作。本 npm 包是跨平台安装器,负责按平台拉取对应的静态二进制。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @becrafter/sail
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 环境要求
|
|
14
|
+
|
|
15
|
+
- Node.js `>= 18`(仅用于安装器分发二进制,`sail` 本身无运行时依赖)
|
|
16
|
+
- 支持平台:
|
|
17
|
+
|
|
18
|
+
| OS | Arch | 平台子包 |
|
|
19
|
+
|----|------|----------|
|
|
20
|
+
| macOS | arm64 (Apple Silicon) | `@becrafter/sail-darwin-arm64` |
|
|
21
|
+
| macOS | x64 (Intel) | `@becrafter/sail-darwin-x64` |
|
|
22
|
+
| Linux | arm64 | `@becrafter/sail-linux-arm64` |
|
|
23
|
+
| Linux | x64 | `@becrafter/sail-linux-x64` |
|
|
24
|
+
|
|
25
|
+
安装后 npm 会按你的操作系统和 CPU 架构自动只下载一个匹配的平台二进制子包,`sail` 命令开箱即用。
|
|
26
|
+
|
|
27
|
+
## 快速开始
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
sail config init # 交互式生成 ~/.sail/config.yaml
|
|
31
|
+
sail cp local.txt s3://mybucket/path/local.txt # 上传
|
|
32
|
+
sail ls s3://mybucket/ # 列举
|
|
33
|
+
sail cp s3://mybucket/key local.txt # 下载
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
配置示例:
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
default-profile: prod
|
|
40
|
+
profiles:
|
|
41
|
+
prod:
|
|
42
|
+
endpoint: <your-s3-endpoint>
|
|
43
|
+
access-key: ${SAIL_ACCESS_KEY}
|
|
44
|
+
secret-key: ${SAIL_SECRET_KEY}
|
|
45
|
+
bucket: ""
|
|
46
|
+
region: ""
|
|
47
|
+
path-style: true
|
|
48
|
+
cdn-domain: <your-cdn-domain>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
密钥用 `${VAR}` 引用环境变量,避免在配置文件中明文存储。
|
|
52
|
+
|
|
53
|
+
## 常用命令
|
|
54
|
+
|
|
55
|
+
| 命令 | 说明 |
|
|
56
|
+
|------|------|
|
|
57
|
+
| `sail cp` / `upload` / `download` | 上传/下载(本地↔s3、s3↔s3) |
|
|
58
|
+
| `sail ls` / `tree` | 列举与树形查看 |
|
|
59
|
+
| `sail rm` | 删除对象 |
|
|
60
|
+
| `sail mv` | 移动对象(复制后删源) |
|
|
61
|
+
| `sail stat` | 查看对象元信息 |
|
|
62
|
+
| `sail view` / `cat` | 查看对象内容(多格式智能渲染) |
|
|
63
|
+
| `sail presign` | 生成预签名 URL |
|
|
64
|
+
| `sail url` | 生成 CDN 访问地址 |
|
|
65
|
+
|
|
66
|
+
## 文档
|
|
67
|
+
|
|
68
|
+
完整文档、配置说明、路径语法、与 AWS CLI 对照、实现细节等,见[仓库 README](https://github.com/BeCrafter/sail#readme)。
|
|
69
|
+
|
|
70
|
+
- 源码:<https://github.com/BeCrafter/sail>
|
|
71
|
+
- 问题反馈:<https://github.com/BeCrafter/sail/issues>
|
|
72
|
+
|
|
73
|
+
## 许可证
|
|
74
|
+
|
|
75
|
+
MIT
|
package/bin/sail.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('node:child_process');
|
|
3
|
+
const { existsSync } = require('node:fs');
|
|
4
|
+
const { dirname, join } = require('node:path');
|
|
5
|
+
|
|
6
|
+
const PKG = {
|
|
7
|
+
'darwin-arm64': '@becrafter/sail-darwin-arm64',
|
|
8
|
+
'darwin-x64': '@becrafter/sail-darwin-x64',
|
|
9
|
+
'linux-arm64': '@becrafter/sail-linux-arm64',
|
|
10
|
+
'linux-x64': '@becrafter/sail-linux-x64',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const key = `${process.platform}-${process.arch}`;
|
|
14
|
+
const pkg = PKG[key];
|
|
15
|
+
if (!pkg) {
|
|
16
|
+
console.error(`sail: unsupported platform ${key}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let pkgDir;
|
|
21
|
+
try {
|
|
22
|
+
pkgDir = dirname(require.resolve(`${pkg}/package.json`));
|
|
23
|
+
} catch {
|
|
24
|
+
console.error(`sail: platform package ${pkg} not installed. Try: npm install ${pkg}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const binName = 'sail';
|
|
29
|
+
const binPath = join(pkgDir, 'bin', binName);
|
|
30
|
+
if (!existsSync(binPath)) {
|
|
31
|
+
console.error(`sail: binary not found at ${binPath}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const child = spawn(binPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
36
|
+
child.on('error', e => { console.error(`sail: ${e.message}`); process.exit(1); });
|
|
37
|
+
child.on('close', code => process.exit(code ?? 0));
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@becrafter/sail",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "S3-compatible object storage CLI — single static binary, zero runtime deps.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "BeCrafter",
|
|
7
|
+
"homepage": "https://github.com/BeCrafter/sail#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/BeCrafter/sail.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/BeCrafter/sail/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"s3",
|
|
17
|
+
"object-storage",
|
|
18
|
+
"cli",
|
|
19
|
+
"aws-s3",
|
|
20
|
+
"minio",
|
|
21
|
+
"oss",
|
|
22
|
+
"storage",
|
|
23
|
+
"command-line"
|
|
24
|
+
],
|
|
25
|
+
"bin": {
|
|
26
|
+
"sail": "bin/sail.js"
|
|
27
|
+
},
|
|
28
|
+
"optionalDependencies": {
|
|
29
|
+
"@becrafter/sail-darwin-arm64": "0.0.1",
|
|
30
|
+
"@becrafter/sail-darwin-x64": "0.0.1",
|
|
31
|
+
"@becrafter/sail-linux-arm64": "0.0.1",
|
|
32
|
+
"@becrafter/sail-linux-x64": "0.0.1"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"bin/sail.js",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|