firespring_dev_commands 3.0.0.pre.alpha.3 → 3.0.0.pre.alpha.5

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: 7ae0ecadec576f4f6c986fc7391faa03f1d148473f3c04f250c40edb120355df
4
- data.tar.gz: ab84f1118a1c28c1667d0a825bbf57bfddf01d3a219e07715422e4e0ec50bf04
3
+ metadata.gz: 74a37674c322ba4923bcc2c3a71e1f092f8d6f7c8fed161ec75de3b59abd9fb6
4
+ data.tar.gz: 5f8172b903826380c524d6c8538064ef0873425924a978fb7bcc55565875070d
5
5
  SHA512:
6
- metadata.gz: 575c45ba8a86cad256f030eebe6a9ee7987fb0cd0bb8f413989efa92e237d7fc40e1030a325e965696b5c6da47cd55e91a941eecd5b8e2f4bd81bcafcaeaee3b
7
- data.tar.gz: 3c07674f01809f4f8aaa2042691815c4795cffc298ff3ffffeabf293d00b4e61c64d5989a4d81ebcaa287258cf75002836eaa0d1c23ef22af445b7420dd786b7
6
+ metadata.gz: 7c142bc163404cb7aeb66a9311744a144b6700cb6bb1221ae9b6154b0092d9bd130e56bda0ef3580d3ca42f9118f83d1a3278db5ec53e5c84c3ac81803b645cd
7
+ data.tar.gz: 4adeb0e47c6e5df27836412d1e169093394d5f0c7d9b3a643318ae9312560890997b292a979d1556540bcfce81da42ef02d0628a65080742ec7b2a26d03dd3f8
@@ -0,0 +1,59 @@
1
+ module Dev
2
+ # Class contains methods for requesting a certificate from route53.
3
+ # You must have a hosted zone defined for the desired domain
4
+ class Certificate
5
+ attr_accessor :domains, :email
6
+
7
+ def initialize(domains, email)
8
+ @domains = Array(domains)
9
+ @email = email
10
+ raise 'No certificate domains specified' if domains.empty?
11
+ end
12
+
13
+ # Request the certificate using the route53 docker image
14
+ # Certificate is stored in /etc/letsencrypt
15
+ def request
16
+ puts
17
+ puts 'Getting SSL Certs For:'
18
+ puts domains.join("\n")
19
+ puts
20
+ puts 'This process can take up to 10 minutes'
21
+ puts
22
+ puts Time.now
23
+
24
+ # TODO: Really should use the docker api for this
25
+ cmd = %w(docker run -it --rm --name certbot)
26
+ cmd << '-e' << 'AWS_ACCESS_KEY_ID'
27
+ cmd << '-e' << 'AWS_SECRET_ACCESS_KEY'
28
+ cmd << '-e' << 'AWS_SESSION_TOKEN'
29
+ cmd << '-v' << '/etc/letsencrypt:/etc/letsencrypt'
30
+ cmd << 'certbot/dns-route53:latest'
31
+ cmd << 'certonly'
32
+ cmd << '-n'
33
+ cmd << '--agree-tos'
34
+ cmd << '--dns-route53'
35
+ cmd << '-d' << domains.join(',')
36
+ cmd << '--email' << email
37
+ cmd << '--server' << 'https://acme-v02.api.letsencrypt.org/directory'
38
+ puts cmd.join(' ')
39
+ Dev::Common.new.run_command(cmd)
40
+ end
41
+
42
+ # Saves the latest version of the certificate into the given dest_dir
43
+ def save(dest_dir)
44
+ raise "directory #{dest_dir} must be an existing directory" unless File.directory?(dest_dir)
45
+
46
+ domain = domains.first.sub(/^\*\./, '') # Need to strip off the '*.' if this is a wildcard cert
47
+ directories = Dir.glob("/etc/letsencrypt/live/#{domain}*/")
48
+ no_suffix = directories.delete("/etc/letsencrypt/live/#{domain}/")
49
+ biggest_suffix = directories.max
50
+ source_dir = biggest_suffix || no_suffix
51
+ raise "unable to determine certificate directory for #{domain}" unless source_dir
52
+
53
+ FileUtils.cp("#{source_dir}privkey.pem", dest_dir, verbose: true)
54
+ FileUtils.cp("#{source_dir}cert.pem", dest_dir, verbose: true)
55
+ FileUtils.cp("#{source_dir}chain.pem", dest_dir, verbose: true)
56
+ FileUtils.cp("#{source_dir}fullchain.pem", dest_dir, verbose: true)
57
+ end
58
+ end
59
+ end
@@ -176,5 +176,14 @@ module Dev
176
176
 
