smdev 1.1.1 → 1.2.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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/smdev/cursor_rules/backup_manager.rb +103 -0
  3. data/lib/smdev/cursor_rules/config_manager.rb +60 -0
  4. data/lib/smdev/cursor_rules/directory_manager.rb +55 -0
  5. data/lib/smdev/cursor_rules/file_copier.rb +53 -0
  6. data/lib/smdev/cursor_rules/file_operations.rb +83 -0
  7. data/lib/smdev/cursor_rules/installer.rb +128 -0
  8. data/lib/smdev/cursor_rules/templates/.cursor/rules/core-rules/readme.md +1 -0
  9. data/lib/smdev/cursor_rules/templates/.cursor/rules/core-rules/rule-generating-agent.mdc +86 -0
  10. data/lib/smdev/cursor_rules/templates/.cursor/rules/default.mdc +42 -0
  11. data/lib/smdev/cursor_rules/templates/.cursor/rules/documentation/markdown-auto.mdc +59 -0
  12. data/lib/smdev/cursor_rules/templates/.cursor/rules/documentation/readme.md +1 -0
  13. data/lib/smdev/cursor_rules/templates/.cursor/rules/global-rules/emoji-communication-always.mdc +33 -0
  14. data/lib/smdev/cursor_rules/templates/.cursor/rules/global-rules/performance-standards-agent.mdc +36 -0
  15. data/lib/smdev/cursor_rules/templates/.cursor/rules/global-rules/readme.md +5 -0
  16. data/lib/smdev/cursor_rules/templates/.cursor/rules/global-rules/tech-stack-agent.mdc +42 -0
  17. data/lib/smdev/cursor_rules/templates/.cursor/rules/rb-rules/database-standards-agent.mdc +52 -0
  18. data/lib/smdev/cursor_rules/templates/.cursor/rules/rb-rules/rails-conventions-agent.mdc +48 -0
  19. data/lib/smdev/cursor_rules/templates/.cursor/rules/rb-rules/readme.md +1 -0
  20. data/lib/smdev/cursor_rules/templates/.cursor/rules/testing-rules/rspec-standards-agent.mdc +51 -0
  21. data/lib/smdev/cursor_rules/templates/.cursor/rules/tool-rules/gitpush.mdc +35 -0
  22. data/lib/smdev/cursor_rules/templates/.cursor/rules/tool-rules/readme.md +1 -0
  23. data/lib/smdev/cursor_rules/templates/.cursor/rules/ts-rules/readme.md +1 -0
  24. data/lib/smdev/cursor_rules/templates/.cursor/rules/ui-rules/readme.md +11 -0
  25. data/lib/smdev/cursor_rules/templates/.cursor/rules/ui-rules/ui-component-standards-agent.mdc +55 -0
  26. data/lib/smdev/cursor_rules/templates/.cursor/rules/workflows/workflow-agile-manual.mdc +48 -0
  27. data/lib/smdev/cursor_rules/templates/.cursor/templates/template-arch.md +76 -0
  28. data/lib/smdev/cursor_rules/templates/.cursor/templates/template-prd.md +136 -0
  29. data/lib/smdev/cursor_rules/templates/.cursor/templates/template-story.md +146 -0
  30. data/lib/smdev/cursor_rules/templates/docs/agile-readme.md +251 -0
  31. data/lib/smdev/cursor_rules/templates/docs/cursor_rules.md +88 -0
  32. data/lib/smdev/cursor_rules/user_interface.rb +27 -0
  33. data/lib/smdev/cursor_rules.rb +16 -0
  34. data/lib/smdev/ecs_exec.rb +0 -4
  35. data/lib/smdev.rb +86 -105
  36. metadata +34 -2
data/lib/smdev.rb CHANGED
@@ -2,128 +2,133 @@
2
2
  require 'io/console'
3
3
  require 'octokit'
4
4
  require 'optparse'
5
+ require 'base64'
5
6
  require 'smdev/ecs_exec'
6
7
  require 'smdev/pr_critic'
8
+ require 'smdev/cursor_rules'
7
9
 
8
10
  module Smdev
11
+ class Error < StandardError; end
12
+
9
13
  class CLI
10
14
  def run(args = ARGV)
11
- options = {}
12
- commands = ["local_app_setup : Install local requirements for application. (Rails Only Currently)\n",
13
- "system_install : Install Homebrew, Ruby, PostgreSQL, and Ruby on Rails\n",
14
- "clone_repos : Checkout all repositories for StrongMind\n",
15
- "update_repos : Checkout all repositories for StrongMind\n",
16
- "console : Open a rails console on ECS\n",
17
- "ssh : Open a bash shell on ECS\n"
18
- ]
19
-
20
- OptionParser.new do |opts|
21
- opts.banner = "Usage: smdev.rb [options] <command>"
22
-
23
- opts.on("-t", "--team TEAM_NAME", "Pull repositories assigned to a specific team") do |team_name|
24
- options[:team] = team_name
25
- end
15
+ command = args.shift || 'help'
16
+ subcommand = args.shift
26
17
 
