kdeploy 0.8.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: d5e47ea7a547681734c52efc1ab39eb1dea4a936653577db030db86bad052bd4
4
- data.tar.gz: 8c404c8331553539ab29e5dc5e7c54bb0c83fd9ca9ea98d96b98e7da144ced09
3
+ metadata.gz: 49d961844c07920b802b76ae12a6f45d49be63955e3d5c78ab68cc0e2c2b4f3e
4
+ data.tar.gz: 7eb0c1863c4874c481f71af6f7c4b0f523984349200c8eb8592c1b9fe20025cd
5
5
  SHA512:
6
- metadata.gz: 208cfb462d50209c4b3a07fe97e87f12173bd610990fb67cbc0248e68a391492bc13fcfd560dc579752a1538421c2411be14be6d6ae5105cd689828cf4646f79
7
- data.tar.gz: d4f52d5428dd67ccb467e1851577a682f162549e2f354826def815c9d70cc03663e0d6b23f0a2152a9def7fd08c5d057e7621550eb626bee8dc14829e78eec10
6
+ metadata.gz: 18ad6647967c2388bd76d4d1d3b81b890116e236d8059bf9d653009cebe09989341b1573c957f5eb3a8ab81f24c8ad5ea1dcd6351d7d58886e62d57bf898cde2
7
+ data.tar.gz: 795c2c40e0614ac08e535b5ec16613fe1370c2f0513498da454a7a660af425b768bfe8c1694db95a1926bb3633e2cc9549c0ef927b0fd2223ead3010a72ab908
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
@@ -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
@@ -0,0 +1,110 @@
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
+ 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
37
+ end
38
+ puts "✅ Bash completion configured in #{bashrc_path}"
39
+ rescue StandardError => e
40
+ puts "⚠️ Failed to configure Bash completion: #{e.message}"
41
+ end
42
+
43
+ def setup_zsh_completion
44
+ return unless File.exist?(zshrc_path)
45
+
46
+ completion_path = find_completion_file('kdeploy.zsh')
47
+ return if completion_path.nil?
48
+
49
+ source_lines = [
50
+ "source \"#{completion_path}\"",
51
+ 'autoload -Uz compinit && compinit'
52
+ ]
53
+
54
+ content = File.read(zshrc_path)
55
+
56
+ # 检查是否已经配置
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
67
+ end
68
+ puts "✅ Zsh completion configured in #{zshrc_path}"
69
+ rescue StandardError => e
70
+ puts "⚠️ Failed to configure Zsh completion: #{e.message}"
71
+ end
72
+
73
+ def find_completion_file(filename)
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
93
+ end
94
+
95
+ puts "⚠️ Could not find completion file: #{filename}"
96
+ puts 'Searched paths:'
97
+ paths.each { |path| puts " - #{path}" }
98
+ nil
99
+ end
100
+
101
+ def bashrc_path
102
+ File.join(Dir.home, '.bashrc')
103
+ end
104
+
105
+ def zshrc_path
106
+ File.join(Dir.home, '.zshrc')
107
+ end
108
+ end
109
+ end
110
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '0.8.0'
4
+ VERSION = '1.0.1'
5
5
  end
data/lib/kdeploy.rb CHANGED
@@ -7,6 +7,7 @@ require_relative 'kdeploy/executor'
7
7
  require_relative 'kdeploy/runner'
8
8
  require_relative 'kdeploy/initializer'
9
9
  require_relative 'kdeploy/template'
10
+ require_relative 'kdeploy/post_install'
10
11
  require_relative 'kdeploy/cli'
11
12
 
12
13
  module Kdeploy
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.8.0
4
+ version: 1.0.1
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,11 +170,13 @@ 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
@@ -170,6 +186,7 @@ files:
170
186
  - lib/kdeploy/dsl.rb
171
187
  - lib/kdeploy/executor.rb
172
188
  - lib/kdeploy/initializer.rb
189
+ - lib/kdeploy/post_install.rb
173
190
  - lib/kdeploy/runner.rb
174
191
  - lib/kdeploy/template.rb
175
192
  - lib/kdeploy/version.rb
@@ -181,11 +198,10 @@ metadata:
181
198
  source_code_uri: https://github.com/kevin197011/kdeploy.git
182
199
  changelog_uri: https://github.com/kevin197011/kdeploy/blob/main/CHANGELOG.md
183
200
  rubygems_mfa_required: 'true'
184
- post_install_message: "\U0001F389 Thanks for installing kdeploy!\n\nTo enable command
185
- completion, add the following to your shell config:\n\nFor Bash (~/.bashrc):\n source
186
- \"$(gem contents kdeploy | grep kdeploy.bash)\"\n\nFor Zsh (~/.zshrc):\n source
187
- \"$(gem contents kdeploy | grep kdeploy.zsh)\"\n autoload -Uz compinit && compinit\n\nHappy
188
- deploying! \U0001F680\n"
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"
189
205
  rdoc_options: []
190
206
  require_paths:
191
207
  - lib