177
177
  format('%.1f %s', size.to_f / (1024**exp), units[exp])
178
178
  end
179
+
180
+ # Center the string and pad on either side with the given padding character
181
+ def center_pad(string = '', pad: '-', len: 80)
182
+ string = " #{string} " unless string.strip.empty?
183
+ center_dash = len / 2
184
+ string = string.to_s
185
+ center_str = string.length / 2
186
+ string.rjust(center_dash + center_str - 1, pad).ljust(len - 1, pad)
187
+ end
179
188
  end
180
189
  end
@@ -1,18 +1,23 @@
1
1
  module Dev
2
2
  module Coverage
3
+ # Class which defines the methods which must be implemented to function as a coverage class
3
4
  class Base
5
+ # Raises not implemented
4
6
  def php_options
5
7
  raise 'not implemented'
6
8
  end
7
9
 
10
+ # Raises not implemented
8
11
  def node_options
9
12
  raise 'not implemented'
10
13
  end
11
14
 
15
+ # Raises not implemented
12
16
  def ruby_options
13
17
  raise 'not implemented'
14
18
  end
15
19
 
20
+ # Raises not implemented
16
21
  def check(*)
17
22
  raise 'not implemented'
18
23
  end
@@ -1,22 +1,28 @@
1
1
  module Dev
2
+ # Module with a variety of coverage methods for different languages
2
3
  module Coverage
4
+ # Class which provides methods to effectvely skip coverage
3
5
  class None < Base
4
6
  def initialize(*)
5
7
  super()
6
8
  end
7
9
 
10
+ # Returns the php options for generating code coverage file
8
11
  def php_options
9
12
  []
10
13
  end
11
14
 
15
+ # Returns the node options for generating code coverage file
12
16
  def node_options
13
17
  []
14
18
  end
15
19
 
20
+ # Returns the ruby options for generating code coverage file
16
21
  def ruby_options
17
22
  []
18
23
  end
19
24
 
25
+ # Checks the code coverage against the defined threshold
20
26
  def check(*)
21
27
  # Nothing to do here
22
28
  end
@@ -1,5 +1,6 @@
1
1
  module Dev
2
2
  class Docker
3
+ # Contains the local path and container path for and artifact that should be copied back to the user's local systea
3
4
  class Artifact
4
5
  attr_accessor :container_path, :local_path
5
6
 
