kscript 1.0.7 → 1.0.8

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: 4c903c89ab57a0f91270b2b320b60981ba56ba5d6e4bb4096eb6bd26ab7b5a61
4
- data.tar.gz: 17a2a9d64078442493704bb60065bcc14a4b5728dcf1b7caf2440f0ce80c0008
3
+ metadata.gz: c849a066ee71710301195b2291bdfc84ef1e94544273010bc081c2654af9a198
4
+ data.tar.gz: ec56f9ebe0ad082112060f6d53a63efae05c7095ecd0ead03bbd237c78001db7
5
5
  SHA512:
6
- metadata.gz: f27cd8c019f492bd37359c01e0ca710ecc3ec99818b795efc3fd7a688ff4b06b47892421e01c7ceda79066c44184f60d86cfa07ed0c79df9db97dc367cb358cb
7
- data.tar.gz: e83ee610a5684dea38c12a68933e23224dee8b2654e9c689ed81ae57e4ee6c7f52620fec51347d6b1f9288075b10e1a42fa041ae8a8c4c4c61614e04ce8dfc51
6
+ metadata.gz: '0068635e992da14c93ac3525a631157c62eb57f66271cdea4818672e7a05afe35507a87c0eee713fecbfe17941bf0cba617a89038581b928f76a7c7165c99f2b'
7
+ data.tar.gz: 2e708a65ccb4de60db91990360f3705e1545b1d51fbe81973e2dd78ce6f510a22c3237d9b69f8051805af56e12c82e50e5e6218cd1af2ee90264e6ef4850776f
data/README.md CHANGED
@@ -140,7 +140,6 @@ AWS_SECRET_ACCESS_KEY=yyy
140
140
  KSCRIPT_LOG_LEVEL=info
141
141
  LOG=1