27
- opts.on("-s", "--https", "Use HTTPS to pull repos") do
28
- options[:https] = true
29
- end
18
+ case command
19
+ when 'update'
20
+ handle_update_command(subcommand)
21
+ when 'help'
22
+ display_help
23
+ else
24
+ puts "Unknown command: #{command}"
25
+ display_help
26
+ end
27
+ end
30
28
 
31
- opts.on("-r", "--cluster CLUSTER", "Lookup this cluster for the ECS execute (defaults to the name of your current folder)") do |cluster|
32
- options[:cluster] = cluster
33
- end
29
+ private
34
30
 
35
- opts.on("-v", "--service SERVICE", "Lookup this service for the ECS execute (defaults to \"prod-worker\")") do |svc|
36
- options[:service] = svc
37
- end
31
+ def handle_update_command(subcommand)
32
+ case subcommand
33
+ when 'cursor'
34
+ CursorRules.install
35
+ else
36
+ puts "Invalid update subcommand: #{subcommand}"
37
+ puts "Available update subcommands: cursor"
38
+ end
39
+ end
38
40
 
39
- opts.on("-c", "--command COMMAND", "Set the command for the ECS execute (defaults to a bash shell when you use 'ssh' and rails console when you use 'console')") do |ecs_command|
40
- options[:command] = ecs_command
41
+ def parse_options
42
+ options = {}
43
+ OptionParser.new do |parser|
44
+ parser.banner = "Usage: smdev COMMAND [options]"
45
+ parser.on("-h", "--help", "Show this help message") do
46
+ puts parser
47
+ exit
41
48
  end
49
+ end.parse!
50
+ options
51
+ end
42
52
 
43
- opts.on("-p", "--pr", "Run PR Critic to analyze GitHub pull requests.") do
44
- options[:pr_critic] = true
45
- end
53
+ def display_help
54
+ puts "Usage: smdev COMMAND [options]"
55
+ puts "\nCommands:"
56
+ puts " update cursor - Install or update cursor rules"
57
+ puts " help - Show this help message"
58
+ puts "\nOptions:"
59
+ puts " -h, --help - Show this help message"
60
+ end
46
61
 
47
- opts.on("--open", "Filter to show only open pull requests. (default)") do
48
- options[:pr_state] = 'open'
49
- end
62
+ def handle_pr_critic(options)
63
+ options[:pr_state] ||= 'open'
64
+ Smdev::PrCritic.analyze(options)
65
+ end
50
66
 
51
- opts.on("--closed", "Filter to show only closed pull requests.") do
52
- options[:pr_state] = 'closed'
53
- end
67
+ def execute_command(command, subcommand, options)
68
+ case command
69
+ when "local_app_setup" then execute_local_app_setup
70
+ when "system_install" then system_install
71
+ when "clone_repos" then clone_repos(options)
72
+ when "update_repos" then update_repos(options)
73
+ when "console" then execute_console(options)
74
+ when "ssh" then execute_ssh(options)
75
+ when "update" then handle_update(subcommand)
76
+ else
77
+ puts "Invalid command: #{command}. Use --help for a list of commands."
78
+ end
79
+ end
54
80
 
55
- opts.on("-h", "--help", "Prints this help message") do
56
- puts opts
57
- puts "\nCommands:"
58
- commands.each { |cmd| puts " #{cmd}" }
59
- exit
60
- end
81
+ def execute_local_app_setup
82
+ puts "Running Bundle Install"
83
+ system('bundle', 'install')
61
84
 
62
- end.parse!
85
+ puts "Copying env file"
86
+ system('cp', '.env.example', '.env')
63
87
 
64
- # Check for pr_critic flag before command processing
65
- if options[:pr_critic]
66
- options[:pr_state] ||= 'open' # Set default state if none specified
67
- Smdev::PrCritic.analyze(options)
68
- return
69
- end
88
+ puts "Create database"
89
+ system('bin/rails', 'db:create')
70
90
 
71
- command = args.shift
91
+ puts "Run database migrations"
92
+ system('rails', 'db:migrate')
93
+ end
72
94
 