@@ -0,0 +1,59 @@
1
+ module Dev
2
+ class Docker
3
+ # Class for configuring docker desktop
4
+ # This is mostly around configuring the docker URL correctly
5
+ class Desktop
6
+ # A snippet of a docker compose file which forwards a socket to a local port so that we can read it in the docker library
7
+ WIN_TCP_COMPOSE_CONTENT = "
8
+ ---
9
+ version: '3.8'
10
+ services:
11
+ windows_tcp:
12
+ image: alpine/socat
13
+ network_mode: bridge
14
+ ports:
15
+ - 127.0.0.1:23750:2375
16
+ volumes:
17
+ - /var/run/docker.sock:/var/run/docker.sock
18
+ command: tcp-listen:2375,reuseaddr,fork unix-connect:/var/run/docker.sock
19
+ restart: always".freeze
20
+
21
+ # Set up the local ports/sockets correctly based off of the os type
22
+ def configure
23
+ if Dev::Os.new.windows?
24
+ # Start up a small proxy container if running Docker Desktop on windows
25
+ # This is needed because the docker api library cannot connect to the windows socket
26
+ unless Dev::Port.new('127.0.0.1', 23_750).open?
27
+ LOG.info('Starting local proxy port for docker')
28
+
29
+ # Write the compose data to a tmp file
30
+ tmp_compose_file = Tempfile.new('windows_tcp')
31
+ tmp_compose_file.write(WIN_TCP_COMPOSE_CONTENT)
32
+ tmp_compose_file.close
33
+
34
+ # Start up the container
35
+ Dev::Docker::Compose.new(
36
+ compose_files: tmp_compose_file.path,
37
+ options: ['--detach'],
38
+ project_name: 'proxy'
39
+ ).up
40
+
41
+ # Wait 1 second before we continue
42
+ sleep 1
43
+ end
44
+
45
+ # Configure the docker url to use 23750 on windows
46
+ ::Docker.url = 'tcp://127.0.0.1:23750'
47
+
48
+ else
49
+ # If a user based socket has been defined, default to that
50
+ ::Docker.url = if File.exist?("/#{Dir.home}/.docker/run/docker.sock")
51
+ "unix://#{Dir.home}/.docker/run/docker.sock"
52
+ elsif File.exist?("/#{Dir.home}/.docker/desktop/docker.sock")
53
+ "unix://#{Dir.home}/.docker/desktop/docker.sock"
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -33,6 +33,26 @@ module Dev
33
33
  EXITED,
34
34
  DEAD
35
35
  ].freeze
36
+
37
+ # TODO: Can we use 'curses' here and overwrite the correct line?
38
+ def response_callback(response)
39
+ response.split("\n").each do |line|
40
+ data = JSON.parse(line)
41
+ if data.include?('status')
42
+ if data['id']
43
+ LOG.info "#{data['id']}: #{data['status']}"
44
+ else
45
+ LOG.info (data['status']).to_s
46
+ end
47
+ elsif data.include?('errorDetail')
48
+ raise data['errorDetail']['message']
49
+ elsif data.include?('aux')
50
+ next
51
+ else
52
+ raise "Unrecognized message from docker: #{data}"
53
+ end
54
+ end
55
+ end
36
56
  end
37
57
  end
38
58
  end
@@ -77,6 +77,7 @@ module Dev
77
77
  _prune('volumes', opts:)
78
78
  end
79
79
 
80
+ # Prunes all volumes which start wth the given project name
80
81
  def prune_project_volumes(project_name:)
81
82
  project_name = project_name.to_s.strip
82
83
  raise 'No project name defined' if project_name.empty?
@@ -122,6 +123,44 @@ module Dev
122
123
  LOG.info "Total reclaimed space: #{Dev::Common.new.filesize(info['SpaceReclaimed'])}"
123
124
  end
124
125
 
126
+ # Push the local version of the docker image to the defined remote repository
127
+ def push_image(image, name, tag = nil)
128
+ unless tag
129
+ if name.include?(':')
130
+ name, tag = name.split(':')
131
+ else
132
+ tag = 'latest'
133
+ end
134
+ end
135
+
136
+ puts "Pushing to #{name}:#{tag}"
137
+ image.push(::Docker.creds, repo_tag: "#{name}:#{tag}") { |response| Dev::Docker::Status.new.response_callback(response) }
138
+ end
139
+
140
+ # Push the remote version of the docker image from the defined remote repository
141
+ def pull_image(name, tag = nil)
142
+ unless tag
143
+ if name.include?(':')
144
+ name, tag = name.split(':')
145
+ else
146
+ tag = 'latest'
147
+ end
148
+ end
149
+
150
+ puts "\nPulling #{name}:#{tag}"
151
+ opts = {
152
+ fromImage: "#{name}:#{tag}",
153
+ platform: Dev::Platform.new.architecture
154
+ }
155
+ ::Docker::Image.create(**opts) { |response| Dev::Docker::Status.new.response_callback(response) }
156
+ end
157
+
158
+ # Remove the local version of the given docker image
159
+ def untag_image(image, name, tag)
160
+ puts "Untagging #{name}:#{tag}"
161
+ image.remove(name: "#{name}:#{tag}")
162
+ end
163
+
125
164
  # Remove docker images with the "force" option set to true
