shipfe 0.2.0 → 1.0.0

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,22 @@ 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
+ ### Activate License (for premium features)
63
+ ```bash
64
+ shipfe activate --profile prod --file license.key
65
+ ```
66
+
67
+ ### Rollback Deployment
68
+ ```bash
69
+ shipfe rollback --profile prod --to 20260303_034945
28
70
  ```
29
71
 
30
72
  ### Configuration
@@ -143,6 +185,9 @@ Deploy to sub-environments:
143
185
  shipfe deploy --profile dev-admin
144
186
  shipfe deploy --profile dev-shop
145
187
  shipfe deploy --profile dev-cu
188
+
189
+ # Deploy to all sub-environments at once
190
+ shipfe deploy --profile dev --all-sub
146
191
  ```
147
192
 
148
193
  ### Deploy all sub-environments at once
@@ -154,6 +199,30 @@ This will deploy to all sub-environments (admin, shop, cu) in sequence.
154
199
 
155
200
  Sub-environments inherit settings from the parent environment and can override `build_command`, `local_dist_path`, and `remote_deploy_path`.
156
201
 
202
+ ### Atomic Deployment
203
+
204
+ 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.
205
+
206
+ ```bash
207
+ # Atomic deployment to default environment
208
+ shipfe deploy --atomic
209
+
210
+ # Atomic deployment to specific environment
211
+ shipfe deploy --profile prod --atomic
212
+ ```
213
+
214
+ **Directory Structure:**
215
+ ```
216
+ remote_deploy_path/
217
+ ├── releases/
218
+ │ ├── 20260303_034945/
219
+ │ ├── 20260303_035012/
220
+ │ └── 20260303_035045/
221
+ └── current -> releases/20260303_035045
222
+ ```
223
+
224
+ Your web server should serve from `remote_deploy_path/current`.
225
+
157
226
  **Or use environment variable for all servers:**
158
227
  ```bash
159
228
  export SSH_PRIVATE_KEY="$(cat ~/.ssh/prod_key)"