73
- case command
74
- when "local_app_setup"
75
- puts "Running Bundle Install"
76
- system('bundle', 'install')
77
-
78
- puts "Copying env file"
79
- system('cp', '.env.example', '.env')
80
-
81
- puts "Create database"
82
- system('bin/rails', 'db:create')
83
-
84
- puts "Run database migrations"
85
- system('rails', 'db:migrate')
86
- when "system_install"
87
- system_install
88
- when "clone_repos"
89
- clone_repos(options)
90
- when "update_repos"
91
- update_repos(options)
92
- when "console"
93
- options[:command] = "rails c"
94
- open_ssh(options)
95
- when "ssh"
96
- options[:command] ||= "/bin/sh"
97
- open_ssh(options)
95
+ def execute_console(options)
96
+ options[:command] = "rails c"
97
+ open_ssh(options)
98
+ end
99
+
100
+ def execute_ssh(options)
101
+ options[:command] ||= "/bin/sh"
102
+ open_ssh(options)
103
+ end
104
+
105
+ def handle_update(subcommand)
106
+ case subcommand
107
+ when "cursor"
108
+ CursorRules.install
98
109
  else
99
- puts "Invalid command: #{command}. Use --help for a list of commands."
110
+ puts "Invalid update subcommand: #{subcommand}. Use --help for a list of commands."
100
111
  end
101
-
102
112
  end
103
113
 
104
114
  def system_install
105
115
  puts "Installing Homebrew..."
106
116
  system({ 'SHELL' => '/bin/bash' }, '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"')
107
- # system('/bin/bash', '-c', "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)")
108
117
 
109
- # Add Homebrew to PATH and run initialization script
110
118
  puts "adding homebrew to .zshrc"
111
119
  File.open("#{ENV['HOME']}/.zshrc", "a") do |file|
112
120
  file.write("\n")
113
121
  file.write('eval "$(/opt/homebrew/bin/brew shellenv)"')
114
122
  end
115
123
 
116
- # Update PATH to include Homebrew
117
124
  ENV['PATH'] = "#{ENV['HOME']}/.homebrew/bin:#{ENV['HOME']}/.homebrew/sbin:#{ENV['PATH']}"
118
125
 
119
- # Install PostgreSQL
120
126
  puts "Installing PostgreSQL..."
121
127
  system('brew', 'install', 'libpq')
122
128
 
123
129
  puts "Installing lib-pq..."
124
130
  system('brew', 'install', 'postgresql@15')
125
131
 
126
- # Install Code Climate
127
132
  puts "Preparing Code Climate Formulae..."
128
133
  system('brew', 'tap', 'codeclimate/formulae')
129
134
 
@@ -136,12 +141,6 @@ module Smdev
136
141
  puts "Installing AWS Session Manager Plugin..."
137
142
  system('brew', 'install', '--cask', 'session-manager-plugin')
138
143
 
139
- # TODO: need to add the path & compiler flags
140
- # echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
141
- # export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
142
- # export CPPFLAGS="-I/opt/homebrew/opt/libpq/include"
143
-
144
- # Install RBenv
145
144
  puts "Installing RBenv..."
146
145
  system('brew', 'install', 'rbenv')
147
146
  puts "Initialize RBenv..."
@@ -149,19 +148,15 @@ module Smdev
149
148
  file.write("\n")
150
149
  file.write('eval "$(rbenv init - zsh)"')
151
150
  end
152
- # Load the contents of .zshrc into a string
153
151
  zshrc_contents = File.read(File.expand_path('~/.zshrc'))
154
152
 
155
- # Execute a new shell session with the .zshrc contents
156
153
  exec('zsh', '-c', zshrc_contents)
157
154
 
158
- # Install Ruby
159
155
  puts "Installing Ruby via RBenv..."
160
156
  system('rbenv', 'install', '3.2.6')
161
157
  puts "Making ruby 3.2.6 global ..."
162
158
  system('rbenv', 'global', '3.2.6')
163
159
 
164
- # Install Ruby on Rails
165
160
  puts "Installing Ruby on Rails..."
166
161
  system('sudo', 'gem', 'install', 'rails')
167
162
  end
@@ -169,31 +164,23 @@ module Smdev
169
164
  def get_repos(options)
170
165
  token = ENV['GITHUB_TOKEN']
171
166
  if token.nil?
172
- # Prompt the user for their GitHub personal access token
173
167
  print "GitHub personal access token: "
174
168
  token = STDIN.noecho(&:gets).chomp
175
169
  puts ""
176
170
  end
177
171
 
178
- # Authenticate with the GitHub API using the user's credentials
179
172
  client = Octokit::Client.new(access_token: token)
180
173
 
181
- # Specify the organization name
182
174
  org_name = "StrongMind"
183
175
 
184
176
  if options[:team]
185
- # A team name was provided as a command-line argument
186
177
  team_name = options[:team]
187
- # Get a list of all teams in the organization
188
178
  teams = client.organization_teams(org_name)
189
- # Find the team with the specified name
190
179
  team = teams.find { |t| t.name == team_name }
191
180
  if team.nil?
192
181
  puts "Error: Could not find team with name '#{team_name}' in organization '#{org_name}'"
193
182
  exit
194
183
  end
