cobra_commander 0.8.1 → 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 +21 -7
- data/.github/workflows/release.yml +20 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +8 -38
- data/CHANGELOG.md +23 -0
- data/Gemfile +0 -1
- data/README.md +3 -4
- data/cobra_commander.gemspec +13 -11
- data/gemfiles/bundler1.gemfile +7 -0
- data/gemfiles/bundler2.gemfile +7 -0
- data/lib/cobra_commander/change.rb +6 -6
- data/lib/cobra_commander/cli.rb +12 -4
- data/lib/cobra_commander/component.rb +1 -1
- data/lib/cobra_commander/dependencies/bundler.rb +16 -12
- data/lib/cobra_commander/dependencies/yarn/package.rb +3 -2
- data/lib/cobra_commander/dependencies/yarn/package_repo.rb +3 -2
- data/lib/cobra_commander/executor.rb +11 -10
- data/lib/cobra_commander/executor/component_exec.rb +33 -0
- data/lib/cobra_commander/executor/multi_exec.rb +60 -0
- data/lib/cobra_commander/output/graph_viz.rb +1 -1
- data/lib/cobra_commander/umbrella.rb +4 -3
- data/lib/cobra_commander/version.rb +1 -1
- metadata +88 -43
- data/.travis.yml +0 -12
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,24 +1,36 @@
|
|
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:
|
7
10
|
name: Tests
|
8
11
|
runs-on: ubuntu-latest
|
9
12
|
strategy:
|
13
|
+
fail-fast: false
|
10
14
|
matrix:
|
11
15
|
ruby:
|
12
16
|
- "2.5"
|
13
17
|
- "2.6"
|
18
|
+
- "2.7"
|
19
|
+
- "3.0"
|
20
|
+
bundler:
|
21
|
+
- "1"
|
22
|
+
- "2"
|
23
|
+
env:
|
24
|
+
BUNDLE_GEMFILE: gemfiles/bundler${{ matrix.bundler }}.gemfile
|
14
25
|
steps:
|
15
26
|
- uses: actions/checkout@v2
|
16
|
-
-
|
17
|
-
uses: ruby/setup-ruby@v1
|
27
|
+
- uses: ruby/setup-ruby@v1
|
18
28
|
with:
|
19
29
|
ruby-version: ${{ matrix.ruby }}
|
20
|
-
bundler:
|
30
|
+
bundler: ${{ matrix.bundler }}
|
21
31
|
bundler-cache: true
|
32
|
+
- name: Install bundler v1 # Even if we're testing bundler v2, we need v1 available because the fixture components have it in their Gemfile.locks
|
33
|
+
run: gem install bundler -v "~> 1" --no-document
|
22
34
|
- name: Install Graphviz
|
23
35
|
run: sudo apt -qq install graphviz
|
24
36
|
- name: Run tests
|
@@ -28,10 +40,12 @@ jobs:
|
|
28
40
|
runs-on: ubuntu-latest
|
29
41
|
steps:
|
30
42
|
- uses: actions/checkout@v2
|
31
|
-
-
|
32
|
-
uses: reviewdog/action-rubocop@v1
|
43
|
+
- uses: ruby/setup-ruby@v1
|
33
44
|
with:
|
34
|
-
|
45
|
+
ruby-version: 3.0
|
46
|
+
- uses: reviewdog/action-rubocop@v1
|
47
|
+
with:
|
48
|
+
rubocop_version: 0.88.0
|
35
49
|
filter_mode: nofilter
|
36
50
|
fail_on_error: true
|
37
51
|
rubocop_extensions: ""
|
@@ -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/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,50 +1,20 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
3
|
-
|
4
|
-
Metrics/LineLength:
|
5
|
-
Max: 120
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
NewCops: enable
|
6
4
|
|
7
5
|
Metrics/BlockLength:
|
8
6
|
Exclude:
|
9
7
|
- spec/**/*.rb
|
10
8
|
- cobra_commander.gemspec
|
11
9
|
|
12
|
-
|
13
|
-
Exclude:
|
14
|
-
- spec/**/*.rb
|
15
|
-
- cobra_commander.gemspec
|
16
|
-
|
17
|
-
Style/AccessModifierIndentation:
|
10
|
+
Layout/AccessModifierIndentation:
|
18
11
|
EnforcedStyle: outdent
|
19
12
|
|
20
|
-
Style/Documentation:
|
21
|
-
Enabled: true
|
22
|
-
|
23
|
-
Style/ExtraSpacing:
|
24
|
-
Exclude:
|
25
|
-
- cobra_commander.gemspec
|
26
|
-
|
27
|
-
Style/SpaceAroundOperators:
|
28
|
-
Exclude:
|
29
|
-
- cobra_commander.gemspec
|
30
|
-
|
31
|
-
Style/Lambda:
|
32
|
-
EnforcedStyle: literal
|
33
|
-
|
34
|
-
Style/PercentLiteralDelimiters:
|
35
|
-
PreferredDelimiters:
|
36
|
-
default: ()
|
37
|
-
'%i': '[]'
|
38
|
-
'%I': '[]'
|
39
|
-
'%r': '{}'
|
40
|
-
'%w': '[]'
|
41
|
-
'%W': '[]'
|
42
|
-
|
43
|
-
# Single quotes being faster is hardly measurable and only affects parse time.
|
44
|
-
# Enforcing double quotes reduces the times where you need to change them when introducing an interpolation.
|
45
|
-
# Use single quotes only if their semantics are needed.
|
46
13
|
Style/StringLiterals:
|
47
14
|
EnforcedStyle: double_quotes
|
48
15
|
|
49
|
-
Style/
|
50
|
-
EnforcedStyleForMultiline:
|
16
|
+
Style/TrailingCommaInArrayLiteral:
|
17
|
+
EnforcedStyleForMultiline: consistent_comma
|
18
|
+
|
19
|
+
Style/TrailingCommaInHashLiteral:
|
20
|
+
EnforcedStyleForMultiline: consistent_comma
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,29 @@
|
|
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
|
+
|
24
|
+
## Version 0.9.0 - 2020-08-26
|
25
|
+
|
26
|
+
* Add support for parallel task execution to `cobra exec` [#49](https://github.com/powerhome/cobra_commander/pull/49)
|
27
|
+
|
5
28
|
## Version 0.8.1 - 2020-07-29
|
6
29
|
|
7
30
|
* Fix CobraCommander::Executor when running [`bundler`](https://bundler.io/) based commands (i.e.: `bundle exec rspec`)
|
data/Gemfile
CHANGED
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
@@ -1,7 +1,6 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
lib = File.expand_path("
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
5
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
5
|
require "cobra_commander/version"
|
7
6
|
|
@@ -13,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
13
12
|
"Garett Arrowood",
|
14
13
|
"Carlos Palhares",
|
15
14
|
]
|
16
|
-
spec.email
|
15
|
+
spec.email = [
|
17
16
|
"blangfeld@powerhrg.com",
|
18
17
|
"garett.arrowood@powerhrg.com",
|
19
18
|
"carlos.palhares@powerhrg.com",
|
@@ -23,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
23
22
|
Tools for working with Component Based Rails Apps (see http://shageman.github.io/cbra.info/).
|
24
23
|
Includes tools for graphing the components of an app and their relationships, as well as selectively
|
25
24
|
testing components based on changes made.
|
26
|
-
DESCRIPTION
|
25
|
+
DESCRIPTION
|
27
26
|
spec.homepage = "http://tech.powerhrg.com/cobra_commander/"
|
28
27
|
spec.license = "MIT"
|
29
28
|
|
@@ -34,15 +33,18 @@ DESCRIPTION
|
|
34
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
34
|
spec.require_paths = ["lib"]
|
36
35
|
|
37
|
-
spec.add_dependency "bundler"
|
38
|
-
spec.add_dependency "
|
36
|
+
spec.add_dependency "bundler"
|
37
|
+
spec.add_dependency "concurrent-ruby", "~> 1.1"
|
39
38
|
spec.add_dependency "ruby-graphviz", "~> 1.2.3"
|
39
|
+
spec.add_dependency "thor", ["< 2.0", ">= 0.18.1"]
|
40
|
+
spec.add_dependency "tty-command", "~> 0.10.0"
|
41
|
+
spec.add_dependency "tty-spinner", "~> 0.9.3"
|
40
42
|
|
41
|
-
spec.add_development_dependency "bundler", "~> 1.17"
|
42
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
43
|
-
spec.add_development_dependency "rspec", "~> 3.5"
|
44
|
-
spec.add_development_dependency "guard-rspec"
|
45
43
|
spec.add_development_dependency "aruba", "~> 0.14.2"
|
46
|
-
spec.add_development_dependency "
|
44
|
+
spec.add_development_dependency "bundler"
|
45
|
+
spec.add_development_dependency "guard-rspec"
|
47
46
|
spec.add_development_dependency "pry"
|
47
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
48
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
49
|
+
spec.add_development_dependency "rubocop", "0.88.0"
|
48
50
|
end
|
@@ -42,16 +42,16 @@ module CobraCommander
|
|
42
42
|
Open3.capture3("git", "diff", "--name-only", @branch)
|
43
43
|
end
|
44
44
|
|
45
|
-
if result.exitstatus == 128
|
46
|
-
raise InvalidSelectionError, "Specified --branch could not be found"
|
47
|
-
end
|
45
|
+
raise InvalidSelectionError, "Specified --branch could not be found" if result.exitstatus == 128
|
48
46
|
|
49
47
|
diff.split("\n").map { |f| File.join(@root_dir, f) }
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
51
|
def assert_valid_result_choice
|
54
|
-
|
52
|
+
return if %w[test full name json].include?(@results)
|
53
|
+
|
54
|
+
raise InvalidSelectionError, "--results must be 'test', 'full', 'name' or 'json'"
|
55
55
|
end
|
56
56
|
|
57
57
|
def selected_result?(result)
|
@@ -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
|
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
|
|
@@ -58,8 +64,8 @@ module CobraCommander
|
|
58
64
|
options.output
|
59
65
|
)
|
60
66
|
puts "Graph generated at #{options.output}"
|
61
|
-
rescue ArgumentError =>
|
62
|
-
error
|
67
|
+
rescue ArgumentError => e
|
68
|
+
error e.message
|
63
69
|
end
|
64
70
|
|
65
71
|
desc "changes [--results=RESULTS] [--branch=BRANCH]", "Prints list of changed files"
|
@@ -83,10 +89,12 @@ module CobraCommander
|
|
83
89
|
|
84
90
|
def components_filtered(component_name)
|
85
91
|
return umbrella.components unless component_name
|
92
|
+
|
86
93
|
component = find_component(component_name)
|
87
94
|
|
88
95
|
return component.deep_dependencies if options.dependencies
|
89
96
|
return component.deep_dependents if options.dependents
|
97
|
+
|
90
98
|
[component]
|
91
99
|
end
|
92
100
|
end
|
@@ -1,23 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bundler"
|
4
|
+
require "bundler/lockfile_parser"
|
5
|
+
require "pathname"
|
6
|
+
|
3
7
|
module CobraCommander
|
4
8
|
module Dependencies
|
5
9
|
# Calculates ruby bundler dependencies
|
6
10
|
class Bundler
|
7
|
-
|
8
|
-
@definition = ::Bundler::Definition.build(
|
9
|
-
Pathname.new(File.join(root, "Gemfile")).realpath,
|
10
|
-
Pathname.new(File.join(root, "Gemfile.lock")).realpath,
|
11
|
-
false
|
12
|
-
)
|
13
|
-
end
|
11
|
+
attr_reader :path
|
14
12
|
|
15
|
-
def
|
16
|
-
@
|
13
|
+
def initialize(root)
|
14
|
+
@root = Pathname.new(root)
|
15
|
+
@path = @root.join("Gemfile.lock").realpath
|
17
16
|
end
|
18
17
|
|
19
18
|
def dependencies
|
20
|
-
|
19
|
+
lockfile.dependencies.values.map(&:name)
|
21
20
|
end
|
22
21
|
|
23
22
|
def components
|
@@ -28,9 +27,14 @@ module CobraCommander
|
|
28
27
|
|
29
28
|
private
|
30
29
|
|
30
|
+
def lockfile
|
31
|
+
@lockfile ||= ::Bundler::LockfileParser.new(::Bundler.read_file(path))
|
32
|
+
end
|
33
|
+
|
31
34
|
def components_source
|
32
|
-
@components_source ||=
|
33
|
-
source.path.to_s.eql?("components")
|
35
|
+
@components_source ||= begin
|
36
|
+
source = @lockfile.sources.find { |s| s.path.to_s.eql?("components") }
|
37
|
+
::Bundler::Source::Path.new(source.options.merge("root_path" => @root))
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "json"
|
4
|
+
require "pathname"
|
4
5
|
|
5
6
|
module CobraCommander
|
6
7
|
module Dependencies
|
@@ -10,11 +11,11 @@ module CobraCommander
|
|
10
11
|
attr_reader :path
|
11
12
|
|
12
13
|
def initialize(path)
|
13
|
-
@path = Pathname.new(File.join(path, "package.json")).realpath
|
14
|
+
@path = ::Pathname.new(File.join(path, "package.json")).realpath
|
14
15
|
end
|
15
16
|
|
16
17
|
def project_tag
|
17
|
-
name.match(%r{^@[\w-]
|
18
|
+
name.match(%r{^@[\w-]+/}).to_s
|
18
19
|
end
|
19
20
|
|
20
21
|
def name
|
@@ -6,7 +6,7 @@ module CobraCommander
|
|
6
6
|
# Yarn package repository to load and cache package.json files
|
7
7
|
class PackageRepo
|
8
8
|
def initialize
|
9
|
-
@specs
|
9
|
+
@specs = {}
|
10
10
|
end
|
11
11
|
|
12
12
|
def specs
|
@@ -14,8 +14,9 @@ module CobraCommander
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def load_linked_specs(package)
|
17
|
-
package.dependencies.
|
17
|
+
package.dependencies.each_value do |spec|
|
18
18
|
next unless spec =~ /link:(.+)/
|
19
|
+
|
19
20
|
load_spec(File.join(package.path, "..", Regexp.last_match(1)))
|
20
21
|
end
|
21
22
|
end
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "executor/component_exec"
|
4
|
+
require_relative "executor/multi_exec"
|
5
|
+
|
3
6
|
module CobraCommander
|
4
7
|
# Execute commands on all components of a ComponentTree
|
5
8
|
module Executor
|
6
|
-
def self.exec(components
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
9
|
+
def self.exec(components:, command:, concurrency:, output: $stdout, status_output: $stderr)
|
10
|
+
components = Array(components)
|
11
|
+
exec = if components.size == 1
|
12
|
+
ComponentExec.new(components.first)
|
13
|
+
else
|
14
|
+
MultiExec.new(components, concurrency: concurrency, spin_output: status_output)
|
15
|
+
end
|
16
|
+
exec.run(command, output: output)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tty-command"
|
4
|
+
|
5
|
+
module CobraCommander
|
6
|
+
module Executor
|
7
|
+
# Execute a command on a single component
|
8
|
+
class ComponentExec
|
9
|
+
def initialize(component)
|
10
|
+
@component = component
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(command, output: $stdout, **cmd_options)
|
14
|
+
tty = TTY::Command.new(pty: true, printer: :quiet, output: output)
|
15
|
+
isolate_bundle do
|
16
|
+
@component.root_paths.all? do |path|
|
17
|
+
tty.run!(command, chdir: path, **cmd_options).success?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def isolate_bundle(&block)
|
25
|
+
if Bundler.respond_to?(:with_unbundled_env)
|
26
|
+
Bundler.with_unbundled_env(&block)
|
27
|
+
else
|
28
|
+
Bundler.with_clean_env(&block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tty-spinner"
|
4
|
+
require "stringio"
|
5
|
+
require "concurrent-ruby"
|
6
|
+
|
7
|
+
require_relative "component_exec"
|
8
|
+
|
9
|
+
module CobraCommander
|
10
|
+
module Executor
|
11
|
+
# Execute a command on multiple components
|
12
|
+
class MultiExec
|
13
|
+
def initialize(components, concurrency:, spin_output: $stderr)
|
14
|
+
@components = components
|
15
|
+
@multi = TTY::Spinner::Multi.new(":spinner :task", output: spin_output)
|
16
|
+
@semaphore = Concurrent::Semaphore.new(concurrency)
|
17
|
+
end
|
18
|
+
|
19
|
+
def run(command, output: $stdout, **kwargs)
|
20
|
+
buffer = StringIO.new
|
21
|
+
@multi.top_spinner.update(task: "Running #{command}")
|
22
|
+
@components.each do |component|
|
23
|
+
register_job(command: command, component: component,
|
24
|
+
output: buffer, stderr: :stdout,
|
25
|
+
only_output_on_error: true, **kwargs)
|
26
|
+
end
|
27
|
+
@multi.auto_spin
|
28
|
+
output << buffer.string
|
29
|
+
@multi.success?
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
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
|
+
}
|
44
|
+
end
|
45
|
+
|
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
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -18,7 +18,7 @@ module CobraCommander
|
|
18
18
|
|
19
19
|
private_class_method def self.extract_format(output)
|
20
20
|
format = output[-3..-1]
|
21
|
-
return format if
|
21
|
+
return format if %w[png dot].include?(format)
|
22
22
|
|
23
23
|
raise ArgumentError, "output format must be 'png' or 'dot'"
|
24
24
|
end
|
@@ -21,6 +21,7 @@ module CobraCommander
|
|
21
21
|
|
22
22
|
def resolve(component_root_path)
|
23
23
|
return root if root.root_paths.include?(component_root_path)
|
24
|
+
|
24
25
|
components.find do |component|
|
25
26
|
component.root_paths.include?(component_root_path)
|
26
27
|
end
|
@@ -28,9 +29,9 @@ module CobraCommander
|
|
28
29
|
|
29
30
|
def add_source(key, source)
|
30
31
|
@root_component.add_source key, source.path, source.dependencies
|
31
|
-
source.components.each do |
|
32
|
-
@components[name] ||= Component.new(self, name)
|
33
|
-
@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]
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -10,98 +10,126 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-04-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: concurrent-ruby
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
18
32
|
requirements:
|
19
33
|
- - "~>"
|
20
34
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
35
|
+
version: '1.1'
|
22
36
|
type: :runtime
|
23
37
|
prerelease: false
|
24
38
|
version_requirements: !ruby/object:Gem::Requirement
|
25
39
|
requirements:
|
26
40
|
- - "~>"
|
27
41
|
- !ruby/object:Gem::Version
|
28
|
-
version: '1.
|
42
|
+
version: '1.1'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
44
|
+
name: ruby-graphviz
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
32
46
|
requirements:
|
33
|
-
- - "
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '2.0'
|
36
|
-
- - ">="
|
47
|
+
- - "~>"
|
37
48
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
49
|
+
version: 1.2.3
|
39
50
|
type: :runtime
|
40
51
|
prerelease: false
|
41
52
|
version_requirements: !ruby/object:Gem::Requirement
|
42
53
|
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.2.3
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: thor
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.18.1
|
43
64
|
- - "<"
|
44
65
|
- !ruby/object:Gem::Version
|
45
66
|
version: '2.0'
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
46
71
|
- - ">="
|
47
72
|
- !ruby/object:Gem::Version
|
48
73
|
version: 0.18.1
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.0'
|
49
77
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
78
|
+
name: tty-command
|
51
79
|
requirement: !ruby/object:Gem::Requirement
|
52
80
|
requirements:
|
53
81
|
- - "~>"
|
54
82
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
83
|
+
version: 0.10.0
|
56
84
|
type: :runtime
|
57
85
|
prerelease: false
|
58
86
|
version_requirements: !ruby/object:Gem::Requirement
|
59
87
|
requirements:
|
60
88
|
- - "~>"
|
61
89
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
90
|
+
version: 0.10.0
|
63
91
|
- !ruby/object:Gem::Dependency
|
64
|
-
name:
|
92
|
+
name: tty-spinner
|
65
93
|
requirement: !ruby/object:Gem::Requirement
|
66
94
|
requirements:
|
67
95
|
- - "~>"
|
68
96
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
70
|
-
type: :
|
97
|
+
version: 0.9.3
|
98
|
+
type: :runtime
|
71
99
|
prerelease: false
|
72
100
|
version_requirements: !ruby/object:Gem::Requirement
|
73
101
|
requirements:
|
74
102
|
- - "~>"
|
75
103
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
104
|
+
version: 0.9.3
|
77
105
|
- !ruby/object:Gem::Dependency
|
78
|
-
name:
|
106
|
+
name: aruba
|
79
107
|
requirement: !ruby/object:Gem::Requirement
|
80
108
|
requirements:
|
81
109
|
- - "~>"
|
82
110
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
111
|
+
version: 0.14.2
|
84
112
|
type: :development
|
85
113
|
prerelease: false
|
86
114
|
version_requirements: !ruby/object:Gem::Requirement
|
87
115
|
requirements:
|
88
116
|
- - "~>"
|
89
117
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
118
|
+
version: 0.14.2
|
91
119
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
120
|
+
name: bundler
|
93
121
|
requirement: !ruby/object:Gem::Requirement
|
94
122
|
requirements:
|
95
|
-
- - "
|
123
|
+
- - ">="
|
96
124
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
125
|
+
version: '0'
|
98
126
|
type: :development
|
99
127
|
prerelease: false
|
100
128
|
version_requirements: !ruby/object:Gem::Requirement
|
101
129
|
requirements:
|
102
|
-
- - "
|
130
|
+
- - ">="
|
103
131
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
132
|
+
version: '0'
|
105
133
|
- !ruby/object:Gem::Dependency
|
106
134
|
name: guard-rspec
|
107
135
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,47 +145,61 @@ dependencies:
|
|
117
145
|
- !ruby/object:Gem::Version
|
118
146
|
version: '0'
|
119
147
|
- !ruby/object:Gem::Dependency
|
120
|
-
name:
|
148
|
+
name: pry
|
121
149
|
requirement: !ruby/object:Gem::Requirement
|
122
150
|
requirements:
|
123
|
-
- - "
|
151
|
+
- - ">="
|
124
152
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0
|
153
|
+
version: '0'
|
126
154
|
type: :development
|
127
155
|
prerelease: false
|
128
156
|
version_requirements: !ruby/object:Gem::Requirement
|
129
157
|
requirements:
|
130
|
-
- - "
|
158
|
+
- - ">="
|
131
159
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0
|
160
|
+
version: '0'
|
133
161
|
- !ruby/object:Gem::Dependency
|
134
|
-
name:
|
162
|
+
name: rake
|
135
163
|
requirement: !ruby/object:Gem::Requirement
|
136
164
|
requirements:
|
137
|
-
- -
|
165
|
+
- - ">="
|
138
166
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
167
|
+
version: 12.3.3
|
140
168
|
type: :development
|
141
169
|
prerelease: false
|
142
170
|
version_requirements: !ruby/object:Gem::Requirement
|
143
171
|
requirements:
|
144
|
-
- -
|
172
|
+
- - ">="
|
145
173
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
174
|
+
version: 12.3.3
|
147
175
|
- !ruby/object:Gem::Dependency
|
148
|
-
name:
|
176
|
+
name: rspec
|
149
177
|
requirement: !ruby/object:Gem::Requirement
|
150
178
|
requirements:
|
151
|
-
- - "
|
179
|
+
- - "~>"
|
152
180
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
181
|
+
version: '3.5'
|
154
182
|
type: :development
|
155
183
|
prerelease: false
|
156
184
|
version_requirements: !ruby/object:Gem::Requirement
|
157
185
|
requirements:
|
158
|
-
- - "
|
186
|
+
- - "~>"
|
159
187
|
- !ruby/object:Gem::Version
|
160
|
-
version: '
|
188
|
+
version: '3.5'
|
189
|
+
- !ruby/object:Gem::Dependency
|
190
|
+
name: rubocop
|
191
|
+
requirement: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - '='
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: 0.88.0
|
196
|
+
type: :development
|
197
|
+
prerelease: false
|
198
|
+
version_requirements: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - '='
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: 0.88.0
|
161
203
|
description: |
|
162
204
|
Tools for working with Component Based Rails Apps (see http://shageman.github.io/cbra.info/).
|
163
205
|
Includes tools for graphing the components of an app and their relationships, as well as selectively
|
@@ -173,10 +215,10 @@ extra_rdoc_files: []
|
|
173
215
|
files:
|
174
216
|
- ".editorconfig"
|
175
217
|
- ".github/workflows/ci.yml"
|
218
|
+
- ".github/workflows/release.yml"
|
176
219
|
- ".gitignore"
|
177
220
|
- ".rspec"
|
178
221
|
- ".rubocop.yml"
|
179
|
-
- ".travis.yml"
|
180
222
|
- CHANGELOG.md
|
181
223
|
- CODE_OF_CONDUCT.md
|
182
224
|
- Gemfile
|
@@ -189,6 +231,8 @@ files:
|
|
189
231
|
- bin/setup
|
190
232
|
- cobra_commander.gemspec
|
191
233
|
- exe/cobra
|
234
|
+
- gemfiles/bundler1.gemfile
|
235
|
+
- gemfiles/bundler2.gemfile
|
192
236
|
- lib/cobra_commander.rb
|
193
237
|
- lib/cobra_commander/affected.rb
|
194
238
|
- lib/cobra_commander/change.rb
|
@@ -200,6 +244,8 @@ files:
|
|
200
244
|
- lib/cobra_commander/dependencies/yarn/package_repo.rb
|
201
245
|
- lib/cobra_commander/dependencies/yarn_workspace.rb
|
202
246
|
- lib/cobra_commander/executor.rb
|
247
|
+
- lib/cobra_commander/executor/component_exec.rb
|
248
|
+
- lib/cobra_commander/executor/multi_exec.rb
|
203
249
|
- lib/cobra_commander/output.rb
|
204
250
|
- lib/cobra_commander/output/ascii_tree.rb
|
205
251
|
- lib/cobra_commander/output/flat_list.rb
|
@@ -226,8 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
272
|
- !ruby/object:Gem::Version
|
227
273
|
version: '0'
|
228
274
|
requirements: []
|
229
|
-
|
230
|
-
rubygems_version: 2.7.3
|
275
|
+
rubygems_version: 3.0.3
|
231
276
|
signing_key:
|
232
277
|
specification_version: 4
|
233
278
|
summary: Tools for working with Component Based Rails Apps
|
data/.travis.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
sudo: true
|
2
|
-
language: ruby
|
3
|
-
before_install:
|
4
|
-
- "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
|
5
|
-
- gem install bundler:"$BUNDLER_VERSION"
|
6
|
-
- sudo apt-get -qq install graphviz
|
7
|
-
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0
|
8
|
-
- export PATH="$HOME/.yarn/bin:$PATH"
|
9
|
-
rvm:
|
10
|
-
- 2.5.1
|
11
|
-
env:
|
12
|
-
- BUNDLER_VERSION=1.17.3
|