capistrano-addon-fm 0.1.1 → 0.1.3

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: 52453fe086dda55f4fb47b7e69ceb803166c8622b4dad45792ba31d088f2396f
4
- data.tar.gz: fba1b31e7d11fd4f26f422bb1d3bb4af40ce722655dc2cdeeeb676868183e5d2
3
+ metadata.gz: 5701d4dd587e45f260c6d05bded677f6e2885b1ef22f0d7b75f2a8997149c95b
4
+ data.tar.gz: f19ab3fb1ba5e7b83afcd908e863023b3effcb19e4becb66a4b69a035957396b
5
5
  SHA512:
6
- metadata.gz: 611af17bbed983069b57dbc7545d2f83f88c55b6ce8cd57803be682d73f67a0aae71abe10b31a448435a03846223675f43c281b12c34c2db15562702b461d8c2
7
- data.tar.gz: c665aa995fb140c45b4821160fbc60f36a30ce0e18f9b424ac85f55815ef7603016eff98ad923250190721f2e526d6f37e122cb204c487438277ce691fa7a00e
6
+ metadata.gz: 2e57f2376477429d2557d52de9c75eacf4bfff991040a41f6c417e1c790ca8cd6243ac89e2130af361f0a10c7bdf5dae26d93bab8446ce02c7356c21b03ab523
7
+ data.tar.gz: 772dea6e4d0fed85789331725dd40bd8b80bedb14fda966d08711abd7078992a394371fde20d4e5412d46f3251255fd06360a1255d3be7f6672e07bcf6e9f305
data/CHANGELOG.md CHANGED
@@ -1,9 +1,21 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.1.3] - 2025-08-26
5
+ ### Added
6
+ - fix env-with-secrets : fix release_path (latest)
7
+ - add `cap fm:readme` task that will output addon readme file
8
+ - add `cap fm:readme:tasks` task that will output addon readme file - only tasks part
9
+ - improved readme.md docs
10
+
11
+ ## [0.1.2] - 2025-02-18
12
+ ### Added
13
+ - fix env-with-secrets; add missing php-fpm README text
14
+
4
15
  ## [0.1.1] - 2025-02-18
5
16
  ### Added
6
17
  - add php-fpm tasks
7
- ## [0.1.0] - 2025-02-18
18
+
19
+ ## [0.1.0] - 2025-02-17
8
20
  ### Added
9
21
  - add generic tasks - documented in README.md
data/README.md CHANGED
@@ -17,6 +17,8 @@ require 'capistrano/addon/fm'
17
17
  ## Usage
18
18
 
19
19
  ### this will add new tasks for `cap` command
20
+ #### addon related commands (no stage needed):
21
+ cap fm:readme Will output this readme file
20
22
  new tasks (example run: cap prod TASK - replace 'prod' with your stage (devel/local/etc))
21
23
  #### supervisor related commands:
22
24
  cap prod supervisor:start Will run supervisorctl `start all`
@@ -57,11 +59,11 @@ new tasks (example run: cap prod TASK - replace 'prod' with your stage (devel/lo
57
59
  cap prod system:disk_space: all|df|zfs|btrfs
58
60
  cap prod system:connections:count: total|per_address|via_ss
59
61
  #### env-with-secrets:
60
- cap env:upload Will upload .env file to server and decrypt
61
- cap env:upload:diff Will run `diff` command to server's .env versus local .env - decrypted
62
- cap env:local:encrypt_file Will encrypt `cap-secrets-LOCAL.txt` to `ap-secrets.enc.b64`
63
- cap env:local:decrypt_file Will decrypt `ap-secrets.enc.b64` into `cap-secrets-LOCAL.txt`
64
- cap env:local:secrets cat `cap-secrets-LOCAL.txt`
62
+ cap prod env:upload Will upload .env file to server and decrypt
63
+ cap prod env:upload:diff Will run `diff` command to server's .env versus local .env - decrypted
64
+ cap prod env:local:encrypt_file Will encrypt `cap-secrets-LOCAL.txt` to `ap-secrets.enc.b64`
65
+ cap prod env:local:decrypt_file Will decrypt `ap-secrets.enc.b64` into `cap-secrets-LOCAL.txt`
66
+ cap prod env:local:secrets cat `cap-secrets-LOCAL.txt`
65
67
  #### custom related commands:
66
68
  cap prod cat:env Run `cat /var/www/*/*/.env`
67
69
  cap prod empty_file:check Run `la -lah on nginx, fpm, laravel and var/www/*/current/logs/*`
@@ -0,0 +1 @@
1
+ set :stage, :'fm-addon-stage'
@@ -1,3 +1,5 @@
1
+ require 'tempfile'
2
+
1
3
  namespace "env" do
2
4
  # Set default values
3
5
  set :default_local_path, './'
@@ -40,6 +42,7 @@ namespace "env" do
40
42
  base64_file = fetch(:file_to_decrypt, fetch(:default_file_to_decrypt))
41
43
  encrypted_file = base64_file.gsub('.b64', '')
42
44
  decrypted_file_tmp = "cap-secrets-tmp.txt"
45
+ latest_release_path = "#{shared_path.sub(/shared$/, 'releases')}/#{capture("ls -1 #{shared_path.sub(/shared$/, 'releases')} | sort -r | head -n 1").strip}"
43
46
 
44
47
  # Read the .env file
45
48
  env_file = capture(:cat, "#{shared_path}/.env.tmp")
@@ -48,7 +51,7 @@ namespace "env" do
48
51
  encryption_key = File.read(encryption_key_file).strip
49
52
 
50
53
  # Decode and decrypt cap-secrets.enc.b64 into a temporary file cap-secrets-tmp.txt
51
- execute "base64 -d #{release_path}/#{base64_file} > #{shared_path}/#{encrypted_file} && openssl enc -aes-256-cbc -d -pbkdf2 -in #{shared_path}/#{encrypted_file} -out #{shared_path}/#{decrypted_file_tmp} -pass pass:#{encryption_key}"
54
+ execute "base64 -d #{latest_release_path}/#{base64_file} > #{shared_path}/#{encrypted_file} && openssl enc -aes-256-cbc -d -pbkdf2 -in #{shared_path}/#{encrypted_file} -out #{shared_path}/#{decrypted_file_tmp} -pass pass:#{encryption_key}"
52
55
 
53
56
  # Read the secrets from the temporary cap-secrets-tmp.txt file
54
57
  secrets = {}
@@ -66,9 +69,17 @@ namespace "env" do
66
69
  secrets[$1]
67
70
  end
68
71
  end
72
+ decrypted_content = decrypted_lines.join
73
+
74
+ # Create a temporary local file with the decrypted content
75
+ Tempfile.open('.env.tmp') do |tempfile|
76
+ tempfile.write(decrypted_content)
77
+ tempfile.write("\n")
78
+ tempfile.close
69
79
 
70
- # Write the modified .env file back to the server
71
- execute :echo, "'#{decrypted_lines.join}' > #{shared_path}/.env.tmp", verbosity: :DEBUG
80
+ # Upload the temporary file to the remote server
81
+ upload! tempfile.path, "#{shared_path}/.env.tmp", verbosity: :DEBUG
82
+ end
72
83
  end
73
84
  end
74
85
  namespace :local do
@@ -126,7 +137,7 @@ namespace "env" do
126
137
  use_local_path = fetch(:local_path, fetch(:default_local_path))
127
138
  Dir.chdir(use_local_path) do
128
139
  file = fetch(:file_to_encrypt, fetch(:default_file_to_encrypt))
129
- puts "Contents of file #{use_local_path}/#{file}:\n\n"
140
+ puts "Contents of file #{use_local_path}#{file}:\n\n"
130
141
  system("cat #{file}")
131
142
  end
132
143
  end
@@ -3,7 +3,7 @@
3
3
  module Capistrano
4
4
  module Addon
5
5
  module Fm
6
- VERSION = "0.1.1"
6
+ VERSION = "0.1.3"
7
7
  end
8
8
  end
9
9
  end
@@ -2,6 +2,9 @@
2
2
 
3
3
  require_relative "fm/version"
4
4
 
5
+ load File.expand_path("fm/stages/fm-addon-stage.rb", __dir__)
6
+ # set :stage, :'fm-addon-stage' unless fetch(:stage, nil)
7
+
5
8
  # Load all .rake files from the tasks directory
6
9
  Dir.glob(File.expand_path("./fm/tasks/**/*.rake", __dir__)).each { |r| load r }
7
10
 
@@ -13,3 +16,27 @@ module Capistrano
13
16
  end
14
17
  end
15
18
  end
19
+
20
+ namespace 'fm' do
21
+ task 'readme' do
22
+ run_locally do
23
+ gem_root = File.expand_path('../../../', __dir__)
24
+ Dir.chdir(gem_root) do
25
+ system('cat readme.md')
26
+ end
27
+ end
28
+ end
29
+ task 'readme:tasks' do
30
+ run_locally do
31
+ gem_root = File.expand_path('../../../', __dir__)
32
+ Dir.chdir(gem_root) do
33
+ system("awk '
34
+ /^## Usage$/ { print; in_section=1; next }
35
+ /^## Configuration$/ { exit }
36
+ in_section { print }
37
+ ' README.md
38
+ ")
39
+ end
40
+ end
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-addon-fm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florin Motoc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-18 00:00:00.000000000 Z
11
+ date: 2025-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -38,6 +38,7 @@ files:
38
38
  - Rakefile
39
39
  - lib/capistrano/addon.rb
40
40
  - lib/capistrano/addon/fm.rb
41
+ - lib/capistrano/addon/fm/stages/fm-addon-stage.rb
41
42
  - lib/capistrano/addon/fm/tasks/custom.rake
42
43
  - lib/capistrano/addon/fm/tasks/env-with-secrets.rake
43
44
  - lib/capistrano/addon/fm/tasks/fpm.rake