package/README_CN.md ADDED
@@ -0,0 +1,295 @@
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
+ shipfe activate --profile prod --file license.key
65
+ ```
66
+
67
+ ### 回滚部署
68
+ ```bash
69
+ shipfe rollback --profile prod --to 20260303_034945
70
+ ```
71
+
72
+ ## 配置
73
+
74
+ 编辑 `shipfe.config.json` 来配置您的部署设置:
75
+
76
+ ```json
77
+ {
78
+ "environments": {
79
+ "dev": {
80
+ "build_command": "npm run build",
81
+ "local_dist_path": "./dist",
82
+ "servers": [
83
+ {
84
+ "host": "dev.example.com",
85
+ "port": 22,
86
+ "username": "deploy",
87
+ "remote_deploy_path": "/var/www/dev",
88
+ "delete_old": false
89
+ }
90
+ ],
91
+ "remote_tmp": "/tmp"
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ ### 认证选项
98
+
99
+ 每个服务器可以有自己的认证方法。Shipfe 按以下顺序尝试认证方法:
100
+
101
+ 1. **密码**(如果在服务器配置中设置了 `password`)
102
+ 2. **环境变量中的 SSH 私钥**(如果设置了 `SSH_PRIVATE_KEY` 环境变量)
103
+ 3. **SSH 密钥文件**(如果在服务器配置中设置了 `key_path`)
104
+
105
+ **使用不同认证方法的多个服务器示例:**
106
+
107
+ ```json
108
+ {
109
+ "environments": {
110
+ "prod": {
111
+ "build_command": "npm run build",
112
+ "local_dist_path": "./dist",
113
+ "servers": [
114
+ {
115
+ "host": "web1.prod.com",
116
+ "port": 22,
117
+ "username": "deploy",
118
+ "password": "web1_password",
119
+ "remote_deploy_path": "/var/www/prod",
120
+ "delete_old": false
121
+ },
122
+ {
123
+ "host": "web2.prod.com",
124
+ "port": 22,
125
+ "username": "deploy",
126
+ "key_path": "/home/user/.ssh/web2_key",
127
+ "remote_deploy_path": "/var/www/prod",
128
+ "delete_old": false
129
+ },
130
+ {
131
+ "host": "web3.prod.com",
132
+ "port": 22,
133
+ "username": "deploy",
134
+ "remote_deploy_path": "/var/www/prod",
135
+ "delete_old": false
136
+ }
137
+ ],
138
+ "remote_tmp": "/tmp"
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ ### 子环境
145
+
146
+ 对于在同一服务器部署多个应用或不同配置,使用子环境:
147
+
148
+ ```json
149
+ {
150
+ "environments": {
151
+ "dev": {
152
+ "build_command": "npm run build",
153
+ "local_dist_path": "./dist",
154
+ "servers": [
155
+ {
156
+ "host": "dev.example.com",
157
+ "port": 22,
158
+ "username": "deploy",
159
+ "remote_deploy_path": "/var/www/dev",
160
+ "delete_old": false
161
+ }
162
+ ],
163
+ "remote_tmp": "/tmp",
164
+ "sub_environments": {
165
+ "admin": {
166
+ "build_command": "npm run build:admin",
167
+ "remote_deploy_path": "/var/www/dev/admin"
168
+ },
169
+ "shop": {
170
+ "build_command": "npm run build:shop",
171
+ "remote_deploy_path": "/var/www/dev/shop"
172
+ },
173
+ "cu": {
174
+ "build_command": "npm run build:cu",
175
+ "remote_deploy_path": "/var/www/dev/cu"
176
+ }
177
+ }
178
+ }
179
+ }
180
+ }
181
+ ```
182
+
183
+ 部署到子环境:
184
+ ```bash
185
+ shipfe deploy --profile dev-admin
186
+ shipfe deploy --profile dev-shop
187
+ shipfe deploy --profile dev-cu
188
+
189
+ # 一次部署到所有子环境
190
+ shipfe deploy --profile dev --all-sub
191
+ ```
192
+
193
+ ### 一次部署所有子环境
194
+ ```bash
195
+ shipfe deploy --profile dev --all-sub
196
+ ```
197
+
198
+ 这将按顺序部署到所有子环境(admin、shop、cu)。
199
+
200
+ 子环境继承父环境的设置,可以覆盖 `build_command`、`local_dist_path` 和 `remote_deploy_path`。
201
+
202
+ ### 原子部署
203
+
204
+ Shipfe 支持原子部署以最小化停机时间。使用 `--atomic` 时,部署会创建一个带时间戳的发布目录,并更新 `current` 符号链接,实现零停机切换。
205
+
206
+ ```bash
207
+ # 原子部署到默认环境
208
+ shipfe deploy --atomic
209
+
210
+ # 原子部署到指定环境
211
+ shipfe deploy --profile prod --atomic
212
+ ```
213
+
214
+ **目录结构:**
215
+ ```
216
+ remote_deploy_path/
217
+ ├── releases/
218
+ │ ├── 20260303_034945/
219
+ │ ├── 20260303_035012/
220
+ │ └── 20260303_035045/
221
+ └── current -> releases/20260303_035045
222
+ ```
223
+
224
+ 您的 Web 服务器应从 `remote_deploy_path/current` 提供服务。
225
+
226
+ **或为所有服务器使用环境变量:**
227
+ ```bash
228
+ export SSH_PRIVATE_KEY="$(cat ~/.ssh/prod_key)"
229
+ shipfe deploy --profile prod
230
+ ```
231
+
232
+ ### 认证
233
+
234
+ Shipfe 支持为每个服务器单独设置多种 SSH 认证方法。对于每个服务器,按以下顺序尝试认证方法:
235
+
236
+ 1. **密码认证**:如果该服务器配置中设置了 `password`
237
+ 2. **环境变量中的 SSH 私钥**:如果设置了 `SSH_PRIVATE_KEY` 环境变量(适用于所有服务器)
238
+ 3. **SSH 密钥文件**:如果该服务器配置中设置了 `key_path`
239
+
240
+ #### 使用示例:
241
+
242
+ ```bash
243
+ # 每个服务器可以使用不同的认证
244
+ shipfe deploy --profile prod
245
+
246
+ # 或为所有服务器使用环境变量覆盖
247
+ export SSH_PRIVATE_KEY="$(cat ~/.ssh/prod_key)"
248
+ shipfe deploy --profile prod
249
+ ```
250
+
251
+ #### 为单个服务器设置 SSH 密钥:
252
+
253
+ 1. **为每个服务器生成 SSH 密钥对**:
254
+ ```bash
255
+ # 服务器 1
256
+ ssh-keygen -t rsa -b 4096 -f ~/.ssh/server1_key -C "server1"
257
+
258
+ # 服务器 2
259
+ ssh-keygen -t rsa -b 4096 -f ~/.ssh/server2_key -C "server2"
260
+ ```
261
+
262
+ 2. **将公钥复制到相应服务器**:
263
+ ```bash
264
+ ssh-copy-id -i ~/.ssh/server1_key.pub user@server1.com
265
+ ssh-copy-id -i ~/.ssh/server2_key.pub user@server2.com
266
+ ```
267
+
268
+ 3. **使用服务器特定密钥配置 shipfe**:
269
+ ```json
270
+ {
271
+ "servers": [
272
+ {
273
+ "host": "server1.com",
274
+ "key_path": "~/.ssh/server1_key"
275
+ },
276
+ {
277
+ "host": "server2.com",
278
+ "key_path": "~/.ssh/server2_key"
279
+ }
280
+ ]
281
+ }
282
+ ```
283
+
284
+ ## 功能特性
285
+
286
+ - 多环境支持
287
+ - 子环境配置
288
+ - 自定义构建命令
289
+ - 基于 SSH 的部署
290
+ - 自动备份和回滚
291
+ - 详细日志记录
292
+
293
+ ## 许可证
294
+
295
+ 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.0",
3
+ "version": "1.0.0",
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",