capistrano-ops 1.0.2 → 1.0.4
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 +4 -4
- data/lib/capistrano/ops/backup.rb +1 -13
- data/lib/capistrano/ops/figaro_yml/helpers.rb +13 -14
- data/lib/capistrano/ops/figaro_yml/tasks/compare.rake +2 -2
- data/lib/capistrano/ops/figaro_yml/tasks/get.rake +4 -4
- data/lib/capistrano/ops/figaro_yml.rb +1 -23
- data/lib/capistrano/ops/helper.rb +6 -6
- data/lib/capistrano/ops/logrotate.rb +1 -13
- data/lib/capistrano/ops/logs.rb +1 -12
- data/lib/capistrano/ops/task_loader.rb +23 -0
- data/lib/capistrano/ops/version.rb +1 -1
- data/lib/capistrano/ops/whenever.rb +2 -14
- data/lib/capistrano/ops/wkhtmltopdf.rb +1 -13
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6028f991e964a7ce6f029c3878b1c36b322802df80013019de85c1f9f9220f9f
|
4
|
+
data.tar.gz: 1664aea997e5db3daa236ea04758cb68bd3b34262e29faa90fa41564b2e88aeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99aba98f09eee78b13851eec6ad35dd142fe1252903af6f3c5faf36260c02c693ef6245eddef8dfdefaac9965c9836b08de2620bf449716e47ad096380e26d3b
|
7
|
+
data.tar.gz: 69d303c90aad93e679ac797d90bf759f615e82431ef9a39008fad8c430aa66938cf1fd2b14dfb4249bc9c17bd8fbdf76786c00d0a1b226b3c588fe650024b1e8
|
@@ -1,18 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'capistrano/ops/
|
3
|
+
require 'capistrano/ops/task_loader'
|
4
4
|
require 'capistrano/ops/backup/helper'
|
5
5
|
|
6
|
-
module TaskLoader
|
7
|
-
extend Capistrano::Ops::Helper
|
8
|
-
|
9
|
-
def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
|
10
|
-
if gem_in_gemfile?(gem_name)
|
11
|
-
Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
|
12
|
-
else
|
13
|
-
puts warning_message
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
6
|
TaskLoader.load_tasks_if_gem_present('rails', 'backup/tasks', 'WARNING: Gemfile does not include rails gem which is required for backup tasks')
|
@@ -56,20 +56,10 @@ module Capistrano
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def local_figaro_yml(
|
59
|
+
def local_figaro_yml(_env)
|
60
60
|
@local_figaro_yml ||= YAML.load(ERB.new(File.read(figaro_yml_local_path)).result)
|
61
|
-
local_figaro = {}
|
62
|
-
deployment_env = fetch(:rails_env, env).to_s
|
63
|
-
|
64
|
-
@local_figaro_yml.each do |key, value|
|
65
|
-
if key == env
|
66
|
-
local_figaro[deployment_env] = @local_figaro_yml[key]
|
67
|
-
elsif !value.is_a?(Hash)
|
68
|
-
local_figaro[key] = @local_figaro_yml[key]
|
69
|
-
end
|
70
|
-
end
|
71
61
|
|
72
|
-
|
62
|
+
@local_figaro_yml || {}
|
73
63
|
end
|
74
64
|
|
75
65
|
def local_yaml
|
@@ -85,9 +75,18 @@ module Capistrano
|
|
85
75
|
end
|
86
76
|
|
87
77
|
def configs(yaml, env)
|
88
|
-
|
78
|
+
env_str = env.to_s
|
79
|
+
stage_yml = yaml[env_str]&.sort.to_h
|
89
80
|
global_yml = remove_nested(yaml)&.sort.to_h
|
90
|
-
|
81
|
+
|
82
|
+
other_stages_yml = stages.each_with_object({}) do |f, hash|
|
83
|
+
f_str = f.to_s
|
84
|
+
next if f_str == env_str
|
85
|
+
|
86
|
+
hash[f_str] = yaml[f_str]&.sort.to_h
|
87
|
+
end.compact
|
88
|
+
|
89
|
+
[global_yml, stage_yml, other_stages_yml]
|
91
90
|
end
|
92
91
|
|
93
92
|
def remove_nested(hash)
|
@@ -10,12 +10,12 @@ namespace :figaro_yml do
|
|
10
10
|
local = local_figaro_yml(figaro_yml_env)
|
11
11
|
|
12
12
|
# Split into stage-specific and global configurations
|
13
|
-
local_global_env, local_stage_env = configs(local, figaro_yml_env)
|
13
|
+
local_global_env, local_stage_env, _local_rest = configs(local, figaro_yml_env)
|
14
14
|
|
15
15
|
on release_roles :all do
|
16
16
|
# Read and parse remote application.yml
|
17
17
|
remote = YAML.safe_load(capture("cat #{figaro_yml_remote_path}"))
|
18
|
-
remote_global_env, remote_stage_env = configs(remote, figaro_yml_env)
|
18
|
+
remote_global_env, remote_stage_env, _remote_rest = configs(remote, figaro_yml_env)
|
19
19
|
|
20
20
|
# Compare hashes and handle nil results with empty hashes
|
21
21
|
differences_global = compare_hashes(local_global_env, remote_global_env)
|
@@ -8,11 +8,11 @@ namespace :figaro_yml do
|
|
8
8
|
invoke 'figaro_yml:create_local'
|
9
9
|
else
|
10
10
|
local_yml = local_figaro_yml(figaro_yml_env)
|
11
|
-
local_global, local_stage = configs(local_yml, figaro_yml_env)
|
11
|
+
local_global, local_stage, local_rest = configs(local_yml, figaro_yml_env)
|
12
12
|
on release_roles :all do
|
13
13
|
remote = capture "cat #{figaro_yml_remote_path}"
|
14
14
|
remote_yml = YAML.safe_load(remote).sort.to_h
|
15
|
-
remote_global, remote_stage = configs(remote_yml, figaro_yml_env)
|
15
|
+
remote_global, remote_stage, _remote_rest = configs(remote_yml, figaro_yml_env)
|
16
16
|
differences_global = compare_hashes(remote_global, local_global || {})
|
17
17
|
differences_stage = compare_hashes(remote_stage, local_stage || {})
|
18
18
|
|
@@ -29,10 +29,10 @@ namespace :figaro_yml do
|
|
29
29
|
global_overwrite = ask_to_overwrite('Overwrite local application.yml globals') if differences_global
|
30
30
|
puts 'Nothing written to local application.yml' unless stage_overwrite || global_overwrite
|
31
31
|
exit unless stage_overwrite || global_overwrite
|
32
|
-
|
33
32
|
# compose new yml
|
33
|
+
|
34
34
|
composed_yml = {}
|
35
|
-
composed_yml.merge!(
|
35
|
+
composed_yml.merge!(local_rest) # local yml is always included to avoid losing any data
|
36
36
|
composed_yml.merge!(local_global) unless global_overwrite
|
37
37
|
composed_yml.merge!(remote_global) if global_overwrite
|
38
38
|
composed_yml[figaro_yml_env.to_s] = stage_overwrite ? remote_stage : local_stage
|
@@ -1,29 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'capistrano/ops/
|
3
|
+
require 'capistrano/ops/task_loader'
|
4
4
|
require 'capistrano/ops/figaro_yml/paths'
|
5
5
|
require 'capistrano/ops/figaro_yml/helpers'
|
6
6
|
|
7
|
-
module TaskLoader
|
8
|
-
extend Capistrano::Ops::Helper
|
9
|
-
|
10
|
-
def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
|
11
|
-
if gem_in_gemfile?(gem_name)
|
12
|
-
Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
|
13
|
-
else
|
14
|
-
puts warning_message
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
7
|
TaskLoader.load_tasks_if_gem_present('figaro', 'figaro_yml/tasks', 'WARNING: Gemfile does not include figaro gem which is required for figaro_yml tasks')
|
20
|
-
# include Capistrano::Ops::Helper
|
21
|
-
|
22
|
-
# Dir.glob("#{File.expand_path(__dir__)}/figaro_yml/tasks/*.rake").each { |f| load f }
|
23
|
-
|
24
|
-
# # gem 'figaro' is required for figaro_yml tasks
|
25
|
-
|
26
|
-
# figaro_gem = gem_in_gemfile?('figaro')
|
27
|
-
|
28
|
-
# # check if Gemfile environment includes figaro gem and warn user if not found
|
29
|
-
# puts 'WARNING: Gemfile does not include figaro gem which is required for figaro_yml tasks' unless figaro_gem
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Capistrano
|
2
4
|
module Ops
|
3
5
|
module Helper
|
4
6
|
def gem_in_gemfile?(gem_name)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
false
|
7
|
+
return false unless File.exist?('Gemfile')
|
8
|
+
|
9
|
+
regex = Regexp.new("^\s*gem\s+['\"]#{gem_name}['\"].*?(?=#|$)", Regexp::MULTILINE)
|
10
|
+
File.read('Gemfile').match?(regex)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,19 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'capistrano/ops/
|
3
|
+
require 'capistrano/ops/task_loader'
|
4
4
|
require 'capistrano/ops/logrotate/helpers'
|
5
5
|
require 'capistrano/ops/logrotate/paths'
|
6
6
|
|
7
|
-
module TaskLoader
|
8
|
-
extend Capistrano::Ops::Helper
|
9
|
-
|
10
|
-
def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
|
11
|
-
if gem_in_gemfile?(gem_name)
|
12
|
-
Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
|
13
|
-
else
|
14
|
-
puts warning_message
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
7
|
TaskLoader.load_tasks_if_gem_present('whenever', 'logrotate/tasks', 'WARNING: Gemfile does not include whenever gem which is required for logrotate tasks')
|
data/lib/capistrano/ops/logs.rb
CHANGED
@@ -1,18 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'capistrano/ops/
|
3
|
+
require 'capistrano/ops/task_loader'
|
4
4
|
require 'capistrano/ops/logs/paths'
|
5
5
|
require 'capistrano/ops/logs/helpers'
|
6
6
|
|
7
|
-
module TaskLoader
|
8
|
-
extend Capistrano::Ops::Helper
|
9
|
-
def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
|
10
|
-
if gem_in_gemfile?(gem_name)
|
11
|
-
Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
|
12
|
-
else
|
13
|
-
puts warning_message
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
7
|
TaskLoader.load_tasks_if_gem_present('rails', 'logs/tasks', 'WARNING: Gemfile does not include rails gem which is required for logs tasks')
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'capistrano/ops/helper'
|
4
|
+
|
5
|
+
module TaskLoader
|
6
|
+
extend Capistrano::Ops::Helper
|
7
|
+
|
8
|
+
def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
|
9
|
+
unless gem_in_gemfile?(gem_name)
|
10
|
+
warn warning_message
|
11
|
+
return
|
12
|
+
end
|
13
|
+
|
14
|
+
base_path = File.expand_path(__dir__)
|
15
|
+
task_files = Dir.glob("#{base_path}/#{task_path}/**/*.rake")
|
16
|
+
|
17
|
+
task_files.each do |file|
|
18
|
+
load file
|
19
|
+
rescue StandardError => e
|
20
|
+
puts "Failed to load #{file}: #{e.message}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,17 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'capistrano/ops/
|
3
|
+
require 'capistrano/ops/task_loader'
|
4
4
|
|
5
|
-
|
6
|
-
extend Capistrano::Ops::Helper
|
7
|
-
|
8
|
-
def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
|
9
|
-
if gem_in_gemfile?(gem_name)
|
10
|
-
Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
|
11
|
-
else
|
12
|
-
puts warning_message
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
TaskLoader.load_tasks_if_gem_present('whenever', 'whenever/tasks', 'WARNING: Gemfile does not include whenever gem which is required for logrotate tasks')
|
5
|
+
TaskLoader.load_tasks_if_gem_present('whenever', 'whenever/tasks', 'WARNING: Gemfile does not include whenever gem which is required for whenever tasks')
|
@@ -1,19 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'capistrano/ops/
|
3
|
+
require 'capistrano/ops/task_loader'
|
4
4
|
require 'capistrano/ops/wkhtmltopdf/helpers'
|
5
5
|
|
6
|
-
module TaskLoader
|
7
|
-
extend Capistrano::Ops::Helper
|
8
|
-
|
9
|
-
def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
|
10
|
-
if gem_in_gemfile?(gem_name)
|
11
|
-
Dir.glob("#{File.expand_path(__dir__)}/#{task_path}/**/*.rake").each { |f| load f }
|
12
|
-
else
|
13
|
-
puts warning_message
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
6
|
TaskLoader.load_tasks_if_gem_present('wicked_pdf', 'wkhtmltopdf/tasks',
|
19
7
|
'WARNING: Gemfile does not include wkhtmltopdf-binary gem which is required for wkhtmltopdf tasks')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-ops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Crusius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|
@@ -200,6 +200,7 @@ files:
|
|
200
200
|
- lib/capistrano/ops/rails/lib/tasks/pg/remove_old_dumps.rake
|
201
201
|
- lib/capistrano/ops/rails/lib/tasks/storage/backup.rake
|
202
202
|
- lib/capistrano/ops/rails/lib/tasks/storage/remove_old_backups.rake
|
203
|
+
- lib/capistrano/ops/task_loader.rb
|
203
204
|
- lib/capistrano/ops/version.rb
|
204
205
|
- lib/capistrano/ops/whenever.rb
|
205
206
|
- lib/capistrano/ops/whenever/tasks/show_crontab.rake
|