smdev 0.1.1 → 0.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.
- checksums.yaml +4 -4
- data/lib/smdev.rb +87 -83
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74b463faf28bf0f34c9bfc7ab00726862bf4763bcb70ca3ebe7f77d6673f2052
|
|
4
|
+
data.tar.gz: ae57a1b92b6686b953867d803f3f213db31b970275587541ef19c735c2e1bb3b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1a91f538de100ccdfcf5601d448107a8afd027ed774d62b0404b72e907eeaacb052b6e56eea11c3a028f36ea2fef68683dc20fa09afd358e8c96836ee5665f2
|
|
7
|
+
data.tar.gz: 2907d1be5ad5c1fea1d3b0a404ba4ef6f4d198b3045c3ac232a1d84d1efc3332d79afa01fe100e59eb7cf03f894f142d9c7f88f474e20df18ad45aac85f156e8
|
data/lib/smdev.rb
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
require 'io/console'
|
|
3
3
|
require 'octokit'
|
|
4
4
|
require 'optparse'
|
|
5
|
-
require_relative 'smdev/cli'
|
|
6
|
-
|
|
7
5
|
|
|
8
6
|
module Smdev
|
|
9
7
|
class CLI
|
|
10
|
-
def run
|
|
8
|
+
def run(args = ARGV)
|
|
11
9
|
options = {}
|
|
10
|
+
commands = ["local_app_setup : Install local requirements for application. (Rails Only Currently)\n",
|
|
11
|
+
"system_install : Install Homebrew, Ruby, PostgreSQL, and Ruby on Rails\n",
|
|
12
|
+
"checkout_repos : Checkout all repositories for StrongMind\n"]
|
|
13
|
+
|
|
12
14
|
OptionParser.new do |opts|
|
|
13
|
-
opts.banner = "Usage: smdev.rb [options]"
|
|
15
|
+
opts.banner = "Usage: smdev.rb [options] <command>"
|
|
14
16
|
|
|
15
17
|
opts.on("-t", "--team TEAM_NAME", "Pull repositories assigned to a specific team") do |team_name|
|
|
16
18
|
options[:team] = team_name
|
|
@@ -22,35 +24,14 @@ module Smdev
|
|
|
22
24
|
|
|
23
25
|
opts.on("-h", "--help", "Prints this help message") do
|
|
24
26
|
puts opts
|
|
27
|
+
puts "\nCommands:"
|
|
28
|
+
commands.each { |cmd| puts " #{cmd}" }
|
|
25
29
|
exit
|
|
26
30
|
end
|
|
27
31
|
|
|
28
|
-
opts.on("-l", "--local-app-install", "Setup this local application") do
|
|
29
|
-
options[:local_install] = true
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
opts.on("-i", "--install", "Install Homebrew, Ruby, PostgreSQL, and Ruby on Rails") do
|
|
33
|
-
options[:install] = true
|
|
34
|
-
end
|
|
35
32
|
end.parse!
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
puts "Running Bundle Install"
|
|
39
|
-
system('bundle', 'install')
|
|
40
|
-
|
|
41
|
-
puts "Copying env file"
|
|
42
|
-
system('cp', '.env.example', '.env')
|
|
43
|
-
|
|
44
|
-
puts "Create database"
|
|
45
|
-
system('bin/rails', 'db:create')
|
|
46
|
-
|
|
47
|
-
puts "Run database migrations"
|
|
48
|
-
system('rails', 'db:migrate')
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
if options[:install]
|
|
53
|
-
# Install Homebrew
|
|
34
|
+
def system_install
|
|
54
35
|
puts "Installing Homebrew..."
|
|
55
36
|
system({ 'SHELL' => '/bin/bash' }, '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"')
|
|
56
37
|
# system('/bin/bash', '-c', "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)")
|
|
@@ -107,68 +88,91 @@ module Smdev
|
|
|
107
88
|
# Install Ruby on Rails
|
|
108
89
|
puts "Installing Ruby on Rails..."
|
|
109
90
|
system('sudo', 'gem', 'install', 'rails')
|
|
110
|
-
|
|
111
|
-
# If install option is provided, exit the script
|
|
112
|
-
exit if options[:install]
|
|
113
91
|
end
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
end
|
|
122
|
-
# Authenticate with the GitHub API using the user's credentials
|
|
123
|
-
client = Octokit::Client.new(access_token: token)
|
|
124
|
-
|
|
125
|
-
# Specify the organization name
|
|
126
|
-
org_name = "StrongMind"
|
|
127
|
-
|
|
128
|
-
if options[:team]
|
|
129
|
-
# A team name was provided as a command-line argument
|
|
130
|
-
team_name = options[:team]
|
|
131
|
-
# Get a list of all teams in the organization
|
|
132
|
-
teams = client.organization_teams(org_name)
|
|
133
|
-
# Find the team with the specified name
|
|
134
|
-
team = teams.find { |t| t.name == team_name }
|
|
135
|
-
if team.nil?
|
|
136
|
-
puts "Error: Could not find team with name '#{team_name}' in organization '#{org_name}'"
|
|
137
|
-
exit
|
|
92
|
+
def checkout_repos(options)
|
|
93
|
+
token = ENV['GITHUB_TOKEN']
|
|
94
|
+
if token.nil?
|
|
95
|
+
# Prompt the user for their GitHub personal access token
|
|
96
|
+
print "GitHub personal access token: "
|
|
97
|
+
token = STDIN.noecho(&:gets).chomp
|
|
98
|
+
puts ""
|
|
138
99
|
end
|
|
139
|
-
#
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
100
|
+
# Authenticate with the GitHub API using the user's credentials
|
|
101
|
+
client = Octokit::Client.new(access_token: token)
|
|
102
|
+
|
|
103
|
+
# Specify the organization name
|
|
104
|
+
org_name = "StrongMind"
|
|
105
|
+
|
|
106
|
+
if options[:team]
|
|
107
|
+
# A team name was provided as a command-line argument
|
|
108
|
+
team_name = options[:team]
|
|
109
|
+
# Get a list of all teams in the organization
|
|
110
|
+
teams = client.organization_teams(org_name)
|
|
111
|
+
# Find the team with the specified name
|
|
112
|
+
team = teams.find { |t| t.name == team_name }
|
|
113
|
+
if team.nil?
|
|
114
|
+
puts "Error: Could not find team with name '#{team_name}' in organization '#{org_name}'"
|
|
115
|
+
exit
|
|
116
|
+
end
|
|
117
|
+
# Get a list of all repositories in the organization that are assigned to the specified team
|
|
118
|
+
#
|
|
119
|
+
repos = client.org_repos(org_name, { :affiliation => 'organization_member', :team_id => team.id })
|
|
120
|
+
puts "Team Name #{team_name} - Team ID: #{team.id}"
|
|
121
|
+
else
|
|
122
|
+
repos = []
|
|
123
|
+
page_number = 1
|
|
124
|
+
per_page = 100
|
|
125
|
+
loop do
|
|
126
|
+
repos_page = client.organization_repositories(org_name, { :affiliation => 'owner,organization_member', :per_page => per_page, :page => page_number })
|
|
127
|
+
repos.concat(repos_page)
|
|
128
|
+
break if repos_page.length < per_page
|
|
129
|
+
page_number += 1
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# # No team name was provided, so get a list of all teams in the organization
|
|
133
|
+
# teams = client.organization_teams(org_name)
|
|
134
|
+
# # Get a list of all repositories in the organization that are assigned to each team
|
|
135
|
+
# repos = []
|
|
136
|
+
# teams.each do |team|
|
|
137
|
+
# team_repos = client.team_repos(team.id)
|
|
138
|
+
# repos.concat(team_repos)
|
|
139
|
+
# end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Clone each repository to a local directory
|
|
143
|
+
repos.each do |repo|
|
|
144
|
+
clone_url = repo.clone_url
|
|
145
|
+
ssh_url = repo.ssh_url
|
|
146
|
+
repo_name = repo.name
|
|
147
|
+
url = options[:https] ? clone_url : ssh_url
|
|
148
|
+
`git clone #{url} #{repo_name}`
|
|
152
149
|
end
|
|
153
150
|
|
|
154
|
-
# # No team name was provided, so get a list of all teams in the organization
|
|
155
|
-
# teams = client.organization_teams(org_name)
|
|
156
|
-
# # Get a list of all repositories in the organization that are assigned to each team
|
|
157
|
-
# repos = []
|
|
158
|
-
# teams.each do |team|
|
|
159
|
-
# team_repos = client.team_repos(team.id)
|
|
160
|
-
# repos.concat(team_repos)
|
|
161
|
-
# end
|
|
162
151
|
end
|
|
163
152
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
153
|
+
command = args.shift
|
|
154
|
+
|
|
155
|
+
case command
|
|
156
|
+
when "local_app_setup"
|
|
157
|
+
puts "Running Bundle Install"
|
|
158
|
+
system('bundle', 'install')
|
|
159
|
+
|
|
160
|
+
puts "Copying env file"
|
|
161
|
+
system('cp', '.env.example', '.env')
|
|
162
|
+
|
|
163
|
+
puts "Create database"
|
|
164
|
+
system('bin/rails', 'db:create')
|
|
165
|
+
|
|
166
|
+
puts "Run database migrations"
|
|
167
|
+
system('rails', 'db:migrate')
|
|
168
|
+
when "system_install"
|
|
169
|
+
system_install(options)
|
|
170
|
+
when "checkout_repos"
|
|
171
|
+
checkout_repos(options)
|
|
172
|
+
else
|
|
173
|
+
puts "Invalid command: #{command}. Use --help for a list of commands."
|
|
171
174
|
end
|
|
175
|
+
|
|
172
176
|
end
|
|
173
177
|
end
|
|
174
178
|
end
|
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: 0.
|
|
4
|
+
version: 0.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: 2023-
|
|
11
|
+
date: 2023-09-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: StrongMind Development Tool
|
|
14
14
|
email: derek.neighbors@strongmind.com
|