cobra_commander 0.2.0 → 0.3.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
  SHA1:
3
- metadata.gz: c08e78acc81afe93b06677fe59da88133927cd5a
4
- data.tar.gz: 060cc5c2e75fdd9d85d9686cb9d34f23e2b60eba
3
+ metadata.gz: 9f6f02282233ec41c21d79041849fed2e2e2cc60
4
+ data.tar.gz: 78739e6b66cdbda390a0dacc7aa9ed188cfcd391
5
5
  SHA512:
6
- metadata.gz: 1b9341d5b477afc484ff76eff6eab70efa90ff26e9ff4df804737ecc36db2d5b4bd0d2644565226b2d46e8db69919aa70880c48a35b1138ed272a5b832d78258
7
- data.tar.gz: 953c630c3f7751ad8306f8098e3bf815f0d79d57931c2b23cafdfd6e70bf5d9a0a535bc9799e3bb591226b1df28bfb68256f7c29884bab455fc4ab167578bd68
6
+ metadata.gz: cb9108f46b25e17f6da9261f10e88d623476b70b3c5341b214b8184e7d9b51d656afd66ab5b1316d61f404fe579760f592bd5a7e30caba235ccac9a55a6efa39
7
+ data.tar.gz: 7800ed167bca503ca3ad2f6c5bdcd6c7cd4241dc96d54fab2e4d8c92f73445aa7952fda746bf99b5255addee46dd2a9aa7483f2bb9a74c4d50c015eff10ffe87
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## Version 0.3.0 - 2017-10-22
6
+
7
+ ### Added
8
+
9
+ * Add `name` option for `changes --result` flag that outputs affected component names. PR [#12](https://github.com/powerhome/cobra_commander/pull/12)
10
+
11
+ * Track package.json `devDependencies` in addition to `dependencies`. PR [#13](https://github.com/powerhome/cobra_commander/pull/13)
12
+
13
+ * Add `json` option for `changes --result` flag that outputs data as json object. PR [#15](https://github.com/powerhome/cobra_commander/pull/15)
14
+
5
15
  ## Version 0.2.0 - 2017-09-01
6
16
 
7
17
  ### Added
@@ -12,10 +12,26 @@ module CobraCommander
12
12
  run!
13
13
  end
14
14
 
15
- def needs_testing
16
- @needs_testing ||= all_affected.map! do |component|
17
- File.join(component[:path], "test.sh")
18
- end
15
+ def names
16
+ @names ||= paths.map { |path| File.basename(path) }
17
+ end
18
+
19
+ def scripts
20
+ @scripts ||= paths.map { |path| File.join(path, "test.sh") }
21
+ end
22
+
23
+ def json_representation # rubocop:disable Metrics/MethodLength
24
+ {
25
+ changed_files: @changes,
26
+ directly_affected_components: @directly,
27
+ transitively_affected_components: @transitively,
28
+ test_scripts: scripts,
29
+ component_names: names,
30
+ languages: {
31
+ ruby: contains_ruby?,
32
+ javascript: contains_js?,
33
+ },
34
+ }.to_json
19
35
  end
20
36
 
21
37
  private
@@ -46,7 +62,23 @@ module CobraCommander
46
62
  end
47
63
 
48
64
  def all_affected
49
- (@directly + @transitively).uniq.sort_by { |h| h[:path] }
65
+ @all_affected ||= (@directly + @transitively).uniq.sort_by { |h| h[:path] }
66
+ end
67
+
68
+ def paths
69
+ @paths ||= all_affected.map { |component| component[:path] }
70
+ end
71
+
72
+ def types
73
+ @types ||= all_affected.map { |component| component[:type] }
74
+ end
75
+
76
+ def contains_ruby?
77
+ types.uniq.join.include?("Ruby")
78
+ end
79
+
80
+ def contains_js?
81
+ types.uniq.join.include?("JS")
50
82
  end
51
83
  end
52
84
  end
@@ -19,8 +19,12 @@ module CobraCommander
19
19
 
20
20
  def run!
21
21
  assert_valid_result_choice
22
- show_full if selected_full_results?
23
- tests_to_run
22
+ if selected_result?("json")
23
+ puts @affected.json_representation
24
+ else
25
+ show_full if selected_result?("full")
26
+ tests_to_run
27
+ end
24
28
  rescue InvalidSelectionError => e
25
29
  puts e.message
26
30
  end
@@ -48,11 +52,11 @@ module CobraCommander
48
52
  end
49
53
 
50
54
  def assert_valid_result_choice
51
- raise InvalidSelectionError, "--results must be 'test' or 'full'" unless %w[test full].include?(@results)
55
+ raise InvalidSelectionError, "--results must be 'test', 'full', 'name' or 'json'" unless %w[test full name json].include?(@results) # rubocop:disable Metrics/LineLength
52
56
  end
53
57
 
54
- def selected_full_results?
55
- @results == "full"
58
+ def selected_result?(result)
59
+ @results == result
56
60
  end
57
61
 
58
62
  def changes_since_last_commit
@@ -74,8 +78,12 @@ module CobraCommander
74
78
  end
75
79
 
76
80
  def tests_to_run
77
- puts "<<< Test scripts to run >>>" if selected_full_results?
78
- @affected.needs_testing.each { |script| puts script }
81
+ puts "<<< Test scripts to run >>>" if selected_result?("full")
82
+ if selected_result?("name")
83
+ @affected.names.each { |component_name| puts component_name }
84
+ else
85
+ @affected.scripts.each { |component_script| puts component_script }
86
+ end
79
87
  end
80
88
 
81
89
  def display(component)
@@ -22,7 +22,7 @@ module CobraCommander
22
22
  end
23
23
 
24
24
  desc "changes APP_PATH [--results=RESULTS] [--branch=BRANCH]", "Prints list of changed files"
25
- method_option :results, default: "test", aliases: "-r", desc: "Accepts test or full"
25
+ method_option :results, default: "test", aliases: "-r", desc: "Accepts test, full, name or json"
26
26
  method_option :branch, default: "master", aliases: "-b", desc: "Specified target to calculate against"
27
27
  def changes(app_path)
28
28
  Change.new(app_path, @options[:results], @options[:branch]).run!
@@ -105,7 +105,7 @@ module CobraCommander
105
105
  @deps ||= begin
106
106
  return [] unless node?
107
107
  json = JSON.parse(File.read(package_json_path))
108
- format(json["dependencies"])
108
+ format combined_deps(json)
109
109
  end
110
110
  end
111
111
 
@@ -126,6 +126,10 @@ module CobraCommander
126
126
  def package_json_path
127
127
  File.join(@root_path, "package.json")
128
128
  end
129
+
130
+ def combined_deps(json)
131
+ Hash(json["dependencies"]).merge(Hash(json["devDependencies"]))
132
+ end
129
133
  end
130
134
  end
131
135
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CobraCommander
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Langfeld
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-09-01 00:00:00.000000000 Z
12
+ date: 2017-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor