credman 0.0.2.pre.alpha → 0.0.5

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: 14ab2fa1b4e48d6a90fdcc7632bf78993238e82533010090388f92e1f91f553d
4
- data.tar.gz: 3c88995c1aec932c2d1ce18cdd7c332ca94fab5124280c864030038a9aa8b30e
3
+ metadata.gz: f25d3191780d08906d8892c1f95ad775b11bebef09037be0bb93118bf3d86886
4
+ data.tar.gz: b07393ac4330ee9aaa4bc9b022ab9a64f7330cbea16f130b8a00886fa76dcdcd
5
5
  SHA512:
6
- metadata.gz: 5dea53acfd5ced3cc7b9d277bc8512552aece3c6268e1329a8cb2a23592058401e2c34d5f77bf2acb5bb89b414ab02217646fd3a2b8385ebebc11d78dfdd845a
7
- data.tar.gz: 71401829d82d9555f4bee7672eb4168ffb8211e7e1b2b627a1aa10570d0439204812e68b1d7ec573cbd5fc439a99ee53f71e36f05743793be2a16c073b31bab2
6
+ metadata.gz: 32b50f324c60ae1257b2838cc596d30d5c6681351885cb0f0b9f98f7ee6d6d8ee6df053ee6b0d593574567cca3008b3878e4c2e99b20ff83c2af6d04979f6644
7
+ data.tar.gz: 24389f20374400c35c28813bd463f41f51af0f807cda971aa8e1c9d29f39542956596cd2bc69abedd7feb912db2f189a9531279cefa2b75dd9fc9b969153d445
data/Appraisals ADDED
@@ -0,0 +1,15 @@
1
+ appraise "activesupport-6" do
2
+ gem "activesupport", "~> 6.0.0"
3
+ end
4
+
5
+ appraise "activesupport-6-1" do
6
+ gem "activesupport", "~> 6.1.0"
7
+ end
8
+
9
+ appraise "activesupport-7" do
10
+ gem "activesupport", "~> 7.0.0"
11
+ end
12
+
13
+ appraise "activesupport-master" do
14
+ gem "activesupport", github: "rails/rails", branch: "main"
15
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [0.0.5] - 2022-09-06
2
+
3
+ - Introduce config with `default_diff_branch` and `available_environments` options (PR #9)
4
+ - Setup Github actions (PR #6)
5
+ - small fixes related to linters and specs (PR #6)
6
+
7
+ ## [0.0.4] - 2022-09-06
8
+
9
+ - fix: list command failure when root key exists (PR #2)
10
+
11
+ ## [0.0.3] - 2022-08-24
12
+
13
+ - add `bin/rspec` binstubs
14
+ - introduce `delete` command
15
+
1
16
  ## [0.0.2-alpha] - 2022-08-24
2
17
  - Rename gem to `credman`
3
18
 
data/Gemfile CHANGED
@@ -4,7 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in credman.gemspec
6
6
  gemspec
7
-
8
- gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.0"
10
- gem "standard", "~> 1.13"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- credman (0.0.2.pre.alpha)
4
+ credman (0.0.5)
5
5
  activesupport (>= 6.0)
6
6
  dry-cli (~> 0.7)
7
7
  hash_diff (~> 1.0)
@@ -16,11 +16,15 @@ GEM
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
18
18
  tzinfo (~> 2.0)
19
+ appraisal (2.4.1)
20
+ bundler
21
+ rake
22
+ thor (>= 0.14.0)
19
23
  ast (2.4.2)
20
24
  concurrent-ruby (1.1.10)
21
25
  diff-lcs (1.5.0)
22
26
  dry-cli (0.7.0)
23
- hash_diff (1.1.0)
27
+ hash_diff (1.1.1)
24
28
  i18n (1.12.0)
25
29
  concurrent-ruby (~> 1.0)
26
30
  json (2.6.2)
@@ -66,6 +70,7 @@ GEM
66
70
  standard (1.13.0)
67
71
  rubocop (= 1.31.2)
68
72
  rubocop-performance (= 1.14.3)
73
+ thor (1.2.1)
69
74
  tty-color (0.6.0)
70
75
  tty-command (0.10.1)
71
76
  pastel (~> 0.8)
@@ -74,9 +79,12 @@ GEM
74
79
  unicode-display_width (2.2.0)
75
80
 
76
81
  PLATFORMS
82
+ ruby
77
83
  x86_64-darwin-21
84
+ x86_64-linux
78
85
 
79
86
  DEPENDENCIES
87
+ appraisal
80
88
  credman!
81
89
  rake (~> 13.0)
82
90
  rspec (~> 3.0)
data/README.md CHANGED
@@ -1,28 +1,85 @@
1
- # Rails::Credentials::Manager
1
+ # Credman
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails/credentials/manager`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Handy console command for developers to manage Rails credentials.
6
4
 
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
10
8
 
11
9
  ```ruby
12
- gem 'credman'
10
+ group :development do
11
+ gem 'credman'
12
+ end
13
13
  ```
14
14
 
15
- And then execute:
15
+ ## Usage
16
+
17
+ List of all commands:
16
18
 
17
- $ bundle install
19
+ ### credman help
20
+ ```
21
+ bundle exec credman
22
+ or
23
+ bundle exec credman help
24
+ or
25
+ bundle exec credman usage
26
+ ```
18
27
 
19
- Or install it yourself as:
28
+ Details of any command:
20
29
 
21
- $ gem install credman
30
+ ```
31
+ bundle exec credman set -h
32
+ ```
22
33
 
23
- ## Usage
34
+ ### credman list
35
+ List all your keys for all environments.
36
+
37
+ ```
38
+ bundle exec credman list
39
+ ```
40
+
41
+ ### credman get
42
+ Getting a particular key's values.
43
+
44
+ ```
45
+ bundle exec credman get google.maps.api_key github.private_key
46
+ ```
47
+
48
+ ### credman set
49
+
50
+ Add/change a value for a particular key. `-e` attribute is mandatory for this command.
51
+
52
+
53
+ ```
54
+ bundle exec credman set new_service.super_key new_secret_value -e development,test,staging,production
55
+ ```
56
+
57
+ ### credman delete
58
+
59
+ Delete for keys. `-e` attribute is mandatory for this command.
60
+
61
+ ```
62
+ bundle exec credman delete new_service.super_key new_service.another_key -e development,test,staging,production
63
+ ```
64
+
65
+ ### credman diff
66
+
67
+ Shows all keys changed compared with `heroku` branch by default. You can specify any branch from origin you want to. For example `bin/earl diff my_branch`
68
+
69
+ ```
70
+ > bundle exec credman diff
71
+ development:
72
+ new_service.super_key: ADDED: "new_secret_value"
73
+ test:
74
+ new_service.super_key: ADDED: "new_secret_value"
75
+ staging:
76
+ new_service.super_key: ADDED: "new_secret_value"
77
+ production:
78
+ new_service.super_key: ADDED: "new_secret_value"
79
+ ```
24
80
 
25
- TODO: Write usage instructions here
81
+ ### credman conflicts
82
+ Run it if you have merge conflicts in `configs/credentials/*.yml.enc`. That interactive tool will help you resolve the conflict.
26
83
 
27
84
  ## Development
28
85
 
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -0,0 +1,5 @@
1
+ default_diff_branch: main
2
+ available_environments:
3
+ - development
4
+ - test
5
+ - production
data/credman.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
24
24
  end
25
25
  end
26
- spec.executables = 'credman'
26
+ spec.executables = "credman"
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  spec.add_dependency "activesupport", ">= 6.0"
@@ -32,6 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "pastel", "~> 0.8"
33
33
  spec.add_dependency "hash_diff", "~> 1.0"
34
34
 
35
+ spec.add_development_dependency "rake", "~> 13.0"
35
36
  spec.add_development_dependency "rspec", "~> 3.0"
36
37
  spec.add_development_dependency "standard", "~> 1.13"
38
+ spec.add_development_dependency "appraisal"
37
39
  end
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 6.0.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ credman (0.0.5)
5
+ activesupport (>= 6.0)
6
+ dry-cli (~> 0.7)
7
+ hash_diff (~> 1.0)
8
+ pastel (~> 0.8)
9
+ tty-command (~> 0.10)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (6.0.5.1)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ zeitwerk (~> 2.2, >= 2.2.2)
20
+ appraisal (2.4.1)
21
+ bundler
22
+ rake
23
+ thor (>= 0.14.0)
24
+ ast (2.4.2)
25
+ concurrent-ruby (1.1.10)
26
+ diff-lcs (1.5.0)
27
+ dry-cli (0.7.0)
28
+ hash_diff (1.1.1)
29
+ i18n (1.12.0)
30
+ concurrent-ruby (~> 1.0)
31
+ json (2.6.2)
32
+ minitest (5.16.3)
33
+ parallel (1.22.1)
34
+ parser (3.1.2.1)
35
+ ast (~> 2.4.1)
36
+ pastel (0.8.0)
37
+ tty-color (~> 0.5)
38
+ rainbow (3.1.1)
39
+ rake (13.0.6)
40
+ regexp_parser (2.5.0)
41
+ rexml (3.2.5)
42
+ rspec (3.11.0)
43
+ rspec-core (~> 3.11.0)
44
+ rspec-expectations (~> 3.11.0)
45
+ rspec-mocks (~> 3.11.0)
46
+ rspec-core (3.11.0)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-expectations (3.11.0)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.11.0)
51
+ rspec-mocks (3.11.1)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.11.0)
54
+ rspec-support (3.11.0)
55
+ rubocop (1.35.1)
56
+ json (~> 2.3)
57
+ parallel (~> 1.10)
58
+ parser (>= 3.1.2.1)
59
+ rainbow (>= 2.2.2, < 4.0)
60
+ regexp_parser (>= 1.8, < 3.0)
61
+ rexml (>= 3.2.5, < 4.0)
62
+ rubocop-ast (>= 1.20.1, < 2.0)
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 1.4.0, < 3.0)
65
+ rubocop-ast (1.21.0)
66
+ parser (>= 3.1.1.0)
67
+ rubocop-performance (1.14.3)
68
+ rubocop (>= 1.7.0, < 2.0)
69
+ rubocop-ast (>= 0.4.0)
70
+ ruby-progressbar (1.11.0)
71
+ standard (1.16.1)
72
+ rubocop (= 1.35.1)
73
+ rubocop-performance (= 1.14.3)
74
+ thor (1.2.1)
75
+ thread_safe (0.3.6)
76
+ tty-color (0.6.0)
77
+ tty-command (0.10.1)
78
+ pastel (~> 0.8)
79
+ tzinfo (1.2.10)
80
+ thread_safe (~> 0.1)
81
+ unicode-display_width (2.2.0)
82
+ zeitwerk (2.6.0)
83
+
84
+ PLATFORMS
85
+ ruby
86
+ x86_64-darwin-21
87
+ x86_64-linux
88
+
89
+ DEPENDENCIES
90
+ activesupport (~> 6.0.0)
91
+ appraisal
92
+ credman!
93
+ rake (~> 13.0)
94
+ rspec (~> 3.0)
95
+ standard (~> 1.13)
96
+
97
+ BUNDLED WITH
98
+ 2.2.29
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 6.1.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ credman (0.0.5)
5
+ activesupport (>= 6.0)
6
+ dry-cli (~> 0.7)
7
+ hash_diff (~> 1.0)
8
+ pastel (~> 0.8)
9
+ tty-command (~> 0.10)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (6.1.5.1)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ zeitwerk (~> 2.3)
20
+ appraisal (2.4.1)
21
+ bundler
22
+ rake
23
+ thor (>= 0.14.0)
24
+ ast (2.4.2)
25
+ concurrent-ruby (1.1.10)
26
+ diff-lcs (1.5.0)
27
+ dry-cli (0.7.0)
28
+ hash_diff (1.1.1)
29
+ i18n (1.12.0)
30
+ concurrent-ruby (~> 1.0)
31
+ json (2.6.2)
32
+ minitest (5.16.3)
33
+ parallel (1.22.1)
34
+ parser (3.1.2.1)
35
+ ast (~> 2.4.1)
36
+ pastel (0.8.0)
37
+ tty-color (~> 0.5)
38
+ rainbow (3.1.1)
39
+ rake (13.0.6)
40
+ regexp_parser (2.5.0)
41
+ rexml (3.2.5)
42
+ rspec (3.11.0)
43
+ rspec-core (~> 3.11.0)
44
+ rspec-expectations (~> 3.11.0)
45
+ rspec-mocks (~> 3.11.0)
46
+ rspec-core (3.11.0)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-expectations (3.11.0)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.11.0)
51
+ rspec-mocks (3.11.1)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.11.0)
54
+ rspec-support (3.11.0)
55
+ rubocop (1.35.1)
56
+ json (~> 2.3)
57
+ parallel (~> 1.10)
58
+ parser (>= 3.1.2.1)
59
+ rainbow (>= 2.2.2, < 4.0)
60
+ regexp_parser (>= 1.8, < 3.0)
61
+ rexml (>= 3.2.5, < 4.0)
62
+ rubocop-ast (>= 1.20.1, < 2.0)
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 1.4.0, < 3.0)
65
+ rubocop-ast (1.21.0)
66
+ parser (>= 3.1.1.0)
67
+ rubocop-performance (1.14.3)
68
+ rubocop (>= 1.7.0, < 2.0)
69
+ rubocop-ast (>= 0.4.0)
70
+ ruby-progressbar (1.11.0)
71
+ standard (1.16.1)
72
+ rubocop (= 1.35.1)
73
+ rubocop-performance (= 1.14.3)
74
+ thor (1.2.1)
75
+ tty-color (0.6.0)
76
+ tty-command (0.10.1)
77
+ pastel (~> 0.8)
78
+ tzinfo (2.0.5)
79
+ concurrent-ruby (~> 1.0)
80
+ unicode-display_width (2.2.0)
81
+ zeitwerk (2.6.0)
82
+
83
+ PLATFORMS
84
+ ruby
85
+ x86_64-darwin-21
86
+ x86_64-linux
87
+
88
+ DEPENDENCIES
89
+ activesupport (~> 6.1.0)
90
+ appraisal
91
+ credman!
92
+ rake (~> 13.0)
93
+ rspec (~> 3.0)
94
+ standard (~> 1.13)
95
+
96
+ BUNDLED WITH
97
+ 2.2.29
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 7.0.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,95 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ credman (0.0.5)
5
+ activesupport (>= 6.0)
6
+ dry-cli (~> 0.7)
7
+ hash_diff (~> 1.0)
8
+ pastel (~> 0.8)
9
+ tty-command (~> 0.10)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (7.0.3.1)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ appraisal (2.4.1)
20
+ bundler
21
+ rake
22
+ thor (>= 0.14.0)
23
+ ast (2.4.2)
24
+ concurrent-ruby (1.1.10)
25
+ diff-lcs (1.5.0)
26
+ dry-cli (0.7.0)
27
+ hash_diff (1.1.1)
28
+ i18n (1.12.0)
29
+ concurrent-ruby (~> 1.0)
30
+ json (2.6.2)
31
+ minitest (5.16.3)
32
+ parallel (1.22.1)
33
+ parser (3.1.2.1)
34
+ ast (~> 2.4.1)
35
+ pastel (0.8.0)
36
+ tty-color (~> 0.5)
37
+ rainbow (3.1.1)
38
+ rake (13.0.6)
39
+ regexp_parser (2.5.0)
40
+ rexml (3.2.5)
41
+ rspec (3.11.0)
42
+ rspec-core (~> 3.11.0)
43
+ rspec-expectations (~> 3.11.0)
44
+ rspec-mocks (~> 3.11.0)
45
+ rspec-core (3.11.0)
46
+ rspec-support (~> 3.11.0)
47
+ rspec-expectations (3.11.0)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.11.0)
50
+ rspec-mocks (3.11.1)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.11.0)
53
+ rspec-support (3.11.0)
54
+ rubocop (1.35.1)
55
+ json (~> 2.3)
56
+ parallel (~> 1.10)
57
+ parser (>= 3.1.2.1)
58
+ rainbow (>= 2.2.2, < 4.0)
59
+ regexp_parser (>= 1.8, < 3.0)
60
+ rexml (>= 3.2.5, < 4.0)
61
+ rubocop-ast (>= 1.20.1, < 2.0)
62
+ ruby-progressbar (~> 1.7)
63
+ unicode-display_width (>= 1.4.0, < 3.0)
64
+ rubocop-ast (1.21.0)
65
+ parser (>= 3.1.1.0)
66
+ rubocop-performance (1.14.3)
67
+ rubocop (>= 1.7.0, < 2.0)
68
+ rubocop-ast (>= 0.4.0)
69
+ ruby-progressbar (1.11.0)
70
+ standard (1.16.1)
71
+ rubocop (= 1.35.1)
72
+ rubocop-performance (= 1.14.3)
73
+ thor (1.2.1)
74
+ tty-color (0.6.0)
75
+ tty-command (0.10.1)
76
+ pastel (~> 0.8)
77
+ tzinfo (2.0.5)
78
+ concurrent-ruby (~> 1.0)
79
+ unicode-display_width (2.2.0)
80
+
81
+ PLATFORMS
82
+ ruby
83
+ x86_64-darwin-21
84
+ x86_64-linux
85
+
86
+ DEPENDENCIES
87
+ activesupport (~> 7.0.0)
88
+ appraisal
89
+ credman!
90
+ rake (~> 13.0)
91
+ rspec (~> 3.0)
92
+ standard (~> 1.13)
93
+
94
+ BUNDLED WITH
95
+ 2.2.29
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", github: "rails/rails", branch: "main"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,103 @@
1
+ GIT
2
+ remote: https://github.com/rails/rails.git
3
+ revision: 9a439f633205af0800f34af32f2122150faa2767
4
+ branch: main
5
+ specs:
6
+ activesupport (7.1.0.alpha)
7
+ concurrent-ruby (~> 1.0, >= 1.0.2)
8
+ connection_pool (>= 2.2.5)
9
+ i18n (>= 1.6, < 2)
10
+ minitest (>= 5.1)
11
+ tzinfo (~> 2.0)
12
+
13
+ PATH
14
+ remote: ..
15
+ specs:
16
+ credman (0.0.5)
17
+ activesupport (>= 6.0)
18
+ dry-cli (~> 0.7)
19
+ hash_diff (~> 1.0)
20
+ pastel (~> 0.8)
21
+ tty-command (~> 0.10)
22
+
23
+ GEM
24
+ remote: https://rubygems.org/
25
+ specs:
26
+ appraisal (2.4.1)
27
+ bundler
28
+ rake
29
+ thor (>= 0.14.0)
30
+ ast (2.4.2)
31
+ concurrent-ruby (1.1.10)
32
+ connection_pool (2.2.5)
33
+ diff-lcs (1.5.0)
34
+ dry-cli (0.7.0)
35
+ hash_diff (1.1.1)
36
+ i18n (1.12.0)
37
+ concurrent-ruby (~> 1.0)
38
+ json (2.6.2)
39
+ minitest (5.16.3)
40
+ parallel (1.22.1)
41
+ parser (3.1.2.1)
42
+ ast (~> 2.4.1)
43
+ pastel (0.8.0)
44
+ tty-color (~> 0.5)
45
+ rainbow (3.1.1)
46
+ rake (13.0.6)
47
+ regexp_parser (2.5.0)
48
+ rexml (3.2.5)
49
+ rspec (3.11.0)
50
+ rspec-core (~> 3.11.0)
51
+ rspec-expectations (~> 3.11.0)
52
+ rspec-mocks (~> 3.11.0)
53
+ rspec-core (3.11.0)
54
+ rspec-support (~> 3.11.0)
55
+ rspec-expectations (3.11.0)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.11.0)
58
+ rspec-mocks (3.11.1)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.11.0)
61
+ rspec-support (3.11.0)
62
+ rubocop (1.35.1)
63
+ json (~> 2.3)
64
+ parallel (~> 1.10)
65
+ parser (>= 3.1.2.1)
66
+ rainbow (>= 2.2.2, < 4.0)
67
+ regexp_parser (>= 1.8, < 3.0)
68
+ rexml (>= 3.2.5, < 4.0)
69
+ rubocop-ast (>= 1.20.1, < 2.0)
70
+ ruby-progressbar (~> 1.7)
71
+ unicode-display_width (>= 1.4.0, < 3.0)
72
+ rubocop-ast (1.21.0)
73
+ parser (>= 3.1.1.0)
74
+ rubocop-performance (1.14.3)
75
+ rubocop (>= 1.7.0, < 2.0)
76
+ rubocop-ast (>= 0.4.0)
77
+ ruby-progressbar (1.11.0)
78
+ standard (1.16.1)
79
+ rubocop (= 1.35.1)
80
+ rubocop-performance (= 1.14.3)
81
+ thor (1.2.1)
82
+ tty-color (0.6.0)
83
+ tty-command (0.10.1)
84
+ pastel (~> 0.8)
85
+ tzinfo (2.0.5)
86
+ concurrent-ruby (~> 1.0)
87
+ unicode-display_width (2.2.0)
88
+
89
+ PLATFORMS
90
+ ruby
91
+ x86_64-darwin-21
92
+ x86_64-linux
93
+
94
+ DEPENDENCIES
95
+ activesupport!
96
+ appraisal
97
+ credman!
98
+ rake (~> 13.0)
99
+ rspec (~> 3.0)
100
+ standard (~> 1.13)
101
+
102
+ BUNDLED WITH
103
+ 2.2.29
data/lib/credman/base.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  module Credman
2
2
  class Base
3
- AVAILABLE_ENVIRONMENTS = %i[development test staging production].freeze
4
-
5
3
  def initialize(environment_list)
6
- @environment_list = environment_list.map(&:to_sym).keep_if { |env| env.to_sym.in?(AVAILABLE_ENVIRONMENTS) }
4
+ @environment_list = environment_list.keep_if { |env| env.in?(Credman.config.available_environments) }
7
5
  abort pastel.red("No valid environments specified. Valid example: `-e development,test`") if @environment_list.empty?
8
6
  end
9
7
 
@@ -9,7 +9,7 @@ module Credman
9
9
  option :environments,
10
10
  aliases: ["e"],
11
11
  type: :array,
12
- default: Credman::Base::AVAILABLE_ENVIRONMENTS,
12
+ default: Credman.config.available_environments,
13
13
  desc: "filter for environments"
14
14
 
15
15
  def call(keys:, environments:, **)
@@ -23,7 +23,7 @@ module Credman
23
23
  option :environments,
24
24
  aliases: ["e"],
25
25
  type: :array,
26
- default: Credman::Base::AVAILABLE_ENVIRONMENTS,
26
+ default: Credman.config.available_environments,
27
27
  desc: "filter for environments"
28
28
 
29
29
  def call(environments:, **)
@@ -48,15 +48,31 @@ module Credman
48
48
  end
49
49
  end
50
50
 
51
+ class Delete < Dry::CLI::Command
52
+ desc "Delete keys for given environments"
53
+
54
+ argument :keys, type: :array, required: true, desc: "keys to delete"
55
+
56
+ option :environments,
57
+ aliases: ["e"],
58
+ type: :array,
59
+ default: [],
60
+ desc: "filter for environments"
61
+
62
+ def call(keys:, environments:, **)
63
+ Credman::Delete.new(environments).perform(keys)
64
+ end
65
+ end
66
+
51
67
  class Diff < Dry::CLI::Command
52
68
  desc "Show credentials diff between given branch (heroku by default) and current changes"
53
69
 
54
- argument :branch, type: :string, default: "heroku", required: false
70
+ argument :branch, type: :string, default: Credman.config.default_diff_branch, required: false
55
71
 
56
72
  option :environments,
57
73
  aliases: ["e"],
58
74
  type: :array,
59
- default: Credman::Base::AVAILABLE_ENVIRONMENTS,
75
+ default: Credman.config.available_environments,
60
76
  desc: "filter for environments"
61
77
 
62
78
  def call(branch:, environments:, **)
@@ -70,7 +86,7 @@ module Credman
70
86
  option :environments,
71
87
  aliases: ["e"],
72
88
  type: :array,
73
- default: Credman::Base::AVAILABLE_ENVIRONMENTS,
89
+ default: Credman.config.available_environments,
74
90
  desc: "filter for environments"
75
91
 
76
92
  def call(environments:, **)
@@ -0,0 +1,42 @@
1
+ require "yaml"
2
+
3
+ module Credman
4
+ class Configuration
5
+ include Singleton
6
+
7
+ attr_writer :settings_list
8
+
9
+ def self.add_setting(name, default_value = nil)
10
+ attr_accessor name
11
+ instance.send("#{name}=", default_value)
12
+ instance.settings_list = instance.settings_list.push(name.to_sym)
13
+ end
14
+
15
+ def self.reset
16
+ load __FILE__
17
+ self
18
+ end
19
+
20
+ def settings_list
21
+ @settings_list ||= []
22
+ end
23
+
24
+ def setting_exists?(setting_name)
25
+ settings_list.include?(setting_name)
26
+ end
27
+
28
+ def load_from_yml(config_path = "config/credman.yml")
29
+ return unless File.exist?(config_path)
30
+
31
+ settings = YAML.load_file(config_path)
32
+ return unless settings
33
+
34
+ settings.each do |setting_name, setting_value|
35
+ send("#{setting_name}=", setting_value) if setting_exists?(setting_name.to_sym)
36
+ end
37
+ end
38
+
39
+ add_setting :default_diff_branch, "main"
40
+ add_setting :available_environments, %w[development test production]
41
+ end
42
+ end
@@ -43,9 +43,7 @@ module Credman
43
43
  end
44
44
 
45
45
  def deserialize(raw_config)
46
- # rubocop:disable Security/YAMLLoad
47
- YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(raw_config) : YAML.load(raw_config)
48
- # rubocop:enable Security/YAMLLoad
46
+ YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(raw_config) : YAML.safe_load(raw_config)
49
47
  end
50
48
 
51
49
  def deep_print_diff(diff, key_path = [])
@@ -0,0 +1,56 @@
1
+ module Credman
2
+ class Delete < Credman::Base
3
+ def perform(keys)
4
+ abort pastel.red("At least one key required") if keys.empty?
5
+
6
+ configs.each do |env, config|
7
+ puts pastel.green("#{env}:")
8
+
9
+ updated_config = config.dup
10
+ is_updated = false
11
+
12
+ keys_with_path = keys.index_with { |key| key.split(".").map(&:to_sym) }
13
+ keys_with_path.each do |full_key, key_path|
14
+ if config_has_keys?(config, key_path)
15
+ is_updated ||= true
16
+ deep_delete!(updated_config, key_path)
17
+ print pastel.blue("\t#{full_key}:\t"), pastel.green("✅ deleted\n")
18
+ else
19
+ print pastel.blue("\t#{full_key}:\t"), pastel.red("❌ key not found, can't delete\n")
20
+ end
21
+ end
22
+
23
+ if is_updated
24
+ # removes "---\n" in the very beginning
25
+ config_as_string = updated_config.deep_stringify_keys.to_yaml[4..]
26
+ rewrite_config_for(env, config_as_string)
27
+ end
28
+ end
29
+ end
30
+
31
+ def rewrite_config_for(environment, new_config)
32
+ ActiveSupport::EncryptedConfiguration.new(
33
+ config_path: "config/credentials/#{environment}.yml.enc",
34
+ key_path: "config/credentials/#{environment}.key",
35
+ env_key: "RAILS_MASTER_KEY",
36
+ raise_if_missing_key: true
37
+ ).write(new_config)
38
+ end
39
+
40
+ def deep_delete!(obj, keys)
41
+ key = keys.first
42
+ if keys.length == 1
43
+ obj.delete(key)
44
+ else
45
+ obj[key] = {} unless obj[key]
46
+ deep_delete!(obj[key], keys.slice(1..-1))
47
+ end
48
+ end
49
+
50
+ def normalize_new_value(new_value)
51
+ return if new_value.in?(%w[nil null])
52
+
53
+ new_value
54
+ end
55
+ end
56
+ end
data/lib/credman/diff.rb CHANGED
@@ -37,9 +37,7 @@ module Credman
37
37
  end
38
38
 
39
39
  def deserialize(raw_config)
40
- # rubocop:disable Security/YAMLLoad
41
- YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(raw_config) : YAML.load(raw_config)
42
- # rubocop:enable Security/YAMLLoad
40
+ YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(raw_config) : YAML.safe_load(raw_config)
43
41
  end
44
42
 
45
43
  def deep_print_diff(diff, key_path = [])
data/lib/credman/list.rb CHANGED
@@ -5,7 +5,14 @@ module Credman
5
5
  puts pastel.green("#{env}:")
6
6
 
7
7
  config.each do |key, value|
8
- deep_print_key_and_value(value, [key])
8
+ if value.is_a?(Hash)
9
+ key_path = [key]
10
+ else
11
+ value = {key => value}
12
+ key_path = []
13
+ end
14
+
15
+ deep_print_key_and_value(value, key_path)
9
16
  end
10
17
  end
11
18
  end
@@ -1,3 +1,3 @@
1
1
  module Credman
2
- VERSION = "0.0.2-alpha".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
data/lib/credman.rb CHANGED
@@ -5,11 +5,21 @@ require "dry/cli"
5
5
  require "pastel"
6
6
  require "hash_diff"
7
7
 
8
+ require_relative "credman/configuration"
9
+ module Credman
10
+ def self.configuration
11
+ Credman::Configuration.instance
12
+ end
13
+ singleton_class.send(:alias_method, :config, :configuration)
14
+ end
15
+ Credman.configuration.load_from_yml
16
+
8
17
  require_relative "credman/base"
9
18
  require_relative "credman/commands"
10
19
  require_relative "credman/get"
11
20
  require_relative "credman/list"
12
21
  require_relative "credman/set"
22
+ require_relative "credman/delete"
13
23
  require_relative "credman/diff"
14
24
  require_relative "credman/conflicts"
15
25
  require_relative "credman/version"
@@ -22,6 +32,7 @@ module Credman
22
32
  register "get", Get
23
33
  register "list", List
24
34
  register "set", Set
35
+ register "delete", Delete
25
36
  register "diff", Diff
26
37
  register "conflicts", Conflicts
27
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.pre.alpha
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Andronov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '13.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rspec
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '1.13'
125
+ - !ruby/object:Gem::Dependency
126
+ name: appraisal
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  description: The tool what you miss for managing Rails credentials
112
140
  email:
113
141
  - dev@uscreen.tv
@@ -118,6 +146,7 @@ extra_rdoc_files: []
118
146
  files:
119
147
  - ".rspec"
120
148
  - ".vscode/settings.json"
149
+ - Appraisals
121
150
  - CHANGELOG.md
122
151
  - Gemfile
123
152
  - Gemfile.lock
@@ -126,12 +155,25 @@ files:
126
155
  - Rakefile
127
156
  - bin/console
128
157
  - bin/credman
158
+ - bin/rspec
129
159
  - bin/setup
160
+ - config/credman.yml
130
161
  - credman.gemspec
162
+ - gemfiles/.bundle/config
163
+ - gemfiles/activesupport_6.gemfile
164
+ - gemfiles/activesupport_6.gemfile.lock
165
+ - gemfiles/activesupport_6_1.gemfile
166
+ - gemfiles/activesupport_6_1.gemfile.lock
167
+ - gemfiles/activesupport_7.gemfile
168
+ - gemfiles/activesupport_7.gemfile.lock
169
+ - gemfiles/activesupport_master.gemfile
170
+ - gemfiles/activesupport_master.gemfile.lock
131
171
  - lib/credman.rb
132
172
  - lib/credman/base.rb
133
173
  - lib/credman/commands.rb
174
+ - lib/credman/configuration.rb
134
175
  - lib/credman/conflicts.rb
176
+ - lib/credman/delete.rb
135
177
  - lib/credman/diff.rb
136
178
  - lib/credman/get.rb
137
179
  - lib/credman/list.rb
@@ -155,9 +197,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
197
  version: 2.7.0
156
198
  required_rubygems_version: !ruby/object:Gem::Requirement
157
199
  requirements:
158
- - - ">"
200
+ - - ">="
159
201
  - !ruby/object:Gem::Version
160
- version: 1.3.1
202
+ version: '0'
161
203
  requirements: []
162
204
  rubygems_version: 3.1.6
163
205
  signing_key: