cobra_commander 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8461ea231fa9be478360d33fbadfb8983512172687831ac7c17ac1f927614200
4
- data.tar.gz: 0b36b28eadecb6e0bc6e7ee8c3e6db951f7dc7d74be67c91b97659dc7bd52c5e
3
+ metadata.gz: 4eb007805f5f11954ed14e349409c7486fc6b52d0a041f8066c75c47f8d045b8
4
+ data.tar.gz: 68ac383fb087d118a276e5aed0199b51fd09b05c110d7ff4539f18097b1ea367
5
5
  SHA512:
6
- metadata.gz: 39a0956db1750d63553d87e4d13ad75246f4f4633b3d6a42de621c45f11a515506ab5f0d7f14343d61f183d03df7e8218dee8f93a439da023e442d70c7f3b681
7
- data.tar.gz: 227acbdb961e2903cdaacd44ed4bdd7b07a48e7298737bbe5b6228bd28df8aa6c7aea6a6949de2a3eea999287b633e9bfcd32b7b9e108e3f7f4fcaa7385e2806
6
+ metadata.gz: 6a5f69e411bf49bd1de717934f27c0d364378e07ce1728855b2783de0c73dff791be433565b689656d4481b2ad294086fc43118beafc16ca445a2c91ea7916c9
7
+ data.tar.gz: afdf327649c953bc155f5e01a6db9f4cef12ed625f7c791534e7ae65ac0d05c2260bfd20b03f382eac9aaee9f2e84612806c050327491c2f806223d7e612aa67
@@ -40,10 +40,7 @@ jobs:
40
40
  - uses: ruby/setup-ruby@v1
41
41
  with:
42
42
  ruby-version: 3.0
43
- - uses: reviewdog/action-rubocop@v1
44
- with:
45
- rubocop_version: 0.88.0
46
- filter_mode: nofilter
47
- fail_on_error: true
48
- rubocop_extensions: ""
49
- github_token: ${{ secrets.github_token }}
43
+ - name: Bundle
44
+ run: bundle
45
+ - name: Run standard
46
+ run: bundle exec rake standard
@@ -10,7 +10,7 @@ jobs:
10
10
  build:
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v1
13
+ - uses: actions/checkout@v2
14
14
  - name: Release Gem
15
15
  uses: cadwallion/publish-rubygems-action@master
