firespring_dev_commands 2.0.0 → 2.0.1.pre.alpha.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52fab6ead6110ad2641d13003b16757be66c3928545d8185c4db3eed806d2443
4
- data.tar.gz: '0892d45189fef73d8b20364d696bbd853c635096848e04c8ade75e46f6ba8d2b'
3
+ metadata.gz: 7ab3da39b3b9d7336453745fafa4a50563e03a90e785c29d3bf7cd17543322da
4
+ data.tar.gz: 79b31dec877f099d7ef6d7444ce44563828bd305a790bd943da3d55ca29f2044
5
5
  SHA512:
6
- metadata.gz: c8e557565fd8478b0a8d55d3415290871c00201aed6030bbc95ccccddc36d399b47ec58933a8cc915e350ebf3fcfaa7c7066551509bd17705d33aa36b4dd1fb9
7
- data.tar.gz: a3449ac14b161ff2dc385f1b68ab0a6362a8bfab21b4c964b2a04db90740b5c866f22b3fda1e4b8e3f1ce9b89711f1c5e759405dcd411851a9a31de42fc549ad
6
+ metadata.gz: 79c3ddcc441e1a943b2fe9ca412e1b3a00eb85d49e7469b67720fc910dfdab492b40d6f9148e76c265922458734e382ffb8b45d38993e1661b95e2dd81dbebdc
7
+ data.tar.gz: bf74bb5fc32c3841c6c41562aac41ecc6d2f145f615f8759fe18a79b3bbeb6da9bb77eefa84bd6a638fa4529b436627a70c802cbc08a31c3edc74f0603508698
@@ -7,13 +7,16 @@ module Dev
7
7
  class Docker
8
8
  # Class containing methods for interfacing with the docker compose cli
9
9
  class Compose
10
+ # The name of the docker compose executable
11
+ EXECUTABLE_NAME = %w(docker compose).freeze
12
+
10
13
  # Config object for setting top level docker compose config options
11
14
  Config = Struct.new(:project_dir, :project_name, :compose_files, :min_version, :max_version) do
12
15
  def initialize
13
16
  self.project_dir = DEV_COMMANDS_ROOT_DIR
14
17
  self.project_name = DEV_COMMANDS_PROJECT_NAME
15
18
  self.compose_files = ["#{DEV_COMMANDS_ROOT_DIR}/docker-compose.yml"]
16
- self.min_version = nil
19
+ self.min_version = '2.0.0'
17
20
  self.max_version = nil
18
21
  end
19
22
  end
@@ -33,14 +36,11 @@ module Dev
33
36
 
34
37
  # Returns the version of the docker-compose executable on the system
35
38
  def version
36
- @version ||= `#{EXECUTABLE_NAME} --version`.match(/version v?([0-9.]+)/)[1]
39
+ version_cmd = EXECUTABLE_NAME.dup << 'version'
40
+ @version ||= `#{version_cmd.join(' ')}`.match(/version v?([0-9.]+)/)[1]
37
41
  end
38
42
  end
39
43
 
40
- # @todo Change this to "docker compose" when everyone is off v1
41
- # The name of the docker compose executable
42
- EXECUTABLE_NAME = 'docker-compose'.freeze
43
-
44
44
  attr_accessor :capture, :compose_files, :environment, :options, :project_dir, :project_name, :services, :user, :volumes
45
45
 
46
46
  def initialize(
@@ -69,12 +69,12 @@ module Dev
69
69
  # Checks the min and max version against the current docker version if they have been configured
70
70
  def check_version
71
71
  min_version = self.class.config.min_version
72
- raise "requires #{EXECUTABLE_NAME} version >= #{min_version} (found #{self.class.version})" if min_version &&
73
- !Dev::Common.new.version_greater_than(min_version, self.class.version)
72
+ version_too_low = min_version && !Dev::Common.new.version_greater_than(min_version, self.class.version)
73
+ raise "requires docker compose version >= #{min_version} (found #{self.class.version})" if version_too_low
74
74
 
75
75
  max_version = self.class.config.max_version
76
- raise "requires #{EXECUTABLE_NAME} version < #{max_version} (found #{self.class.version})" if max_version &&
77
- Dev::Common.new.version_greater_than(max_version, self.class.version)
76
+ version_too_high = max_version && Dev::Common.new.version_greater_than(max_version, self.class.version)
77
+ raise "requires docker compose version < #{max_version} (found #{self.class.version})" if version_too_high
78
78
  end
79
79
 
80
80
  # Pull in supported env settings and call build
@@ -83,6 +83,7 @@ module Dev
83
83
  def build
84
84
  merge_options('--parallel')
85
85
  merge_env_pull_option
86
+ merge_env_push_option
86
87
  merge_env_cache_option
87
88
  execute_command(build_command('build'))
88
89
  end
@@ -181,6 +182,13 @@ module Dev
181
182
  merge_options('--pull') if ENV['PULL'].to_s.strip == 'true'
182
183
  end
183
184
 
185
+ # Merge --push option if PUSH is set to true and no existing push options are present
186
+ private def merge_env_push_option
187
+ return if @options.any? { |it| it.include?('push') }
188
+
189
+ merge_options('--push') if ENV['PUSH'].to_s.strip == 'true'
190
+ end
191
+
184
192
  # Merge --no-build option unless BUILD is set to true and no existing build options are present
185
193
  private def merge_env_build_option
186
194
  return if @options.any? { |it| it.include?('build') }
@@ -230,7 +238,7 @@ module Dev
230
238
 
231
239
  # Build the compose command with the given inputs
232
240
  private def build_command(action, *cmd)
233
- command = [EXECUTABLE_NAME]
241
+ command = EXECUTABLE_NAME.dup
234
242
  command << '--project-directory' << project_dir
235
243
  command << '-p' << project_name if project_name
236
244
  Array(compose_files).compact.each { |file| command << '-f' << file }
@@ -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.0.0'.freeze
9
+ VERSION = '2.0.1.pre.alpha.2'.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.0.0
4
+ version: 2.0.1.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
11
+ date: 2023-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -313,9 +313,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
313
313
  version: '3.2'
314
314
  required_rubygems_version: !ruby/object:Gem::Requirement
315
315
  requirements:
316
- - - ">="
316
+ - - ">"
317
317
  - !ruby/object:Gem::Version
318
- version: '0'
318
+ version: 1.3.1
319
319
  requirements: []
320
320
  rubygems_version: 3.4.10
321
321
  signing_key: