firespring_dev_commands 2.1.27.pre.alpha.1 → 2.1.27.pre.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f810ca7ab797bb1ec56674b67d42de056d5f88cd95a8e9c45b67d26a3570d19
4
- data.tar.gz: 487bdc8a74717f11bb48b5b81a33093fde87ddb2b44d97cdf84a0372e3b93627
3
+ metadata.gz: 74cb8d292f6a24d8229db1785ba9911e31b88a73dd102fb192266ed12834cdfb
4
+ data.tar.gz: 533e6747c1b5262c3a417f4bff11297dc9401fb116cd3c4dc142c3b1c0e13540
5
5
  SHA512:
6
- metadata.gz: 212273f4a640214bf8001c12419f33bb6dc621dc37a29b95e75d06c5b5e4bd3f7b7231c003cd032ed1be1c2dc0667d3474fb74892a7577ddd57eca248d96ab09
7
- data.tar.gz: 480720fd9de858a1ce969644958e61238e866fef1126fb91909992eca3301275d04fd42df45c1f34a7c5126758172a4c89f7bfc0ea3c1b8e2528816de97dbfba
6
+ metadata.gz: 525c93fe98d0301a321b1fbfa6c0133be6fdab762943d46d751cb5d50ed8ec59ee563c292afee118c66aa72c71cdd000e4dcff20b82de68aa9c33012c9203252
7
+ data.tar.gz: 7e8be2aa9d3f174d77a49a70430a7282203beadb12ac3672ccf4e1220a8091084c5a433308d96da413f2212e1f4196ae4a54970635b216d4fe98b7cba60d01f4
@@ -43,7 +43,7 @@ module Dev
43
43
  def save(dest_dir)
44
44
  raise "directory #{dest_dir} must be an existing directory" unless File.directory?(dest_dir)
45
45
 
46
- domain = domains.first.sub(/^\*\./, '')
46
+ domain = domains.first.sub(/^\*\./, '') # Need to strip off the '*.' if this is a wildcard cert
47
47
  directories = Dir.glob("/etc/letsencrypt/live/#{domain}*/")
48
48
  no_suffix = directories.delete("/etc/letsencrypt/live/#{domain}/")
49
49
  biggest_suffix = directories.max
@@ -187,5 +187,14 @@ module Dev
187
187
  return false
188
188
  end
189
189
  end
190
+
191
+ # Center the string and pad on either side with the given padding character
192
+ def center_pad(string = '', pad: '-', len: 80)
193
+ string = " #{string} " unless string.strip.empty?
194
+ center_dash = len / 2
195
+ string = string.to_s
196
+ center_str = string.length / 2
197
+ string.rjust(center_dash + center_str - 1, pad).ljust(len - 1, pad)
198
+ end
190
199
  end
191
200
  end
@@ -144,7 +144,7 @@ module Dev
144
144
  puts "\nPulling #{name}:#{tag}"
145
145
  opts = {
146
146
  fromImage: "#{name}:#{tag}",
147
- platform: Dev::Common::Platform.new.architecture
147
+ platform: Dev::Platform.new.architecture
148
148
  }
149
149
  ::Docker::Image.create(**opts) { |response| Dev::Docker::Status.new.response_callback(response) }
150
150
  end
@@ -46,13 +46,23 @@ module Dev
46
46
  @products
47
47
  end
48
48
 
49
+ # Prints all of the product version statuses
50
+ def status
51
+ product_versions.sort_by(&:name).each(&:print_status)
52
+ end
53
+
54
+ # Returns true if any of the products are EOL
55
+ def eol?
56
+ product_versions.any?(&:eol)
57
+ end
58
+
49
59
  # Prints all of the product version statuses
50
60
  # Raises an error if any products are EOL
51
61
  def check
52
62
  puts
53
- product_versions.sort_by(&:name).each(&:print_status)
63
+ status
54
64
  puts
55
- raise 'found EOL versions' if product_versions.any?(&:eol)
65
+ raise 'found EOL versions' if eol?
56
66
  end
