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 +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/cobra_commander/affected.rb +37 -5
- data/lib/cobra_commander/change.rb +15 -7
- data/lib/cobra_commander/cli.rb +1 -1
- data/lib/cobra_commander/component_tree.rb +5 -1
- data/lib/cobra_commander/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f6f02282233ec41c21d79041849fed2e2e2cc60
|
4
|
+
data.tar.gz: 78739e6b66cdbda390a0dacc7aa9ed188cfcd391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
16
|
-
@
|
17
|
-
|
18
|
-
|
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
|
-
|
23
|
-
|
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 '
|
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
|
55
|
-
@results ==
|
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
|
78
|
-
|
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)
|
data/lib/cobra_commander/cli.rb
CHANGED
@@ -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
|
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
|
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
|
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.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-
|
12
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|