kdeploy 1.0.1 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49d961844c07920b802b76ae12a6f45d49be63955e3d5c78ab68cc0e2c2b4f3e
4
- data.tar.gz: 7eb0c1863c4874c481f71af6f7c4b0f523984349200c8eb8592c1b9fe20025cd
3
+ metadata.gz: 0ae0aae915ce13a7baf32218819dd5dae722477d70ec9a3d6c51f1fdf6758f81
4
+ data.tar.gz: 258b0f8e7f74bfacac534cef9add8cc9c48b809f7cab81b35ddbc38b9658606b
5
5
  SHA512:
6
- metadata.gz: 18ad6647967c2388bd76d4d1d3b81b890116e236d8059bf9d653009cebe09989341b1573c957f5eb3a8ab81f24c8ad5ea1dcd6351d7d58886e62d57bf898cde2
7
- data.tar.gz: 795c2c40e0614ac08e535b5ec16613fe1370c2f0513498da454a7a660af425b768bfe8c1694db95a1926bb3633e2cc9549c0ef927b0fd2223ead3010a72ab908
6
+ metadata.gz: 2430cd40535b7b35973acca3046e56a9c74626b299c94f7d56bc4cda3b41ca95fb62a0cf582cc7a0bce6dd4ecae921258f6b065a73b55e91390a9a7c7c47a952
7
+ data.tar.gz: 181af2943ea7bb12f569ef4884e270bfbc414aed51a508e77c13e98d4a45df24dd63e853ad14ceeb1e3a7f27d54707bda630906729233dcf577fa4e356e99b92
data/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  \/ \/\__,_|\___| .__/|_|\___/ \__, |
8
8
  |_| |___/
9
9
 
10
-
11
10
  ⚡ Lightweight Agentless Deployment Tool
12
11
  🚀 Deploy with confidence, scale with ease
13
12
 
@@ -15,6 +14,9 @@
15
14
 
16
15
  A lightweight agentless deployment automation tool written in Ruby.
17
16
 
