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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e14af235c838f2eedcd245709e574da869a894aeb8a56546ad3e91a3ca539b81
4
- data.tar.gz: eb26703e45873b1f531436ec824cc4b5d24dc9e08a1719aede9b67946208ad9c
3
+ metadata.gz: 49d961844c07920b802b76ae12a6f45d49be63955e3d5c78ab68cc0e2c2b4f3e
4
+ data.tar.gz: 7eb0c1863c4874c481f71af6f7c4b0f523984349200c8eb8592c1b9fe20025cd
5
5
  SHA512:
6
- metadata.gz: aba8d30f09879f60a61362bb2e36276bf648efac29c81a1c9f69958813465124ccd7463c1e3811936f9194bef95d1bc6a6c3cf4cfc713829122c6f80ec86d4d6
7
- data.tar.gz: '09eb4d286a72d68e382a6453114de89f58e9f2d9c7e455e84f6fbe474fcf46537aff910bb2002d03ddca2ec05708d4c2fc67bd3617f84d80b4efcec38f20d5b3'
6
+ metadata.gz: 18ad6647967c2388bd76d4d1d3b81b890116e236d8059bf9d653009cebe09989341b1573c957f5eb3a8ab81f24c8ad5ea1dcd6351d7d58886e62d57bf898cde2
7
+ data.tar.gz: 795c2c40e0614ac08e535b5ec16613fe1370c2f0513498da454a7a660af425b768bfe8c1694db95a1926bb3633e2cc9549c0ef927b0fd2223ead3010a72ab908
@@ -1,8 +1,10 @@
1
1
  #compdef kdeploy
2
2
 
3
3
  _kdeploy() {
4
- local -a commands options
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 -C \
20
- '1: :->cmds' \
21
- '*:: :->args'
22
+ _arguments \
23
+ '1: :->command' \
24
+ '*: :->args'
22
25
 
23
- case "$state" in
24
- cmds)
26
+ case $state in
27
+ command)
25
28
  _describe -t commands 'kdeploy commands' commands
26
29
  ;;
27
30
  args)
28
- case $words[1] in
31
+ case $words[2] in
29
32
  execute)
30
- if (( CURRENT == 2 )); then
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
@@ -23,12 +23,17 @@ module Kdeploy
23
23
  source_line = "source \"#{completion_path}\""
24
24
 
25
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
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
- 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) }
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
- 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
+ # 尝试所有可能的路径
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
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: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norton