57
67
  end
58
68
  end
@@ -113,10 +113,10 @@ module Dev
113
113
  next unless File.exist?(project_dir)
114
114
 
115
115
  repo_basename = File.basename(File.realpath(project_dir))
116
- header = " #{repo_basename} (#{original_branches[project_dir]}) "
117
- puts center_pad(header).light_green
116
+ header = "#{repo_basename} (#{original_branches[project_dir]})"
117
+ puts Dev::Common.new.center_pad(header).light_green
118
118
  @success &= status(dir: project_dir)
119
- puts center_pad.light_green
119
+ puts Dev::Common.new.center_pad.light_green
120
120
  end
121
121
  puts
122
122
 
@@ -165,10 +165,10 @@ module Dev
165
165
  next unless File.exist?(project_dir)
166
166
 
167
167
  repo_basename = File.basename(File.realpath(project_dir))
168
- header = " #{repo_basename} (#{original_branches[project_dir]}) "
169
- puts center_pad(header).light_green
168
+ header = "#{repo_basename} (#{original_branches[project_dir]})"
169
+ puts Dev::Common.new.center_pad(header).light_green
170
170
  reset(dir: project_dir)
171
- puts center_pad.light_green
171
+ puts Dev::Common.new.center_pad.light_green
172
172
  end
173
173
  puts
174
174
  end
@@ -191,10 +191,9 @@ module Dev
191
191
  next unless File.exist?(project_dir)
192
192
 
193
193
  repo_basename = File.basename(File.realpath(project_dir))
194
- header = " #{repo_basename} "
195
- puts center_pad(header).light_green
194
+ puts Dev::Common.new.center_pad(repo_basename).light_green
196
195
  @success &= checkout(branch, dir: project_dir)
197
- puts center_pad.light_green
196
+ puts Dev::Common.new.center_pad.light_green
198
197
  end
199
198
  puts
200
199
 
@@ -285,10 +284,9 @@ module Dev
285
284
  next unless File.exist?(project_dir)
286
285
 
287
286
  repo_basename = File.basename(File.realpath(project_dir))
288
- header = " #{repo_basename} "
289
- puts center_pad(header).light_green
287
+ puts Dev::Common.new.center_pad(repo_basename).light_green
290
288
  @success &= merge(branch, dir: project_dir)
291
- puts center_pad.light_green
289
+ puts Dev::Common.new.center_pad.light_green
292
290
  end
293
291
  puts
294
292
 
@@ -334,10 +332,9 @@ module Dev
334
332
  next unless File.exist?(project_dir)
335
333
 
336
334
  repo_basename = File.basename(File.realpath(project_dir))
337
- header = " #{repo_basename} "
338
- puts center_pad(header).light_green
335
+ puts Dev::Common.new.center_pad(repo_basename).light_green
339
336
  @success &= pull(dir: project_dir)
340
- puts center_pad.light_green
337
+ puts Dev::Common.new.center_pad.light_green
341
338
  end
342
339
  puts
343
340
 
@@ -373,10 +370,9 @@ module Dev
373
370
  next unless File.exist?(project_dir)
374
371
 
375
372
  repo_basename = File.basename(File.realpath(project_dir))
376
- header = " #{repo_basename} "
377
- puts center_pad(header).light_green
373
+ puts Dev::Common.new.center_pad(repo_basename).light_green
378
374
  @success &= push(dir: project_dir)
379
- puts center_pad.light_green
375
+ puts Dev::Common.new.center_pad.light_green
380
376
  end
381
377
  puts
382
378
 
@@ -439,11 +435,10 @@ module Dev
439
435
  end
440
436
 
441
437
  # Center the string and pad on either side with the given padding character
438
+ # @deprecated Please use {Dev::Common#center_pad} instead
442
439
  def center_pad(string = '', pad: '-', len: 80)
