rails-credentials-git 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +5 -2
- data/README.md +1 -1
- data/bin/console +15 -0
- data/lib/rails-credentials-git/cli.rb +1 -1
- data/lib/rails-credentials-git/templates/enc +48 -0
- data/lib/rails-credentials-git/version.rb +1 -1
- data/rails-credentials-git.gemspec +1 -1
- metadata +4 -3
- data/Gemfile.lock +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2745a47b6cb5e3f79f47c495fb82e1a768635c85955dd6bb9d303e5e8df5a906
|
4
|
+
data.tar.gz: 874beed8043efa141cc8f1587812c6c7b3c8fe2faf70c46e6f7b3ebb59245c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbcec101574290dd577f0b74532b65ec9cf61b5e18253ae229eed74320543dae480774af2577b6d41f03e566eef711661a9bc5818a61a46eb0546326e5a93ed2
|
7
|
+
data.tar.gz: 76c44df99a4d80ab7cfa6a29048a9f70363c5da19657a736775bf527677586394597157e8c641a5d952c1d3905b672613c9d2b833729a6edb13a729a3e632196
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
|
+
dist: bionic
|
3
4
|
env:
|
4
5
|
- "RAILS_VERSION=5.2.0"
|
5
6
|
- "RAILS_VERSION=6.0.0"
|
@@ -9,5 +10,7 @@ rvm:
|
|
9
10
|
- 3.0.2
|
10
11
|
before_install:
|
11
12
|
- gem update bundler
|
12
|
-
|
13
|
-
|
13
|
+
jobs:
|
14
|
+
exclude:
|
15
|
+
- rvm: 3.0.2
|
16
|
+
env: "RAILS_VERSION=5.2.0"
|
data/README.md
CHANGED
@@ -61,7 +61,7 @@ bin/enc --conflict # with RAILS_MASTER_KEY set if you need to
|
|
61
61
|
|
62
62
|
## Development
|
63
63
|
|
64
|
-
After checking out the repo, run `
|
64
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests.
|
65
65
|
|
66
66
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
67
67
|
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "rails-credentials-git"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
@@ -10,7 +10,7 @@ module RailsCredentialsGit
|
|
10
10
|
|
11
11
|
desc "install", "Copy binary into project's folder"
|
12
12
|
def install
|
13
|
-
copy_file "
|
13
|
+
copy_file "lib/rails-credentials-git/templates/enc", "bin/enc", mode: :preserve
|
14
14
|
|
15
15
|
method = RailsCredentialsGit.decrypt_method.sub("self.", "")
|
16
16
|
insert_into_file "bin/enc", "\n#{method}" , after: %{require "openssl"\n}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "optparse"
|
5
|
+
require "base64"
|
6
|
+
require "openssl"
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: enc [options] <encryped_file>"
|
11
|
+
|
12
|
+
opts.on('-k', '--key-path', 'Path to master key') do |path|
|
13
|
+
options[:key_path] = path
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.on("--conflict") do
|
17
|
+
options[:conflict] = true
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on("--compare=BRANCH") do |branch|
|
21
|
+
options[:compare] = branch
|
22
|
+
end
|
23
|
+
end.parse!
|
24
|
+
|
25
|
+
key = ENV["RAILS_MASTER_KEY"]
|
26
|
+
|
27
|
+
unless key
|
28
|
+
path = options[:key_path] || File.expand_path("../config/master.key", __dir__)
|
29
|
+
key = File.read(path).strip
|
30
|
+
end
|
31
|
+
|
32
|
+
if options.empty?
|
33
|
+
content_file = ARGV.empty? ? File.expand_path("../config/credentials.yml.enc", __dir__) : ARGV[0]
|
34
|
+
content = File.read(content_file)
|
35
|
+
puts decrypt(content, key)
|
36
|
+
else
|
37
|
+
require "open3"
|
38
|
+
|
39
|
+
stdout, _, _ = if (target = options[:compare])
|
40
|
+
Open3.capture3("git diff --color #{target}:config/credentials.yml.enc HEAD:config/credentials.yml.enc")
|
41
|
+
else
|
42
|
+
target = File.exist?(File.expand_path("../.git/REBASE_HEAD", __dir__)) ? "REBASE_HEAD" : "MERGE_HEAD"
|
43
|
+
Open3.capture3("git diff --color HEAD:config/credentials.yml.enc #{target}:config/credentials.yml.enc")
|
44
|
+
end
|
45
|
+
|
46
|
+
stdout = "Nothing changed" if stdout.empty?
|
47
|
+
puts stdout
|
48
|
+
end
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
23
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test)/}) }
|
25
25
|
end
|
26
26
|
spec.bindir = "bin"
|
27
27
|
spec.executables = ["rails_credentials_git"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-credentials-git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ccocchi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -104,13 +104,14 @@ files:
|
|
104
104
|
- ".travis.yml"
|
105
105
|
- CODE_OF_CONDUCT.md
|
106
106
|
- Gemfile
|
107
|
-
- Gemfile.lock
|
108
107
|
- LICENSE.txt
|
109
108
|
- README.md
|
110
109
|
- Rakefile
|
110
|
+
- bin/console
|
111
111
|
- bin/rails_credentials_git
|
112
112
|
- lib/rails-credentials-git.rb
|
113
113
|
- lib/rails-credentials-git/cli.rb
|
114
|
+
- lib/rails-credentials-git/templates/enc
|
114
115
|
- lib/rails-credentials-git/version.rb
|
115
116
|
- rails-credentials-git.gemspec
|
116
117
|
homepage: https://github.com/ccocchi/rails-credentials-git
|
data/Gemfile.lock
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rails-credentials-git (0.1.0)
|
5
|
-
thor (> 0.19, < 2)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activesupport (5.2.6)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>= 0.7, < 2)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
concurrent-ruby (1.1.9)
|
16
|
-
i18n (1.8.10)
|
17
|
-
concurrent-ruby (~> 1.0)
|
18
|
-
minitest (5.14.4)
|
19
|
-
rake (13.0.6)
|
20
|
-
thor (1.0.1)
|
21
|
-
thread_safe (0.3.6)
|
22
|
-
tzinfo (1.2.9)
|
23
|
-
thread_safe (~> 0.1)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
universal-darwin-19
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
activesupport (~> 5.2.0)
|
30
|
-
bundler (~> 2.2.5)
|
31
|
-
minitest (~> 5.0)
|
32
|
-
rails-credentials-git!
|
33
|
-
rake (~> 13.0)
|
34
|
-
|
35
|
-
BUNDLED WITH
|
36
|
-
2.2.5
|