capistrano3-env 0.1.0
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 +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +52 -0
- data/Rakefile +1 -0
- data/bin/cap-env +18 -0
- data/capistrano3-env.gemspec +21 -0
- data/lib/capistrano/env.rb +2 -0
- data/lib/capistrano/tasks/env.rake +89 -0
- data/lib/capistrano3-env.rb +0 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 524b3c098df722042a4254e332e1e580a14f9afa
|
4
|
+
data.tar.gz: 4a33aedb2d3bec236f04d56e49a23747fdff036c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8abba5f21ff0fba8616ef595a3189ff2b7c7f58f70a690d8cb0231f48250940f50ad90062e61dffc69c70eab08b121dd03a0f35bf09d423c331776ade0e76ce
|
7
|
+
data.tar.gz: 175e55a0cc994bd71856e2e78e75d3ec155816fb0ad338f6024f50a76bdfe3bbcec0d93466f053ff54949d6b83b150ed5dd59be0589a645a47a26c8ab096ac07
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013, Miguel Palhas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Capistrano 3 Configuration Management
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add the gem to your Gemfile
|
6
|
+
|
7
|
+
gem 'capistrano-doenv', '~> 0.1.0'
|
8
|
+
|
9
|
+
Run `bundle` to update your `Gemfile.lock`
|
10
|
+
Add the following to your `Capfile`:
|
11
|
+
|
12
|
+
require 'capistrano/env'
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Rake (which is used by Capistrano) has a not so pratical way of specifying task
|
17
|
+
arguments. To alleviate that issue, a small custom executable was made:
|
18
|
+
|
19
|
+
bundle exec cap-config [stage] [operation] [KEY] [VALUE]
|
20
|
+
|
21
|
+
The possible use cases are the following:
|
22
|
+
|
23
|
+
cap-env production get # shows the current env file for
|
24
|
+
production
|
25
|
+
cap-env production set APP_ID 123456 # sets KEY=value
|
26
|
+
cap-env production get APP_ID # shows the current value of KEY
|
27
|
+
cap-env production delete APP_ID # deletes the given KEY
|
28
|
+
|
29
|
+
Alternatively, you can use the underlying Capistrano tasks directly with `cap
|
30
|
+
production TASK`, where `TASK` is one of the following:
|
31
|
+
|
32
|
+
env:get # shows the current env file
|
33
|
+
env:get[KEY] # KEY # shows the current value of KEY from the env file
|
34
|
+
env:set[KEY,value] # sets KEY=value in the env file
|
35
|
+
env:delete[KEY] # deletes the given KEY
|
36
|
+
|
37
|
+
|
38
|
+
## Configuration
|
39
|
+
|
40
|
+
The following configurations are available to you in config/deploy.rb (default
|
41
|
+
values are shown here, no need to set them)
|
42
|
+
|
43
|
+
set :config_backend, :dotenv # currently this is the only supported backend
|
44
|
+
set :config_file, '.env' # you might want to use .env.production instead
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/cap-env
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
stage, cmd, key, value = ARGV
|
4
|
+
|
5
|
+
args = case cmd
|
6
|
+
when /create/ then nil
|
7
|
+
when /get|delete/ then key
|
8
|
+
when /set/ then "#{key},#{value}"
|
9
|
+
end
|
10
|
+
|
11
|
+
args = "[#{args}]" if args
|
12
|
+
task = "env:#{cmd}#{args}"
|
13
|
+
|
14
|
+
require 'capistrano/all'
|
15
|
+
ARGV.clear
|
16
|
+
ARGV << stage
|
17
|
+
ARGV << task
|
18
|
+
Capistrano::Application.new.run
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "capistrano3-env"
|
7
|
+
gem.version = '0.1.0'
|
8
|
+
gem.authors = ["Miguel Palhas"]
|
9
|
+
gem.email = ["mpalhas@gmail.com"]
|
10
|
+
gem.description = %q{Environment variables management for Capistrano 3}
|
11
|
+
gem.summary = %q{Environment variables management for Capistrano 3}
|
12
|
+
gem.homepage = "https://github.com/naps62/capistrano-env"
|
13
|
+
gem.licenses = ['MIT']
|
14
|
+
gem.executables << 'cap-env'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'capistrano', '~> 3.1'
|
21
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
namespace :env do
|
2
|
+
|
3
|
+
task :create do
|
4
|
+
on roles :app do
|
5
|
+
backend.create
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Shows the current dotenv configuration (optional argument specifies a single key to show)'
|
10
|
+
task :get, [:key] do |task, args|
|
11
|
+
on roles :app do
|
12
|
+
config = backend.read
|
13
|
+
if args[:key]
|
14
|
+
config = { args[:key] => config[args[:key]] }
|
15
|
+
end
|
16
|
+
config.each do |key, val|
|
17
|
+
puts "#{key}: #{val}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Sets a dotenv key to a value'
|
23
|
+
task :set, [:key, :val] do |task, args|
|
24
|
+
on roles :app do
|
25
|
+
config = backend.read
|
26
|
+
config[args[:key]] = args[:val]
|
27
|
+
backend.write(config)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Deletes a key from the dotenv file'
|
32
|
+
task :delete, [:key] do |task, args|
|
33
|
+
on roles :app do
|
34
|
+
config = backend.read
|
35
|
+
config.delete args[:key] if args[:key]
|
36
|
+
backend.write(config)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def backend
|
41
|
+
# TODO make this generic
|
42
|
+
Capistrano::Env::Backend::Dotenv.new(self)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :load do
|
47
|
+
task :defaults do
|
48
|
+
set :config_backend, :dotenv
|
49
|
+
set :config_file, '.env'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
module Capistrano
|
54
|
+
module Env
|
55
|
+
module Backend
|
56
|
+
class Dotenv
|
57
|
+
def initialize(context)
|
58
|
+
@context = context
|
59
|
+
end
|
60
|
+
|
61
|
+
def create
|
62
|
+
@context.execute :touch, filename
|
63
|
+
end
|
64
|
+
|
65
|
+
def read
|
66
|
+
hashify(@context.capture :cat, filename)
|
67
|
+
end
|
68
|
+
|
69
|
+
def write(values)
|
70
|
+
@context.execute :echo, "\"#{stringify(values)}\"", '>', filename
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def filename
|
76
|
+
Pathname(shared_path).join(fetch(:config_file))
|
77
|
+
end
|
78
|
+
|
79
|
+
def hashify(string)
|
80
|
+
Hash[string.split("\n").map {|val| val.split(/:|\n/).map(&:strip) }]
|
81
|
+
end
|
82
|
+
|
83
|
+
def stringify(values)
|
84
|
+
values.map { |key, val| "#{key}: #{val}" }.join("\n")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano3-env
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Miguel Palhas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
description: Environment variables management for Capistrano 3
|
28
|
+
email:
|
29
|
+
- mpalhas@gmail.com
|
30
|
+
executables:
|
31
|
+
- cap-env
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- bin/cap-env
|
41
|
+
- capistrano3-env.gemspec
|
42
|
+
- lib/capistrano/env.rb
|
43
|
+
- lib/capistrano/tasks/env.rake
|
44
|
+
- lib/capistrano3-env.rb
|
45
|
+
homepage: https://github.com/naps62/capistrano-env
|
46
|
+
licenses:
|
47
|
+
- MIT
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 2.1.11
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: Environment variables management for Capistrano 3
|
69
|
+
test_files: []
|
70
|
+
has_rdoc:
|