cobra_commander 0.10.0 → 0.11.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/ci.yml +10 -5
- data/.github/workflows/release.yml +20 -0
- data/CHANGELOG.md +20 -1
- data/README.md +3 -4
- data/cobra_commander.gemspec +3 -2
- data/lib/cobra_commander/change.rb +2 -2
- data/lib/cobra_commander/cli.rb +8 -2
- data/lib/cobra_commander/executor.rb +3 -3
- data/lib/cobra_commander/executor/multi_exec.rb +35 -21
- data/lib/cobra_commander/umbrella.rb +3 -3
- data/lib/cobra_commander/version.rb +1 -1
- metadata +33 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf88be500ee51ad9217ce6729399a3dd45ea69bc91f8d0a2f9ffc97521f802a3
|
4
|
+
data.tar.gz: 13c889293a2173dc698257d1e614a2072b705faca25c3a59d8066e5d09326974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2300c5d0b41084a2d6403444c8548710e57a6645e770ee0d1befa029bfa947e738fe0909d33c522a1543b24892580e0acd7dd2504baae7100ed05af5e32e4a45
|
7
|
+
data.tar.gz: 64e6ff60e979d5ffe2c0c7cceed3cd23733694cc479ad96f484b4af1b6ed421a2aa65ec2e4450699363b3006274784daed0737e27b4b4f4c904123764b1c11ed
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
name: CI
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
types: [opened, reopened]
|
4
7
|
|
5
8
|
jobs:
|
6
9
|
test:
|
@@ -13,6 +16,7 @@ jobs:
|
|
13
16
|
- "2.5"
|
14
17
|
- "2.6"
|
15
18
|
- "2.7"
|
19
|
+
- "3.0"
|
16
20
|
bundler:
|
17
21
|
- "1"
|
18
22
|
- "2"
|
@@ -20,8 +24,7 @@ jobs:
|
|
20
24
|
BUNDLE_GEMFILE: gemfiles/bundler${{ matrix.bundler }}.gemfile
|
21
25
|
steps:
|
22
26
|
- uses: actions/checkout@v2
|
23
|
-
-
|
24
|
-
uses: ruby/setup-ruby@v1
|
27
|
+
- uses: ruby/setup-ruby@v1
|
25
28
|
with:
|
26
29
|
ruby-version: ${{ matrix.ruby }}
|
27
30
|
bundler: ${{ matrix.bundler }}
|
@@ -37,8 +40,10 @@ jobs:
|
|
37
40
|
runs-on: ubuntu-latest
|
38
41
|
steps:
|
39
42
|
- uses: actions/checkout@v2
|
40
|
-
-
|
41
|
-
|
43
|
+
- uses: ruby/setup-ruby@v1
|
44
|
+
with:
|
45
|
+
ruby-version: 3.0
|
46
|
+
- uses: reviewdog/action-rubocop@v1
|
42
47
|
with:
|
43
48
|
rubocop_version: 0.88.0
|
44
49
|
filter_mode: nofilter
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
tags:
|
8
|
+
- v*
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v1
|
14
|
+
- name: Release Gem
|
15
|
+
uses: cadwallion/publish-rubygems-action@master
|
16
|
+
if: contains(github.ref, 'refs/tags/v')
|
17
|
+
env:
|
18
|
+
GITHUB_TOKEN: ${{ secrets.github_token }}
|
19
|
+
RUBYGEMS_API_KEY: ${{ secrets.rubygems_api_key }}
|
20
|
+
RELEASE_COMMAND: rake release
|
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,28 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## Version 0.11.0 - 2021-04-23
|
6
|
+
|
7
|
+
* Add concurrency limit to multi exec [#57](https://github.com/powerhome/cobra_commander/pull/57)
|
8
|
+
* Ruby 3.0 compatibility [#55](https://github.com/powerhome/cobra_commander/pull/55)
|
9
|
+
|
10
|
+
## Version 0.10.0 - 2021-02-25
|
11
|
+
|
12
|
+
* Add support for Bundler 2 [#54](https://github.com/powerhome/cobra_commander/pull/54)
|
13
|
+
* Add support for Ruby 2.7 [#53](https://github.com/powerhome/cobra_commander/pull/53)
|
14
|
+
|
15
|
+
## Version 0.9.2 -
|
16
|
+
|
17
|
+
* Another fix for binstubs [#51](https://github.com/powerhome/cobra_commander/pull/51)
|
18
|
+
|
19
|
+
## Version 0.9.1 -
|
20
|
+
|
21
|
+
* Replace bundler encapsulation violation by LockfileParser [#48](https://github.com/powerhome/cobra_commander/pull/48)
|
22
|
+
* Fix bundle binstubs [#50](https://github.com/powerhome/cobra_commander/pull/50)
|
23
|
+
|
5
24
|
## Version 0.9.0 - 2020-08-26
|
6
25
|
|
7
|
-
* Add support for parallel task execution to `cobra exec
|
26
|
+
* Add support for parallel task execution to `cobra exec` [#49](https://github.com/powerhome/cobra_commander/pull/49)
|
8
27
|
|
9
28
|
## Version 0.8.1 - 2020-07-29
|
10
29
|
|
data/README.md
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/cobra_commander)
|
4
4
|
[](https://rubygems.org/gems/cobra_commander)
|
5
|
-
[](https://gemnasium.com/github.com/powerhome/cobra_commander)
|
5
|
+
[](https://github.com/powerhome/cobra_commander/actions/workflows/ci.yml)
|
6
|
+
[](https://codeclimate.com/github/powerhome/cobra_commander/maintainability)
|
8
7
|
|
9
|
-
Tools for working with Component Based Rails Apps (see
|
8
|
+
Tools for working with Component Based Rails Apps (see https://cbra.info/). Includes tools for graphing both Ruby and Javascript components in an application and their relationships, as well as selectively testing components based on changes made.
|
10
9
|
|
11
10
|
## Installation
|
12
11
|
|
data/cobra_commander.gemspec
CHANGED
@@ -34,16 +34,17 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.require_paths = ["lib"]
|
35
35
|
|
36
36
|
spec.add_dependency "bundler"
|
37
|
+
spec.add_dependency "concurrent-ruby", "~> 1.1"
|
37
38
|
spec.add_dependency "ruby-graphviz", "~> 1.2.3"
|
38
39
|
spec.add_dependency "thor", ["< 2.0", ">= 0.18.1"]
|
39
|
-
spec.add_dependency "tty-command", "~> 0.
|
40
|
+
spec.add_dependency "tty-command", "~> 0.10.0"
|
40
41
|
spec.add_dependency "tty-spinner", "~> 0.9.3"
|
41
42
|
|
42
43
|
spec.add_development_dependency "aruba", "~> 0.14.2"
|
43
44
|
spec.add_development_dependency "bundler"
|
44
45
|
spec.add_development_dependency "guard-rspec"
|
45
46
|
spec.add_development_dependency "pry"
|
46
|
-
spec.add_development_dependency "rake", "
|
47
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
47
48
|
spec.add_development_dependency "rspec", "~> 3.5"
|
48
49
|
spec.add_development_dependency "rubocop", "0.88.0"
|
49
50
|
end
|
@@ -66,13 +66,13 @@ module CobraCommander
|
|
66
66
|
|
67
67
|
def directly_affected_components
|
68
68
|
puts "<<< Directly affected components >>>"
|
69
|
-
@affected.directly.each { |component| puts display(component) }
|
69
|
+
@affected.directly.each { |component| puts display(**component) }
|
70
70
|
puts blank_line
|
71
71
|
end
|
72
72
|
|
73
73
|
def transitively_affected_components
|
74
74
|
puts "<<< Transitively affected components >>>"
|
75
|
-
@affected.transitively.each { |component| puts display(component) }
|
75
|
+
@affected.transitively.each { |component| puts display(**component) }
|
76
76
|
puts blank_line
|
77
77
|
end
|
78
78
|
|
data/lib/cobra_commander/cli.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "thor"
|
4
4
|
require "fileutils"
|
5
|
+
require "concurrent-ruby"
|
5
6
|
|
6
7
|
require "cobra_commander"
|
7
8
|
require "cobra_commander/affected"
|
@@ -12,6 +13,8 @@ require "cobra_commander/output"
|
|
12
13
|
module CobraCommander
|
13
14
|
# Implements the tool's CLI
|
14
15
|
class CLI < Thor
|
16
|
+
DEFAULT_CONCURRENCY = (Concurrent.processor_count / 2.0).ceil
|
17
|
+
|
15
18
|
class_option :app, default: Dir.pwd, aliases: "-a", type: :string
|
16
19
|
class_option :js, default: false, type: :boolean, desc: "Consider only the JS dependency graph"
|
17
20
|
class_option :ruby, default: false, type: :boolean, desc: "Consider only the Ruby dependency graph"
|
@@ -36,10 +39,13 @@ module CobraCommander
|
|
36
39
|
"Defaults to all components."
|
37
40
|
method_option :dependencies, type: :boolean, desc: "Run the command on each dependency of a given component"
|
38
41
|
method_option :dependents, type: :boolean, desc: "Run the command on each dependency of a given component"
|
42
|
+
method_option :concurrency, type: :numeric, default: DEFAULT_CONCURRENCY, aliases: "-c",
|
43
|
+
desc: "Max number of jobs to run concurrently"
|
39
44
|
def exec(command_or_component, command = nil)
|
40
45
|
CobraCommander::Executor.exec(
|
41
|
-
components_filtered(command && command_or_component),
|
42
|
-
command || command_or_component
|
46
|
+
components: components_filtered(command && command_or_component),
|
47
|
+
command: command || command_or_component,
|
48
|
+
concurrency: options.concurrency
|
43
49
|
)
|
44
50
|
end
|
45
51
|
|
@@ -6,14 +6,14 @@ require_relative "executor/multi_exec"
|
|
6
6
|
module CobraCommander
|
7
7
|
# Execute commands on all components of a ComponentTree
|
8
8
|
module Executor
|
9
|
-
def self.exec(components
|
9
|
+
def self.exec(components:, command:, concurrency:, output: $stdout, status_output: $stderr)
|
10
10
|
components = Array(components)
|
11
11
|
exec = if components.size == 1
|
12
12
|
ComponentExec.new(components.first)
|
13
13
|
else
|
14
|
-
MultiExec.new(components)
|
14
|
+
MultiExec.new(components, concurrency: concurrency, spin_output: status_output)
|
15
15
|
end
|
16
|
-
exec.run(command, output: output
|
16
|
+
exec.run(command, output: output)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -2,44 +2,58 @@
|
|
2
2
|
|
3
3
|
require "tty-spinner"
|
4
4
|
require "stringio"
|
5
|
+
require "concurrent-ruby"
|
5
6
|
|
6
7
|
require_relative "component_exec"
|
7
8
|
|
8
9
|
module CobraCommander
|
9
10
|
module Executor
|
10
|
-
#
|
11
|
+
# Execute a command on multiple components
|
11
12
|
class MultiExec
|
12
|
-
def initialize(components)
|
13
|
+
def initialize(components, concurrency:, spin_output: $stderr)
|
13
14
|
@components = components
|
15
|
+
@multi = TTY::Spinner::Multi.new(":spinner :task", output: spin_output)
|
16
|
+
@semaphore = Concurrent::Semaphore.new(concurrency)
|
14
17
|
end
|
15
18
|
|
16
|
-
def run(command, output: $stdout,
|
17
|
-
|
18
|
-
multi
|
19
|
+
def run(command, output: $stdout, **kwargs)
|
20
|
+
buffer = StringIO.new
|
21
|
+
@multi.top_spinner.update(task: "Running #{command}")
|
19
22
|
@components.each do |component|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
register_job(command: command, component: component,
|
24
|
+
output: buffer, stderr: :stdout,
|
25
|
+
only_output_on_error: true, **kwargs)
|
23
26
|
end
|
24
|
-
multi.auto_spin
|
25
|
-
output <<
|
26
|
-
|
27
|
+
@multi.auto_spin
|
28
|
+
output << buffer.string
|
29
|
+
@multi.success?
|
27
30
|
end
|
28
31
|
|
29
32
|
private
|
30
33
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def pastel
|
35
|
+
@pastel ||= Pastel.new
|
36
|
+
end
|
37
|
+
|
38
|
+
def spinner_options
|
39
|
+
@spinner_options ||= {
|
40
|
+
format: :bouncing,
|
41
|
+
success_mark: pastel.green("[DONE]"),
|
42
|
+
error_mark: pastel.red("[ERROR]"),
|
43
|
+
}
|
36
44
|
end
|
37
45
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
def register_job(component:, command:, **kwargs)
|
47
|
+
@multi.register(":spinner #{component.name}", **spinner_options) do |spinner|
|
48
|
+
@semaphore.acquire
|
49
|
+
exec = ComponentExec.new(component)
|
50
|
+
if exec.run(command, **kwargs)
|
51
|
+
spinner.success
|
52
|
+
else
|
53
|
+
spinner.error
|
54
|
+
end
|
55
|
+
@semaphore.release
|
56
|
+
end
|
43
57
|
end
|
44
58
|
end
|
45
59
|
end
|
@@ -29,9 +29,9 @@ module CobraCommander
|
|
29
29
|
|
30
30
|
def add_source(key, source)
|
31
31
|
@root_component.add_source key, source.path, source.dependencies
|
32
|
-
source.components.each do |
|
33
|
-
@components[name] ||= Component.new(self, name)
|
34
|
-
@components[name].add_source key, path, dependencies
|
32
|
+
source.components.each do |component|
|
33
|
+
@components[component[:name]] ||= Component.new(self, component[:name])
|
34
|
+
@components[component[:name]].add_source key, component[:path], component[:dependencies]
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobra_commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Langfeld
|
8
8
|
- Garett Arrowood
|
9
9
|
- Carlos Palhares
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-04-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -26,6 +26,20 @@ dependencies:
|
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: concurrent-ruby
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '1.1'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.1'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: ruby-graphviz
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,36 +58,36 @@ dependencies:
|
|
44
58
|
name: thor
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
46
60
|
requirements:
|
47
|
-
- - "<"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '2.0'
|
50
61
|
- - ">="
|
51
62
|
- !ruby/object:Gem::Version
|
52
63
|
version: 0.18.1
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.0'
|
53
67
|
type: :runtime
|
54
68
|
prerelease: false
|
55
69
|
version_requirements: !ruby/object:Gem::Requirement
|
56
70
|
requirements:
|
57
|
-
- - "<"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '2.0'
|
60
71
|
- - ">="
|
61
72
|
- !ruby/object:Gem::Version
|
62
73
|
version: 0.18.1
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.0'
|
63
77
|
- !ruby/object:Gem::Dependency
|
64
78
|
name: tty-command
|
65
79
|
requirement: !ruby/object:Gem::Requirement
|
66
80
|
requirements:
|
67
81
|
- - "~>"
|
68
82
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
83
|
+
version: 0.10.0
|
70
84
|
type: :runtime
|
71
85
|
prerelease: false
|
72
86
|
version_requirements: !ruby/object:Gem::Requirement
|
73
87
|
requirements:
|
74
88
|
- - "~>"
|
75
89
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.
|
90
|
+
version: 0.10.0
|
77
91
|
- !ruby/object:Gem::Dependency
|
78
92
|
name: tty-spinner
|
79
93
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,16 +162,16 @@ dependencies:
|
|
148
162
|
name: rake
|
149
163
|
requirement: !ruby/object:Gem::Requirement
|
150
164
|
requirements:
|
151
|
-
- - "
|
165
|
+
- - ">="
|
152
166
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
167
|
+
version: 12.3.3
|
154
168
|
type: :development
|
155
169
|
prerelease: false
|
156
170
|
version_requirements: !ruby/object:Gem::Requirement
|
157
171
|
requirements:
|
158
|
-
- - "
|
172
|
+
- - ">="
|
159
173
|
- !ruby/object:Gem::Version
|
160
|
-
version:
|
174
|
+
version: 12.3.3
|
161
175
|
- !ruby/object:Gem::Dependency
|
162
176
|
name: rspec
|
163
177
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,6 +215,7 @@ extra_rdoc_files: []
|
|
201
215
|
files:
|
202
216
|
- ".editorconfig"
|
203
217
|
- ".github/workflows/ci.yml"
|
218
|
+
- ".github/workflows/release.yml"
|
204
219
|
- ".gitignore"
|
205
220
|
- ".rspec"
|
206
221
|
- ".rubocop.yml"
|
@@ -242,7 +257,7 @@ homepage: http://tech.powerhrg.com/cobra_commander/
|
|
242
257
|
licenses:
|
243
258
|
- MIT
|
244
259
|
metadata: {}
|
245
|
-
post_install_message:
|
260
|
+
post_install_message:
|
246
261
|
rdoc_options: []
|
247
262
|
require_paths:
|
248
263
|
- lib
|
@@ -257,9 +272,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
272
|
- !ruby/object:Gem::Version
|
258
273
|
version: '0'
|
259
274
|
requirements: []
|
260
|
-
|
261
|
-
|
262
|
-
signing_key:
|
275
|
+
rubygems_version: 3.0.3
|
276
|
+
signing_key:
|
263
277
|
specification_version: 4
|
264
278
|
summary: Tools for working with Component Based Rails Apps
|
265
279
|
test_files: []
|