devup 0.3.3 → 0.5.1
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 +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +28 -25
- data/README.md +37 -8
- data/devup.gemspec +2 -1
- data/docker-compose.devup.yml +3 -0
- data/exe/devup +2 -13
- data/lib/devup.rb +4 -2
- data/lib/devup/boot.rb +10 -12
- data/lib/devup/cli.rb +22 -0
- data/lib/devup/cli/commands/command.rb +38 -0
- data/lib/devup/cli/commands/down.rb +17 -0
- data/lib/devup/cli/commands/up.rb +33 -0
- data/lib/devup/compose.rb +13 -3
- data/lib/devup/dotenv.rb +15 -1
- data/lib/devup/dotenv_load_list.rb +35 -0
- data/lib/devup/environment.rb +1 -0
- data/lib/devup/service.rb +1 -1
- data/lib/devup/service_presenter.rb +1 -1
- data/lib/devup/version.rb +1 -1
- metadata +23 -5
- data/lefthook.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d01ca2f4289ff4e43debcf48281affb38e3a81a108e1404206a00c41585fc77f
|
4
|
+
data.tar.gz: '08befd6589ddd7f58728659dca4f852a207a976aadb80728a68cfa461f49e8c5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9302d63bdf377844ee4dd4928ebb8d57a3a509c339aa1ae9374f4fb8bcf6f45506cd64f3bfde46341dfcab74c1af722c417dd7117adc39abf9eb79495bee7a6
|
7
|
+
data.tar.gz: 07f6b96af54b5fe8338935c287a3b380a5ac20c05a15686ab782f0c7dc77ca2213518b5c2f32145cfbcfe237695c52327f65f5512bf81cefbd0f17365517455e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.5.8
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
devup (0.
|
4
|
+
devup (0.5.1)
|
5
5
|
dotenv
|
6
|
+
dry-cli
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
ast (2.4.
|
11
|
+
ast (2.4.1)
|
11
12
|
byebug (11.1.3)
|
12
|
-
|
13
|
+
concurrent-ruby (1.1.7)
|
14
|
+
diff-lcs (1.4.4)
|
13
15
|
docile (1.3.2)
|
14
|
-
dotenv (2.7.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
ast (~> 2.4.0)
|
16
|
+
dotenv (2.7.6)
|
17
|
+
dry-cli (0.6.0)
|
18
|
+
concurrent-ruby (~> 1.0)
|
19
|
+
parallel (1.19.2)
|
20
|
+
parser (2.7.1.4)
|
21
|
+
ast (~> 2.4.1)
|
21
22
|
rainbow (3.0.0)
|
22
23
|
rake (12.3.3)
|
23
|
-
|
24
|
+
regexp_parser (1.7.1)
|
25
|
+
rexml (3.2.4)
|
24
26
|
rspec (3.9.0)
|
25
27
|
rspec-core (~> 3.9.0)
|
26
28
|
rspec-expectations (~> 3.9.0)
|
@@ -34,26 +36,28 @@ GEM
|
|
34
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
37
|
rspec-support (~> 3.9.0)
|
36
38
|
rspec-support (3.9.3)
|
37
|
-
rubocop (0.
|
38
|
-
jaro_winkler (~> 1.5.1)
|
39
|
+
rubocop (0.85.1)
|
39
40
|
parallel (~> 1.10)
|
40
41
|
parser (>= 2.7.0.1)
|
41
42
|
rainbow (>= 2.2.2, < 4.0)
|
43
|
+
regexp_parser (>= 1.7)
|
42
44
|
rexml
|
45
|
+
rubocop-ast (>= 0.0.3)
|
43
46
|
ruby-progressbar (~> 1.7)
|
44
|
-
unicode-display_width (>= 1.4.0, <
|
45
|
-
rubocop-
|
47
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
48
|
+
rubocop-ast (0.1.0)
|
49
|
+
parser (>= 2.7.0.1)
|
50
|
+
rubocop-performance (1.6.1)
|
46
51
|
rubocop (>= 0.71.0)
|
47
52
|
ruby-progressbar (1.10.1)
|
48
|
-
simplecov (0.
|
53
|
+
simplecov (0.18.5)
|
49
54
|
docile (~> 1.1)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
rubocop (~>
|
55
|
-
|
56
|
-
unicode-display_width (1.6.1)
|
55
|
+
simplecov-html (~> 0.11)
|
56
|
+
simplecov-html (0.12.2)
|
57
|
+
standard (0.4.7)
|
58
|
+
rubocop (~> 0.85.0)
|
59
|
+
rubocop-performance (~> 1.6.0)
|
60
|
+
unicode-display_width (1.7.0)
|
57
61
|
|
58
62
|
PLATFORMS
|
59
63
|
ruby
|
@@ -61,11 +65,10 @@ PLATFORMS
|
|
61
65
|
DEPENDENCIES
|
62
66
|
byebug
|
63
67
|
devup!
|
64
|
-
lefthook
|
65
68
|
rake (~> 12.0)
|
66
69
|
rspec (~> 3.0)
|
67
70
|
simplecov
|
68
71
|
standard
|
69
72
|
|
70
73
|
BUNDLED WITH
|
71
|
-
|
74
|
+
1.17.3
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# DevUp! [](https://travis-ci.com/github/sergio-fry/devup) [](https://rubygems.org/gems/devup) [](https://codeclimate.com/github/sergio-fry/devup) [](https://codeclimate.com/github/sergio-fry/devup) [](https://rubygems.org/gems/devup)
|
1
|
+
# DevUp! [](https://travis-ci.com/github/sergio-fry/devup) [](https://rubygems.org/gems/devup) [](https://codeclimate.com/github/sergio-fry/devup) [](https://codeclimate.com/github/sergio-fry/devup) [](https://rubygems.org/gems/devup) [](https://hitsofcode.com/view/github/sergio-fry/devup)
|
2
2
|
|
3
3
|
Describe development dependencies with docker-compose. It is not required to remember any fancy command to start docker. Just start developing your app. Rails is a first-class citizen, but could be used without ruby.
|
4
4
|
|
@@ -38,12 +38,21 @@ and
|
|
38
38
|
Update your database.yml to use ENV:
|
39
39
|
|
40
40
|
```yaml
|
41
|
-
|
42
|
-
|
41
|
+
default: &default
|
42
|
+
adapter: postgresql
|
43
|
+
encoding: unicode
|
44
|
+
host: <%= ENV.fetch("POSTGRES_HOST") %>
|
45
|
+
port: <%= ENV.fetch("POSTGRES_PORT") %>
|
46
|
+
username: postgres
|
47
|
+
password:
|
43
48
|
|
44
49
|
development:
|
45
|
-
|
50
|
+
<<: *default
|
51
|
+
database: development
|
46
52
|
|
53
|
+
test:
|
54
|
+
<<: *default
|
55
|
+
database: test
|
47
56
|
```
|
48
57
|
|
49
58
|
|
@@ -53,7 +62,7 @@ You are ready to use rails with PostgreSQL configured
|
|
53
62
|
DevUp! INFO starting up...
|
54
63
|
DevUp! INFO up
|
55
64
|
|
56
|
-
$ Created database '
|
65
|
+
$ Created database 'test'
|
57
66
|
|
58
67
|
|
59
68
|
## Without Rails
|
@@ -65,7 +74,7 @@ ENV vars from .env.services are loaded with dotenv automatically.
|
|
65
74
|
require "devup"
|
66
75
|
require "sequel"
|
67
76
|
|
68
|
-
DB = Sequel.connect(ENV.fetch("
|
77
|
+
DB = Sequel.connect(adapter: "postgres", host: ENV.fetch("POSTGRES_HOST"), port: ENV.fetch("POSTGRES_PORT"), database: "blog", user: 'postgres')
|
69
78
|
```
|
70
79
|
|
71
80
|
|
@@ -77,7 +86,7 @@ Install DevUp!
|
|
77
86
|
|
78
87
|
Start up services
|
79
88
|
|
80
|
-
$ devup
|
89
|
+
$ devup up
|
81
90
|
DevUp! INFO starting up...
|
82
91
|
DevUp! INFO up
|
83
92
|
|
@@ -103,10 +112,30 @@ Now you can run app
|
|
103
112
|
|
104
113
|
If you don't want devup to setup your dev services, you can disable it by using `DEVUP_ENABLED=false`. Just add it to .env.local file.
|
105
114
|
|
115
|
+
### Override some service
|
116
|
+
|
117
|
+
If you want to switch some service from DevUp! to another, you can override ENV in a local dotenv configs:
|
118
|
+
|
119
|
+
* .env.local
|
120
|
+
* .env.development.local
|
121
|
+
* .env.test.local
|
122
|
+
|
123
|
+
Just put to your .env.local:
|
124
|
+
|
125
|
+
export POSTGRES_HOST=0.0.0.0
|
126
|
+
export POSTGRES_PORT=5432
|
127
|
+
|
128
|
+
### Get some DATABASE_URL working
|
129
|
+
|
130
|
+
|
131
|
+
Just put to your .env.test or .env.development something like:
|
132
|
+
|
133
|
+
DATABASE_URL=postgres://postgres@$POSTGRES_HOST:$POSTGRES_PORT/test_db
|
134
|
+
|
106
135
|
### Debug
|
107
136
|
|
108
137
|
$ export DEVUP_LOG_LEVEL=debug
|
109
|
-
$ devup
|
138
|
+
$ devup up
|
110
139
|
|
111
140
|
## Development
|
112
141
|
|
data/devup.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ["Sergei O. Udalov"]
|
11
11
|
spec.email = ["sergei@udalovs.ru"]
|
12
12
|
|
13
|
-
spec.summary = "A tool to manage docker-compose for
|
13
|
+
spec.summary = "A tool to manage docker-compose for development"
|
14
14
|
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
15
15
|
spec.homepage = "https://github.com/sergio-fry/devup"
|
16
16
|
spec.license = "MIT"
|
@@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
34
|
spec.add_dependency "dotenv"
|
35
|
+
spec.add_dependency "dry-cli"
|
35
36
|
end
|
data/docker-compose.devup.yml
CHANGED
data/exe/devup
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require "devup/
|
3
|
+
require "devup/cli"
|
4
4
|
|
5
|
-
|
6
|
-
pwd: `pwd`,
|
7
|
-
logger: Devup::Logger.build(ENV.fetch("DEVUP_LOG_LEVEL", "info"))
|
8
|
-
)
|
9
|
-
|
10
|
-
# TODO: use dry-cli here
|
11
|
-
case ARGV[0]
|
12
|
-
when "down"
|
13
|
-
devup.down
|
14
|
-
else
|
15
|
-
devup.up
|
16
|
-
end
|
5
|
+
Dry::CLI.new(Devup::CLI::Commands).call
|
data/lib/devup.rb
CHANGED
data/lib/devup/boot.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
devup.up
|
1
|
+
devup = Devup::Environment.new(
|
2
|
+
pwd: `pwd`,
|
3
|
+
logger: Devup::Logger.build(ENV.fetch("DEVUP_LOG_LEVEL", "info"))
|
4
|
+
)
|
5
|
+
devup.up
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
begin
|
8
|
+
require "spring/commands"
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
10
|
+
Spring.watch devup.root.join("docker-compose.yml")
|
11
|
+
rescue LoadError, ArgumentError, NameError
|
12
|
+
# Spring is not available
|
15
13
|
end
|
data/lib/devup/cli.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "dry/cli"
|
2
|
+
|
3
|
+
require "devup/cli/commands/up"
|
4
|
+
require "devup/cli/commands/down"
|
5
|
+
|
6
|
+
module Devup
|
7
|
+
module CLI
|
8
|
+
module Commands
|
9
|
+
extend Dry::CLI::Registry
|
10
|
+
|
11
|
+
class Version < Dry::CLI::Command
|
12
|
+
def call(*)
|
13
|
+
puts Devup::VERSION
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Devup::CLI::Commands.register "version", Devup::CLI::Commands::Version, aliases: ["v", "-v", "--version"]
|
21
|
+
Devup::CLI::Commands.register "up", Devup::CLI::Commands::Up
|
22
|
+
Devup::CLI::Commands.register "down", Devup::CLI::Commands::Down
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "devup/logger"
|
2
|
+
|
3
|
+
module Devup
|
4
|
+
module CLI
|
5
|
+
module Commands
|
6
|
+
class Command < Dry::CLI::Command
|
7
|
+
def call(**options)
|
8
|
+
@opts = options
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
attr_reader :opts
|
14
|
+
|
15
|
+
def logger
|
16
|
+
@logger ||= Devup::Logger.build(log_level)
|
17
|
+
end
|
18
|
+
|
19
|
+
def log_level
|
20
|
+
if opts.fetch(:verbose)
|
21
|
+
:debug
|
22
|
+
else
|
23
|
+
:info
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def devup
|
28
|
+
require "devup/environment"
|
29
|
+
|
30
|
+
@devup ||= Devup::Environment.new(
|
31
|
+
pwd: `pwd`,
|
32
|
+
logger: logger
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Devup
|
2
|
+
module CLI
|
3
|
+
module Commands
|
4
|
+
class Down < Command
|
5
|
+
desc "Stop dev services"
|
6
|
+
|
7
|
+
option :verbose, type: :boolean, default: false, desc: "Verbose"
|
8
|
+
|
9
|
+
def call(**options)
|
10
|
+
super
|
11
|
+
|
12
|
+
devup.down
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "devup/cli/commands/command"
|
2
|
+
module Devup
|
3
|
+
module CLI
|
4
|
+
module Commands
|
5
|
+
class Up < Command
|
6
|
+
desc "Run dev services"
|
7
|
+
|
8
|
+
option :verbose, type: :boolean, default: false, desc: "Verbose"
|
9
|
+
|
10
|
+
def call(**options)
|
11
|
+
super
|
12
|
+
|
13
|
+
devup.up
|
14
|
+
print_info
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def print_info
|
20
|
+
puts <<~INFO
|
21
|
+
|
22
|
+
Now you are ready to use services. All variables are available
|
23
|
+
in a .env.services file. Just start you ruby application if
|
24
|
+
gem "devup" is used. Or load variable manually with
|
25
|
+
|
26
|
+
$ source .env.services
|
27
|
+
|
28
|
+
INFO
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/devup/compose.rb
CHANGED
@@ -24,11 +24,13 @@ module Devup
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def service_ports(name)
|
27
|
+
return [] if config["services"][name]["ports"].nil?
|
28
|
+
|
27
29
|
config["services"][name]["ports"].map { |el| el.to_s.split(":")[-1].to_i }
|
28
30
|
end
|
29
31
|
|
30
|
-
def port_mapping(
|
31
|
-
|
32
|
+
def port_mapping(port)
|
33
|
+
ComposeHelpers::Ps.new(exec_ps_cached).port_mapping(port)
|
32
34
|
end
|
33
35
|
|
34
36
|
def up
|
@@ -62,7 +64,15 @@ module Devup
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def alive?
|
65
|
-
ComposeHelpers::Ps.new(
|
67
|
+
ComposeHelpers::Ps.new(exec_ps).up?
|
68
|
+
end
|
69
|
+
|
70
|
+
def exec_ps
|
71
|
+
@exec_ps_output = exec("ps")
|
72
|
+
end
|
73
|
+
|
74
|
+
def exec_ps_cached
|
75
|
+
@exec_ps_output ||= exec("ps")
|
66
76
|
end
|
67
77
|
|
68
78
|
def exec(cmd)
|
data/lib/devup/dotenv.rb
CHANGED
@@ -1,2 +1,16 @@
|
|
1
1
|
require "dotenv"
|
2
|
-
|
2
|
+
require "devup/dotenv_load_list"
|
3
|
+
|
4
|
+
begin
|
5
|
+
Dotenv.instrumenter = ActiveSupport::Notifications
|
6
|
+
ActiveSupport::Notifications.subscribe(/^dotenv/) do |*args|
|
7
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
8
|
+
Spring.watch event.payload[:env].filename # if Rails.application
|
9
|
+
end
|
10
|
+
rescue LoadError, ArgumentError, NameError
|
11
|
+
# Spring is not available
|
12
|
+
end
|
13
|
+
|
14
|
+
env = (ENV["RAILS_ENV"] || "development").to_sym
|
15
|
+
list = Devup::DotenvLoadList.new(env: env)
|
16
|
+
Dotenv.load(*list.to_a)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Devup
|
2
|
+
class DotenvLoadList
|
3
|
+
def initialize(env: nil)
|
4
|
+
@env = env.to_sym unless env.nil?
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_a
|
8
|
+
list = []
|
9
|
+
|
10
|
+
list << ".env.#{@env}.local" if env_defined?
|
11
|
+
list << ".env.local" unless test?
|
12
|
+
list << ".env.services"
|
13
|
+
list << ".env.#{@env}" if env_defined?
|
14
|
+
list << ".env"
|
15
|
+
|
16
|
+
list
|
17
|
+
end
|
18
|
+
|
19
|
+
def include?(val)
|
20
|
+
to_a.include? val
|
21
|
+
end
|
22
|
+
|
23
|
+
def index(val)
|
24
|
+
to_a.index val
|
25
|
+
end
|
26
|
+
|
27
|
+
def test?
|
28
|
+
@env == :test
|
29
|
+
end
|
30
|
+
|
31
|
+
def env_defined?
|
32
|
+
!@env.nil?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/devup/environment.rb
CHANGED
data/lib/devup/service.rb
CHANGED
data/lib/devup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergei O. Udalov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-cli
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description:
|
28
42
|
email:
|
29
43
|
- sergei@udalovs.ru
|
@@ -49,12 +63,16 @@ files:
|
|
49
63
|
- devup.gemspec
|
50
64
|
- docker-compose.devup.yml
|
51
65
|
- exe/devup
|
52
|
-
- lefthook.yml
|
53
66
|
- lib/devup.rb
|
54
67
|
- lib/devup/boot.rb
|
68
|
+
- lib/devup/cli.rb
|
69
|
+
- lib/devup/cli/commands/command.rb
|
70
|
+
- lib/devup/cli/commands/down.rb
|
71
|
+
- lib/devup/cli/commands/up.rb
|
55
72
|
- lib/devup/compose.rb
|
56
73
|
- lib/devup/compose/ps.rb
|
57
74
|
- lib/devup/dotenv.rb
|
75
|
+
- lib/devup/dotenv_load_list.rb
|
58
76
|
- lib/devup/environment.rb
|
59
77
|
- lib/devup/logger.rb
|
60
78
|
- lib/devup/port_checker.rb
|
@@ -83,8 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
101
|
- !ruby/object:Gem::Version
|
84
102
|
version: '0'
|
85
103
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.0.8
|
87
105
|
signing_key:
|
88
106
|
specification_version: 4
|
89
|
-
summary: A tool to manage docker-compose for
|
107
|
+
summary: A tool to manage docker-compose for development
|
90
108
|
test_files: []
|