443
- center_dash = len / 2
444
- string = string.to_s
445
- center_str = string.length / 2
446
- string.rjust(center_dash + center_str - 1, pad).ljust(len - 1, pad)
440
+ warn '[DEPRECATION] `Dev::Git#center_pad` is deprecated. Please use `Dev::Common#center_pad` instead.'
441
+ Dev::Common.new.center_pad(string, pad:, len:)
447
442
  end
448
443
 
449
444
  # Exclude the command from the message and print all error lines
@@ -1,40 +1,33 @@
1
1
  module Dev
2
- class Common
3
- # Class which returns information about the current platform
4
- class Platform
5
- # Constant containing all supported architectures
6
- ALLOWED_ARCHITECTURES = %w(arm64 amd64).freeze
2
+ # Class which returns information about the current platform
3
+ class Platform
4
+ # Constant containing all supported architectures
5
+ ALLOWED_ARCHITECTURES = %w(linux/arm64 linux/amd64).freeze
7
6
 
8
- # Normalize the ruby platform to return a docker platform architecture format
9
- def determine_compute_architecture
10
- case RUBY_PLATFORM
11
- when /x86_64|amd64|x64-mingw/
12
- 'linux/amd64' # 64-bit Intel/AMD architecture
13
- when /arm|aarch64/
14
- 'linux/arm64' # ARM architecture
15
- else
16
- raise 'Unknown or unsupported architecture'
17
- end
18
- end
7
+ # If an architecture was specified in the ENV, use that. Otherwise auto-deted based of the OS reported architecture
8
+ def architecture
9
+ arch = env_architecture || os_architecture
10
+ raise "Invalid DOCKER_ARCHITECTURE: #{arch} (allowed are #{ALLOWED_ARCHITECTURES.join(', ')})" unless ALLOWED_ARCHITECTURES.include?(arch)
19
11
 
20
- # Determine the platform architecture
21
- # If one was specified in the DOCKER_ARCHITECTURE variable, use it
22
- # Otherwise, use the RUBY_PLATFORM built-in to auto-detect and architecture
23
- def architecture
24
- docker_architecture = ENV['DOCKER_ARCHITECTURE'].to_s.strip.downcase
25
- if docker_architecture.empty?
26
- determine_compute_architecture
27
- else
28
- raise "Missing 'linux/' prefix in DOCKER_ARCHITECTURE: #{docker_architecture}" unless docker_architecture.start_with?('linux/')
12
+ arch
13
+ end
14
+
15
+ # Check to see if a docker architecture has been specified in the ENV
16
+ # If it has, verify the format and the value
17
+ private def env_architecture
18
+ arch = ENV['DOCKER_ARCHITECTURE'].to_s.strip.downcase
19
+ return nil if arch.empty?
20
+
21
+ "linux/#{arch}" unless arch.start_with?('linux/')
22
+ arch
23
+ end
29
24
 
30
- architecture_name = docker_architecture.split('/')[1]
31
- unless ALLOWED_ARCHITECTURES.include?(architecture_name)
32
- raise "Invalid DOCKER_ARCHITECTURE: #{architecture_name}. Allowed architectures are #{ALLOWED_ARCHITECTURES.join(', ')}"
33
- end
25
+ # Returns a valid docker architecture based off the RUBY_PLATFORM
26
+ private def os_architecture
27
+ return 'linux/amd64' if RUBY_PLATFORM.match?(/x86_64|amd64|x64-mingw/)
28
+ return 'linux/arm64' if RUBY_PLATFORM.match?(/arm|aarch64/)
34
29
 
35
- docker_architecture
36
- end
37
- end
30
+ raise 'Unknown or unsupported architecture'
38
31
  end
39
32
  end
40
33
  end
@@ -90,14 +90,16 @@ module Dev
90
90
 
91
91
  # Build the bundle lint command
92
92
  def lint_command
93
- lint = ['rubocop']
93
+ lint = base_command
94
+ lint << 'exec' << 'rubocop'
94
95
  lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
95
96
  lint
96
97
  end
97
98
 
98
99
  # Build the bundle lint fix command
99
100
  def lint_fix_command
