cobra_commander 0.7.0 → 0.9.2
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 +38 -0
- data/.rubocop.yml +8 -38
- data/CHANGELOG.md +15 -0
- data/README.md +109 -10
- data/cobra_commander.gemspec +11 -9
- data/exe/cobra +1 -1
- data/lib/cobra_commander.rb +0 -9
- data/lib/cobra_commander/affected.rb +9 -1
- data/lib/cobra_commander/change.rb +4 -4
- data/lib/cobra_commander/cli.rb +65 -58
- 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 +12 -13
- data/lib/cobra_commander/executor/component_exec.rb +33 -0
- data/lib/cobra_commander/executor/multi_exec.rb +46 -0
- data/lib/cobra_commander/output.rb +3 -72
- data/lib/cobra_commander/output/ascii_tree.rb +55 -0
- data/lib/cobra_commander/output/flat_list.rb +16 -0
- data/lib/cobra_commander/output/graph_viz.rb +27 -0
- data/lib/cobra_commander/umbrella.rb +1 -0
- data/lib/cobra_commander/version.rb +1 -1
- metadata +76 -33
- data/.travis.yml +0 -12
- data/lib/cobra_commander/cached_component_tree.rb +0 -24
- data/lib/cobra_commander/calculated_component_tree.rb +0 -141
- data/lib/cobra_commander/component_tree.rb +0 -69
- data/lib/cobra_commander/graph.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 187d07e9fd8516472b7db839d6b8076f48f579517e1735697e8f97bc41185917
|
4
|
+
data.tar.gz: a2bac5849bbc81dacd1befa077cb8ba711b653dd3ad586cee7d270342b18dbab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cad76ed9b06db481cefb21a7d71072c53ef7f073e4e1afe0185e506b04a1cd197d0551ebf4b3a8c8a3eebd7388f870dd7e8e3824084fafa6607a8d7c9058950
|
7
|
+
data.tar.gz: 3d7bcff87851fd52d162502282aca2a7f173e78e6f73cf9628ee029b5cdf58c6ad05b8fb211bbd6ad77bbc4aa610a86f207f951f1657d7ba7956d47f1b4a6add
|
@@ -0,0 +1,38 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
name: Tests
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
ruby:
|
12
|
+
- "2.5"
|
13
|
+
- "2.6"
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
bundler: 1
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Install Graphviz
|
23
|
+
run: sudo apt -qq install graphviz
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rake spec
|
26
|
+
lint:
|
27
|
+
name: Lint Ruby
|
28
|
+
runs-on: ubuntu-latest
|
29
|
+
steps:
|
30
|
+
- uses: actions/checkout@v2
|
31
|
+
- name: rubocop
|
32
|
+
uses: reviewdog/action-rubocop@v1
|
33
|
+
with:
|
34
|
+
rubocop_version: 0.88.0
|
35
|
+
filter_mode: nofilter
|
36
|
+
fail_on_error: true
|
37
|
+
rubocop_extensions: ""
|
38
|
+
github_token: ${{ secrets.github_token }}
|
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,21 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## Version 0.9.0 - 2020-08-26
|
6
|
+
|
7
|
+
* Add support for parallel task execution to `cobra exec`.
|
8
|
+
|
9
|
+
## Version 0.8.1 - 2020-07-29
|
10
|
+
|
11
|
+
* Fix CobraCommander::Executor when running [`bundler`](https://bundler.io/) based commands (i.e.: `bundle exec rspec`)
|
12
|
+
|
13
|
+
## Version 0.8 - 2020-07-21
|
14
|
+
|
15
|
+
* Standardize Cobra CLI options
|
16
|
+
* More powerful filters to all cobra commands (--js, --ruby)
|
17
|
+
* More powerful filters to cobra ls and exec (--dependencies, --dependents)
|
18
|
+
* Graphs for components, not just umbrella
|
19
|
+
|
5
20
|
## Version 0.7 - 2020-07-08
|
6
21
|
|
7
22
|
* Introduces CobraCommander::Umbrella with optimizations for dependency resolution
|
data/README.md
CHANGED
@@ -24,19 +24,110 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
$ gem install cobra_commander
|
26
26
|
|
27
|
-
## Usage
|
27
|
+
## Usage (cobra help)
|
28
28
|
|
29
29
|
```bash
|
30
30
|
Commands:
|
31
|
-
cobra
|
32
|
-
cobra
|
33
|
-
cobra
|
34
|
-
cobra
|
35
|
-
cobra
|
36
|
-
cobra
|
37
|
-
cobra
|
38
|
-
|
39
|
-
|
31
|
+
cobra changes [--results=RESULTS] [--branch=BRANCH] # Prints list of changed files
|
32
|
+
cobra exec [component] <command> # Executes the command in the context of a given component or set of components. If no component is given executes the command in all components.
|
33
|
+
cobra graph [component] # Outputs a graph of a given component or umbrella
|
34
|
+
cobra help [COMMAND] # Describe available commands or one specific command
|
35
|
+
cobra ls [component] # Lists the components in the context of a given component or umbrella
|
36
|
+
cobra tree [component] # Prints the dependency tree of a given component or umbrella
|
37
|
+
cobra version # Prints version
|
38
|
+
|
39
|
+
Options:
|
40
|
+
-a, [--app=APP]
|
41
|
+
# Default: /Users/chjunior/workspace/power/cobra_commander
|
42
|
+
[--js], [--no-js] # Consider only the JS dependency graph
|
43
|
+
[--ruby], [--no-ruby] # Consider only the Ruby dependency graph
|
44
|
+
```
|
45
|
+
|
46
|
+
### cobra changes
|
47
|
+
|
48
|
+
```sh
|
49
|
+
➜ nitro git:(nova/remove-cobra-commander) be cobra help changes
|
50
|
+
Usage:
|
51
|
+
cobra changes [--results=RESULTS] [--branch=BRANCH]
|
52
|
+
|
53
|
+
Options:
|
54
|
+
-r, [--results=RESULTS] # Accepts test, full, name or json
|
55
|
+
# Default: test
|
56
|
+
-b, [--branch=BRANCH] # Specified target to calculate against
|
57
|
+
# Default: master
|
58
|
+
-a, [--app=APP]
|
59
|
+
# Default: /Users/chjunior/workspace/power/nitro
|
60
|
+
[--js], [--no-js] # Consider only the JS dependency graph
|
61
|
+
[--ruby], [--no-ruby] # Consider only the Ruby dependency graph
|
62
|
+
|
63
|
+
Prints list of changed files
|
64
|
+
```
|
65
|
+
|
66
|
+
### cobra exec
|
67
|
+
|
68
|
+
```sh
|
69
|
+
Usage:
|
70
|
+
cobra exec [component] <command>
|
71
|
+
|
72
|
+
Options:
|
73
|
+
[--dependencies], [--no-dependencies] # Run the command on each dependency of a given component
|
74
|
+
[--dependents], [--no-dependents] # Run the command on each dependency of a given component
|
75
|
+
-a, [--app=APP]
|
76
|
+
# Default: /Users/chjunior/workspace/power/cobra_commander
|
77
|
+
[--js], [--no-js] # Consider only the JS dependency graph
|
78
|
+
[--ruby], [--no-ruby] # Consider only the Ruby dependency graph
|
79
|
+
|
80
|
+
Executes the command in the context of a given component or set of components. If no component is given executes the command in all components.
|
81
|
+
```
|
82
|
+
|
83
|
+
### cobra graph
|
84
|
+
|
85
|
+
```sh
|
86
|
+
Usage:
|
87
|
+
cobra graph [component]
|
88
|
+
|
89
|
+
Options:
|
90
|
+
-o, [--output=OUTPUT] # Output file, accepts .png or .dot
|
91
|
+
# Default: /Users/chjunior/workspace/power/cobra_commander/output.png
|
92
|
+
-a, [--app=APP]
|
93
|
+
# Default: /Users/chjunior/workspace/power/cobra_commander
|
94
|
+
[--js], [--no-js] # Consider only the JS dependency graph
|
95
|
+
[--ruby], [--no-ruby] # Consider only the Ruby dependency graph
|
96
|
+
|
97
|
+
Outputs a graph of a given component or umbrella
|
98
|
+
```
|
99
|
+
|
100
|
+
### cobra ls
|
101
|
+
|
102
|
+
```sh
|
103
|
+
Usage:
|
104
|
+
cobra ls [component]
|
105
|
+
|
106
|
+
Options:
|
107
|
+
-d, [--dependencies], [--no-dependencies] # Run the command on each dependency of a given component
|
108
|
+
-D, [--dependents], [--no-dependents] # Run the command on each dependency of a given component
|
109
|
+
-t, [--total], [--no-total] # Prints the total count of components
|
110
|
+
-a, [--app=APP]
|
111
|
+
# Default: /Users/chjunior/workspace/power/cobra_commander
|
112
|
+
[--js], [--no-js] # Consider only the JS dependency graph
|
113
|
+
[--ruby], [--no-ruby] # Consider only the Ruby dependency graph
|
114
|
+
|
115
|
+
Lists the components in the context of a given component or umbrella
|
116
|
+
```
|
117
|
+
|
118
|
+
### cobra tree
|
119
|
+
|
120
|
+
```sh
|
121
|
+
Usage:
|
122
|
+
cobra tree [component]
|
123
|
+
|
124
|
+
Options:
|
125
|
+
-a, [--app=APP]
|
126
|
+
# Default: /Users/chjunior/workspace/power/cobra_commander
|
127
|
+
[--js], [--no-js] # Consider only the JS dependency graph
|
128
|
+
[--ruby], [--no-ruby] # Consider only the Ruby dependency graph
|
129
|
+
|
130
|
+
Prints the dependency tree of a given component or umbrella
|
40
131
|
```
|
41
132
|
|
42
133
|
## Development
|
@@ -45,6 +136,14 @@ After checking out the repo, run `bin/setup` to install dependencies. You will a
|
|
45
136
|
|
46
137
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
47
138
|
|
139
|
+
### Bundled App
|
140
|
+
|
141
|
+
In order to maintain the features around umbrella apps and specially `changes`, a bundled [`umbrella app repo`](spec/fixtures/app.tgz) is included in this repository. This repo is compacted by `tar`/`gzip` in order to keep isolation, the format was chosen to avoid issues described in https://github.com/swcarpentry/git-novice/issues/272. To avoid the same issues, the workflow for this fixture app is the following:
|
142
|
+
|
143
|
+
1. unpack it somewhere outside your repo
|
144
|
+
1. do your changes and commit (locally only, it doesn't have a remote)
|
145
|
+
1. from within the app run `tar cfz path/to/cobra/spec/fixtures/app.tgz .`
|
146
|
+
|
48
147
|
## Contributing
|
49
148
|
|
50
149
|
Bug reports and pull requests are welcome on GitHub at https://github.com/powerhome/cobra_commander. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
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,14 +33,17 @@ 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 "
|
36
|
+
spec.add_dependency "bundler", "~> 1.17"
|
38
37
|
spec.add_dependency "ruby-graphviz", "~> 1.2.3"
|
38
|
+
spec.add_dependency "thor", ["< 2.0", ">= 0.18.1"]
|
39
|
+
spec.add_dependency "tty-command", "~> 0.9.0"
|
40
|
+
spec.add_dependency "tty-spinner", "~> 0.9.3"
|
39
41
|
|
42
|
+
spec.add_development_dependency "aruba", "~> 0.14.2"
|
40
43
|
spec.add_development_dependency "bundler", "~> 1.17"
|
41
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
42
|
-
spec.add_development_dependency "rspec", "~> 3.5"
|
43
44
|
spec.add_development_dependency "guard-rspec"
|
44
|
-
spec.add_development_dependency "aruba", "~> 0.14.2"
|
45
|
-
spec.add_development_dependency "rubocop", "0.48.1"
|
46
45
|
spec.add_development_dependency "pry"
|
46
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
47
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
48
|
+
spec.add_development_dependency "rubocop", "0.88.0"
|
47
49
|
end
|
data/exe/cobra
CHANGED
data/lib/cobra_commander.rb
CHANGED
@@ -3,16 +3,7 @@
|
|
3
3
|
require "cobra_commander/dependencies"
|
4
4
|
require "cobra_commander/component"
|
5
5
|
require "cobra_commander/umbrella"
|
6
|
-
|
7
|
-
require "cobra_commander/cli"
|
8
|
-
require "cobra_commander/cached_component_tree"
|
9
|
-
require "cobra_commander/calculated_component_tree"
|
10
6
|
require "cobra_commander/version"
|
11
|
-
require "cobra_commander/graph"
|
12
|
-
require "cobra_commander/change"
|
13
|
-
require "cobra_commander/affected"
|
14
|
-
require "cobra_commander/output"
|
15
|
-
require "cobra_commander/executor"
|
16
7
|
|
17
8
|
# Tools for working with Component Based Rails Apps (see http://shageman.github.io/cbra.info/).
|
18
9
|
# Includes tools for graphing the components of an app and their relationships, as well as selectively
|
@@ -49,8 +49,16 @@ module CobraCommander
|
|
49
49
|
@directly = @directly.sort_by(&:name)
|
50
50
|
end
|
51
51
|
|
52
|
+
def component_changed?(component)
|
53
|
+
component.root_paths.any? do |component_path|
|
54
|
+
@changes.any? do |file_path|
|
55
|
+
file_path.start_with?(component_path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
52
60
|
def add_if_changed(component)
|
53
|
-
return
|
61
|
+
return unless component_changed?(component)
|
54
62
|
|
55
63
|
@directly << component
|
56
64
|
@transitively.merge(component.deep_dependents)
|
@@ -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)
|
data/lib/cobra_commander/cli.rb
CHANGED
@@ -3,86 +3,93 @@
|
|
3
3
|
require "thor"
|
4
4
|
require "fileutils"
|
5
5
|
|
6
|
+
require "cobra_commander"
|
7
|
+
require "cobra_commander/affected"
|
8
|
+
require "cobra_commander/change"
|
9
|
+
require "cobra_commander/executor"
|
10
|
+
require "cobra_commander/output"
|
11
|
+
|
6
12
|
module CobraCommander
|
7
13
|
# Implements the tool's CLI
|
8
14
|
class CLI < Thor
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
COMMON_OPTIONS = "[--app=pwd] [--format=FORMAT] [--cache=nil]"
|
13
|
-
|
14
|
-
desc "do [command] [--app=pwd] [--cache=nil]", "Executes the command in the context of each component in [app]"
|
15
|
-
method_option :app, default: Dir.pwd, aliases: "-a", desc: "App path (default: CWD)"
|
16
|
-
method_option :cache, default: nil, aliases: "-c", desc: CACHE_DESCRIPTION
|
17
|
-
def do(command)
|
18
|
-
executor = Executor.new(umbrella(options.app).components)
|
19
|
-
executor.exec(command)
|
20
|
-
end
|
15
|
+
class_option :app, default: Dir.pwd, aliases: "-a", type: :string
|
16
|
+
class_option :js, default: false, type: :boolean, desc: "Consider only the JS dependency graph"
|
17
|
+
class_option :ruby, default: false, type: :boolean, desc: "Consider only the Ruby dependency graph"
|
21
18
|
|
22
|
-
desc "
|
23
|
-
|
24
|
-
|
25
|
-
method_option :cache, default: nil, aliases: "-c", desc: CACHE_DESCRIPTION
|
26
|
-
def ls(app_path = Dir.pwd)
|
27
|
-
Output.print(
|
28
|
-
umbrella(app_path).root,
|
29
|
-
options.format
|
30
|
-
)
|
19
|
+
desc "version", "Prints version"
|
20
|
+
def version
|
21
|
+
puts CobraCommander::VERSION
|
31
22
|
end
|
32
23
|
|
33
|
-
desc "
|
34
|
-
method_option :
|
35
|
-
|
36
|
-
method_option :
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
24
|
+
desc "ls [component]", "Lists the components in the context of a given component or umbrella"
|
25
|
+
method_option :dependencies, type: :boolean, aliases: "-d",
|
26
|
+
desc: "Run the command on each dependency of a given component"
|
27
|
+
method_option :dependents, type: :boolean, aliases: "-D",
|
28
|
+
desc: "Run the command on each dependency of a given component"
|
29
|
+
method_option :total, type: :boolean, aliases: "-t", desc: "Prints the total count of components"
|
30
|
+
def ls(component = nil)
|
31
|
+
components = components_filtered(component)
|
32
|
+
puts options.total ? components.size : CobraCommander::Output::FlatList.new(components).to_s
|
41
33
|
end
|
42
34
|
|
43
|
-
desc "
|
44
|
-
|
45
|
-
method_option :
|
46
|
-
method_option :
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
desc "exec [component] <command>", "Executes the command in the context of a given component or set thereof. " \
|
36
|
+
"Defaults to all components."
|
37
|
+
method_option :dependencies, type: :boolean, desc: "Run the command on each dependency of a given component"
|
38
|
+
method_option :dependents, type: :boolean, desc: "Run the command on each dependency of a given component"
|
39
|
+
def exec(command_or_component, command = nil)
|
40
|
+
CobraCommander::Executor.exec(
|
41
|
+
components_filtered(command && command_or_component),
|
42
|
+
command || command_or_component
|
51
43
|
)
|
52
44
|
end
|
53
45
|
|
54
|
-
desc "
|
55
|
-
def
|
56
|
-
|
46
|
+
desc "tree [component]", "Prints the dependency tree of a given component or umbrella"
|
47
|
+
def tree(component = nil)
|
48
|
+
component = find_component(component)
|
49
|
+
puts CobraCommander::Output::AsciiTree.new(component).to_s
|
57
50
|
end
|
58
51
|
|
59
|
-
desc "graph
|
60
|
-
method_option :
|
61
|
-
|
62
|
-
def graph(
|
63
|
-
|
52
|
+
desc "graph [component]", "Outputs a graph of a given component or umbrella"
|
53
|
+
method_option :output, default: File.join(Dir.pwd, "output.png"), aliases: "-o",
|
54
|
+
desc: "Output file, accepts .png or .dot"
|
55
|
+
def graph(component = nil)
|
56
|
+
CobraCommander::Output::GraphViz.generate(
|
57
|
+
find_component(component),
|
58
|
+
options.output
|
59
|
+
)
|
60
|
+
puts "Graph generated at #{options.output}"
|
61
|
+
rescue ArgumentError => e
|
62
|
+
error e.message
|
64
63
|
end
|
65
64
|
|
66
|
-
desc "changes
|
65
|
+
desc "changes [--results=RESULTS] [--branch=BRANCH]", "Prints list of changed files"
|
67
66
|
method_option :results, default: "test", aliases: "-r", desc: "Accepts test, full, name or json"
|
68
67
|
method_option :branch, default: "master", aliases: "-b", desc: "Specified target to calculate against"
|
69
|
-
|
70
|
-
|
71
|
-
Change.new(umbrella(app_path), options.results, options.branch).run!
|
68
|
+
def changes
|
69
|
+
Change.new(umbrella, options.results, options.branch).run!
|
72
70
|
end
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
File.write(cache_path, tree.to_json)
|
79
|
-
puts "Created cache of component tree at #{cache_path}"
|
72
|
+
private
|
73
|
+
|
74
|
+
def umbrella
|
75
|
+
@umbrella ||= CobraCommander.umbrella(options.app, yarn: options.js, bundler: options.ruby)
|
80
76
|
end
|
81
77
|
|
82
|
-
|
78
|
+
def find_component(name)
|
79
|
+
return umbrella.root unless name
|
80
|
+
|
81
|
+
umbrella.find(name) || error("Component #{name} not found, try one of `cobra ls`") || exit(1)
|
82
|
+
end
|
83
|
+
|
84
|
+
def components_filtered(component_name)
|
85
|
+
return umbrella.components unless component_name
|
86
|
+
|
87
|
+
component = find_component(component_name)
|
88
|
+
|
89
|
+
return component.deep_dependencies if options.dependencies
|
90
|
+
return component.deep_dependents if options.dependents
|
83
91
|
|
84
|
-
|
85
|
-
CobraCommander.umbrella(path)
|
92
|
+
[component]
|
86
93
|
end
|
87
94
|
end
|
88
95
|
end
|