kdeploy 0.7.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.
- checksums.yaml +4 -4
- data/README.md +24 -0
- data/ext/mkrf_conf.rb +23 -0
- data/lib/kdeploy/completions/kdeploy.bash +41 -0
- data/lib/kdeploy/completions/kdeploy.zsh +47 -0
- data/lib/kdeploy/post_install.rb +88 -0
- data/lib/kdeploy/version.rb +1 -1
- data/lib/kdeploy.rb +1 -0
- metadata +26 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e14af235c838f2eedcd245709e574da869a894aeb8a56546ad3e91a3ca539b81
|
4
|
+
data.tar.gz: eb26703e45873b1f531436ec824cc4b5d24dc9e08a1719aede9b67946208ad9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aba8d30f09879f60a61362bb2e36276bf648efac29c81a1c9f69958813465124ccd7463c1e3811936f9194bef95d1bc6a6c3cf4cfc713829122c6f80ec86d4d6
|
7
|
+
data.tar.gz: '09eb4d286a72d68e382a6453114de89f58e9f2d9c7e455e84f6fbe474fcf46537aff910bb2002d03ddca2ec05708d4c2fc67bd3617f84d80b4efcec38f20d5b3'
|
data/README.md
CHANGED
@@ -47,6 +47,30 @@ Or install it yourself as:
|
|
47
47
|
$ gem install kdeploy
|
48
48
|
```
|
49
49
|
|
50
|
+
### Shell Completion
|
51
|
+
|
52
|
+
To enable command completion, add the following to your shell config:
|
53
|
+
|
54
|
+
For Bash (`~/.bashrc`):
|
55
|
+
```bash
|
56
|
+
source "$(gem contents kdeploy | grep kdeploy.bash)"
|
57
|
+
```
|
58
|
+
|
59
|
+
For Zsh (`~/.zshrc`):
|
60
|
+
```bash
|
61
|
+
source "$(gem contents kdeploy | grep kdeploy.zsh)"
|
62
|
+
autoload -Uz compinit && compinit
|
63
|
+
```
|
64
|
+
|
65
|
+
After adding the configuration:
|
66
|
+
1. For Bash: `source ~/.bashrc`
|
67
|
+
2. For Zsh: `source ~/.zshrc`
|
68
|
+
|
69
|
+
Now you can use Tab completion for:
|
70
|
+
- Commands: `kdeploy [TAB]`
|
71
|
+
- File paths: `kdeploy execute [TAB]`
|
72
|
+
- Options: `kdeploy execute deploy.rb [TAB]`
|
73
|
+
|
50
74
|
## 🚀 Quick Start
|
51
75
|
|
52
76
|
1. Initialize a new project:
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
# Create Rakefile for gem install hook
|
6
|
+
File.write(File.join(File.dirname(__FILE__), 'Rakefile'), <<~RAKEFILE)
|
7
|
+
task :default do
|
8
|
+
# Add lib directory to load path
|
9
|
+
lib_path = File.expand_path('../../lib', __FILE__)
|
10
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
11
|
+
|
12
|
+
require 'kdeploy/post_install'
|
13
|
+
Kdeploy::PostInstall.run
|
14
|
+
end
|
15
|
+
RAKEFILE
|
16
|
+
|
17
|
+
# Run post-install script immediately for local development
|
18
|
+
if ENV['GEM_ENV'] != 'production'
|
19
|
+
lib_path = File.expand_path('../lib', __dir__)
|
20
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
21
|
+
require 'kdeploy/post_install'
|
22
|
+
Kdeploy::PostInstall.run
|
23
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# kdeploy bash completion
|
2
|
+
_kdeploy_completion() {
|
3
|
+
local cur prev opts
|
4
|
+
COMPREPLY=()
|
5
|
+
cur="${COMP_WORDS[COMP_CWORD]}"
|
6
|
+
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
7
|
+
|
8
|
+
# Main commands
|
9
|
+
opts="init execute help version"
|
10
|
+
|
11
|
+
# Handle different cases
|
12
|
+
case "${prev}" in
|
13
|
+
kdeploy)
|
14
|
+
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
15
|
+
return 0
|
16
|
+
;;
|
17
|
+
execute)
|
18
|
+
# Complete with .rb files
|
19
|
+
COMPREPLY=( $(compgen -f -X '!*.rb' -- ${cur}) )
|
20
|
+
return 0
|
21
|
+
;;
|
22
|
+
init)
|
23
|
+
# Complete with directories
|
24
|
+
COMPREPLY=( $(compgen -d -- ${cur}) )
|
25
|
+
return 0
|
26
|
+
;;
|
27
|
+
help)
|
28
|
+
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
29
|
+
return 0
|
30
|
+
;;
|
31
|
+
*)
|
32
|
+
# If we have a .rb file, suggest options
|
33
|
+
if [[ "${COMP_WORDS[@]}" =~ "execute" ]] && [[ "${COMP_WORDS[@]}" =~ ".rb" ]]; then
|
34
|
+
COMPREPLY=( $(compgen -W "--dry-run --limit --parallel" -- ${cur}) )
|
35
|
+
return 0
|
36
|
+
fi
|
37
|
+
;;
|
38
|
+
esac
|
39
|
+
}
|
40
|
+
|
41
|
+
complete -F _kdeploy_completion kdeploy
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#compdef kdeploy
|
2
|
+
|
3
|
+
_kdeploy() {
|
4
|
+
local -a commands options
|
5
|
+
|
6
|
+
commands=(
|
7
|
+
'init:Initialize a new deployment project'
|
8
|
+
'execute:Execute deployment tasks from file'
|
9
|
+
'help:Show help information'
|
10
|
+
'version:Show version information'
|
11
|
+
)
|
12
|
+
|
13
|
+
options=(
|
14
|
+
'--dry-run[Show what would be done without executing]'
|
15
|
+
'--limit[Limit to specific hosts (comma-separated)]'
|
16
|
+
'--parallel[Number of parallel executions (default: 5)]'
|
17
|
+
)
|
18
|
+
|
19
|
+
_arguments -C \
|
20
|
+
'1: :->cmds' \
|
21
|
+
'*:: :->args'
|
22
|
+
|
23
|
+
case "$state" in
|
24
|
+
cmds)
|
25
|
+
_describe -t commands 'kdeploy commands' commands
|
26
|
+
;;
|
27
|
+
args)
|
28
|
+
case $words[1] in
|
29
|
+
execute)
|
30
|
+
if (( CURRENT == 2 )); then
|
31
|
+
_files -g "*.rb"
|
32
|
+
else
|
33
|
+
_values 'options' $options
|
34
|
+
fi
|
35
|
+
;;
|
36
|
+
init)
|
37
|
+
_files -/
|
38
|
+
;;
|
39
|
+
help)
|
40
|
+
_describe -t commands 'kdeploy commands' commands
|
41
|
+
;;
|
42
|
+
esac
|
43
|
+
;;
|
44
|
+
esac
|
45
|
+
}
|
46
|
+
|
47
|
+
_kdeploy "$@"
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kdeploy
|
4
|
+
class PostInstall
|
5
|
+
class << self
|
6
|
+
def run
|
7
|
+
setup_shell_completion
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def setup_shell_completion
|
13
|
+
setup_bash_completion
|
14
|
+
setup_zsh_completion
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup_bash_completion
|
18
|
+
return unless File.exist?(bashrc_path)
|
19
|
+
|
20
|
+
completion_path = find_completion_file('kdeploy.bash')
|
21
|
+
return if completion_path.nil?
|
22
|
+
|
23
|
+
source_line = "source \"#{completion_path}\""
|
24
|
+
|
25
|
+
# 检查是否已经配置
|
26
|
+
return if File.read(bashrc_path).include?(source_line)
|
27
|
+
|
28
|
+
# 添加配置
|
29
|
+
File.open(bashrc_path, 'a') do |f|
|
30
|
+
f.puts "\n# Kdeploy completion"
|
31
|
+
f.puts source_line
|
32
|
+
end
|
33
|
+
puts "✅ Bash completion configured in #{bashrc_path}"
|
34
|
+
rescue StandardError => e
|
35
|
+
puts "⚠️ Failed to configure Bash completion: #{e.message}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup_zsh_completion
|
39
|
+
return unless File.exist?(zshrc_path)
|
40
|
+
|
41
|
+
completion_path = find_completion_file('kdeploy.zsh')
|
42
|
+
return if completion_path.nil?
|
43
|
+
|
44
|
+
source_lines = [
|
45
|
+
"source \"#{completion_path}\"",
|
46
|
+
'autoload -Uz compinit && compinit'
|
47
|
+
]
|
48
|
+
|
49
|
+
content = File.read(zshrc_path)
|
50
|
+
|
51
|
+
# 检查是否已经配置
|
52
|
+
return if source_lines.all? { |line| content.include?(line) }
|
53
|
+
|
54
|
+
# 添加配置
|
55
|
+
File.open(zshrc_path, 'a') do |f|
|
56
|
+
f.puts "\n# Kdeploy completion"
|
57
|
+
source_lines.each { |line| f.puts line unless content.include?(line) }
|
58
|
+
end
|
59
|
+
puts "✅ Zsh completion configured in #{zshrc_path}"
|
60
|
+
rescue StandardError => e
|
61
|
+
puts "⚠️ Failed to configure Zsh completion: #{e.message}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def find_completion_file(filename)
|
65
|
+
# 在开发环境中使用相对路径
|
66
|
+
dev_path = File.expand_path("../completions/#{filename}", __FILE__)
|
67
|
+
return dev_path if File.exist?(dev_path)
|
68
|
+
|
69
|
+
# 在安装环境中使用 GEM_HOME
|
70
|
+
if ENV['GEM_HOME']
|
71
|
+
installed_path = File.join(ENV['GEM_HOME'], 'gems/kdeploy-*/lib/kdeploy/completions', filename)
|
72
|
+
completion_files = Dir.glob(installed_path)
|
73
|
+
return completion_files.first if completion_files.any?
|
74
|
+
end
|
75
|
+
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
|
79
|
+
def bashrc_path
|
80
|
+
File.join(Dir.home, '.bashrc')
|
81
|
+
end
|
82
|
+
|
83
|
+
def zshrc_path
|
84
|
+
File.join(Dir.home, '.zshrc')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/kdeploy/version.rb
CHANGED
data/lib/kdeploy.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kdeploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Norton
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '13.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '13.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: thor
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,18 +170,23 @@ email:
|
|
156
170
|
- kevin197011@outlook.com
|
157
171
|
executables:
|
158
172
|
- kdeploy
|
159
|
-
extensions:
|
173
|
+
extensions:
|
174
|
+
- ext/mkrf_conf.rb
|
160
175
|
extra_rdoc_files: []
|
161
176
|
files:
|
162
177
|
- README.md
|
163
178
|
- exe/kdeploy
|
179
|
+
- ext/mkrf_conf.rb
|
164
180
|
- k.md
|
165
181
|
- lib/kdeploy.rb
|
166
182
|
- lib/kdeploy/banner.rb
|
167
183
|
- lib/kdeploy/cli.rb
|
184
|
+
- lib/kdeploy/completions/kdeploy.bash
|
185
|
+
- lib/kdeploy/completions/kdeploy.zsh
|
168
186
|
- lib/kdeploy/dsl.rb
|
169
187
|
- lib/kdeploy/executor.rb
|
170
188
|
- lib/kdeploy/initializer.rb
|
189
|
+
- lib/kdeploy/post_install.rb
|
171
190
|
- lib/kdeploy/runner.rb
|
172
191
|
- lib/kdeploy/template.rb
|
173
192
|
- lib/kdeploy/version.rb
|
@@ -179,7 +198,10 @@ metadata:
|
|
179
198
|
source_code_uri: https://github.com/kevin197011/kdeploy.git
|
180
199
|
changelog_uri: https://github.com/kevin197011/kdeploy/blob/main/CHANGELOG.md
|
181
200
|
rubygems_mfa_required: 'true'
|
182
|
-
post_install_message:
|
201
|
+
post_install_message: "\U0001F389 Thanks for installing kdeploy!\n\nShell completion
|
202
|
+
will be configured automatically.\nYou may need to restart your shell or run:\n
|
203
|
+
\ - For Bash: source ~/.bashrc\n - For Zsh: source ~/.zshrc\n\nHappy deploying!
|
204
|
+
\U0001F680\n"
|
183
205
|
rdoc_options: []
|
184
206
|
require_paths:
|
185
207
|
- lib
|
@@ -187,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
209
|
requirements:
|
188
210
|
- - ">="
|
189
211
|
- !ruby/object:Gem::Version
|
190
|
-
version: 3.
|
212
|
+
version: 3.1.0
|
191
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
214
|
requirements:
|
193
215
|
- - ">="
|