16
16
  if: contains(github.ref, 'refs/tags/v')
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## Version 0.13.0 - 2021-10-21
6
+
7
+ * Sorts the interactive UI alphabetically with failures first [#66](https://github.com/powerhome/cobra_commander/pull/66)
8
+ * Switch linter to standardrb [#67](https://github.com/powerhome/cobra_commander/pull/67)
9
+
5
10
  ## Version 0.12.0 - 2021-09-21
6
11
 
7
12
  * Add interactive UI and Markdown output to `cobra exec` [#63](https://github.com/powerhome/cobra_commander/pull/63)
data/Rakefile CHANGED
@@ -1,11 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
-
4
+ require "standard/rake"
5
5
  require "rspec/core/rake_task"
6
- RSpec::Core::RakeTask.new(:spec)
7
6
 
8
- require "rubocop/rake_task"
9
- RuboCop::RakeTask.new
7
+ RSpec::Core::RakeTask.new(:spec)
10
8
 
11
- task default: %i[spec rubocop]
9
+ task default: %i[spec standard]
@@ -5,32 +5,32 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "cobra_commander/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = "cobra_commander"
9
- spec.version = CobraCommander::VERSION
10
- spec.authors = [
8
+ spec.name = "cobra_commander"
9
+ spec.version = CobraCommander::VERSION
10
+ spec.authors = [
11
11
  "Ben Langfeld",
12
12
  "Garett Arrowood",
13
- "Carlos Palhares",
13
+ "Carlos Palhares"
14
14
  ]
15
15
  spec.email = [
16
16
  "blangfeld@powerhrg.com",
17
17
  "garett.arrowood@powerhrg.com",
18
- "carlos.palhares@powerhrg.com",
18
+ "carlos.palhares@powerhrg.com"
19
19
  ]
20
- spec.summary = "Tools for working with Component Based Rails Apps"
21
- spec.description = <<~DESCRIPTION
20
+ spec.summary = "Tools for working with Component Based Rails Apps"
21
+ spec.description = <<~DESCRIPTION
22
22
  Tools for working with Component Based Rails Apps (see http://shageman.github.io/cbra.info/).
23
23
  Includes tools for graphing the components of an app and their relationships, as well as selectively
24
24
  testing components based on changes made.
25
25
  DESCRIPTION
26
- spec.homepage = "http://tech.powerhrg.com/cobra_commander/"
27
- spec.license = "MIT"
26
+ spec.homepage = "http://tech.powerhrg.com/cobra_commander/"
27
+ spec.license = "MIT"
28
28
 
29
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
29
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
30
30
  f.match(%r{^(test|spec|features)/})
31
31
  end
32
- spec.bindir = "exe"
33
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
34
  spec.require_paths = ["lib"]
35
35
 
36
36
  spec.add_dependency "bundler"
@@ -47,5 +47,5 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency "pry"
48
48
  spec.add_development_dependency "rake", ">= 12.3.3"
49
49
  spec.add_development_dependency "rspec", "~> 3.5"
50
- spec.add_development_dependency "rubocop", "0.88.0"
50
+ spec.add_development_dependency "standard", ">= 1.3.0"
51
51
  end
@@ -25,21 +25,18 @@ module CobraCommander
25
25
  @transitively.map(&method(:affected_component))
26
26
  end
27
27
 
28
- def json_representation # rubocop:disable Metrics/MethodLength
28
+ def json_representation
29
29
  {
30
30
  changed_files: @changes,
31
31
  directly_affected_components: directly,
32
32
  transitively_affected_components: transitively,
33
33
  test_scripts: scripts,
34
34
  component_names: names,
35
- languages: {
36
- ruby: contains_ruby?,
37
- javascript: contains_js?,
38
- },
35
+ languages: {ruby: contains_ruby?, javascript: contains_js?}
39
36
  }.to_json
40
37
  end
41
38
 
42
- private
39
+ private
43
40
 
44
41
  def run!
45
42
  @transitively = Set.new
@@ -68,7 +65,7 @@ module CobraCommander
68
65
  {
69
66
  name: component.name,
70
67
  path: component.root_paths,
71
- type: component.sources.keys.map(&:to_s).map(&:capitalize).join(" & "),
68
+ type: component.sources.keys.map(&:to_s).map(&:capitalize).join(" & ")
72
69
  }
73
70
  end
74
71
 
@@ -28,7 +28,7 @@ module CobraCommander
28
28
  puts e.message
29
29
  end
30
30
 
31
- private
31
+ private
32
32
 
33
33
  def show_full
34
34
  changes_since_last_commit
@@ -9,7 +9,7 @@ module CobraCommander
9
9
  method_option :self, type: :boolean, default: true, desc: "Include the own component"
10
10
  end
11
11
 
12
- private
12
+ private
13
13
 
14
14
  def find_component(name)
15
15
  return umbrella.root unless name
@@ -28,7 +28,7 @@ module CobraCommander
28
28
 
29
29
  desc "ls [component]", "Lists the components in the context of a given component or umbrella"
30
30
  filter_options dependents: "Lists all dependents of a given component",
31
- dependencies: "Lists all dependencies of a given component"
31
+ dependencies: "Lists all dependencies of a given component"
32
32
  method_option :total, type: :boolean, aliases: "-t", desc: "Prints the total count of components"
33
33
  def ls(component = nil)
34
34
  components = components_filtered(component)
@@ -38,17 +38,17 @@ module CobraCommander
38
38
  desc "exec [component] <command>", "Executes the command in the context of a given component or set thereof. " \
39
39
  "Defaults to all components."
40
40
  filter_options dependents: "Run the command on each dependent of a given component",
41
- dependencies: "Run the command on each dependency of a given component"
41
+ dependencies: "Run the command on each dependency of a given component"
42
42
  method_option :concurrency, type: :numeric, default: DEFAULT_CONCURRENCY, aliases: "-c",
43
43
  desc: "Max number of jobs to run concurrently"
44
44
  method_option :interactive, type: :boolean, default: true, aliases: "-i",
45
- desc: "Runs in interactive mode to allow the user to inspect the output of each component"
45
+ desc: "Runs in interactive mode to allow the user to inspect the output of each " \
46
+ "component"
46
47
  def exec(command_or_component, command = nil)
47
48
  results = CobraCommander::Executor.exec(
48
49
  components: components_filtered(command && command_or_component),
49
50
  command: command || command_or_component,
50
- concurrency: options.concurrency,
51
- status_output: $stderr
51
+ concurrency: options.concurrency, status_output: $stderr
52
52
  )
53
53
  if options.interactive && results.size > 1
54
54
  CobraCommander::Output::InteractivePrinter.run(results, $stdout)
@@ -83,7 +83,7 @@ module CobraCommander
83
83
  Change.new(umbrella, options.results, options.branch).run!
84
84
  end
85
85
 
86
- private
86
+ private
87
87
 
88
88
  def umbrella
89
89
  @umbrella ||= CobraCommander.umbrella(options.app, yarn: options.js, bundler: options.ruby)
@@ -45,8 +45,8 @@ module CobraCommander
45
45
 
46
46
  def dependencies
47
47
  @dependencies ||= @dependency_names.sort
48
- .map(&@umbrella.method(:find))
49
- .compact
48
+ .map(&@umbrella.method(:find))
49
+ .compact
50
50
  end
51
51
  end
52
52
  end
@@ -21,11 +21,11 @@ module CobraCommander
21
21
 
22
22
  def components
23
23
  components_source.specs.map do |spec|
24
- { path: spec.loaded_from, name: spec.name, dependencies: spec.dependencies.map(&:name) }
24
+ {path: spec.loaded_from, name: spec.name, dependencies: spec.dependencies.map(&:name)}
25
25
  end
26
26
  end
27
27
 
28
- private
28
+ private
29
29
 
30
30
  def lockfile
31
31
  @lockfile ||= ::Bundler::LockfileParser.new(::Bundler.read_file(path))
@@ -24,10 +24,10 @@ module CobraCommander
24
24
 
25
25
  def dependencies
26
26
  json.fetch("dependencies", {})
27
- .merge(json.fetch("devDependencies", {}))
27
+ .merge(json.fetch("devDependencies", {}))
28
28
  end
29
29
 
30
- private
30
+ private
31
31
 
32
32
  def json
33
33
  @json ||= JSON.parse(File.read(@path))
@@ -28,11 +28,11 @@ module CobraCommander
28
28
 
29
29
  def components
30
30
  @repo.specs.map do |spec|
31
- { path: spec.path, name: untag(spec.name), dependencies: spec.dependencies.keys.map(&method(:untag)) }
31
+ {path: spec.path, name: untag(spec.name), dependencies: spec.dependencies.keys.map(&method(:untag))}
32
32
  end
33
33
  end
34
34
 
35
- private
35
+ private
36
36
 
37
37
  def load_workspace_packages
38
38
  workspace_spec.map do |_name, spec|
@@ -23,7 +23,7 @@ module CobraCommander
23
23
  @results
24
24
  end
25
25
 
26
- private
26
+ private
27
27
 
28
28
  def pastel
29
29
  @pastel ||= Pastel.new
@@ -33,7 +33,7 @@ module CobraCommander
33
33
  @spinner_options ||= {
34
34
  format: :bouncing,
35
35
  success_mark: pastel.green("[DONE]"),
36
- error_mark: pastel.red("[ERROR]"),
36
+ error_mark: pastel.red("[ERROR]")
37
37
  }
38
38
  end
39
39
 
@@ -4,6 +4,8 @@ require "tty-command"
4
4
 
5
5
  module CobraCommander
6
6
  module Executor
7
+ # Represents a component context to execute a command
8
+ # @private
7
9
  class Context
8
10
  attr_reader :component, :command
9
11
 
@@ -33,7 +35,7 @@ module CobraCommander
33
35
  results.join("\n")
34
36
  end
35
37
 
36
- private
38
+ private
37
39
 
38
40
  def isolate_bundle(&block)
39
41
  if Bundler.respond_to?(:with_unbundled_env)
@@ -8,7 +8,7 @@ module CobraCommander
8
8
  module Executor
9
9
  def self.exec(components:, command:, concurrency:, status_output:)
10
10
  Concurrent.new(components, concurrency: concurrency, spin_output: status_output)
11
- .exec(command)
11
+ .exec(command)
12
12
  end
13
13
  end
14
14
  end
@@ -6,9 +6,9 @@ module CobraCommander
6
6
  module Output
7
7
  # Prints the tree in a nice tree form
8
8
  class AsciiTree
9
- SPACE = " "
10
- BAR = "│   "
11
- TEE = "├── "
9
+ SPACE = " "
10
+ BAR = "│   "
11
+ TEE = "├── "
12
12
  CORNER = "└── "
13
13
 
14
14
  def initialize(component)
@@ -22,7 +22,7 @@ module CobraCommander
22
22
  end.string
23
23
  end
24
24
 
25
- private
25
+ private
26
26
 
27
27
  def list_dependencies(io, component, outdents = [])
28
28
  component.dependencies.each do |dep|
@@ -17,7 +17,7 @@ module CobraCommander
17
17
  end
18
18
 
19
19
  private_class_method def self.extract_format(output)
20
- format = output[-3..-1]
20
+ format = output[-3..-1] # standard:disable Style/SlicingWithRange
21
21
  return format if %w[png dot].include?(format)
22
22
 
23
23
  raise ArgumentError, "output format must be 'png' or 'dot'"
@@ -6,26 +6,42 @@ require "tty-prompt"
6
6
  module CobraCommander
7
7
  module Output
8
8
  # Runs an interactive output printer
9
- module InteractivePrinter
9
+ class InteractivePrinter
10
10
  pastel = Pastel.new
11
- SUCCESS = "#{pastel.green("✔")} %s".freeze
12
- ERROR = "#{pastel.red("✖")} %s".freeze
13
- BYE = pastel.decorate("👋 Bye!", :white, :on_black, :bold).freeze
11
+ SUCCESS = "#{pastel.green("✔")} %s"
12
+ ERROR = "#{pastel.red("✖")} %s"
13
+ BYE = pastel.decorate("\n\n👋 Bye!", :white, :on_black, :bold).freeze
14
14
 
15
15
  def self.run(contexts, output)
16
- prompt = TTY::Prompt.new
17
- context_options = contexts.reduce({}) do |options, context|
16
+ new(contexts).run(output)
17
+ end
18
+
19
+ def initialize(contexts)
20
+ @prompt = TTY::Prompt.new
21
+ @options = contexts.sort(&method(:sort_contexts))
22
+ .reduce({}) do |options, context|
18
23
  template = context.success? ? SUCCESS : ERROR
19
- options.merge(
20
- format(template, context.component_name) => context
21
- )
24
+ options.merge format(template, context.component_name) => context
22
25
  end
26
+ end
27
+
28
+ def run(output)
23
29
  loop do
24
- context = prompt.select("Print output?", context_options)
30
+ context = @prompt.select("Print output?", @options)
25
31
  output.puts context.output
26
32
  end
27
33
  rescue TTY::Reader::InputInterrupt
28
- output.puts "\n\n", BYE
34
+ output.puts BYE
35
+ end
36
+
37
+ private
38
+
39
+ def sort_contexts(context_a, context_b)
40
+ if context_a.success? == context_b.success?
41
+ context_a.component_name <=> context_b.component_name
42
+ else
43
+ context_a.success? ? 1 : -1
44
+ end
29
45
  end
30
46
  end
31
47
  end
@@ -7,9 +7,9 @@ module CobraCommander
7
7
  module Output
8
8
  # Prints the given CobraCommander::Executor::Context to [output] collection in markdown
9
9
  module MarkdownPrinter
10
- SUCCESS = "\n## ✔ %s\n".freeze
11
- ERROR = "\n## ✖ %s\n".freeze
12
- OUTPUT = "\n```\n$ %s\n\n%s\n```\n".freeze
10
+ SUCCESS = "\n## ✔ %s\n"
11
+ ERROR = "\n## ✖ %s\n"
12
+ OUTPUT = "\n```\n$ %s\n\n%s\n```\n"
13
13
 
14
14
  def self.run(contexts, output)
15
15
  contexts.each do |context|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CobraCommander
4
- VERSION = "0.12.0"
4
+ VERSION = "0.13.0"
5
5
  end
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.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Langfeld
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-09-21 00:00:00.000000000 Z
13
+ date: 2021-10-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -201,19 +201,19 @@ dependencies:
201
201
  - !ruby/object:Gem::Version
202
202
  version: '3.5'
203
203
  - !ruby/object:Gem::Dependency
204
- name: rubocop
204
+ name: standard
205
205
  requirement: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - '='
207
+ - - ">="
208
208
  - !ruby/object:Gem::Version
209
- version: 0.88.0
209
+ version: 1.3.0
210
210
  type: :development
211
211
  prerelease: false
212
212
  version_requirements: !ruby/object:Gem::Requirement
213
213
  requirements:
214
- - - '='
214
+ - - ">="
215
215
  - !ruby/object:Gem::Version
216
- version: 0.88.0
216
+ version: 1.3.0
217
217
  description: |
218
218
  Tools for working with Component Based Rails Apps (see http://shageman.github.io/cbra.info/).
219
219
  Includes tools for graphing the components of an app and their relationships, as well as selectively