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 +4 -4
- data/README.md +1 -1
- data/lib/kscript/plugins/kk_cursor_rules_utils.rb +114 -0
- data/lib/kscript/plugins/kk_port_scan_utils.rb +7 -12
- data/lib/kscript/plugins/kk_project_scan_utils.rb +2 -1
- data/lib/kscript/plugins/kk_shell_helper_utils.rb +1 -1
- data/lib/kscript/plugins/kk_vcs_cleaner_utils.rb +1 -1
- data/lib/kscript/version.rb +1 -1
- data/lib/kscript.rb +0 -1
- metadata +5 -5
- data/lib/kscript/utils.rb +0 -1
- /data/lib/{completions → kscript/completions}/kscript.bash +0 -0
- /data/lib/{completions → kscript/completions}/kscript.zsh +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c849a066ee71710301195b2291bdfc84ef1e94544273010bc081c2654af9a198
|
4
|
+
data.tar.gz: ec56f9ebe0ad082112060f6d53a63efae05c7095ecd0ead03bbd237c78001db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0068635e992da14c93ac3525a631157c62eb57f66271cdea4818672e7a05afe35507a87c0eee713fecbfe17941bf0cba617a89038581b928f76a7c7165c99f2b'
|
7
|
+
data.tar.gz: 2e708a65ccb4de60db91990360f3705e1545b1d51fbe81973e2dd78ce6f510a22c3237d9b69f8051805af56e12c82e50e5e6218cd1af2ee90264e6ef4850776f
|
data/README.md
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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)
|
@@ -64,7 +64,7 @@ module Kscript
|
|
64
64
|
version_count = versions.length
|
65
65
|
return if version_count <= @retain_count
|
66
66
|
|
67
|
-
logger.
|
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
|
|
data/lib/kscript/version.rb
CHANGED
data/lib/kscript.rb
CHANGED
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.
|
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-
|
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
|
File without changes
|
File without changes
|