kdeploy 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5e47ea7a547681734c52efc1ab39eb1dea4a936653577db030db86bad052bd4
4
- data.tar.gz: 8c404c8331553539ab29e5dc5e7c54bb0c83fd9ca9ea98d96b98e7da144ced09
3
+ metadata.gz: e14af235c838f2eedcd245709e574da869a894aeb8a56546ad3e91a3ca539b81
4
+ data.tar.gz: eb26703e45873b1f531436ec824cc4b5d24dc9e08a1719aede9b67946208ad9c
5
5
  SHA512:
6
- metadata.gz: 208cfb462d50209c4b3a07fe97e87f12173bd610990fb67cbc0248e68a391492bc13fcfd560dc579752a1538421c2411be14be6d6ae5105cd689828cf4646f79
7
- data.tar.gz: d4f52d5428dd67ccb467e1851577a682f162549e2f354826def815c9d70cc03663e0d6b23f0a2152a9def7fd08c5d057e7621550eb626bee8dc14829e78eec10
6
+ metadata.gz: aba8d30f09879f60a61362bb2e36276bf648efac29c81a1c9f69958813465124ccd7463c1e3811936f9194bef95d1bc6a6c3cf4cfc713829122c6f80ec86d4d6
7
+ data.tar.gz: '09eb4d286a72d68e382a6453114de89f58e9f2d9c7e455e84f6fbe474fcf46537aff910bb2002d03ddca2ec05708d4c2fc67bd3617f84d80b4efcec38f20d5b3'
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,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
@@ -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.0'
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.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,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