195
- # Get a list of all repositories in the organization that are assigned to the specified team
196
- #
197
184
  repos = client.org_repos(org_name, { :affiliation => 'organization_member', :team_id => team.id })
198
185
  puts "Team Name #{team_name} - Team ID: #{team.id}"
199
186
  else
@@ -213,7 +200,6 @@ module Smdev
213
200
 
214
201
  def update_repos(options)
215
202
  repos = get_repos(options)
216
- # Clone each repository to a local directory
217
203
  repos.each do |repo|
218
204
  clone_url = repo.clone_url
219
205
  ssh_url = repo.ssh_url
@@ -235,15 +221,11 @@ module Smdev
235
221
  puts "Repository '#{repo_name}' isn't cloned locally. Skipping update."
236
222
  end
237
223
  end
238
-
239
224
  end
240
225
 
241
-
242
226
  def clone_repos(options)
243
227
  repos = get_repos(options)
244
228
 
245
-
246
- # Clone each repository to a local directory
247
229
  repos.each do |repo|
248
230
  clone_url = repo.clone_url
249
231
  ssh_url = repo.ssh_url
@@ -256,7 +238,6 @@ module Smdev
256
238
  `git clone #{url} #{repo_name}`
257
239
  end
258
240
  end
259
-
260
241
  end
261
242
 
262
243
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smdev
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Neighbors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-08 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: StrongMind Development Tool
14
14
  email: derek.neighbors@strongmind.com
@@ -19,6 +19,38 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - bin/smdev
21
21
  - lib/smdev.rb
22
+ - lib/smdev/cursor_rules.rb
23
+ - lib/smdev/cursor_rules/backup_manager.rb
24
+ - lib/smdev/cursor_rules/config_manager.rb
25
+ - lib/smdev/cursor_rules/directory_manager.rb
26
+ - lib/smdev/cursor_rules/file_copier.rb
27
+ - lib/smdev/cursor_rules/file_operations.rb
28
+ - lib/smdev/cursor_rules/installer.rb
29
+ - lib/smdev/cursor_rules/templates/.cursor/rules/core-rules/readme.md
30
+ - lib/smdev/cursor_rules/templates/.cursor/rules/core-rules/rule-generating-agent.mdc
31
+ - lib/smdev/cursor_rules/templates/.cursor/rules/default.mdc
32
+ - lib/smdev/cursor_rules/templates/.cursor/rules/documentation/markdown-auto.mdc
33
+ - lib/smdev/cursor_rules/templates/.cursor/rules/documentation/readme.md
34
+ - lib/smdev/cursor_rules/templates/.cursor/rules/global-rules/emoji-communication-always.mdc
35
+ - lib/smdev/cursor_rules/templates/.cursor/rules/global-rules/performance-standards-agent.mdc
36
+ - lib/smdev/cursor_rules/templates/.cursor/rules/global-rules/readme.md
37
+ - lib/smdev/cursor_rules/templates/.cursor/rules/global-rules/tech-stack-agent.mdc
38
+ - lib/smdev/cursor_rules/templates/.cursor/rules/rb-rules/database-standards-agent.mdc
39
+ - lib/smdev/cursor_rules/templates/.cursor/rules/rb-rules/rails-conventions-agent.mdc
40
+ - lib/smdev/cursor_rules/templates/.cursor/rules/rb-rules/readme.md
41
+ - lib/smdev/cursor_rules/templates/.cursor/rules/testing-rules/rspec-standards-agent.mdc
42
+ - lib/smdev/cursor_rules/templates/.cursor/rules/tool-rules/gitpush.mdc
43
+ - lib/smdev/cursor_rules/templates/.cursor/rules/tool-rules/readme.md
44
+ - lib/smdev/cursor_rules/templates/.cursor/rules/ts-rules/readme.md
45
+ - lib/smdev/cursor_rules/templates/.cursor/rules/ui-rules/readme.md
46
+ - lib/smdev/cursor_rules/templates/.cursor/rules/ui-rules/ui-component-standards-agent.mdc
47
+ - lib/smdev/cursor_rules/templates/.cursor/rules/workflows/workflow-agile-manual.mdc
48
+ - lib/smdev/cursor_rules/templates/.cursor/templates/template-arch.md
49
+ - lib/smdev/cursor_rules/templates/.cursor/templates/template-prd.md
50
+ - lib/smdev/cursor_rules/templates/.cursor/templates/template-story.md
51
+ - lib/smdev/cursor_rules/templates/docs/agile-readme.md
52
+ - lib/smdev/cursor_rules/templates/docs/cursor_rules.md
53
+ - lib/smdev/cursor_rules/user_interface.rb
22
54
  - lib/smdev/ecs_exec.rb
23
55
  - lib/smdev/pr_critic.rb
24
56
  homepage: https://github.com/StrongMind/Helpers/tree/main/smdev