djin 0.4.0 → 0.8.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 +4 -4
- data/.github/workflows/ruby.yml +14 -0
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +17 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +6 -5
- data/README.md +122 -57
- data/Rakefile +6 -4
- data/Vertofile +4 -3
- data/bin/console +4 -3
- data/djin.gemspec +26 -23
- data/djin.yml +29 -20
- data/examples/djin.yml +25 -23
- data/exe/djin +2 -1
- data/lib/djin.rb +30 -23
- data/lib/djin/cli.rb +7 -5
- data/lib/djin/config_loader.rb +106 -0
- data/lib/djin/entities/file_config.rb +17 -0
- data/lib/djin/entities/task.rb +5 -5
- data/lib/djin/entities/types.rb +2 -0
- data/lib/djin/executor.rb +4 -11
- data/lib/djin/extensions/hash_extensions.rb +7 -1
- data/lib/djin/interpreter.rb +16 -63
- data/lib/djin/interpreter/base_command_builder.rb +26 -0
- data/lib/djin/interpreter/docker_command_builder.rb +29 -0
- data/lib/djin/interpreter/docker_compose_command_builder.rb +17 -0
- data/lib/djin/interpreter/local_command_builder.rb +11 -0
- data/lib/djin/repositories/task_repository.rb +2 -0
- data/lib/djin/task_contract.rb +38 -7
- data/lib/djin/version.rb +3 -1
- metadata +52 -30
- data/lib/djin/extensions/custom_predicates.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 558aca989aad2d1cfd7b19768a7a5d6fd2f660afb5135fb9ca3ae03eacb233b4
|
4
|
+
data.tar.gz: f2e5c3861c6db601b77bc04321386cb2c22ec049d315781966830ba8a5f6e8af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a898ea486006d81980a4e963a1e7b2d31f40c5bec00d9b5948f4b32d0be5c222b61525c90fd214523cd482aadeab88e3927cb3a3697f7fc86b8180901e015543
|
7
|
+
data.tar.gz: 3d6b0a29b1faa6a3bffb0fa5076ee88083229cbb36f77f2166e44bc19ddd84b73bd6b254578da2c721e1c08ffc7e9583f1325bdd73acc87511ceec47b3f0e512
|
data/.github/workflows/ruby.yml
CHANGED
@@ -18,3 +18,17 @@ jobs:
|
|
18
18
|
gem install bundler
|
19
19
|
bundle install --jobs 4 --retry 3
|
20
20
|
bundle exec rake
|
21
|
+
|
22
|
+
lint:
|
23
|
+
runs-on: ubuntu-16.04
|
24
|
+
name: Lint
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v2
|
27
|
+
- uses: actions/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: '2.6'
|
30
|
+
- run: |
|
31
|
+
gem install bundler
|
32
|
+
bundle install --jobs 4 --retry 3
|
33
|
+
bundle exec rubocop
|
34
|
+
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-07-14 01:12:35 UTC using RuboCop version 0.86.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
# Configuration parameters: IgnoredMethods.
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Max: 21
|
13
|
+
|
14
|
+
# Offense count: 2
|
15
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Max: 19
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 0.8.0 - 31/08/2020
|
2
|
+
* [FEATURE] Adds aliases option
|
3
|
+
|
4
|
+
## 0.7.0 - 20/08/2020
|
5
|
+
* [FEATURE] Adds description option
|
6
|
+
|
7
|
+
## 0.6.1 - 11/08/2020
|
8
|
+
* [TECH] Better Error Handling
|
9
|
+
|
10
|
+
## 0.6.0 - 22/07/2020
|
11
|
+
* [FEATURE] Djin Variables
|
12
|
+
|
13
|
+
## 0.5.0 - 13/07/2020
|
14
|
+
* [FEATURE] Adds local command task
|
15
|
+
* [FEATURE] Template Args for entire djin.yml
|
16
|
+
|
1
17
|
## 0.4.0 - 25/06/2020
|
2
18
|
* [FEATURE] Adds Custom Args and Environment support in djin.yml
|
3
19
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
djin (0.
|
4
|
+
djin (0.8.0)
|
5
5
|
dry-cli (~> 0.6.0)
|
6
|
+
dry-equalizer (~> 0.3.0)
|
6
7
|
dry-struct (~> 1.3.0)
|
7
8
|
dry-validation (~> 1.5.1)
|
8
9
|
mustache (~> 1.1.1)
|
@@ -13,7 +14,7 @@ GEM
|
|
13
14
|
specs:
|
14
15
|
ast (2.4.1)
|
15
16
|
byebug (11.1.1)
|
16
|
-
concurrent-ruby (1.1.
|
17
|
+
concurrent-ruby (1.1.7)
|
17
18
|
diff-lcs (1.3)
|
18
19
|
dry-cli (0.6.0)
|
19
20
|
concurrent-ruby (~> 1.0)
|
@@ -29,11 +30,11 @@ GEM
|
|
29
30
|
dry-equalizer (0.3.0)
|
30
31
|
dry-inflector (0.2.0)
|
31
32
|
dry-initializer (3.0.3)
|
32
|
-
dry-logic (1.0.
|
33
|
+
dry-logic (1.0.7)
|
33
34
|
concurrent-ruby (~> 1.0)
|
34
35
|
dry-core (~> 0.2)
|
35
36
|
dry-equalizer (~> 0.2)
|
36
|
-
dry-schema (1.5.
|
37
|
+
dry-schema (1.5.3)
|
37
38
|
concurrent-ruby (~> 1.0)
|
38
39
|
dry-configurable (~> 0.8, >= 0.8.3)
|
39
40
|
dry-core (~> 0.4)
|
@@ -53,7 +54,7 @@ GEM
|
|
53
54
|
dry-equalizer (~> 0.3)
|
54
55
|
dry-inflector (~> 0.1, >= 0.1.2)
|
55
56
|
dry-logic (~> 1.0, >= 1.0.2)
|
56
|
-
dry-validation (1.5.
|
57
|
+
dry-validation (1.5.4)
|
57
58
|
concurrent-ruby (~> 1.0)
|
58
59
|
dry-container (~> 0.7, >= 0.7.1)
|
59
60
|
dry-core (~> 0.4)
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Djin
|
2
2
|
|
3
3
|

|
4
|
+
[](https://codeclimate.com/github/catks/djin/maintainability)
|
4
5
|
|
5
6
|
Djin is a make-like utility for docker containers
|
6
7
|
|
@@ -25,104 +26,168 @@ If you use Rbenv you can install djin only once and create a alias in your .basr
|
|
25
26
|
To use djin first you need to create a djin.yml file:
|
26
27
|
|
27
28
|
```yaml
|
28
|
-
djin_version: '0.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
29
|
+
djin_version: '0.8.0'
|
30
|
+
|
31
|
+
tasks:
|
32
|
+
# With a docker image
|
33
|
+
script:
|
34
|
+
docker:
|
35
|
+
image: "ruby:2.6"
|
36
|
+
run:
|
37
|
+
commands:
|
38
|
+
- "ruby /scripts/my_ruby_script.rb"
|
39
|
+
options: "--rm -v $(pwd)/my_ruby_script.rb:/scripts/my_ruby_script.rb"
|
40
|
+
|
41
|
+
# Using a docker-compose service
|
42
|
+
test:
|
43
|
+
docker-compose:
|
44
|
+
service: app
|
45
|
+
run:
|
46
|
+
commands: rspec
|
47
|
+
options: "--rm"
|
48
|
+
aliases: # Optional Array of strings
|
49
|
+
- rspec
|
47
50
|
```
|
48
51
|
|
49
52
|
You can also set task dependencies with depends_on option:
|
50
53
|
|
51
54
|
|
52
55
|
```yaml
|
53
|
-
djin_version: '0.
|
56
|
+
djin_version: '0.8.0'
|
54
57
|
|
55
58
|
_default_run_options: &default_run_options
|
56
59
|
options: "--rm"
|
57
60
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
61
|
+
tasks:
|
62
|
+
"db:create":
|
63
|
+
docker-compose:
|
64
|
+
service: app
|
65
|
+
run:
|
66
|
+
commands: rake db:create
|
67
|
+
<<: *default_run_options
|
68
|
+
|
69
|
+
"db:migrate":
|
70
|
+
docker-compose:
|
71
|
+
service: app
|
72
|
+
run:
|
73
|
+
commands: rake db:migrate
|
74
|
+
<<: *default_run_options
|
75
|
+
|
76
|
+
"db:setup":
|
77
|
+
depends_on:
|
78
|
+
- "db:create"
|
79
|
+
- "db:migrate"
|
80
|
+
```
|
81
|
+
|
82
|
+
Or mix local commands and docker/docker-compose commands:
|
83
|
+
|
84
|
+
```yaml
|
85
|
+
djin_version: '0.8.0'
|
76
86
|
|
87
|
+
_default_run_options: &default_run_options
|
88
|
+
options: "--rm"
|
89
|
+
|
90
|
+
tasks:
|
91
|
+
"db:create":
|
92
|
+
docker-compose:
|
93
|
+
service: app
|
94
|
+
run:
|
95
|
+
commands: rake db:create
|
96
|
+
<<: *default_run_options
|
97
|
+
|
98
|
+
"db:migrate":
|
99
|
+
docker-compose:
|
100
|
+
service: app
|
101
|
+
run:
|
102
|
+
commands: rake db:migrate
|
103
|
+
<<: *default_run_options
|
104
|
+
|
105
|
+
"setup:copy_samples":
|
106
|
+
local:
|
107
|
+
run:
|
108
|
+
- cp config/database.yml.sample config/database.yml
|
109
|
+
|
110
|
+
"setup":
|
111
|
+
depends_on:
|
112
|
+
- "setup:copy_samples"
|
113
|
+
- "db:create"
|
114
|
+
- "db:migrate"
|
77
115
|
```
|
78
116
|
|
79
117
|
After that you can run `djin {{task_name}}`, like `djin script` or `djin test`
|
80
118
|
|
81
|
-
## Using Environment variables and custom args in djin.yml
|
119
|
+
## Using Environment variables, custom variables and custom args in djin.yml tasks
|
82
120
|
|
83
|
-
You can use environment variables using the '{{YOUR_ENV_HERE}}' syntax, like so:
|
121
|
+
You can also use environment variables using the '{{YOUR_ENV_HERE}}' syntax, like so:
|
84
122
|
|
85
123
|
```yaml
|
86
|
-
djin_version: '0.
|
124
|
+
djin_version: '0.8.0'
|
87
125
|
|
88
126
|
_default_run_options: &default_run_options
|
89
127
|
options: "--rm"
|
90
128
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
129
|
+
tasks:
|
130
|
+
"db:migrate":
|
131
|
+
docker-compose:
|
132
|
+
service: app
|
133
|
+
run:
|
134
|
+
commands: ENV={{ENV}} rake db:migrate
|
135
|
+
<<: *default_run_options
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
Or define some variables to use in multiple locations
|
140
|
+
```yaml
|
141
|
+
djin_version: '0.8.0'
|
142
|
+
|
143
|
+
_default_run_options: &default_run_options
|
144
|
+
options: "--rm"
|
145
|
+
|
146
|
+
variables:
|
147
|
+
my_ssh_user: user
|
148
|
+
some_host: test.local
|
149
|
+
|
150
|
+
tasks:
|
151
|
+
"some_host:ssh":
|
152
|
+
local:
|
153
|
+
run:
|
154
|
+
- ssh {{my_ssh_user}}@{{some_host}}
|
97
155
|
|
156
|
+
"some_host:logs":
|
157
|
+
local:
|
158
|
+
run:
|
159
|
+
- ssh -t {{my_ssh_user}}@{{some_host}} 'tail -f /var/log/syslog'
|
98
160
|
```
|
99
161
|
|
100
|
-
It's also possible to pass custom arguments to the command,
|
162
|
+
It's also possible to pass custom arguments to the command, which means is possible to make a djin task act like the command itself:
|
101
163
|
|
102
164
|
```yaml
|
103
|
-
djin_version: '0.
|
165
|
+
djin_version: '0.8.0'
|
104
166
|
|
105
167
|
_default_run_options: &default_run_options
|
106
168
|
options: "--rm"
|
107
169
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
170
|
+
tasks:
|
171
|
+
"rubocop":
|
172
|
+
docker-compose:
|
173
|
+
service: app
|
174
|
+
run:
|
175
|
+
commands: rubocop {{args}}
|
176
|
+
<<: *default_run_options
|
177
|
+
aliases:
|
178
|
+
- lint
|
114
179
|
|
115
180
|
```
|
116
181
|
|
117
182
|
With that you can pass custom args after `--`, eg: `djin rubocop -- --parallel`, which wil make djin runs `rubocop --parallel` inside the service `app`.
|
118
183
|
|
119
|
-
Under the hood djin uses [Mustache](https://mustache.github.io/), so you can use other features like conditionals: `{{#IS_ENABLE}} Enabled {{/IS_ENABLE}}` (for args use the `args?`, eg: {{#args} {{args}} --and-other-thing{{/args?}}), to see more more options you can access this [Link](https://mustache.github.io/mustache.5.html)
|
184
|
+
Under the hood djin uses [Mustache](https://mustache.github.io/), so you can use other features like conditionals: `{{#IS_ENABLE}} Enabled {{/IS_ENABLE}}` (for args use the `args?`, eg: `{{#args?}} {{args}} --and-other-thing{{/args?}}`), to see more more options you can access this [Link](https://mustache.github.io/mustache.5.html)
|
120
185
|
|
121
186
|
## Development
|
122
187
|
|
123
188
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
124
189
|
|
125
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version,
|
190
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run `djin release -- {{increment_option}}` (where {{incremment_option}} can be `--patch`, `--minor` or `major`), which will change version, update the CHANGELOG.md, create a new commit, create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
126
191
|
|
127
192
|
## TODO:
|
128
193
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require_relative 'lib/djin'
|
4
6
|
|
5
7
|
RSpec::Core::RakeTask.new(:spec)
|
6
8
|
|
7
|
-
task :
|
9
|
+
task default: :spec
|
8
10
|
|
9
11
|
desc 'Djin REPL'
|
10
12
|
task :console do
|
data/Vertofile
CHANGED
@@ -29,10 +29,11 @@ context(branch('master')) {
|
|
29
29
|
git!('add CHANGELOG.md')
|
30
30
|
|
31
31
|
file('lib/djin/version.rb').replace(latest_version.to_s, new_version.to_s)
|
32
|
-
|
33
|
-
|
32
|
+
file('djin.yml').replace(latest_version.to_s, new_version.to_s)
|
33
|
+
file('examples/djin.yml').replace(latest_version.to_s, new_version.to_s)
|
34
34
|
file('README.md').replace_all(latest_version.to_s, new_version.to_s)
|
35
|
-
|
35
|
+
|
36
|
+
git!('add lib/djin/version.rb djin.yml examples/djin.yml README.md')
|
36
37
|
|
37
38
|
sh!('bundle install')
|
38
39
|
sh!('rake install')
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'djin'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "djin"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/djin.gemspec
CHANGED
@@ -1,38 +1,41 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
5
|
+
require 'djin/version'
|
4
6
|
|
5
7
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
8
|
+
spec.name = 'djin'
|
7
9
|
spec.version = Djin::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
10
|
+
spec.authors = ['Carlos Atkinson']
|
11
|
+
spec.email = ['carlos.atks@gmail.com']
|
10
12
|
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
13
|
+
spec.summary = 'djin is a make-like utility for docker containers'
|
14
|
+
spec.homepage = 'https://github.com/catks/djin'
|
15
|
+
spec.license = 'MIT'
|
14
16
|
|
15
17
|
# spec.metadata["homepage_uri"] = spec.homepage
|
16
|
-
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
17
|
-
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
18
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
19
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
18
20
|
|
19
21
|
# Specify which files should be added to the gem when it is released.
|
20
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files = Dir.chdir(File.expand_path(
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
25
|
end
|
24
|
-
spec.bindir =
|
26
|
+
spec.bindir = 'exe'
|
25
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
-
spec.require_paths = [
|
28
|
+
spec.require_paths = ['lib']
|
27
29
|
|
28
|
-
spec.add_dependency
|
29
|
-
spec.add_dependency
|
30
|
-
spec.add_dependency
|
31
|
-
spec.add_dependency
|
32
|
-
spec.add_dependency
|
33
|
-
spec.
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
30
|
+
spec.add_dependency 'dry-cli', '~> 0.6.0'
|
31
|
+
spec.add_dependency 'dry-equalizer', '~> 0.3.0'
|
32
|
+
spec.add_dependency 'dry-struct', '~> 1.3.0'
|
33
|
+
spec.add_dependency 'dry-validation', '~> 1.5.1'
|
34
|
+
spec.add_dependency 'mustache', '~> 1.1.1'
|
35
|
+
spec.add_dependency 'vseries', '~> 0.1.0'
|
36
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
37
|
+
spec.add_development_dependency 'byebug'
|
38
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
39
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
40
|
+
spec.add_development_dependency 'rubocop'
|
38
41
|
end
|