firespring_dev_commands 3.1.6 → 3.1.7
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/firespring_dev_commands/aws/login.rb +33 -7
- data/lib/firespring_dev_commands/docker/compose.rb +2 -1
- data/lib/firespring_dev_commands/env.rb +23 -0
- data/lib/firespring_dev_commands/eol/product_version.rb +1 -1
- data/lib/firespring_dev_commands/git.rb +7 -5
- data/lib/firespring_dev_commands/jira/project.rb +1 -1
- data/lib/firespring_dev_commands/ruby.rb +9 -3
- data/lib/firespring_dev_commands/templates/docker/ruby/application.rb +3 -3
- data/lib/firespring_dev_commands/templates/git.rb +6 -4
- data/lib/firespring_dev_commands/version.rb +1 -1
- 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: 70070678129ffdda3267e54d13f9021b4e577d8ec1b48191ad45776aaf166658
|
4
|
+
data.tar.gz: e46d2399cfbaac2e906e9829a49586afbe019d95b78709d2f4aacb09810a0ea2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e25f8ebe3e368a49ec73392028a398943b9b84a78cc1663935f2a025668ca5ab847230cdd60a4c4697abf6e6e79eee9c92ab9155e34b3435986441eba4b1d148
|
7
|
+
data.tar.gz: fa2e963ab14b0f899a93aef2e2f2b070dfd99f4541e9af2f67aed849e09412a0327cd0f1882ffb5deb73df6bb1236237fcb736647091af4bfbfa349d2e702963
|
@@ -61,15 +61,15 @@ module Dev
|
|
61
61
|
puts " Logging in to #{account} in #{region} as #{role}".light_yellow
|
62
62
|
puts
|
63
63
|
|
64
|
-
code =
|
64
|
+
code = mfa_code(serial)
|
65
65
|
raise 'MFA is required' unless code.to_s.strip
|
66
66
|
|
67
67
|
sts = ::Aws::STS::Client.new(profile: 'default', region:)
|
68
68
|
creds = sts.assume_role(
|
69
|
-
serial_number: serial,
|
69
|
+
serial_number: mfa_serial || serial,
|
70
70
|
role_arn: role,
|
71
71
|
role_session_name: session_name,
|
72
|
-
token_code: code,
|
72
|
+
token_code: code.to_s.strip,
|
73
73
|
duration_seconds: session_duration
|
74
74
|
).credentials
|
75
75
|
puts
|
@@ -77,6 +77,32 @@ module Dev
|
|
77
77
|
Dev::Aws::Credentials.new.write!(account, creds)
|
78
78
|
end
|
79
79
|
|
80
|
+
# The custom local file where target information is stored.
|
81
|
+
CUSTOM_CONFIG_FILE = "#{Dir.home}/.bash_profile.d/config/.main".freeze
|
82
|
+
|
83
|
+
# Targets a custom ini config.
|
84
|
+
def custom_config_ini
|
85
|
+
IniFile.new(filename: CUSTOM_CONFIG_FILE, default: 'default')['default']
|
86
|
+
end
|
87
|
+
|
88
|
+
def mfa_serial
|
89
|
+
return unless !ENV.fetch('OP_LOGIN', nil).nil? && File.exist?(CUSTOM_CONFIG_FILE)
|
90
|
+
|
91
|
+
custom_config_ini['aws_1pass_mfa_serial']
|
92
|
+
end
|
93
|
+
|
94
|
+
# Handles the MFA code logic.
|
95
|
+
def mfa_code(serial)
|
96
|
+
# Note, OP_LOGIN likely not needed. Available as feature flag.
|
97
|
+
# Checks if OnePassword CLI is installed and the custom config file exist.
|
98
|
+
if !ENV.fetch('OP_LOGIN', nil).nil? && system('op --version', out: '/dev/null') && File.exist?(CUSTOM_CONFIG_FILE)
|
99
|
+
cmd = "op item get #{custom_config_ini['aws_uuid']} --otp"
|
100
|
+
`#{cmd}`
|
101
|
+
else
|
102
|
+
ENV['AWS_TOKEN_CODE'] || Dev::Common.new.ask("Enter the MFA code for the #{ENV.fetch('USERNAME', 'no_username_found')} user serial #{serial}")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
80
106
|
# Returns the config ini file
|
81
107
|
# Runs the setup for our current account if it's not already setup
|
82
108
|
def setup_cfgini(account)
|
@@ -88,8 +114,8 @@ module Dev
|
|
88
114
|
cfgini
|
89
115
|
end
|
90
116
|
|
91
|
-
#
|
92
|
-
#
|
117
|
+
# Authorizes the docker cli to pull/push images from the Aws container registry (e.g. if docker compose needs to pull an image)
|
118
|
+
# Authorizes the docker ruby library to pull/push images from the Aws container registry
|
93
119
|
def registry_logins!(registry_ids: nil, region: nil)
|
94
120
|
registry_ids ||= Dev::Aws::Account.new.ecr_registry_ids
|
95
121
|
region ||= Dev::Aws::Credentials.new.logged_in_region || Dev::Aws::DEFAULT_REGION
|
@@ -100,8 +126,8 @@ module Dev
|
|
100
126
|
puts
|
101
127
|
end
|
102
128
|
|
103
|
-
#
|
104
|
-
#
|
129
|
+
# Authorizes the docker cli to pull/push images from the Aws container registry (e.g. if docker compose needs to pull an image)
|
130
|
+
# Authorizes the docker ruby library to pull/push images from the Aws container registry
|
105
131
|
def registry_login!(registry_id: nil, region: nil)
|
106
132
|
registry_id ||= Dev::Aws::Account.new.ecr_registry_ids.first
|
107
133
|
region ||= Dev::Aws::Credentials.new.logged_in_region || Dev::Aws::DEFAULT_REGION
|
@@ -238,7 +238,8 @@ module Dev
|
|
238
238
|
|
239
239
|
# Merges two arrays removing nested structure and duplicate keys
|
240
240
|
private def merge_options(*opts)
|
241
|
-
|
241
|
+
puts 'WARNING: merging options disabled' if @options.any? { |it| it.include?('--build-arg') }
|
242
|
+
@options = (@options + Array(opts)).flatten.uniq unless @options.any? { |it| it.include?('--build-arg') }
|
242
243
|
end
|
243
244
|
|
244
245
|
# Build the compose command with the given inputs
|
@@ -34,5 +34,28 @@ module Dev
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def containerized?
|
39
|
+
# Fast path: common flags files
|
40
|
+
return true if File.exist?('/.dockerenv') # Docker
|
41
|
+
return true if File.exist?('/run/.containerenv') # Podman / some runtimes
|
42
|
+
|
43
|
+
# Env flags some images set
|
44
|
+
return true if ENV['DOCKER_CONTAINER'] == 'true'
|
45
|
+
return true if ENV['container']&.match?(/docker|podman|lxc|containerd/i)
|
46
|
+
|
47
|
+
# cgroup hints (docker, containerd, kubernetes, podman)
|
48
|
+
%w(/proc/1/cgroup /proc/self/cgroup).any? do |p|
|
49
|
+
next false unless File.readable?(p)
|
50
|
+
|
51
|
+
File.read(p).match?(/docker|containerd|kubepods|podman|libpod/i)
|
52
|
+
end
|
53
|
+
rescue
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
def on_host
|
58
|
+
yield unless containerized?
|
59
|
+
end
|
37
60
|
end
|
38
61
|
end
|
@@ -53,7 +53,7 @@ module Dev
|
|
53
53
|
detail = JSON.parse(response.body) if response.is_a?(Net::HTTPSuccess)
|
54
54
|
|
55
55
|
# If EOL info is a boolean or missing from the current details, overwrite with the manual date (if present)
|
56
|
-
manual_date = Dev::EndOfLife.config.manual_dates["#{product}_#{cycle.tr('.', '_')}"
|
56
|
+
manual_date = Dev::EndOfLife.config.manual_dates[:"#{product}_#{cycle.tr('.', '_')}"]
|
57
57
|
detail['eol'] = manual_date if manual_date && (detail['eol'].boolean? || detail['eol'].nil?)
|
58
58
|
detail['eol'] = '1979-01-01' if detail.empty?
|
59
59
|
detail
|
@@ -185,7 +185,7 @@ module Dev
|
|
185
185
|
end
|
186
186
|
|
187
187
|
# Checks out the given branch in all repositories with some additional formatting
|
188
|
-
def checkout_all(branch)
|
188
|
+
def checkout_all(branch, default)
|
189
189
|
@success = true
|
190
190
|
puts
|
191
191
|
puts "Checking out #{branch} in each repo".light_yellow if project_dirs.length > 1
|
@@ -194,7 +194,7 @@ module Dev
|
|
194
194
|
|
195
195
|
repo_basename = File.basename(File.realpath(project_dir))
|
196
196
|
puts Dev::Common.new.center_pad(repo_basename).light_green
|
197
|
-
@success &= checkout(branch, dir: project_dir)
|
197
|
+
@success &= checkout(branch, default, dir: project_dir)
|
198
198
|
puts Dev::Common.new.center_pad.light_green
|
199
199
|
end
|
200
200
|
puts
|
@@ -203,9 +203,10 @@ module Dev
|
|
203
203
|
end
|
204
204
|
|
205
205
|
# Checks out the given branch in the given repo
|
206
|
+
# If the given branch isn't found, falls back to default branch, then staging, then main
|
206
207
|
# Defaults to the current directory
|
207
208
|
# optionally raise errors
|
208
|
-
def checkout(branch, dir: default_project_dir, raise_errors: false)
|
209
|
+
def checkout(branch, default, dir: default_project_dir, raise_errors: false)
|
209
210
|
raise 'branch is required' if branch.to_s.strip.empty?
|
210
211
|
return unless File.exist?(dir)
|
211
212
|
|
@@ -215,10 +216,11 @@ module Dev
|
|
215
216
|
g = ::Git.open(dir)
|
216
217
|
g.fetch('origin', prune: true)
|
217
218
|
|
218
|
-
# If the branch we are checking out doesn't exist,
|
219
|
+
# If the branch we are checking out doesn't exist,
|
220
|
+
# check out either the default branch, staging branch, or the main branch
|
219
221
|
actual_branch = branch
|
220
222
|
unless branch_exists?(dir, branch)
|
221
|
-
actual_branch = [staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
|
223
|
+
actual_branch = [default, staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
|
222
224
|
puts "Branch #{branch} not found, checking out #{actual_branch} instead".light_yellow
|
223
225
|
end
|
224
226
|
|
@@ -95,7 +95,9 @@ module Dev
|
|
95
95
|
# Build the bundle lint command
|
96
96
|
def lint_command
|
97
97
|
lint = base_command
|
98
|
-
|
98
|
+
target_lint = Dev::Env.new.containerized? ? %w(rake lint) : ['rubocop']
|
99
|
+
lint << 'exec'
|
100
|
+
lint.concat(target_lint)
|
99
101
|
lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
100
102
|
lint
|
101
103
|
end
|
@@ -103,7 +105,9 @@ module Dev
|
|
103
105
|
# Build the bundle lint fix command
|
104
106
|
def lint_fix_command
|
105
107
|
lint_fix = base_command
|
106
|
-
|
108
|
+
target_lint = Dev::Env.new.containerized? ? %w(rake lint:fix) : %w(rubocop -A)
|
109
|
+
lint_fix << 'exec'
|
110
|
+
lint_fix.concat(target_lint)
|
107
111
|
lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
108
112
|
lint_fix
|
109
113
|
end
|
@@ -111,7 +115,9 @@ module Dev
|
|
111
115
|
# Build the bundle test command
|
112
116
|
def test_command
|
113
117
|
test = base_command
|
114
|
-
|
118
|
+
target_test = Dev::Env.new.containerized? ? %w(rake test) : ['rspec']
|
119
|
+
test << 'exec'
|
120
|
+
test.concat(target_test)
|
115
121
|
test.concat(coverage.ruby_options) if coverage
|
116
122
|
test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
117
123
|
test
|
@@ -74,7 +74,7 @@ module Dev
|
|
74
74
|
# Run the lint command
|
75
75
|
options = []
|
76
76
|
options << '-T' if Dev::Common.new.running_codebuild?
|
77
|
-
environment =
|
77
|
+
environment = %w(OPTS)
|
78
78
|
Dev::Docker::Compose.new(services: application, options:, environment:).exec(*ruby.lint_command)
|
79
79
|
ensure
|
80
80
|
# Copy any defined artifacts back
|
@@ -92,7 +92,7 @@ module Dev
|
|
92
92
|
# Run the lint fix command
|
93
93
|
options = []
|
94
94
|
options << '-T' if Dev::Common.new.running_codebuild?
|
95
|
-
environment =
|
95
|
+
environment = %w(OPTS)
|
96
96
|
Dev::Docker::Compose.new(services: application, options:, environment:).exec(*ruby.lint_fix_command)
|
97
97
|
end
|
98
98
|
end
|
@@ -190,7 +190,7 @@ module Dev
|
|
190
190
|
namespace :ruby do
|
191
191
|
desc 'Install all bundled gems'
|
192
192
|
task install: %w(init_docker up_no_deps) do
|
193
|
-
environment =
|
193
|
+
environment = %w(OPTS)
|
194
194
|
Dev::Docker::Compose.new(services: application, environment:).exec(*ruby.install_command)
|
195
195
|
end
|
196
196
|
end
|
@@ -31,13 +31,15 @@ module Dev
|
|
31
31
|
return if exclude.include?(:checkout)
|
32
32
|
|
33
33
|
desc 'Checks out a branch for each repo (alias: git:co)' \
|
34
|
-
"\n\tuse BRANCH=abc123 to specify the branch of code you
|
35
|
-
"\n\
|
34
|
+
"\n\tuse BRANCH=abc123 to specify the branch of code you wish to switch to (required)" \
|
35
|
+
"\n\tuse DEFAULT=abc456 to specify the branch of code to fall back to" \
|
36
|
+
"\n\tIf branch and default do not exist, the configured staging or main branch will be checked out"
|
36
37
|
task checkout: %w(init) do
|
37
38
|
branch = ENV['BRANCH'].to_s.strip
|
39
|
+
default = ENV['DEFAULT'].to_s.strip
|
38
40
|
raise 'branch is required' if branch.empty?
|
39
41
|
|
40
|
-
Dev::Git.new.checkout_all(branch)
|
42
|
+
Dev::Git.new.checkout_all(branch, default)
|
41
43
|
end
|
42
44
|
|
43
45
|
task co: %w(init checkout) do
|
@@ -48,7 +50,7 @@ module Dev
|
|
48
50
|
[d.main_branch, d.staging_branch].uniq.each do |it|
|
49
51
|
desc "Checks out the #{it} branch for each repo (alias: git:co:#{it})"
|
50
52
|
task "checkout:#{it}": %w(init) do
|
51
|
-
Dev::Git.new.checkout_all(it)
|
53
|
+
Dev::Git.new.checkout_all(it, '')
|
52
54
|
end
|
53
55
|
|
54
56
|
task "co:#{it}": %W(init checkout:#{it}) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firespring_dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|