126
165
  # This will remove the images even if they are currently in use and cause unintended side effects.
127
166
  def force_remove_images(name_and_tag)
@@ -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
 
@@ -438,14 +434,6 @@ module Dev
438
434
  string.to_s.split("\n").each { |line| puts "#{padding}#{line}" }
439
435
  end
440
436
 
441
- # Center the string and pad on either side with the given padding character
442
- 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)
447
- end
448
-
449
437
  # Exclude the command from the message and print all error lines
450
438
  private def print_errors(message)
451
439
  indent message.split('error:')[1..].join
@@ -5,11 +5,13 @@ module Dev
5
5
  # Issue subtypes which do not map to a story type
6
6
  NON_STORY_TYPES = ['epic', 'review', 'sub-task', 'code review sub-task', 'pre-deploy sub-task', 'deploy sub-task', 'devops sub-task'].freeze
7
7
 
8
- attr_accessor :data, :project, :id, :title, :points, :assignee, :resolved_date, :histories, :last_in_progress_history, :first_in_review_history, :last_closed_history
8
+ attr_accessor :data, :project, :parent, :id, :title, :points, :assignee, :resolved_date, :histories,
9
+ :last_in_progress_history, :first_in_review_history, :last_closed_history
9
10
 
10
11
  def initialize(data)
11
12
  @data = data
12
13
  @project = Jira::Project.new(data)
14
+ @parent = Jira::Parent.new(data) if data.respond_to?(:parent)
13
15
  @id = data.key
14
16
  @title = data.summary
15
17
  @points = calculate_points(data)
@@ -0,0 +1,19 @@
1
+ module Dev
2
+ class Jira
3
+ # Contains information on the Jira parent issue
4
+ class Parent
5
+ attr_accessor :data, :id, :title
6
+
7
+ def initialize(data)
8
+ @data = data.parent
9
+ @id = data.parent['key']
10
+ @title = data.parent['fields']['summary']
11
+ end
12
+
13
+ # Converts the jira parent object to a string representation
14
+ def to_s
15
+ "[#{id}] #{title}"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ module Dev
2
+ # Class containing methods for determining operating system information
3
+ class Os
4
+ attr_accessor :os
5
+
6
+ def initialize
7
+ @os = ::RbConfig::CONFIG['host_os']
8
+ end
9
+
10
+ # Returns true if the host_os contains windowsy text
11
+ def windows?
12
+ os.match?(/(mingw|mswin|windows)/i)
13
+ end
14
+
15
+ # Returns true if the host_os contains darwinsy text
16
+ def darwin?
17
+ os.match?(/(darwin|mac os)/i)
18
+ end
19
+
20
+ # Returns true if the host_os contains macsy text
21
+ def mac?
22
+ darwin?
23
+ end
24
+
25
+ # Returns true if the host_os contains nixy text
26
+ def nix?
27
+ os.match?(/(linux|bsd|aix|solaris)/i)
28
+ end
29
+
30
+ # Returns true if the host_os contains cygwiny text
31
+ def cygwin?
32
+ os.match?(/(cygwin)/i)
33
+ end
34
+ end
35
+ end
@@ -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
@@ -0,0 +1,24 @@
1
+ module Dev
2
+ # Class containing methods for actions to be taken on ports
3
+ class Port
4
+ attr_accessor :ip_address, :port
5
+
6
+ def initialize(ip_address, port)
7
+ @ip_address = ip_address
8
+ @port = port
9
+ end
10
+
11
+ # Returns true if the port is open
12
+ # Returns false otherwise
13
+ def open?(timeout = 1)
14
+ Timeout.timeout(timeout) do
15
+ TCPSocket.new(ip_address, port).close
16
+ return true
17
+ end
18
+
19
+ false
20
+ rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
21
+ false
22
+ end
23
+ end
24
+ end
@@ -99,14 +99,22 @@ module Dev
99
99
 