100
- lint_fix = ['rubocop']
101
+ lint_fix = base_command
102
+ lint_fix << 'exec' << 'rubocop'
101
103
  lint_fix << '-A'
102
104
  lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
103
105
  lint_fix
@@ -105,7 +107,8 @@ module Dev
105
107
 
106
108
  # Build the bundle test command
107
109
  def test_command
108
- test = ['rspec']
110
+ test = base_command
111
+ test << 'exec' << 'rspec'
109
112
  test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
110
113
  test
111
114
  end
@@ -101,14 +101,22 @@ module Dev
101
101
 
102
102
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
103
103
  return if exclude.include?(:eol)
104
+ return if ENV.fetch('CHECK_AWS', nil).to_s.strip == 'false'
104
105
 
105
- desc 'Compares the current date to the EOL date for supported resources'
106
- task eol: %w(init ensure_aws_credentials) do
107
- account_id = Dev::Aws::Profile.new.current
108
- account_name = Dev::Aws::Account.new.name_by_account(account_id)
109
- LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
106
+ task eol: [:'eol:aws'] do
107
+ # This is just a placeholder to execute the dependencies
108
+ end
110
109
 
111
- Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).check
110
+ namespace :eol do
111
+ desc 'Compares the current date to the EOL date for supported aws resources'
112
+ task aws: %w(init ensure_aws_credentials) do
113
+ account_id = Dev::Aws::Profile.new.current
114
+ account_name = Dev::Aws::Account.new.name_by_account(account_id)
115
+ LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
116
+ puts
117
+ Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).status
118
+ puts
119
+ end
112
120
  end
113
121
  end
114
122
  end
@@ -4,10 +4,10 @@ module Dev
4
4
  module Template
5
5
  # Class contains rake templates for managing configured certificates
6
6
  class Certificate < Dev::Template::BaseInterface
7
- attr_reader :names, :email, :paths
7
+ attr_reader :domains, :email, :paths
8
8
 
9
- def initialize(names, email:, paths:, exclude: [])
10
- @names = names
9
+ def initialize(domains, email:, paths:, exclude: [])
10
+ @domains = domains
11
11
  @email = email
12
12
  @paths = Array(paths)
13
13
 
@@ -17,7 +17,7 @@ module Dev
17
17
  # Create the rake task for the generate method
18
18
  def create_generate_task!
19
19
  # Have to set a local variable to be accessible inside of the instance_eval block
20
- names = @names
20
+ domains = @domains
21
21
  email = @email
22
22
  paths = @paths
23
23
  exclude = @exclude
@@ -29,7 +29,7 @@ module Dev
29
29
  desc 'Requests a new certificate for the configured domain using the route53 validation and deposits it in the configured paths'
30
30
  task generate: %w(init_docker ensure_aws_credentials) do
31
31
  Dev::Docker.new.pull_image('certbot/dns-route53', 'latest')
32
- c = Dev::Certificate.new(names, email)
32
+ c = Dev::Certificate.new(domains, email)
33
33
  c.request
34
34
  paths.each { |path| c.save(path) }
35
35
  end
@@ -29,6 +29,7 @@ module Dev
29
29
  end
30
30
 
31
31
  # Create the rake task which runs linting for the application name
32
+ # rubocop:disable Metrics/MethodLength
32
33
  def create_lint_task!
33
34
  application = @name
34
35
  node = @node
@@ -42,6 +43,13 @@ module Dev
42
43
  # This is just a placeholder to execute the dependencies
43
44
  end
44
45
 
46
+ namespace :lint do
47
+ desc 'Run all linting software and apply all available fixes'
48
+ task fix: %w(node:lint:fix) do
49
+ # This is just a placeholder to execute the dependencies
50
+ end
51
+ end
52
+
45
53
  namespace :node do
46
54
  desc "Run the node linting software against the #{application}'s codebase"
47
55
  task lint: %w(init_docker up_no_deps) do
@@ -66,6 +74,7 @@ module Dev
66
74
  end
67
75
  end
68
76
  end
77
+ # rubocop:enable Metrics/MethodLength
69
78
 
