railsdocks 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eae59bfa42a70c9c629c3d43d0af0b41f42ba79b492f68bdbfc0498e8513560d
4
- data.tar.gz: 20f46b9fbc1ee330e278711e2d0784eee88674cd60fe92534f6f37b5298576c8
3
+ metadata.gz: ee057c9a4fb29cb3002d6dd8eaac99bab25b44cd4650eb42a5940c9da1e7b239
4
+ data.tar.gz: ad097635e565df2cd32f882db1a0881382e762e3590f1add79347b3140eb294d
5
5
  SHA512:
6
- metadata.gz: 4427a2ffaf198c320bcc9e1bf43effc58b71e80f68a37591d5eaefd3d3488b063de4f64cd954e900e7cda242f8bb57863df5a202b7513022e1f2e516e843668b
7
- data.tar.gz: 5903433c21dc4ee9d5717672faae4db2e38ec41f91c1f79b94c6804bd65c0b76d17faf5ba11025a87ffd566ac478ac34fb052c80390474b57ded175a64d08ef4
6
+ metadata.gz: 8298495d87240c7e310c123ad76d1c6daa3cf2596b1d8307728f33b66bf84e6fac2af39cf42fb0456d256a5f5586eaff2750cc33651aeda39d5c1c2a136d580d
7
+ data.tar.gz: 83d0a1b2a5b3cca7d362bb2e712564626ac6ad730aa8eae86eca0201c45e3d730f97dcff330f82445d80c1f3c598364f17059c8eb0a7212089fc7bdffba3ec8c
@@ -23,6 +23,8 @@ module RailsDocks
23
23
  database_command("migrate")
24
24
  when "db:rollback"
25
25
  database_command("rollback")
26
+ when "db:seed"
27
+ database_command("seed")
26
28
  when "domains:list"
27
29
  domains_list
28
30
  when "domains:add"
@@ -181,6 +183,7 @@ module RailsDocks
181
183
  end
182
184
 
183
185
  if inside_git_repository?
186
+ configure_production_credentials_key
184
187
  add_git_remote(git_url)
185
188
  else
186
189
  puts
@@ -337,7 +340,8 @@ module RailsDocks
337
340
  1
338
341
  rescue KeyError
339
342
  warn(
340
- "Destroy failed: RailsDocks returned " "an unexpected response."
343
+ "Destroy failed: RailsDocks returned " \
344
+ "an unexpected response."
341
345
  )
342
346
  1
343
347
  end
@@ -366,9 +370,14 @@ module RailsDocks
366
370
  end
367
371
 
368
372
  display_name =
369
- operation == "migrate" ?
370
- "Migrating" :
373
+ case operation
374
+ when "migrate"
375
+ "Migrating"
376
+ when "rollback"
371
377
  "Rolling back"
378
+ when "seed"
379
+ "Seeding"
380
+ end
372
381
 
373
382
  puts "#{display_name} #{slug}..."
374
383
 
@@ -384,11 +393,17 @@ module RailsDocks
384
393
 
385
394
  puts output unless output.empty?
386
395
 
387
- puts(
388
- operation == "migrate" ?
389
- "Migration complete." :
396
+ completion_message =
397
+ case operation
398
+ when "migrate"
399
+ "Migration complete."
400
+ when "rollback"
390
401
  "Rollback complete."
391
- )
402
+ when "seed"
403
+ "Seed complete."
404
+ end
405
+
406
+ puts completion_message
392
407
 
393
408
  0
394
409
  rescue Client::Error => e
@@ -660,6 +675,109 @@ module RailsDocks
660
675
  match[:slug]
661
676
  end
662
677
 
678
+ def self.configure_production_credentials_key
679
+ key_path =
680
+ File.join(
681
+ "config",
682
+ "credentials",
683
+ "production.key"
684
+ )
685
+
686
+ unless File.file?(key_path)
687
+ warn
688
+ warn(
689
+ "Production credentials key not found at " \
690
+ "#{key_path}."
691
+ )
692
+ warn(
693
+ "RailsDocks could not add it to the deployment."
694
+ )
695
+ return
696
+ end
697
+
698
+ configure_dockerignore_for_production_key
699
+ add_production_key_to_git(key_path)
700
+ end
701
+
702
+ def self.configure_dockerignore_for_production_key
703
+ dockerignore_path =
704
+ ".dockerignore"
705
+
706
+ return unless File.file?(
707
+ dockerignore_path
708
+ )
709
+
710
+ exception =
711
+ "!/config/credentials/production.key"
712
+
713
+ lines =
714
+ File.readlines(
715
+ dockerignore_path,
716
+ chomp: true
717
+ )
718
+
719
+ return if lines.include?(
720
+ exception
721
+ )
722
+
723
+ File.open(
724
+ dockerignore_path,
725
+ "a"
726
+ ) do |file|
727
+ file.puts unless File.zero?(
728
+ dockerignore_path
729
+ )
730
+
731
+ file.puts exception
732
+ end
733
+
734
+ _output,
735
+ error,
736
+ status =
737
+ Open3.capture3(
738
+ "git",
739
+ "add",
740
+ dockerignore_path
741
+ )
742
+
743
+ unless status.success?
744
+ warn(
745
+ "Could not stage .dockerignore: " \
746
+ "#{error.strip}"
747
+ )
748
+ return
749
+ end
750
+
751
+ puts(
752
+ "Production credentials key allowed " \
753
+ "through .dockerignore."
754
+ )
755
+ end
756
+
757
+ def self.add_production_key_to_git(key_path)
758
+ _output,
759
+ error,
760
+ status =
761
+ Open3.capture3(
762
+ "git",
763
+ "add",
764
+ "-f",
765
+ key_path
766
+ )
767
+
768
+ unless status.success?
769
+ warn(
770
+ "Could not add production credentials key: " \
771
+ "#{error.strip}"
772
+ )
773
+ return
774
+ end
775
+
776
+ puts(
777
+ "Production credentials key added for deployment."
778
+ )
779
+ end
780
+
663
781
  def self.add_git_remote(git_url)
664
782
  _output,
665
783
  _error,
@@ -734,6 +852,9 @@ module RailsDocks
734
852
  db:rollback
735
853
  Roll back the last application migration
736
854
 
855
+ db:seed
856
+ Run Rails database seeds
857
+
737
858
  domains:list
738
859
  List all custom domains
739
860
 
@@ -756,7 +877,10 @@ module RailsDocks
756
877
  private_class_method \
757
878
  :inside_git_repository?,
758
879
  :current_app_slug,
880
+ :configure_production_credentials_key,
881
+ :configure_dockerignore_for_production_key,
882
+ :add_production_key_to_git,
759
883
  :add_git_remote,
760
884
  :help
761
885
  end
762
- end
886
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsDocks
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railsdocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nelson