shipfe 0.2.1 → 1.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 CHANGED
@@ -1,6 +1,18 @@
1
1
  # Shipfe
2
2
 
3
- A powerful deployment tool for web applications with support for multiple environments and sub-environments.
3
+ A powerful, **free**, **Rust-based** deployment tool for web applications that **never requests network** and enables **one-click static frontend deployment** to servers. Supports multiple environments and sub-environments with zero-downtime atomic deployments.
4
+
5
+ ## Key Features
6
+
7
+ - 🚀 **Free and Open Source**: No hidden costs, MIT licensed
8
+ - 🦀 **Built with Rust**: Fast, reliable, and memory-safe
9
+ - 🔒 **No Network Requests**: Works completely offline, ensuring security and privacy
10
+ - ⚡ **One-Click Deployment**: Upload static frontend packages to servers instantly
11
+ - 🔄 **Atomic Deployments**: Zero-downtime deployments with automatic rollback
12
+ - 🌍 **Multi-Environment Support**: Configure different environments (dev, staging, prod)
13
+ - 📦 **Sub-Environment Support**: Deploy multiple apps to the same server
14
+ - 🔑 **Flexible Authentication**: SSH key, password, or environment variable authentication
15
+ - 📝 **Detailed Logging**: Comprehensive deployment logs for troubleshooting
4
16
 
5
17
  ## Installation
6
18
 
@@ -8,6 +20,20 @@ A powerful deployment tool for web applications with support for multiple enviro
8
20
  npm install -g shipfe
9
21
  ```
10
22
 
23
+ ## Quick Start
24
+
25
+ 1. Initialize your project:
26
+ ```bash
27
+ shipfe init
28
+ ```
29
+
30
+ 2. Configure your deployment in `shipfe.config.json`
31
+
32
+ 3. Deploy:
33
+ ```bash
34
+ shipfe deploy --profile prod
35
+ ```
36
+
11
37
  ## Usage
12
38
 
13
39
  ### Initialize project
@@ -25,6 +51,21 @@ shipfe deploy --profile dev
25
51
 
26
52
  # Deploy to sub-environment
27
53
  shipfe deploy --profile dev-admin
54
+
55
+ # Deploy to all sub-environments
56
+ shipfe deploy --profile dev --all-sub
57
+
58
+ # Atomic deployment (creates releases/timestamp and updates current symlink)
59
+ shipfe deploy --atomic
60
+ ```
61
+
62
+ ### Rollback Deployment
63
+ ```bash
64
+ # Rollback main environment
65
+ shipfe rollback --profile prod --to 20260303_034945
66
+
67
+ # Rollback sub-environment
68
+ shipfe rollback --profile prod-admin --to 20260303_034945
28
69
  ```
29
70
 
30
71
  ### Configuration
@@ -143,6 +184,9 @@ Deploy to sub-environments:
143
184
  shipfe deploy --profile dev-admin
144
185
  shipfe deploy --profile dev-shop
145
186
  shipfe deploy --profile dev-cu
187
+
188
+ # Deploy to all sub-environments at once
189
+ shipfe deploy --profile dev --all-sub
146
190
  ```
147
191
 
148
192
  ### Deploy all sub-environments at once
@@ -154,6 +198,30 @@ This will deploy to all sub-environments (admin, shop, cu) in sequence.
154
198
 
155
199
  Sub-environments inherit settings from the parent environment and can override `build_command`, `local_dist_path`, and `remote_deploy_path`.
156
200
 
201
+ ### Atomic Deployment
202
+
203
+ Shipfe supports atomic deployment to minimize downtime. When using `--atomic`, the deployment creates a timestamped release directory and updates a `current` symlink for zero-downtime switching.
204
+
205
+ ```bash
206
+ # Atomic deployment to default environment
207
+ shipfe deploy --atomic
208
+
209
+ # Atomic deployment to specific environment
210
+ shipfe deploy --profile prod --atomic
211
+ ```
212
+
213
+ **Directory Structure:**
214
+ ```
215
+ remote_deploy_path/
216
+ ├── releases/
217
+ │ ├── 20260303_034945/
218
+ │ ├── 20260303_035012/
219
+ │ └── 20260303_035045/
220
+ └── current -> releases/20260303_035045
221
+ ```
222
+
223
+ Your web server should serve from `remote_deploy_path/current`.
224
+
157
225
  **Or use environment variable for all servers:**
158
226
  ```bash
