simple_infrastructure 0.1.0 → 0.1.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: bb8f4aec9834f672b6d225487853b1e935d642b54fc1e6c68f2cf9de94261174
4
- data.tar.gz: 0a954b0c4d971c07e47840a99aacbbdcc9022a02d2338eb40c722a475b99866c
3
+ metadata.gz: 55184dee56e24b9300bf725d4594bd803110b97f48f8b4d61a2eb896903affcf
4
+ data.tar.gz: bbbd09a4162cb33839a6b8667cb2b0b4d85ac9f5c50eec6298fe4a051ec8b3ba
5
5
  SHA512:
6
- metadata.gz: 494eaf07fe0d6eefb7c6e2f1d8a2750b3ac7c22ef936dcaab9c91722534e9163f0333efac7654c5bb017afd792df19131f372322d0a19002a6789bc591512051
7
- data.tar.gz: 23df4ef7dc6bc28d64a271d7ff83dd20965cd4ee6bfec7ad458360fd0f1fbe999fdae677a012fd3e903232280171b9cd46ace2ffd916d191944bcbcad9b16f23
6
+ metadata.gz: 21abb10a5bcf5f2763a183c50b076c226a5b88c233d8db98b609a67d7bca7ab89ad608c22476130d4792f569913455e33350da5c1114cdcc7c7654b629bda191
7
+ data.tar.gz: c63a565b95cbf6afc843ae28b45aeb93fb677497565f0bb65632a0fbc8b383e06d3692e36ae41aa09367b6400c310ed8783f7bcd90e7c42a93891309672d11ec
data/README.md CHANGED
@@ -22,8 +22,14 @@ Then run:
22
22
 
23
23
  ```bash
24
24
  bundle install
25
+ rails generate simple_infrastructure:install
25
26
  ```
26
27
 
28
+ This creates:
29
+ - `bin/infrastructure` — CLI tool
30
+ - `config/infrastructure/inventory.yml` — server inventory
31
+ - `config/infrastructure/changes/` — directory for change files
32
+
27
33
  For Rails apps, the gem auto-configures via Railtie (sets `project_root` to `Rails.root` and `logger` to `Rails.logger`).
28
34
 
29
35
  For standalone use:
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module SimpleInfrastructure
6
+ module Generators
7
+ class InstallGenerator < Rails::Generators::Base
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ def create_binstub
11
+ template "infrastructure.tt", "bin/infrastructure"
12
+ chmod "bin/infrastructure", 0o755
13
+ end
14
+
15
+ def create_inventory
16
+ template "inventory.yml.tt", "config/infrastructure/inventory.yml", skip: true
17
+ end
18
+
19
+ def create_changes_directory
20
+ empty_directory "config/infrastructure/changes"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../config/boot"
4
+ require_relative "../config/environment"
5
+
6
+ SimpleInfrastructure::Cli.new(ARGV).run
@@ -0,0 +1,6 @@
1
+ defaults:
2
+ user: root
3
+
4
+ servers:
5
+ production: []
6
+ staging: []
@@ -278,6 +278,9 @@ module SimpleInfrastructure
278
278
  .join
279
279
  .strip
280
280
 
281
+ change_summary = success.is_a?(Integer) && success > 0 ?
282
+ " (#{success} change#{'s' unless success == 1} applied)" : ""
283
+
281
284
  if error || !success
282
285
  print "#{CLEAR_LINE}#{RED}⚠️ #{label}#{RESET}\n"
283
286
  puts output unless output.empty?
@@ -285,12 +288,12 @@ module SimpleInfrastructure
285
288
  puts
286
289
  @results << false
287
290
  elsif show_output && !output.empty?
288
- print "#{CLEAR_LINE}⏳ #{label}\n"
291
+ print "#{CLEAR_LINE}⏳ #{label}#{change_summary}\n"
289
292
  puts output
290
293
  puts
291
294
  @results << true
292
295
  else
293
- print "#{CLEAR_LINE}✅ #{label}\n"
296
+ print "#{CLEAR_LINE}✅ #{label}#{change_summary}\n"
294
297
  @results << true
295
298
  end
296
299
  end
@@ -16,6 +16,7 @@ module SimpleInfrastructure
16
16
  end
17
17
 
18
18
  generators do
19
+ require_relative "../generators/simple_infrastructure/install_generator"
19
20
  require_relative "../generators/simple_infrastructure/change_generator"
20
21
  end
21
22
  end
@@ -55,7 +55,7 @@ module SimpleInfrastructure
55
55
  SimpleInfrastructure.logger.debug "\r\e[K"
56
56
  if pending.empty?
57
57
  SimpleInfrastructure.logger.debug "#{server}: up to date"
58
- return true
58
+ return 0
59
59
  end
60
60
 
61
61
  SimpleInfrastructure.logger.debug "#{server}: #{pending.length} pending change(s)"
@@ -84,7 +84,7 @@ module SimpleInfrastructure
84
84
  SimpleInfrastructure.logger.debug " DONE: #{change.name}"
85
85
  SimpleInfrastructure.logger.debug "" if index < pending.length - 1
86
86
  end
87
- true
87
+ pending.length
88
88
  rescue StandardError => e
89
89
  SimpleInfrastructure.logger.debug "\r\e[K"
90
90
  SimpleInfrastructure.logger.debug "#{server}: FAILED - #{e.message}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleInfrastructure
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_infrastructure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - FounderCatalyst
@@ -52,7 +52,10 @@ files:
52
52
  - README.md
53
53
  - bin/simple_infrastructure
54
54
  - lib/generators/simple_infrastructure/change_generator.rb
55
+ - lib/generators/simple_infrastructure/install_generator.rb
55
56
  - lib/generators/simple_infrastructure/templates/change.rb.tt
57
+ - lib/generators/simple_infrastructure/templates/infrastructure.tt
58
+ - lib/generators/simple_infrastructure/templates/inventory.yml.tt
56
59
  - lib/simple_infrastructure.rb
57
60
  - lib/simple_infrastructure/change.rb
58
61
  - lib/simple_infrastructure/cli.rb