17
+ [![Gem Version](https://img.shields.io/gem/v/kdeploy)](https://rubygems.org/gems/kdeploy)
18
+ [![Ruby](https://github.com/kevin197011/kdeploy/actions/workflows/gem-push.yml/badge.svg)](https://github.com/kevin197011/kdeploy/actions/workflows/gem-push.yml)
19
+
18
20
  ## 🌟 Features
19
21
 
20
22
  - 🔑 **Agentless Remote Deployment**: Uses SSH for secure remote execution
@@ -38,13 +40,13 @@ gem 'kdeploy'
38
40
  And then execute:
39
41
 
40
42
  ```bash
41
- $ bundle install
43
+ bundle install
42
44
  ```
43
45
 
44
46
  Or install it yourself as:
45
47
 
46
48
  ```bash
47
- $ gem install kdeploy
49
+ gem install kdeploy
48
50
  ```
49
51
 
50
52
  ### Shell Completion
@@ -76,7 +78,7 @@ Now you can use Tab completion for:
76
78
  1. Initialize a new project:
77
79
 
78
80
  ```bash
79
- $ kdeploy init my-deployment
81
+ kdeploy init my-deployment
80
82
  ```
81
83
 
82
84
  2. Edit the deployment configuration:
@@ -104,11 +106,7 @@ end
104
106
  3. Run the deployment:
105
107
 
106
108
  ```bash
107
- # Execute all tasks in deploy.rb
108
- $ kdeploy execute deploy.rb
109
-
110
- # Execute a specific task
111
- $ kdeploy execute deploy.rb deploy_web
109
+ kdeploy execute deploy.rb
112
110
  ```
113
111
 
114
112
  ## 📖 Usage Guide
data/ext/mkrf_conf.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'fileutils'
4
5
 
data/lib/kdeploy/cli.rb CHANGED
@@ -175,61 +175,47 @@ module Kdeploy
175
175
  puts
176
176
 
177
177
  results.each do |host, result|
178
- status = if result[:status] == :success
179
- pastel.green('✓ Success')
180
- else
181
- pastel.red('✗ Failed')
182
- end
183
-
178
+ status = result[:status] == :success ? pastel.green('✓ Success') : pastel.red('✗ Failed')
184
179
  puts "#{pastel.bright_white(host)} - #{status}"
185
180
 
186
181
  if result[:status] == :success
187
182
  result[:output].each do |cmd|
188
- puts " #{pastel.bright_yellow('$')} #{cmd[:command]}"
189
- if cmd[:output].is_a?(Hash)
190
- unless cmd[:output][:stdout].empty?
191
- cmd[:output][:stdout].each_line do |line|
192
- line = line.strip
193
- next if line.empty?
194
-
195
- # 根据输出内容的特征来决定颜色
196
- colored_line = if line.match?(/error|fail|fatal|critical/i)
197
- pastel.red(line)
198
- elsif line.match?(/warn|deprecat|notice/i)
199
- pastel.yellow(line)
200
- else
201
- pastel.green(line)
202
- end
203
- puts " #{colored_line}"
204
- end
205
- end
206
- unless cmd[:output][:stderr].empty?
207
- cmd[:output][:stderr].each_line do |line|
208
- puts " #{pastel.red(line)}" unless line.strip.empty?
209
- end
183
+ # 显示命令
184
+ if cmd[:command].include?('<<') || cmd[:command].include?("\n")
185
+ # 多行命令显示
186
+ first_line = cmd[:command].lines.first.strip
187
+ puts " #{pastel.bright_yellow('$')} #{first_line}"
188
+ cmd[:command].lines[1..].each do |line|
189
+ next if line.strip.empty?
190
+
191
+ puts " #{pastel.bright_yellow('>')} #{line.strip}"
210
192
  end
211
- elsif cmd[:output]
212
- cmd[:output].each_line do |line|
213
- line = line.strip
214
- next if line.empty?
215
-
216
- # 根据输出内容的特征来决定颜色
217
- colored_line = if line.match?(/error|fail|fatal|critical/i)
218
- pastel.red(line)
219
- elsif line.match?(/warn|deprecat|notice/i)
220
- pastel.yellow(line)
221
- else
222
- pastel.green(line)
223
- end
224
- puts " #{colored_line}"
193
+ else
194
+ # 单行命令显示
195
+ puts " #{pastel.bright_yellow('$')} #{cmd[:command].strip}"
196
+ end
197
+
198
+ # 显示输出
199
+ output = cmd[:output].is_a?(Hash) ? cmd[:output][:stdout] : cmd[:output].to_s
200
+ output.each_line do |line|
201
+ next if line.strip.empty?
202
+
203
+ puts " #{line.rstrip}"
204
+ end
205
+
206
+ # 显示错误输出
207
+ if cmd[:output].is_a?(Hash) && !cmd[:output][:stderr].empty?
208
+ cmd[:output][:stderr].each_line do |line|
209
+ puts " #{pastel.red(line.rstrip)}" unless line.strip.empty?
225
210
  end
226
211
  end
212
+
227
213
  puts
228
214
  end
229
215
  else
230
216
  puts " #{pastel.red(result[:error])}"
217
+ puts
231
218
  end
232
- puts
233
219
  end
234
220
  end
235
221
  end
@@ -156,19 +156,6 @@ module Kdeploy
156
156
  def create_readme
157
157
  File.write(File.join(@target_dir, 'README.md'), <<~MD)
158
158
  # Deployment Project
159
- ```
160
- _ _
161
- /\ /\__| | ___ _ __ | | ___ _ _
162
- / //_/ _` |/ _ \ '_ \| |/ _ \| | | |
163
- / __ \ (_| | __/ |_) | | (_) | |_| |
164
- \/ \/\__,_|\___| .__/|_|\___/ \__, |
165
- |_| |___/
166
-
167
-
168
- ⚡ Lightweight Agentless Deployment Tool
169
- 🚀 Deploy with confidence, scale with ease
170
-
171
- ```
172
159
 
173
160
  This is a deployment project created with Kdeploy.
174
161
 
@@ -226,9 +213,9 @@ module Kdeploy
226
213
  2. Run tasks in the order they were defined
227
214
  3. Show task name before each task execution
228
215
  4. Display color-coded output for better readability:
229
- - 🟢 Green: Normal output and success messages
230
- - 🔴 Red: Errors and failure messages
231
- - 🟡 Yellow: Warnings and notices
216
+ - 🟢 Green: Normal output and success messages
217
+ - 🔴 Red: Errors and failure messages
218
+ - 🟡 Yellow: Warnings and notices
232
219
 
233
220
  ### Available Tasks
234
221
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-30 00:00:00.000000000 Z
11
+ date: 2025-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -177,7 +177,6 @@ files:
177
177
  - README.md
178
178
  - exe/kdeploy
179
179
  - ext/mkrf_conf.rb
180
- - k.md
181
180
  - lib/kdeploy.rb
182
181
  - lib/kdeploy/banner.rb
183
182
  - lib/kdeploy/cli.rb
data/k.md DELETED
@@ -1,149 +0,0 @@
1
- 以下是将 Kdeploy 项目的开发需求整理成的标准 Markdown 格式文档,可保存为 `dev_requirements.md`:
2
-
3
- ---
4
-
5
- ```markdown
6
- # 📦 Kdeploy 开发需求文档
7
-
8
- > **项目名称**:Kdeploy
9
- > **项目类型**:Ruby Gem
10
- > **定位**:轻量级 agentless 运维部署工具
11
- > **灵感来源**:Ansible、Chef、Puppet
12
- > **目标用户**:DevOps、SRE、系统运维工程师
13
-
14
- ---
15
-
16
- ## 🧭 项目目标
17
-
18
- - 提供 **无 agent** 的远程部署解决方案
19
- - 使用 **优雅的 Ruby DSL** 编写部署任务
20
- - 支持任务的 **并发执行**
21
- - 能够进行任务 **状态统计与结果输出**
22
- - 管理 **完整的部署生命周期**(准备、执行、清理、回滚等)
23
- - 简洁、轻量、便于嵌入其他工具链
24
- - 可支持 **多主机、多环境配置管理**
25
-
26
- ---
27
-
28
- ## 📁 项目结构
29
-
30
- ```
31
-
32
- kdeploy/
33
- ├── bin/
34
- │ └── kdeploy # 主执行文件
35
- ├── lib/
36
- │ ├── kdeploy/
37
- │ │ ├── dsl.rb # DSL 定义
38
- │ │ ├── executor.rb # 并发执行器
39
- │ │ ├── inventory.rb # 主机清单管理
40
- │ │ ├── lifecycle.rb # 生命周期管理
41
- │ │ ├── logger.rb # 日志与输出
42
- │ │ └── version.rb
43
- │ └── kdeploy.rb # 主入口
44
- ├── tasks/
45
- │ └── deploy.rb # 示例任务(用户自定义)
46
- ├── spec/
47
- │ └── kdeploy\_spec.rb # RSpec 测试
48
- ├── kdeploy.gemspec
49
- └── README.md
50
-
51
- ````
52
-
53
- ---
54
-
55
- ## 🔧 功能模块设计
56
-
57
- ### 1. DSL 任务定义
58
-
59
- ```ruby
60
- host 'web01', user: 'ubuntu', ip: '10.0.0.1'
61
-
62
- task :deploy_web do
63
- run 'sudo systemctl stop nginx'
64
- upload './nginx.conf', '/etc/nginx/nginx.conf'
65
- run 'sudo systemctl start nginx'
66
- end
67
- ````
68
-
69
- ### 2. 并发执行器
70
-
71
- * 线程池并发执行远程任务
72
- * 自动记录成功/失败状态
73
- * 支持最大并发数限制
74
-
75
- ### 3. 生命周期管理
76
-
77
- * `prepare`:初始化(如环境检查)
78
- * `run`:主要任务执行
79
- * `cleanup`:清理临时文件或状态
80
- * `rollback`:失败回滚(可选)
81
-
82
- ### 4. 主机清单
83
-
84
- 支持静态或动态清单,如:
85
-
86
- ```ruby
87
- inventory do
88
- host 'web01', user: 'ubuntu', ip: '10.0.0.1'
89
- host 'db01', user: 'root', ip: '10.0.0.2'
90
- end
91
- ```
92
-
93
- ### 5. 输出日志与状态统计
94
-
95
- * 控制台美化输出(使用 `pastel`、`tty-table` 等)
96
- * 最终报告:执行成功/失败主机、任务耗时、回滚信息等
97
-
98
- ---
99
-
100
- ## 🖥️ 命令行工具设计
101
-
102
- 执行文件:`bin/kdeploy`
103
-
104
- ```bash
105
- kdeploy run tasks/deploy.rb --limit web01,web02 --parallel 5 --dry-run
106
- ```
107
-
108
- | 参数 | 说明 |
109
- | ------------- | ------------- |
110
- | `run` | 执行某个 DSL 任务文件 |
111
- | `--limit` | 限定主机 |
112
- | `--parallel` | 设置并发线程数 |
113
- | `--dry-run` | 预览任务,不真正执行 |
114
- | `--rollback` | 启动回滚 |
115
- | `--inventory` | 使用特定主机清单文件 |
116
-
117
- ---
118
-
119
- ## 🧩 可扩展性设计
120
-
121
- * 支持插件机制:可注册自定义任务类型
122
- * 可支持其他协议(如 WinRM、Docker、Kubernetes 等)
123
- * 日后可支持多环境配置(dev/stage/prod)
124
- * 支持本地/远程日志聚合
125
-
126
- ---
127
-
128
- ## 📦 开发计划建议
129
-
130
- | 阶段 | 内容 |
131
- | ---------- | ----------------------------------------- |
132
- | 1️⃣ 初始化 | 使用 `bundle gem .` 生成项目骨架,添加执行文件 |
133
- | 2️⃣ DSL 实现 | 定义基本任务语法(`host`, `task`, `run`, `upload`) |
134
- | 3️⃣ SSH 执行 | 实现基础 SSH 执行器(使用 `net-ssh`) |
135
- | 4️⃣ 并发执行 | 引入线程池或 `concurrent-ruby` |
136
- | 5️⃣ 生命周期 | 支持 prepare/run/cleanup/rollback 阶段 |
137
- | 6️⃣ 状态统计 | 记录执行状态并输出汇总表 |
138
- | 7️⃣ CLI 工具 | 实现 `bin/kdeploy` 命令入口 |
139
- | 8️⃣ 测试与发布 | 使用 RSpec 添加测试,推送到 RubyGems |
140
-
141
- ---
142
-
143
- ## 📝 初始化命令
144
-
145
- ```bash
146
- bundle gem . --test=rspec --mit --coc --no-ext
147
- ```
148
-
149
-