159
227
  export SSH_PRIVATE_KEY="$(cat ~/.ssh/prod_key)"
package/README_CN.md ADDED
@@ -0,0 +1,294 @@
1
+ # Shipfe
2
+
3
+ 一个强大的、**免费**、**基于 Rust** 的 Web 应用部署工具,**不请求网络**,实现**一键前端静态部署包上传到服务器**。支持多环境和子环境部署,具有零停机原子部署功能。
4
+
5
+ ## 主要特性
6
+
7
+ - 🚀 **免费开源**: 无隐藏费用,MIT 许可证
8
+ - 🦀 **基于 Rust**: 快速、可靠、内存安全
9
+ - 🔒 **不请求网络**: 完全离线工作,确保安全和隐私
10
+ - ⚡ **一键部署**: 即时上传静态前端包到服务器
11
+ - 🔄 **原子部署**: 零停机部署,自动回滚
12
+ - 🌍 **多环境支持**: 配置不同环境(开发、预发布、生产)
13
+ - 📦 **子环境支持**: 在同一服务器部署多个应用
14
+ - 🔑 **灵活认证**: SSH 密钥、密码或环境变量认证
15
+ - 📝 **详细日志**: 全面的部署日志用于故障排除
16
+
17
+ ## 安装
18
+
19
+ ```bash
20
+ npm install -g shipfe
21
+ ```
22
+
23
+ ## 快速开始
24
+
25
+ 1. 初始化项目:
26
+ ```bash
27
+ shipfe init
28
+ ```
29
+
30
+ 2. 在 `shipfe.config.json` 中配置部署
31
+
32
+ 3. 部署:
33
+ ```bash
34
+ shipfe deploy --profile prod
35
+ ```
36
+
37
+ ## 使用方法
38
+
39
+ ### 初始化项目
40
+ ```bash
41
+ shipfe init
42
+ ```
43
+
44
+ ### 部署到环境
45
+ ```bash
46
+ # 部署到默认环境
47
+ shipfe deploy
48
+
49
+ # 部署到指定环境
50
+ shipfe deploy --profile dev
51
+
52
+ # 部署到子环境
53
+ shipfe deploy --profile dev-admin
54
+
55
+ # 部署到所有子环境
56
+ shipfe deploy --profile dev --all-sub
57
+
58
+ # 原子部署(创建 releases/时间戳 并更新 current 符号链接)
59
+ shipfe deploy --atomic
60
+ ```
61
+
62
+ ### 回滚部署
63
+ ```bash
64
+ # 回滚主环境
65
+ shipfe rollback --profile prod --to 20260303_034945
66
+
67
+ # 回滚子环境
68
+ shipfe rollback --profile prod-admin --to 20260303_034945
69
+ ```
70
+
71
+ ## 配置
72
+
73
+ 编辑 `shipfe.config.json` 来配置您的部署设置:
74
+
75
+ ```json
76
+ {
77
+ "environments": {
78
+ "dev": {
79
+ "build_command": "npm run build",
80
+ "local_dist_path": "./dist",
81
+ "servers": [
82
+ {
83
+ "host": "dev.example.com",
84
+ "port": 22,
85
+ "username": "deploy",
86
+ "remote_deploy_path": "/var/www/dev",
87
+ "delete_old": false
88
+ }
89
+ ],
90
+ "remote_tmp": "/tmp"
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ ### 认证选项
97
+
98
+ 每个服务器可以有自己的认证方法。Shipfe 按以下顺序尝试认证方法:
99
+
100
+ 1. **密码**(如果在服务器配置中设置了 `password`)
101
+ 2. **环境变量中的 SSH 私钥**(如果设置了 `SSH_PRIVATE_KEY` 环境变量)
102
+ 3. **SSH 密钥文件**(如果在服务器配置中设置了 `key_path`)
103
+
104
+ **使用不同认证方法的多个服务器示例:**
105
+
106
+ ```json
107
+ {
108
+ "environments": {
109
+ "prod": {
110
+ "build_command": "npm run build",
111
+ "local_dist_path": "./dist",
112
+ "servers": [
113
+ {
114
+ "host": "web1.prod.com",
115
+ "port": 22,
116
+ "username": "deploy",
117
+ "password": "web1_password",
118
+ "remote_deploy_path": "/var/www/prod",
119
+ "delete_old": false
120
+ },
121
+ {
122
+ "host": "web2.prod.com",
123
+ "port": 22,
124
+ "username": "deploy",
125
+ "key_path": "/home/user/.ssh/web2_key",
126
+ "remote_deploy_path": "/var/www/prod",
127
+ "delete_old": false
128
+ },
129
+ {
130
+ "host": "web3.prod.com",
131
+ "port": 22,
132
+ "username": "deploy",
133
+ "remote_deploy_path": "/var/www/prod",
134
+ "delete_old": false
135
+ }
136
+ ],
137
+ "remote_tmp": "/tmp"
138
+ }
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### 子环境
144
+
145
+ 对于在同一服务器部署多个应用或不同配置,使用子环境:
146
+
147
+ ```json
148
+ {
149
+ "environments": {
150
+ "dev": {
151
+ "build_command": "npm run build",
152
+ "local_dist_path": "./dist",
153
+ "servers": [
154
+ {
155
+ "host": "dev.example.com",
156
+ "port": 22,
157
+ "username": "deploy",
158
+ "remote_deploy_path": "/var/www/dev",
159
+ "delete_old": false
160
+ }
161
+ ],
162
+ "remote_tmp": "/tmp",
163
+ "sub_environments": {
164
+ "admin": {
165
+ "build_command": "npm run build:admin",
166
+ "remote_deploy_path": "/var/www/dev/admin"
167
+ },
168
+ "shop": {
169
+ "build_command": "npm run build:shop",
170
+ "remote_deploy_path": "/var/www/dev/shop"
171
+ },
172
+ "cu": {
173
+ "build_command": "npm run build:cu",
174
+ "remote_deploy_path": "/var/www/dev/cu"
175
+ }
176
+ }
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ 部署到子环境:
183
+ ```bash
184
+ shipfe deploy --profile dev-admin
185
+ shipfe deploy --profile dev-shop
186
+ shipfe deploy --profile dev-cu
187
+
188
+ # 一次部署到所有子环境
189
+ shipfe deploy --profile dev --all-sub
190
+ ```
191
+
192
+ ### 一次部署所有子环境
193
+ ```bash
194
+ shipfe deploy --profile dev --all-sub
195
+ ```
196
+
197
+ 这将按顺序部署到所有子环境(admin、shop、cu)。
198
+
199
+ 子环境继承父环境的设置,可以覆盖 `build_command`、`local_dist_path` 和 `remote_deploy_path`。
200
+
201
+ ### 原子部署
202
+
203
+ Shipfe 支持原子部署以最小化停机时间。使用 `--atomic` 时,部署会创建一个带时间戳的发布目录,并更新 `current` 符号链接,实现零停机切换。
204
+
205
+ ```bash
206
+ # 原子部署到默认环境
207
+ shipfe deploy --atomic
208
+
209
+ # 原子部署到指定环境
210
+ shipfe deploy --profile prod --atomic
211
+ ```
212
+
213
+ **目录结构:**
214
+ ```
215
+ remote_deploy_path/
216
+ ├── releases/
217
+ │ ├── 20260303_034945/
218
+ │ ├── 20260303_035012/
219
+ │ └── 20260303_035045/
220
+ └── current -> releases/20260303_035045
221
+ ```
222
+
223
+ 您的 Web 服务器应从 `remote_deploy_path/current` 提供服务。
224
+
225
+ **或为所有服务器使用环境变量:**
226
+ ```bash
227
+ export SSH_PRIVATE_KEY="$(cat ~/.ssh/prod_key)"
228
+ shipfe deploy --profile prod
229
+ ```
230
+
231
+ ### 认证
232
+
233
+ Shipfe 支持为每个服务器单独设置多种 SSH 认证方法。对于每个服务器,按以下顺序尝试认证方法:
234
+
235
+ 1. **密码认证**:如果该服务器配置中设置了 `password`
236
+ 2. **环境变量中的 SSH 私钥**:如果设置了 `SSH_PRIVATE_KEY` 环境变量(适用于所有服务器)
237
+ 3. **SSH 密钥文件**:如果该服务器配置中设置了 `key_path`
238
+
239
+ #### 使用示例:
240
+
241
+ ```bash
242
+ # 每个服务器可以使用不同的认证
243
+ shipfe deploy --profile prod
244
+
245
+ # 或为所有服务器使用环境变量覆盖
246
+ export SSH_PRIVATE_KEY="$(cat ~/.ssh/prod_key)"
247
+ shipfe deploy --profile prod
248
+ ```
249
+
250
+ #### 为单个服务器设置 SSH 密钥:
251
+
252
+ 1. **为每个服务器生成 SSH 密钥对**:
253
+ ```bash
254
+ # 服务器 1
255
+ ssh-keygen -t rsa -b 4096 -f ~/.ssh/server1_key -C "server1"
256
+
257
+ # 服务器 2
258
+ ssh-keygen -t rsa -b 4096 -f ~/.ssh/server2_key -C "server2"
259
+ ```
260
+
261
+ 2. **将公钥复制到相应服务器**:
262
+ ```bash
263
+ ssh-copy-id -i ~/.ssh/server1_key.pub user@server1.com
264
+ ssh-copy-id -i ~/.ssh/server2_key.pub user@server2.com
265
+ ```
266
+
267
+ 3. **使用服务器特定密钥配置 shipfe**:
268
+ ```json
269
+ {
270
+ "servers": [
271
+ {
272
+ "host": "server1.com",
273
+ "key_path": "~/.ssh/server1_key"
274
+ },
275
+ {
276
+ "host": "server2.com",
277
+ "key_path": "~/.ssh/server2_key"
278
+ }
279
+ ]
280
+ }
281
+ ```
282
+
283
+ ## 功能特性
284
+
285
+ - 多环境支持
286
+ - 子环境配置
287
+ - 自定义构建命令
288
+ - 基于 SSH 的部署
289
+ - 自动备份和回滚
290
+ - 详细日志记录
291
+
292
+ ## 许可证
293
+
294
+ MIT
package/bin/shipfe CHANGED
Binary file
package/package.json CHANGED
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "name": "shipfe",
3
- "version": "0.2.1",
3
+ "version": "1.0.1",
4
4
  "description": "A deployment tool for web applications",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "shipfe": "bin/shipfe"
8
8
  },
9
9
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "build": "npm run build",
12
+ "build-dev-admin": "npm run build",
13
+ "build-dev-bu": "npm run build",
14
+ "build-dev-shop": "npm run build",
15
+ "build-dev-customer": "npm run build",
16
+ "build-prod-admin": "npm run build",
17
+ "build-prod-api": "npm run build"
11
18
  },
12
19
  "keywords": [
13
20
  "deployment",
@@ -15,12 +22,8 @@
15
22
  "ssh",
16
23
  "ci-cd"
17
24
  ],
18
- "author": "Your Name",
25
+ "author": "Jans",
19
26
  "license": "MIT",
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://github.com/yourusername/shipfe.git"
23
- },
24
27
  "os": [
25
28
  "darwin",
26
29
  "linux",