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