142
142
  ```
143
-
144
143
  ---
145
144
 
146
145
  ## 🧑‍💻 插件开发规范
@@ -185,3 +184,4 @@ MIT License. 详见 [LICENSE](LICENSE)。
185
184
 
186
185
  如需更多示例、插件开发指导或遇到问题,欢迎提 issue 或 PR!
187
186
 
187
+
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2025 kk
4
+ #
5
+ # This software is released under the MIT License.
6
+ # https://opensource.org/licenses/MIT
7
+
8
+ require 'fileutils'
9
+ require 'kscript'
10
+
11
+ module Kscript
12
+ class KkCursorRulesUtils < Base
13
+ def initialize(*_args, **opts)
14
+ super(**opts.merge(service: 'kk_cursor_rules'))
15
+ end
16
+
17
+ def run(*args, **_opts)
18
+ with_error_handling do
19
+ if args[0].to_s == 'deploy'
20
+ deploy
21
+ else
22
+ logger.kwarn("Usage: #{self.class.usage}")
23
+ end
24
+ end
25
+ end
26
+
27
+ def deploy
28
+ logger.kinfo('======= 🚀 Cursor Rules Deploy =======')
29
+ logger.kinfo("📅 Date Time: #{Time.now}")
30
+ logger.kinfo('')
31
+
32
+ # Remove .cursor if exists
33
+ if Dir.exist?('.cursor')
34
+ logger.kinfo('Removing existing .cursor directory...')
35
+ FileUtils.rm_rf('.cursor')
36
+ end
37
+
38
+ # Clone .cursor repo
39
+ logger.kinfo('Cloning .cursor repo from github...')
40
+ system_or_raise('git clone git@github.com:kevin197011/cursor.git .cursor')
41
+
42
+ # Move Rakefile if not exists, else remove .cursor/Rakefile
43
+ if !File.exist?('Rakefile') && File.exist?('.cursor/Rakefile')
44
+ logger.kinfo('Moving .cursor/Rakefile to project root...')
45
+ FileUtils.mv('.cursor/Rakefile', 'Rakefile')
46
+ elsif File.exist?('.cursor/Rakefile')
47
+ logger.kinfo('Removing .cursor/Rakefile (already present in root)...')
48
+ FileUtils.rm_rf('.cursor/Rakefile')
49
+ end
50
+
51
+ # Move push.rb
52
+ if File.exist?('.cursor/push.rb')
53
+ logger.kinfo('Moving .cursor/push.rb to project root...')
54
+ FileUtils.mv('.cursor/push.rb', 'push.rb')
55
+ end
56
+
57
+ # Move .rubocop.yml
58
+ if File.exist?('.cursor/.rubocop.yml')
59
+ logger.kinfo('Moving .cursor/.rubocop.yml to project root...')
60
+ FileUtils.mv('.cursor/.rubocop.yml', '.rubocop.yml')
61
+ end
62
+
63
+ # Remove .cursor/.git if exists
64
+ if File.exist?('.cursor/.git')
65
+ logger.kinfo('Removing .cursor/.git directory...')
66
+ FileUtils.rm_rf('.cursor/.git')
67
+ end
68
+
69
+ # Ensure .gitignore contains .cursor
70
+ if File.exist?('.gitignore') && File.readlines('.gitignore').none? { |l| l.strip == '.cursor' }
71
+ logger.kinfo('Adding .cursor to .gitignore...')
72
+ File.open('.gitignore', 'a') { |f| f.puts '\n.cursor' }
73
+ end
74
+
75
+ logger.kinfo("\n✅ Cursor rules deploy completed!")
76
+ end
77
+
78
+ private
79
+
80
+ def system_or_raise(cmd)
81
+ logger.kinfo("Running: #{cmd}")
82
+ success = system(cmd)
83
+ raise "Command failed: #{cmd}" unless success
84
+ end
85
+
86
+ def with_error_handling
87
+ yield
88
+ rescue StandardError => e
89
+ logger.kerror("[ERROR] #{e.class}: #{e.message}")
90
+ exit(1)
91
+ end
92
+
93
+ # ==== CLI/Plugin Metadata ====
94
+ def self.description
95
+ 'Cursor rules deploy helper: syncs .cursor repo and project rules.'
96
+ end
97
+
98
+ def self.arguments
99
+ '[deploy]'
100
+ end
101
+
102
+ def self.usage
103
+ 'kscript cursor_rules deploy'
104
+ end
105
+
106
+ def self.group
107
+ 'devops'
108
+ end
109
+
110
+ def self.author
111
+ 'kk'
112
+ end
113
+ end
114
+ end
@@ -22,8 +22,12 @@ module Kscript
22
22
  @thread_count = (opts[:thread_count] || 50).to_i
23
23
  end
24
24
 
25
- def run
25
+ def run(*args, **_opts)
26
26
  with_error_handling do
27
+ # 支持命令行参数覆盖
28
+ @target = args[0] if args[0]
29
+ @ports = parse_ports(args[1]) if args[1]
30
+ @thread_count = args[2].to_i if args[2]
27
31
  scan
28
32
  end
29
33
  end
@@ -31,11 +35,7 @@ module Kscript
31
35
  # Execute port scanning using multiple threads
32
36
  def scan
33
37
  msg = "Scanning #{@target} ports #{@ports} with concurrency=#{@thread_count}"
34
- if human_output?
35
- puts msg
36
- else
37
- logger.kinfo(msg)
38
- end
38
+ logger.kinfo(msg)
39
39
  queue = Queue.new
40
40
  @ports.each { |port| queue << port }
41
41
  threads = []
@@ -50,12 +50,7 @@ module Kscript
50
50
  end
51
51
  begin
52
52
  Socket.tcp(@target, port, connect_timeout: 0.5) do |_sock|
53
- if human_output?
54
- puts "Port #{port} is open"
55
- else
56
- logger.kinfo('Port open', port: port)
57
- logger.kinfo("Port #{port} is open")
58
- end
53
+ logger.kinfo('Port open', port: port)
59
54
  end
60
55
  rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, SocketError
61
56
  # closed or filtered
@@ -58,7 +58,8 @@ module Kscript
58
58
  projects = []
59
59
  Dir.glob(File.join(@src_path, '*')).each do |path|
60
60
  next unless File.directory?(path)
61
- next unless git_project?(path)
61
+
62
+ # next unless git_project?(path)
62
63
 
63
64
  project_name = File.basename(path)
64
65
  projects << create_project_entry(project_name, path)
@@ -44,7 +44,7 @@ module Kscript
44
44
  def fetch_help(command)
45
45
  response = make_request(command)
46
46
  response = response.first if response.is_a?(Array)
47
- puts response.body
47
+ logger.kinfo(response.body)
48
48
  rescue StandardError => e
49
49
  display_error(e)
50
50
  end
@@ -64,7 +64,7 @@ module Kscript
64
64
  version_count = versions.length
65
65
  return if version_count <= @retain_count
66
66
 
67
- logger.info("Processing #{app_path}", version_count: version_count, retain: @retain_count)
67
+ logger.kinfo("Processing #{app_path}", version_count: version_count, retain: @retain_count)
68
68
  cleanup_old_versions(versions, version_count)
69
69
  end
70
70
 
@@ -6,5 +6,5 @@
6
6
  # https://opensource.org/licenses/MIT
7
7
 
8
8
  module Kscript
9
- VERSION = '1.0.7'
9
+ VERSION = '1.0.8'
10
10
  end
data/lib/kscript.rb CHANGED
@@ -31,7 +31,6 @@ require 'kscript/config'
31
31
  require 'kscript/plugins'
32
32
  require 'kscript/base'
33
33
  require 'kscript/logger'
34
- require 'kscript/utils'
35
34
  require 'kscript/version'
36
35
 
37
36
  module Kscript
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-07-10 00:00:00.000000000 Z
11
+ date: 2025-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -147,17 +147,18 @@ files:
147
147
  - README.md
148
148
  - exe/kscript
149
149
  - ext/mkrf_conf.rb
150
- - lib/completions/kscript.bash
151
- - lib/completions/kscript.zsh
152
150
  - lib/kscript.rb
153
151
  - lib/kscript/banner.rb
154
152
  - lib/kscript/base.rb
155
153
  - lib/kscript/cli.rb
154
+ - lib/kscript/completions/kscript.bash
155
+ - lib/kscript/completions/kscript.zsh
156
156
  - lib/kscript/config.rb
157
157
  - lib/kscript/logger.rb
158
158
  - lib/kscript/plugins.rb
159
159
  - lib/kscript/plugins/kk_apnic_ip_utils.rb
160
160
  - lib/kscript/plugins/kk_aws_s3_utils.rb
161
+ - lib/kscript/plugins/kk_cursor_rules_utils.rb
161
162
  - lib/kscript/plugins/kk_elastic_cert_finger_utils.rb
162
163
  - lib/kscript/plugins/kk_ffmpeg_install_utils.rb
163
164
  - lib/kscript/plugins/kk_file_rename_utils.rb
@@ -175,7 +176,6 @@ files:
175
176
  - lib/kscript/plugins/kk_wg_acl_utils.rb
176
177
  - lib/kscript/plugins/kk_wg_pass_utils.rb
177
178
  - lib/kscript/post_install.rb
178
- - lib/kscript/utils.rb
179
179
  - lib/kscript/version.rb
180
180
  homepage: https://github.com/kevin197011/kscript
181
181
  licenses:
data/lib/kscript/utils.rb DELETED
@@ -1 +0,0 @@
1
- # frozen_string_literal: true