70
79
  # Create the rake task which runs all tests for the application name
71
80
  def create_test_task!
@@ -74,6 +74,7 @@ module Dev
74
74
  end
75
75
 
76
76
  # Create the rake task which runs linting for the application name
77
+ # rubocop:disable Metrics/MethodLength
77
78
  def create_lint_task!
78
79
  application = @name
79
80
  php = @php
@@ -87,6 +88,13 @@ module Dev
87
88
  # This is just a placeholder to execute the dependencies
88
89
  end
89
90
 
91
+ namespace :lint do
92
+ desc 'Run all linting software and apply all available fixes'
93
+ task fix: %w(php:lint:fix) do
94
+ # This is just a placeholder to execute the dependencies
95
+ end
96
+ end
97
+
90
98
  namespace :php do
91
99
  desc "Run the php linting software against the #{application}'s codebase"
92
100
  task lint: %w(init_docker up_no_deps) do
@@ -111,6 +119,7 @@ module Dev
111
119
  end
112
120
  end
113
121
  end
122
+ # rubocop:enable Metrics/MethodLength
114
123
 
115
124
  # Create the rake task which runs all tests for the application name
116
125
  def create_test_task!
@@ -28,6 +28,7 @@ module Dev
28
28
  end
29
29
 
30
30
  # Create the rake task which runs linting for the application name
31
+ # rubocop:disable Metrics/MethodLength
31
32
  def create_lint_task!
32
33
  application = @name
33
34
  ruby = @ruby
@@ -41,6 +42,13 @@ module Dev
41
42
  # This is just a placeholder to execute the dependencies
42
43
  end
43
44
 
45
+ namespace :lint do
46
+ desc 'Run all linting software and apply all available fixes'
47
+ task fix: %w(ruby:lint:fix) do
48
+ # This is just a placeholder to execute the dependencies
49
+ end
50
+ end
51
+
44
52
  namespace :ruby do
45
53
  desc "Run the ruby linting software against the #{application}'s codebase"
46
54
  task lint: %w(init_docker up_no_deps) do
@@ -65,6 +73,7 @@ module Dev
65
73
  end
66
74
  end
67
75
  end
76
+ # rubocop:enable Metrics/MethodLength
68
77
 
69
78
  # Create the rake task which runs all tests for the application name
70
79
  def create_test_task!
@@ -12,9 +12,10 @@ module Dev
12
12
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
13
13
  return if exclude.include?(:eol)
14
14
 
15
- desc 'Compares the current date to the EOL date for all configured projects'
15
+ desc 'Compares the current date to the EOL date for all configured projects' \
16
+ "\n\toptionally specify CHECK_AWS=<true/false> to toggle whether AWS resources are checked for EOL (defaults to true)"
16
17
  task eol: %w(init) do
17
- Dev::EndOfLife.new.check
18
+ Dev::EndOfLife.new.status
18
19
  end
19
20
  end
20
21
  end
@@ -4,6 +4,23 @@ module Dev
4
4
  module Template
5
5
  # Class contains rake templates for managing your git project
6
6
  class Git < Dev::Template::BaseInterface
7
+ # Create the rake task for cloning all defined repos
8
+ def create_clone_task!
9
+ # Have to set a local variable to be accessible inside of the instance_eval block
10
+ exclude = @exclude
11
+
12
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
13
+ namespace :git do
14
+ return if exclude.include?(:clone)
15
+
16
+ desc 'Make sure all repos are cloned'
17
+ task :clone do
18
+ Dev::Git.new.clone_repos
19
+ end
20
+ end
21
+ end
22
+ end
23
+
7
24
  # Create the rake task for the git checkout method
8
25
  def create_checkout_task!
9
26
  # Have to set a local variable to be accessible inside of the instance_eval block
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.27.pre.alpha.1'.freeze
9
+ VERSION = '2.1.27.pre.alpha.3'.freeze
10
10
  end
11
11
  end
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: 2.1.27.pre.alpha.1
4
+ version: 2.1.27.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport