djin 0.1.1 → 0.6.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 +34 -0
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +17 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +35 -10
- data/README.md +160 -14
- data/Rakefile +6 -4
- data/Vertofile +45 -0
- data/bin/console +4 -3
- data/djin.gemspec +25 -20
- data/djin.yml +30 -12
- data/examples/djin.yml +25 -23
- data/exe/djin +3 -0
- data/lib/djin.rb +35 -22
- data/lib/djin/cli.rb +13 -1
- data/lib/djin/config_loader.rb +92 -0
- data/lib/djin/entities/task.rb +4 -1
- data/lib/djin/entities/types.rb +2 -0
- data/lib/djin/executor.rb +24 -10
- data/lib/djin/extensions/hash_extensions.rb +7 -1
- data/lib/djin/interpreter.rb +24 -54
- 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 +19 -0
- data/lib/djin/task_contract.rb +39 -7
- data/lib/djin/version.rb +3 -1
- metadata +64 -12
- 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: 35900c4ab60e94710d24194ea2192edbf4e806527af87fe9d53e693bcec03704
|
4
|
+
data.tar.gz: 53a1b1caabf4ff2e7a708fa1e31ccd7b552514cc6eb882d7152ba015bb58db01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb346575e3426446ad0c2ea2043d386a6112b9414d84927b24a5f0e3dec6062c361a9a6f0910c34fb13819d978d1721d882f53fe36fcf4a5aa5231eac4b6cc3
|
7
|
+
data.tar.gz: 34888b78f7f7af5792fc75f373870792d41986f818bfef643ad8d27f954b9f5e92791226c282933e0f3d7fa57acc42a0f71838df45acff47d48b424d53c24051
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-16.04
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [ '2.4', '2.5', '2.6' ]
|
11
|
+
name: Ruby ${{ matrix.ruby }}
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- uses: actions/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: ${{ matrix.ruby }}
|
17
|
+
- run: |
|
18
|
+
gem install bundler
|
19
|
+
bundle install --jobs 4 --retry 3
|
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
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## 0.6.0 - 22/07/2020
|
2
|
+
* [FEATURE] Djin Variables
|
3
|
+
|
4
|
+
## 0.5.0 - 13/07/2020
|
5
|
+
* [FEATURE] Adds local command task
|
6
|
+
* [FEATURE] Template Args for entire djin.yml
|
7
|
+
|
8
|
+
## 0.4.0 - 25/06/2020
|
9
|
+
* [FEATURE] Adds Custom Args and Environment support in djin.yml
|
10
|
+
|
11
|
+
## 0.3.1 - 29/05/2020
|
12
|
+
* [PATCH] Handles Ctrl + C
|
13
|
+
* [TECH] Adds Vertofile
|
14
|
+
|
15
|
+
## 0.3.0 - 19/05/2020
|
16
|
+
* [FEATURE] Adds Version Option
|
17
|
+
* [PATCH] Add task name in djin.yml parse errors
|
18
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
djin (0.
|
5
|
-
dry-cli (~> 0.
|
4
|
+
djin (0.6.0)
|
5
|
+
dry-cli (~> 0.6.0)
|
6
6
|
dry-struct (~> 1.3.0)
|
7
|
-
dry-validation (~> 1.5.
|
7
|
+
dry-validation (~> 1.5.1)
|
8
|
+
mustache (~> 1.1.1)
|
9
|
+
vseries (~> 0.1.0)
|
8
10
|
|
9
11
|
GEM
|
10
12
|
remote: https://rubygems.org/
|
11
13
|
specs:
|
14
|
+
ast (2.4.1)
|
12
15
|
byebug (11.1.1)
|
13
16
|
concurrent-ruby (1.1.6)
|
14
17
|
diff-lcs (1.3)
|
15
|
-
dry-cli (0.
|
18
|
+
dry-cli (0.6.0)
|
16
19
|
concurrent-ruby (~> 1.0)
|
17
|
-
dry-configurable (0.11.
|
20
|
+
dry-configurable (0.11.6)
|
18
21
|
concurrent-ruby (~> 1.0)
|
19
22
|
dry-core (~> 0.4, >= 0.4.7)
|
20
23
|
dry-equalizer (~> 0.2)
|
@@ -30,7 +33,7 @@ GEM
|
|
30
33
|
concurrent-ruby (~> 1.0)
|
31
34
|
dry-core (~> 0.2)
|
32
35
|
dry-equalizer (~> 0.2)
|
33
|
-
dry-schema (1.5.
|
36
|
+
dry-schema (1.5.2)
|
34
37
|
concurrent-ruby (~> 1.0)
|
35
38
|
dry-configurable (~> 0.8, >= 0.8.3)
|
36
39
|
dry-core (~> 0.4)
|
@@ -50,7 +53,7 @@ GEM
|
|
50
53
|
dry-equalizer (~> 0.3)
|
51
54
|
dry-inflector (~> 0.1, >= 0.1.2)
|
52
55
|
dry-logic (~> 1.0, >= 1.0.2)
|
53
|
-
dry-validation (1.5.
|
56
|
+
dry-validation (1.5.2)
|
54
57
|
concurrent-ruby (~> 1.0)
|
55
58
|
dry-container (~> 0.7, >= 0.7.1)
|
56
59
|
dry-core (~> 0.4)
|
@@ -58,7 +61,14 @@ GEM
|
|
58
61
|
dry-initializer (~> 3.0)
|
59
62
|
dry-schema (~> 1.5)
|
60
63
|
ice_nine (0.11.2)
|
61
|
-
|
64
|
+
mustache (1.1.1)
|
65
|
+
parallel (1.19.2)
|
66
|
+
parser (2.7.1.4)
|
67
|
+
ast (~> 2.4.1)
|
68
|
+
rainbow (3.0.0)
|
69
|
+
rake (13.0.1)
|
70
|
+
regexp_parser (1.7.1)
|
71
|
+
rexml (3.2.4)
|
62
72
|
rspec (3.9.0)
|
63
73
|
rspec-core (~> 3.9.0)
|
64
74
|
rspec-expectations (~> 3.9.0)
|
@@ -72,6 +82,20 @@ GEM
|
|
72
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
83
|
rspec-support (~> 3.9.0)
|
74
84
|
rspec-support (3.9.2)
|
85
|
+
rubocop (0.86.0)
|
86
|
+
parallel (~> 1.10)
|
87
|
+
parser (>= 2.7.0.1)
|
88
|
+
rainbow (>= 2.2.2, < 4.0)
|
89
|
+
regexp_parser (>= 1.7)
|
90
|
+
rexml
|
91
|
+
rubocop-ast (>= 0.0.3, < 1.0)
|
92
|
+
ruby-progressbar (~> 1.7)
|
93
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
94
|
+
rubocop-ast (0.0.3)
|
95
|
+
parser (>= 2.7.0.1)
|
96
|
+
ruby-progressbar (1.10.1)
|
97
|
+
unicode-display_width (1.7.0)
|
98
|
+
vseries (0.1.1)
|
75
99
|
|
76
100
|
PLATFORMS
|
77
101
|
ruby
|
@@ -80,8 +104,9 @@ DEPENDENCIES
|
|
80
104
|
bundler (~> 2.0)
|
81
105
|
byebug
|
82
106
|
djin!
|
83
|
-
rake (~>
|
107
|
+
rake (~> 13.0)
|
84
108
|
rspec (~> 3.0)
|
109
|
+
rubocop
|
85
110
|
|
86
111
|
BUNDLED WITH
|
87
|
-
2.
|
112
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,47 +1,193 @@
|
|
1
1
|
# Djin
|
2
2
|
|
3
|
+

|
4
|
+
[](https://codeclimate.com/github/catks/djin/maintainability)
|
5
|
+
|
6
|
+
Djin is a make-like utility for docker containers
|
7
|
+
|
3
8
|
## Installation
|
4
9
|
|
5
10
|
Djin is distributed as a Ruby Gem, to install simple run:
|
6
11
|
|
7
12
|
$ gem install djin
|
8
13
|
|
14
|
+
### With Rbenv
|
15
|
+
|
16
|
+
If you use Rbenv you can install djin only once and create a alias in your .basrc, .zshrc, etc:
|
17
|
+
|
18
|
+
#### ZSH
|
19
|
+
$ RBENV_VERSION=$(rbenv global) gem install djin && echo "alias djin='RBENV_VERSION=$(rbenv global) djin'" >> ~/.zshrc
|
20
|
+
|
21
|
+
### Bash
|
22
|
+
$ RBENV_VERSION=$(rbenv global) gem install djin && echo "alias djin='RBENV_VERSION=$(rbenv global) djin'" >> ~/.bashrc
|
23
|
+
|
9
24
|
## Usage
|
10
25
|
|
11
26
|
To use djin first you need to create a djin.yml file:
|
12
27
|
|
13
28
|
```yaml
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
29
|
+
djin_version: '0.6.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:
|
25
43
|
docker-compose:
|
26
44
|
service: app
|
27
45
|
run:
|
28
46
|
commands: rspec
|
29
47
|
options: "--rm"
|
48
|
+
```
|
49
|
+
|
50
|
+
You can also set task dependencies with depends_on option:
|
30
51
|
|
52
|
+
|
53
|
+
```yaml
|
54
|
+
djin_version: '0.6.0'
|
55
|
+
|
56
|
+
_default_run_options: &default_run_options
|
57
|
+
options: "--rm"
|
58
|
+
|
59
|
+
tasks:
|
60
|
+
"db:create":
|
61
|
+
docker-compose:
|
62
|
+
service: app
|
63
|
+
run:
|
64
|
+
commands: rake db:create
|
65
|
+
<<: *default_run_options
|
66
|
+
|
67
|
+
"db:migrate":
|
68
|
+
docker-compose:
|
69
|
+
service: app
|
70
|
+
run:
|
71
|
+
commands: rake db:migrate
|
72
|
+
<<: *default_run_options
|
73
|
+
|
74
|
+
"db:setup":
|
75
|
+
depends_on:
|
76
|
+
- "db:create"
|
77
|
+
- "db:migrate"
|
78
|
+
```
|
79
|
+
|
80
|
+
Or mix local commands and docker/docker-compose commands:
|
81
|
+
|
82
|
+
```yaml
|
83
|
+
djin_version: '0.6.0'
|
84
|
+
|
85
|
+
_default_run_options: &default_run_options
|
86
|
+
options: "--rm"
|
87
|
+
|
88
|
+
tasks:
|
89
|
+
"db:create":
|
90
|
+
docker-compose:
|
91
|
+
service: app
|
92
|
+
run:
|
93
|
+
commands: rake db:create
|
94
|
+
<<: *default_run_options
|
95
|
+
|
96
|
+
"db:migrate":
|
97
|
+
docker-compose:
|
98
|
+
service: app
|
99
|
+
run:
|
100
|
+
commands: rake db:migrate
|
101
|
+
<<: *default_run_options
|
102
|
+
|
103
|
+
"setup:copy_samples":
|
104
|
+
local:
|
105
|
+
run:
|
106
|
+
- cp config/database.yml.sample config/database.yml
|
107
|
+
|
108
|
+
"setup":
|
109
|
+
depends_on:
|
110
|
+
- "setup:copy_samples"
|
111
|
+
- "db:create"
|
112
|
+
- "db:migrate"
|
31
113
|
```
|
32
114
|
|
33
115
|
After that you can run `djin {{task_name}}`, like `djin script` or `djin test`
|
34
116
|
|
117
|
+
## Using Environment variables, custom variables and custom args in djin.yml tasks
|
118
|
+
|
119
|
+
You can also use environment variables using the '{{YOUR_ENV_HERE}}' syntax, like so:
|
120
|
+
|
121
|
+
```yaml
|
122
|
+
djin_version: '0.6.0'
|
123
|
+
|
124
|
+
_default_run_options: &default_run_options
|
125
|
+
options: "--rm"
|
126
|
+
|
127
|
+
tasks:
|
128
|
+
"db:migrate":
|
129
|
+
docker-compose:
|
130
|
+
service: app
|
131
|
+
run:
|
132
|
+
commands: ENV={{ENV}} rake db:migrate
|
133
|
+
<<: *default_run_options
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
Or define some variables to use in multiple locations
|
138
|
+
```yaml
|
139
|
+
djin_version: '0.6.0'
|
140
|
+
|
141
|
+
_default_run_options: &default_run_options
|
142
|
+
options: "--rm"
|
143
|
+
|
144
|
+
variables:
|
145
|
+
my_ssh_user: user
|
146
|
+
some_host: test.local
|
147
|
+
|
148
|
+
tasks:
|
149
|
+
"some_host:ssh":
|
150
|
+
local:
|
151
|
+
run:
|
152
|
+
- ssh {{my_ssh_user}}@{{some_host}}
|
153
|
+
|
154
|
+
"some_host:logs":
|
155
|
+
local:
|
156
|
+
run:
|
157
|
+
- ssh -t {{my_ssh_user}}@{{some_host}} 'tail -f /var/log/syslog'
|
158
|
+
```
|
159
|
+
|
160
|
+
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:
|
161
|
+
|
162
|
+
```yaml
|
163
|
+
djin_version: '0.6.0'
|
164
|
+
|
165
|
+
_default_run_options: &default_run_options
|
166
|
+
options: "--rm"
|
167
|
+
|
168
|
+
tasks:
|
169
|
+
"rubocop":
|
170
|
+
docker-compose:
|
171
|
+
service: app
|
172
|
+
run:
|
173
|
+
commands: rubocop {{args}}
|
174
|
+
<<: *default_run_options
|
175
|
+
|
176
|
+
```
|
177
|
+
|
178
|
+
With that you can pass custom args after `--`, eg: `djin rubocop -- --parallel`, which wil make djin runs `rubocop --parallel` inside the service `app`.
|
179
|
+
|
180
|
+
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)
|
181
|
+
|
35
182
|
## Development
|
36
183
|
|
37
184
|
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.
|
38
185
|
|
39
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version,
|
186
|
+
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).
|
40
187
|
|
41
188
|
## TODO:
|
42
189
|
|
43
|
-
1.
|
44
|
-
2. Adds a `-f` option to load custom djin files
|
190
|
+
1. Adds a `-f` option to load custom djin files
|
45
191
|
|
46
192
|
## Contributing
|
47
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
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
verto_version '0.8.0'
|
2
|
+
|
3
|
+
config {
|
4
|
+
version.prefix = 'v' # Adds a version_prefix
|
5
|
+
git.pull_before_tag_creation = true
|
6
|
+
git.push_after_tag_creation = true
|
7
|
+
}
|
8
|
+
|
9
|
+
context(branch('master')) {
|
10
|
+
before_command_tag_up {
|
11
|
+
command_options.add(filter: 'release_only')
|
12
|
+
}
|
13
|
+
|
14
|
+
before_tag_creation {
|
15
|
+
version_changes = sh(
|
16
|
+
%q#git log --oneline --decorate | grep -B 100 -m 1 "tag:" | grep "pull request" | awk '{print $1}' | xargs git show --format='%b' | grep -v Approved | grep -v "^$" | grep -E "^[[:space:]]*\[.*\]" | sed 's/^[[:space:]]*\(.*\)/ * \1/'#, output: false
|
17
|
+
).output
|
18
|
+
|
19
|
+
puts "---------------------------"
|
20
|
+
version_changes = "## #{new_version} - #{Time.now.strftime('%d/%m/%Y')}\n#{version_changes}\n"
|
21
|
+
exit unless confirm("Create new Realease?\n" \
|
22
|
+
"---------------------------\n" \
|
23
|
+
"#{version_changes}" \
|
24
|
+
"---------------------------\n"
|
25
|
+
)
|
26
|
+
|
27
|
+
# CHANGELOG
|
28
|
+
file('CHANGELOG.md').prepend(version_changes)
|
29
|
+
git!('add CHANGELOG.md')
|
30
|
+
|
31
|
+
file('lib/djin/version.rb').replace(latest_version.to_s, new_version.to_s)
|
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
|
+
file('README.md').replace_all(latest_version.to_s, new_version.to_s)
|
35
|
+
|
36
|
+
git!('add lib/djin/version.rb djin.yml examples/djin.yml README.md')
|
37
|
+
|
38
|
+
sh!('bundle install')
|
39
|
+
sh!('rake install')
|
40
|
+
git!('add Gemfile.lock')
|
41
|
+
|
42
|
+
git!('commit -m "Bumps Version"')
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|