mina-proteus 0.5.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 +1 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +88 -0
- data/Rakefile +1 -0
- data/lib/mina/proteus.rb +123 -0
- data/lib/mina/proteus/version.rb +5 -0
- data/mina_proteus.gemspec +24 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5fb55d1a708f4fec34cd44a2938a15e4db82f78024350776a4b80113dbe54fd1
|
4
|
+
data.tar.gz: 44f0b32ef4b148d2b8362d5541a636e4265773048fb8682e553dc0d277b45d62
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32c09980fc70e5d642b97a9b66e47d72c391e5f2786cf629f58801d862e1d792a17a0d8ca0d4e5056971845d48bb9ace166c64f152a208851e639097e81d957f
|
7
|
+
data.tar.gz: 6766a35f50ad165d009619a221f662c02d01004de19f9c63f7a82741673f3bdb84eb36eac00288c4453d368ef333de942eb580b8707d513112e6d42ed219a599
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 apontini
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
[](http://badge.fury.io/rb/mina-multistage)
|
2
|
+
|
3
|
+
# Mina::Proteus
|
4
|
+
|
5
|
+
Plugin for Mina that adds support for multiple stages and multiple apps to Mina, specifically built for Hanami ruby framework.
|
6
|
+
This gem is based on [endoze's mina-multistage gem](https://github.com/endoze/mina-multistage), huge thanks to him!
|
7
|
+
|
8
|
+
## Installation & Usage
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```rb
|
13
|
+
gem 'mina-proteus', require: false
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
```shell
|
19
|
+
$ bundle install
|
20
|
+
```
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
```shell
|
25
|
+
$ gem install mina-proteus
|
26
|
+
```
|
27
|
+
|
28
|
+
Require `mina/proteus` in your `config/deploy.rb`:
|
29
|
+
|
30
|
+
```rb
|
31
|
+
require 'mina/proteus'
|
32
|
+
require 'mina/bundler'
|
33
|
+
require 'mina/git'
|
34
|
+
|
35
|
+
...
|
36
|
+
|
37
|
+
task setup: do
|
38
|
+
...
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Deploys the current version to the server.'
|
42
|
+
task deploy: do
|
43
|
+
...
|
44
|
+
end
|
45
|
+
```
|
46
|
+
You then need to specify your hanami apps like this:
|
47
|
+
|
48
|
+
```rb
|
49
|
+
set :hanami_apps, %w(app1 app2 app3)
|
50
|
+
```
|
51
|
+
|
52
|
+
That's the only required parameter, optional parameters are:
|
53
|
+
|
54
|
+
```rb
|
55
|
+
# config/deploy.rb
|
56
|
+
|
57
|
+
set :stages, %w(staging production) #specify your stages
|
58
|
+
set :stages_dir, 'config/deploy' #specify which directory will have all the configurations files
|
59
|
+
set :default_stage, 'staging' #specify your default stage
|
60
|
+
|
61
|
+
set :bundle_prefix, -> { %{HANAMI_ENV="#{fetch(:current_stage)}" HANAMI_APPS="#{fetch(:current_app)}" #{fetch(:bundle_bin)} exec} } #used to deploy a single application in a specific environment
|
62
|
+
```
|
63
|
+
|
64
|
+
Then to create every file run:
|
65
|
+
|
66
|
+
```shell
|
67
|
+
$ bundle exec mina proteus:init
|
68
|
+
```
|
69
|
+
|
70
|
+
This will create `config/deploy/staging.rb` and `config/deploy/production.rb` stage files and
|
71
|
+
`config/deploy/staging/app1.rb`, `config/deploy/staging/app1.rb`, etc.
|
72
|
+
Use them to define stage and app specific configuration.
|
73
|
+
|
74
|
+
Now you can deploy the default stage with:
|
75
|
+
|
76
|
+
```shell
|
77
|
+
$ mina <APP-NAME> deploy # this deploys staging by default
|
78
|
+
```
|
79
|
+
|
80
|
+
Or specify a stage explicitly:
|
81
|
+
|
82
|
+
```shell
|
83
|
+
$ mina staging <APP-NAME> deploy
|
84
|
+
$ mina production <APP-NAME> deploy
|
85
|
+
```
|
86
|
+
|
87
|
+
## Maintenance
|
88
|
+
I'll be rearely maintaining this gem due to lack of time, if you want to contibute feel free to fork it, branch it and then create a pull request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/mina/proteus.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
|
2
|
+
def _default_stage
|
3
|
+
fetch(:default_stage, 'staging')
|
4
|
+
end
|
5
|
+
|
6
|
+
def _default_stages
|
7
|
+
fetch(:stages, %w(staging production))
|
8
|
+
end
|
9
|
+
|
10
|
+
def _stages_dir
|
11
|
+
fetch(:stages_dir, 'config/deploy')
|
12
|
+
end
|
13
|
+
|
14
|
+
def _all_stages_empty?
|
15
|
+
!fetch(:all_stages, nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
def _file_for_stage(stage_name)
|
19
|
+
File.join(_stages_dir, "#{stage_name}.rb")
|
20
|
+
end
|
21
|
+
|
22
|
+
def _stage_file_exists?(stage_name)
|
23
|
+
File.exists?(File.expand_path(_file_for_stage(stage_name)))
|
24
|
+
end
|
25
|
+
|
26
|
+
def _get_all_stages
|
27
|
+
Dir["#{_stages_dir}/*.rb"].reduce([]) { |all_stages, file| all_stages << File.basename(file, '.rb') }
|
28
|
+
end
|
29
|
+
|
30
|
+
def _default_apps
|
31
|
+
fetch(:hanami_apps)
|
32
|
+
end
|
33
|
+
|
34
|
+
def _get_all_apps
|
35
|
+
apps = []
|
36
|
+
_get_all_stages.each do |stage|
|
37
|
+
apps << Dir["#{_stages_dir}/#{stage}/*.rb"].reject{ |file| File.basename(file, '.rb') == stage }.reduce([]) { |all_apps, file| all_apps << File.basename(file, '.rb') }
|
38
|
+
end
|
39
|
+
apps.flatten.uniq
|
40
|
+
end
|
41
|
+
|
42
|
+
def _apps_empty?
|
43
|
+
!fetch(:all_apps, nil)
|
44
|
+
end
|
45
|
+
|
46
|
+
def _app_file_in_stage_exists?(stage_name, app_name)
|
47
|
+
File.exists?(File.join(_stages_dir, stage_name, "#{app_name}.rb"))
|
48
|
+
end
|
49
|
+
|
50
|
+
def _file_for_app_in_stage(stage_name, app_name)
|
51
|
+
File.join(_stages_dir, stage_name, "#{app_name}.rb")
|
52
|
+
end
|
53
|
+
|
54
|
+
def _argument_included_in_stages?(arg)
|
55
|
+
fetch(:all_stages).include?(arg)
|
56
|
+
end
|
57
|
+
|
58
|
+
set :all_stages, _get_all_stages if _all_stages_empty?
|
59
|
+
set :all_apps, _get_all_apps if _apps_empty?
|
60
|
+
|
61
|
+
fetch(:all_stages).each do |stage_name|
|
62
|
+
desc "Set the target stage to '#{stage_name}'."
|
63
|
+
task(stage_name) do
|
64
|
+
set :current_stage, stage_name
|
65
|
+
file = "#{_stages_dir}/#{fetch(:current_stage)}.rb"
|
66
|
+
load file
|
67
|
+
end
|
68
|
+
|
69
|
+
fetch(:all_apps).each do |app_name|
|
70
|
+
desc "Set the target app to '#{app_name}'."
|
71
|
+
task(app_name) do
|
72
|
+
set :current_app, app_name
|
73
|
+
file = "#{_stages_dir}/#{fetch(:current_stage)}/#{fetch(:current_app)}.rb"
|
74
|
+
load file
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
_potential_stage = ARGV.first
|
80
|
+
|
81
|
+
if _stage_file_exists?(_potential_stage) && _argument_included_in_stages?(_potential_stage)
|
82
|
+
invoke _potential_stage
|
83
|
+
elsif _stage_file_exists?(_default_stage)
|
84
|
+
invoke _default_stage
|
85
|
+
end
|
86
|
+
|
87
|
+
namespace :proteus do
|
88
|
+
desc 'Create stage and apps files'
|
89
|
+
task :init do
|
90
|
+
ensure!(:hanami_apps)
|
91
|
+
FileUtils.mkdir_p _stages_dir if !File.exists? _stages_dir
|
92
|
+
_default_stages.each do |stage|
|
93
|
+
FileUtils.mkdir_p File.join(_stages_dir, stage) if !File.exists? File.join(_stages_dir, stage)
|
94
|
+
stagefile = _file_for_stage(stage)
|
95
|
+
if !_stage_file_exists?(stage)
|
96
|
+
puts "Creating #{stagefile}"
|
97
|
+
File.open(stagefile, 'w') do |f|
|
98
|
+
f.puts "set :hanami_env, '#{stage}'"
|
99
|
+
f.puts "set :rack_env, 'fetch(:hanami_env)'"
|
100
|
+
f.puts "set :domain, '127.0.0.1'"
|
101
|
+
f.puts "set :repository, 'username@repo.com:project/project.git'"
|
102
|
+
f.puts "set :branch, 'tree_branch'"
|
103
|
+
f.puts "set :user, 'your_user'"
|
104
|
+
end
|
105
|
+
else
|
106
|
+
puts "Skipping #{stagefile}, it already exists"
|
107
|
+
end
|
108
|
+
|
109
|
+
_default_apps.each do |app|
|
110
|
+
appfile = _file_for_app_in_stage(stage, app)
|
111
|
+
if !_app_file_in_stage_exists?(stage, app)
|
112
|
+
puts " Creating #{appfile}"
|
113
|
+
File.open(appfile, 'w') do |f|
|
114
|
+
f.puts "set :deploy_to, '/your/remote/dir'"
|
115
|
+
f.puts "set :hanami_app, '#{app}'"
|
116
|
+
end
|
117
|
+
else
|
118
|
+
puts " Skipping #{appfile}, it already exists"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mina/proteus/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mina-proteus"
|
8
|
+
spec.version = Mina::Multistage::VERSION
|
9
|
+
spec.authors = ["apontini"]
|
10
|
+
spec.email = ["alberto.pontini@gmail.com"]
|
11
|
+
spec.description = %q{Adds multistage and multiapps capabilities to Mina, specifically built for Hanami ruby framework}
|
12
|
+
spec.summary = %q{Adds multistage and multiapps capabilities to Mina, specifically built for Hanami ruby framework}
|
13
|
+
spec.homepage = "http://github.com/apontini/mina-proteus"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "mina", "~> 1.0"
|
22
|
+
spec.add_development_dependency "bundler", ">= 1.3.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mina-proteus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- apontini
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mina
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.3.5
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.5
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Adds multistage and multiapps capabilities to Mina, specifically built
|
56
|
+
for Hanami ruby framework
|
57
|
+
email:
|
58
|
+
- alberto.pontini@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/mina/proteus.rb
|
69
|
+
- lib/mina/proteus/version.rb
|
70
|
+
- mina_proteus.gemspec
|
71
|
+
homepage: http://github.com/apontini/mina-proteus
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.7.6
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Adds multistage and multiapps capabilities to Mina, specifically built for
|
95
|
+
Hanami ruby framework
|
96
|
+
test_files: []
|