100
100
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
101
101
  return if exclude.include?(:eol)
102
+ return if ENV.fetch('CHECK_AWS', nil).to_s.strip == 'false'
102
103
 
103
- desc 'Compares the current date to the EOL date for supported resources'
104
- task eol: %w(init ensure_aws_credentials) do
105
- account_id = Dev::Aws::Profile.new.current
106
- account_name = Dev::Aws::Account.new.name_by_account(account_id)
107
- LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
104
+ task eol: [:'eol:aws'] do
105
+ # This is just a placeholder to execute the dependencies
106
+ end
108
107
 
109
- Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).check
108
+ namespace :eol do
109
+ desc 'Compares the current date to the EOL date for supported aws resources'
110
+ task aws: %w(init ensure_aws_credentials) do
111
+ account_id = Dev::Aws::Profile.new.current
112
+ account_name = Dev::Aws::Account.new.name_by_account(account_id)
113
+ LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
114
+ puts
115
+ Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).status
116
+ puts
117
+ end
110
118
  end
111
119
  end
112
120
  end
@@ -0,0 +1,41 @@
1
+ require_relative 'base_interface'
2
+
3
+ module Dev
4
+ module Template
5
+ # Class contains rake templates for managing configured certificates
6
+ class Certificate < Dev::Template::BaseInterface
7
+ attr_reader :domains, :email, :paths
8
+
9
+ def initialize(domains, email:, paths:, exclude: [])
10
+ @domains = domains
11
+ @email = email
12
+ @paths = Array(paths)
13
+
14
+ super(exclude:)
15
+ end
16
+
17
+ # Create the rake task for the generate method
18
+ def create_generate_task!
19
+ # Have to set a local variable to be accessible inside of the instance_eval block
20
+ domains = @domains
21
+ email = @email
22
+ paths = @paths
23
+ exclude = @exclude
24
+
25
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
26
+ return if exclude.include?(:generate)
27
+
28
+ namespace :certificate do
29
+ desc 'Requests a new certificate for the configured domain using the route53 validation and deposits it in the configured paths'
30
+ task generate: %w(init_docker ensure_aws_credentials) do
31
+ Dev::Docker.new.pull_image('certbot/dns-route53', 'latest')
32
+ c = Dev::Certificate.new(domains, email)
33
+ c.request
34
+ paths.each { |path| c.save(path) }
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -109,9 +109,11 @@ module Dev
109
109
  return if exclude.include?(:restart)
110
110
 
111
111
  desc 'Runs a "down" followed by an "up"'
112
- task restart: %w(_pre_restart_hooks) do
112
+ task restart: %w(init_docker _pre_restart_hooks _pre_down_hooks _pre_up_hooks) do
113
113
  LOG.debug('In base restart')
114
114
  Dev::Docker::Compose.new.restart
115
+ Rake::Task[:_post_up_hooks].execute
116
+ Rake::Task[:_post_down_hooks].execute
115
117
  Rake::Task[:_post_restart_hooks].execute
116
118
  end
117
119
  end
@@ -58,6 +58,13 @@ module Dev
58
58
  # This is just a placeholder to execute the dependencies
59
59
  end
60
60
 
61
+ namespace :lint do
62
+ desc 'Run all linting software and apply all available fixes'
63
+ task fix: %w(node:lint:fix) do
64
+ # This is just a placeholder to execute the dependencies
65
+ end
66
+ end
67
+
61
68
  namespace :node do
62
69
  desc "Run the node linting software against the #{application}'s codebase" \
63
70
  "\n\t(optional) use OPTS=... to pass additional options to the command"
@@ -102,6 +102,13 @@ module Dev
102
102
  # This is just a placeholder to execute the dependencies
103
103
  end
104
104
 
105
+ namespace :lint do
106
+ desc 'Run all linting software and apply all available fixes'
107
+ task fix: %w(php:lint:fix) do
108
+ # This is just a placeholder to execute the dependencies
109
+ end
110
+ end
111
+
105
112
  namespace :php do
