kdeploy 1.0.0 → 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.
- checksums.yaml +4 -4
- data/lib/kdeploy/completions/kdeploy.zsh +12 -9
- data/lib/kdeploy/post_install.rb +43 -21
- data/lib/kdeploy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49d961844c07920b802b76ae12a6f45d49be63955e3d5c78ab68cc0e2c2b4f3e
|
4
|
+
data.tar.gz: 7eb0c1863c4874c481f71af6f7c4b0f523984349200c8eb8592c1b9fe20025cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18ad6647967c2388bd76d4d1d3b81b890116e236d8059bf9d653009cebe09989341b1573c957f5eb3a8ab81f24c8ad5ea1dcd6351d7d58886e62d57bf898cde2
|
7
|
+
data.tar.gz: 795c2c40e0614ac08e535b5ec16613fe1370c2f0513498da454a7a660af425b768bfe8c1694db95a1926bb3633e2cc9549c0ef927b0fd2223ead3010a72ab908
|
@@ -1,8 +1,10 @@
|
|
1
1
|
#compdef kdeploy
|
2
2
|
|
3
3
|
_kdeploy() {
|
4
|
-
local
|
4
|
+
local curcontext="$curcontext" state line
|
5
|
+
typeset -A opt_args
|
5
6
|
|
7
|
+
local -a commands
|
6
8
|
commands=(
|
7
9
|
'init:Initialize a new deployment project'
|
8
10
|
'execute:Execute deployment tasks from file'
|
@@ -10,24 +12,25 @@ _kdeploy() {
|
|
10
12
|
'version:Show version information'
|
11
13
|
)
|
12
14
|
|
15
|
+
local -a options
|
13
16
|
options=(
|
14
17
|
'--dry-run[Show what would be done without executing]'
|
15
18
|
'--limit[Limit to specific hosts (comma-separated)]'
|
16
19
|
'--parallel[Number of parallel executions (default: 5)]'
|
17
20
|
)
|
18
21
|
|
19
|
-
_arguments
|
20
|
-
'1: :->
|
21
|
-
'
|
22
|
+
_arguments \
|
23
|
+
'1: :->command' \
|
24
|
+
'*: :->args'
|
22
25
|
|
23
|
-
case
|
24
|
-
|
26
|
+
case $state in
|
27
|
+
command)
|
25
28
|
_describe -t commands 'kdeploy commands' commands
|
26
29
|
;;
|
27
30
|
args)
|
28
|
-
case $words[
|
31
|
+
case $words[2] in
|
29
32
|
execute)
|
30
|
-
if
|
33
|
+
if [[ $CURRENT -eq 3 ]]; then
|
31
34
|
_files -g "*.rb"
|
32
35
|
else
|
33
36
|
_values 'options' $options
|
@@ -44,4 +47,4 @@ _kdeploy() {
|
|
44
47
|
esac
|
45
48
|
}
|
46
49
|
|
47
|
-
_kdeploy
|
50
|
+
compdef _kdeploy kdeploy
|
data/lib/kdeploy/post_install.rb
CHANGED
@@ -23,12 +23,17 @@ module Kdeploy
|
|
23
23
|
source_line = "source \"#{completion_path}\""
|
24
24
|
|
25
25
|
# 检查是否已经配置
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
content = File.read(bashrc_path)
|
27
|
+
if content.match?(/source.*kdeploy\.bash/)
|
28
|
+
# 更新现有的配置
|
29
|
+
new_content = content.gsub(/source.*kdeploy\.bash.*$/, source_line)
|
30
|
+
File.write(bashrc_path, new_content)
|
31
|
+
else
|
32
|
+
# 添加新配置
|
33
|
+
File.open(bashrc_path, 'a') do |f|
|
34
|
+
f.puts "\n# Kdeploy completion"
|
35
|
+
f.puts source_line
|
36
|
+
end
|
32
37
|
end
|
33
38
|
puts "✅ Bash completion configured in #{bashrc_path}"
|
34
39
|
rescue StandardError => e
|
@@ -49,12 +54,16 @@ module Kdeploy
|
|
49
54
|
content = File.read(zshrc_path)
|
50
55
|
|
51
56
|
# 检查是否已经配置
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
if content.match?(/source.*kdeploy\.zsh/)
|
58
|
+
# 更新现有的配置
|
59
|
+
new_content = content.gsub(/source.*kdeploy\.zsh.*$/, source_lines[0])
|
60
|
+
File.write(zshrc_path, new_content)
|
61
|
+
else
|
62
|
+
# 添加新配置
|
63
|
+
File.open(zshrc_path, 'a') do |f|
|
64
|
+
f.puts "\n# Kdeploy completion"
|
65
|
+
source_lines.each { |line| f.puts line unless content.include?(line) }
|
66
|
+
end
|
58
67
|
end
|
59
68
|
puts "✅ Zsh completion configured in #{zshrc_path}"
|
60
69
|
rescue StandardError => e
|
@@ -62,17 +71,30 @@ module Kdeploy
|
|
62
71
|
end
|
63
72
|
|
64
73
|
def find_completion_file(filename)
|
65
|
-
#
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
+
# 尝试所有可能的路径
|
75
|
+
paths = [
|
76
|
+
# 开发环境路径
|
77
|
+
File.expand_path("../completions/#{filename}", __FILE__),
|
78
|
+
# RubyGems 安装路径
|
79
|
+
*Gem.path.map { |path| File.join(path, "gems/kdeploy-*/lib/kdeploy/completions/#{filename}") },
|
80
|
+
# 系统路径
|
81
|
+
"/usr/local/share/kdeploy/completions/#{filename}",
|
82
|
+
"/usr/share/kdeploy/completions/#{filename}"
|
83
|
+
]
|
84
|
+
|
85
|
+
# 使用 Dir.glob 处理通配符路径
|
86
|
+
paths.each do |path|
|
87
|
+
if path.include?('*')
|
88
|
+
matches = Dir.glob(path)
|
89
|
+
return matches.first if matches.any?
|
90
|
+
elsif File.exist?(path)
|
91
|
+
return path
|
92
|
+
end
|
74
93
|
end
|
75
94
|
|
95
|
+
puts "⚠️ Could not find completion file: #{filename}"
|
96
|
+
puts 'Searched paths:'
|
97
|
+
paths.each { |path| puts " - #{path}" }
|
76
98
|
nil
|
77
99
|
end
|
78
100
|
|
data/lib/kdeploy/version.rb
CHANGED