106
113
  desc "Run the php linting software against the #{application}'s codebase" \
107
114
  "\n\t(optional) use OPTS=... to pass additional options to the command"
@@ -58,6 +58,13 @@ module Dev
58
58
  # This is just a placeholder to execute the dependencies
59
59
  end
60
60
 
61
+ namespace :lint do
62
+ desc 'Run all linting software and apply all available fixes'
63
+ task fix: %w(ruby:lint:fix) do
64
+ # This is just a placeholder to execute the dependencies
65
+ end
66
+ end
67
+
61
68
  namespace :ruby do
62
69
  desc "Run the ruby linting software against the #{application}'s codebase" \
63
70
  "\n\t(optional) use OPTS=... to pass additional options to the command"
@@ -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 = '3.0.0.pre.alpha.3'.freeze
9
+ VERSION = '3.0.0.pre.alpha.5'.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: 3.0.0.pre.alpha.3
4
+ version: 3.0.0.pre.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-25 00:00:00.000000000 Z
11
+ date: 2024-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -332,6 +332,7 @@ files:
332
332
  - lib/firespring_dev_commands/bloom_growth/seat.rb
333
333
  - lib/firespring_dev_commands/bloom_growth/user.rb
334
334
  - lib/firespring_dev_commands/boolean.rb
335
+ - lib/firespring_dev_commands/certificate.rb
335
336
  - lib/firespring_dev_commands/common.rb
336
337
  - lib/firespring_dev_commands/coverage/base.rb
337
338
  - lib/firespring_dev_commands/coverage/cobertura.rb
@@ -340,6 +341,7 @@ files:
340
341
  - lib/firespring_dev_commands/docker.rb
341
342
  - lib/firespring_dev_commands/docker/artifact.rb
342
343
  - lib/firespring_dev_commands/docker/compose.rb
344
+ - lib/firespring_dev_commands/docker/desktop.rb
343
345
  - lib/firespring_dev_commands/docker/status.rb
344
346
  - lib/firespring_dev_commands/dotenv.rb
345
347
  - lib/firespring_dev_commands/env.rb
@@ -352,15 +354,18 @@ files:
352
354
  - lib/firespring_dev_commands/jira/histories.rb
353
355
  - lib/firespring_dev_commands/jira/history.rb
354
356
  - lib/firespring_dev_commands/jira/issue.rb
357
+ - lib/firespring_dev_commands/jira/parent.rb
355
358
  - lib/firespring_dev_commands/jira/project.rb
356
359
  - lib/firespring_dev_commands/jira/user.rb
357
360
  - lib/firespring_dev_commands/jira/user/type.rb
358
361
  - lib/firespring_dev_commands/logger.rb
359
362
  - lib/firespring_dev_commands/node.rb
360
363
  - lib/firespring_dev_commands/node/audit.rb
364
+ - lib/firespring_dev_commands/os.rb
361
365
  - lib/firespring_dev_commands/php.rb
362
366
  - lib/firespring_dev_commands/php/audit.rb
363
367
  - lib/firespring_dev_commands/platform.rb
368
+ - lib/firespring_dev_commands/port.rb
364
369
  - lib/firespring_dev_commands/rake.rb
365
370
  - lib/firespring_dev_commands/ruby.rb
366
371
  - lib/firespring_dev_commands/ruby/audit.rb
@@ -381,6 +386,7 @@ files:
381
386
  - lib/firespring_dev_commands/target_process/user_story_history.rb
382
387
  - lib/firespring_dev_commands/templates/aws.rb
383
388
  - lib/firespring_dev_commands/templates/base_interface.rb
389
+ - lib/firespring_dev_commands/templates/certificate.rb
384
390
  - lib/firespring_dev_commands/templates/ci.rb
385
391
  - lib/firespring_dev_commands/templates/config.rb
386
392
  - lib/firespring_dev_commands/templates/docker/application.rb