anticuado 0.2.14 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +28 -0
- data/README.md +19 -14
- data/anticuado.gemspec +6 -2
- data/lib/anticuado.rb +1 -0
- data/lib/anticuado/base.rb +11 -23
- data/lib/anticuado/elixir/hex.rb +12 -13
- data/lib/anticuado/github.rb +86 -0
- data/lib/anticuado/ios/carthage.rb +28 -10
- data/lib/anticuado/ios/cocoapods.rb +55 -27
- data/lib/anticuado/java/gradle.rb +14 -13
- data/lib/anticuado/javascript/npm.rb +19 -13
- data/lib/anticuado/javascript/yarn.rb +19 -13
- data/lib/anticuado/ruby/bundler.rb +39 -14
- data/lib/anticuado/version.rb +1 -1
- metadata +63 -9
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b031d2164292d5feff8bd65a2d1e2a011e357d71ee7d83f9a2f28016548df84a
|
4
|
+
data.tar.gz: bd94fee7076a9f3d92a116967282d60bad513da4ab07cca219401b4b1879dca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e3a2c447c08cfd1812f75cbbbae08e3e462cf5547163b1ca1983b19097c4056cee02752ad7a3bc7b7c373d2e471b1fe9ed858f7f30cef89df8136b9991f20e2
|
7
|
+
data.tar.gz: 75ee0bf8aef0c1d9e10605d194e9c71774094092494f4d69a6e68a88a296f29e2716d0fc43a3b0cdb231543b32f0e120e4413a3dcc97d8c834ef8dd30d14dc03
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7]
|
15
|
+
os: [ubuntu-latest, macos-latest]
|
16
|
+
|
17
|
+
runs-on: ${{ matrix.os }}
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
- name: Install dependencies
|
26
|
+
run: bundle install
|
27
|
+
- name: Run tests
|
28
|
+
run: bundle exec rake test
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Anticuado
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/KazuCocoa/anticuado.svg?branch=master)](https://travis-ci.org/KazuCocoa/anticuado)
|
4
|
-
|
5
3
|
This library collect __outdated__ libraries for each platforms. [Here](https://github.com/KazuCocoa/anticuado-example) is example how to use this library.
|
6
4
|
And [this travis project](https://travis-ci.org/KazuCocoa/anticuado-example) is just sample how to run this and the output.
|
7
5
|
|
@@ -64,8 +62,9 @@ This library's results are like the following format:
|
|
64
62
|
```ruby
|
65
63
|
require "anticuado"
|
66
64
|
|
67
|
-
|
68
|
-
|
65
|
+
cocoadpos = ::Anticuado::IOS::CocoaPods.new "path/to/project"
|
66
|
+
outdated = cocoadpos.outdated
|
67
|
+
cocoadpos.format outdated
|
69
68
|
```
|
70
69
|
|
71
70
|
#### Carthage
|
@@ -75,8 +74,9 @@ outdated = ::Anticuado::IOS::CocoaPods.outdated "path/to/project"
|
|
75
74
|
```ruby
|
76
75
|
require "anticuado"
|
77
76
|
|
78
|
-
|
79
|
-
|
77
|
+
carthage = ::Anticuado::IOS::Carthage.new "path/to/project"
|
78
|
+
outdated = carthage.outdated
|
79
|
+
carthage.format outdated
|
80
80
|
```
|
81
81
|
|
82
82
|
### Android
|
@@ -91,9 +91,10 @@ https://github.com/ben-manes/gradle-versions-plugin
|
|
91
91
|
```ruby
|
92
92
|
require "anticuado"
|
93
93
|
|
94
|
-
::Anticuado::Java::Gradle.
|
95
|
-
outdated
|
96
|
-
|
94
|
+
gradle = ::Anticuado::Java::Gradle.new "path/to/project"
|
95
|
+
gradle.outdated # Writes the result to "build/dependencyUpdates" by defaylt
|
96
|
+
outdated = gradle.parse_json "build/dependencyUpdates"
|
97
|
+
gradle.format outdated
|
97
98
|
```
|
98
99
|
|
99
100
|
### Elixir
|
@@ -104,8 +105,9 @@ outdated = ::Anticuado::Java::Gradle.parse_json "build/dependencyUpdates"
|
|
104
105
|
```ruby
|
105
106
|
require "anticuado"
|
106
107
|
|
107
|
-
|
108
|
-
|
108
|
+
hex = ::Anticuado::Elixir::Hex.new "path/to/project"
|
109
|
+
outdated = hex.outdated
|
110
|
+
hex.format outdated
|
109
111
|
```
|
110
112
|
|
111
113
|
### Ruby
|
@@ -116,16 +118,19 @@ outdated = ::Anticuado::Elixir::Hex.outdated "path/to/project"
|
|
116
118
|
```ruby
|
117
119
|
require "anticuado"
|
118
120
|
|
119
|
-
|
120
|
-
|
121
|
+
bundler = ::Anticuado::Ruby::Bundler.new "path/to/project"
|
122
|
+
outdated = bundler.outdated
|
123
|
+
bundler.format outdated
|
121
124
|
```
|
122
125
|
|
123
126
|
## In advance
|
127
|
+
- Create a PR automatically to update libraries
|
128
|
+
- See test/anticuado/git_test.rb
|
124
129
|
|
125
130
|
|
126
131
|
## Contributing
|
127
132
|
|
128
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
133
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Kazu_cocoa/anticuado. 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.
|
129
134
|
|
130
135
|
|
131
136
|
## License
|
data/anticuado.gemspec
CHANGED
@@ -20,7 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.
|
24
|
-
spec.
|
23
|
+
spec.add_runtime_dependency "git", ">= 1.3", "< 1.7"
|
24
|
+
spec.add_runtime_dependency "octokit", ">= 4.8", "< 4.17"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", ">= 1.12"
|
27
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
25
28
|
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
spec.add_development_dependency "pry"
|
26
30
|
end
|
data/lib/anticuado.rb
CHANGED
data/lib/anticuado/base.rb
CHANGED
@@ -1,35 +1,23 @@
|
|
1
1
|
module Anticuado
|
2
2
|
class Base
|
3
|
-
|
4
|
-
|
3
|
+
attr_reader :project_dir, :outdated_libraries, :formatted_outdated_libraries
|
4
|
+
|
5
|
+
def initialize(project_dir = nil)
|
6
|
+
@project_dir = project_dir
|
7
|
+
@outdated_libraries = ''
|
8
|
+
@formatted_outdated_libraries = []
|
5
9
|
end
|
6
10
|
|
7
|
-
def
|
11
|
+
def outdated(_project)
|
8
12
|
raise NotImplementedError
|
9
13
|
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
def self.update_with_prefix(pod_file_in:, pod_file_out: nil, libraries:, prefix:)
|
14
|
-
pod_file_out = pod_file_in if pod_file_out.nil?
|
15
|
-
current_pod = File.read(pod_file_in)
|
16
|
-
|
17
|
-
result = current_pod.each_line.reduce("") do |memo, line|
|
18
|
-
memo << if line.strip.start_with?(prefix)
|
19
|
-
key = get_key libraries, line
|
20
|
-
key.nil? ? line : line.sub(/[0-9|.]+/, libraries[key])
|
21
|
-
else
|
22
|
-
line
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
File.write(pod_file_out, result)
|
27
|
-
result
|
15
|
+
def format(_outdated)
|
16
|
+
raise NotImplementedError
|
28
17
|
end
|
29
18
|
|
30
|
-
def
|
31
|
-
|
32
|
-
nil
|
19
|
+
def update_lock(target_name = nil)
|
20
|
+
raise NotImplementedError
|
33
21
|
end
|
34
22
|
end
|
35
23
|
end
|
data/lib/anticuado/elixir/hex.rb
CHANGED
@@ -1,34 +1,33 @@
|
|
1
1
|
module Anticuado
|
2
2
|
module Elixir
|
3
3
|
class Hex < Anticuado::Base
|
4
|
-
# @param [String] project Path to project directory.
|
5
4
|
# @return [String] The result of command `mix hex.outdated`.
|
6
|
-
def
|
5
|
+
def outdated
|
7
6
|
return puts "have no mix command" if `which mix`.empty?
|
8
7
|
`mix local.hex --force`
|
9
8
|
|
10
|
-
if
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Dir.chdir current_dir
|
9
|
+
if @project_dir
|
10
|
+
Dir.chdir(@project_dir) do
|
11
|
+
@outdated_libraries = `mix hex.outdated`
|
12
|
+
end
|
15
13
|
else
|
16
|
-
|
14
|
+
@outdated_libraries = `mix hex.outdated`
|
17
15
|
end
|
18
|
-
|
19
|
-
outdated_str
|
16
|
+
@outdated_libraries
|
20
17
|
end
|
21
18
|
|
22
19
|
# @param [String] outdated The result of command `mix hex.outdated`
|
23
20
|
# @return [Array] Array include outdated data.
|
24
21
|
# If target project have no outdated data, then return blank array such as `[]`
|
25
|
-
def
|
26
|
-
|
22
|
+
def format(outdated = nil)
|
23
|
+
@outdated_libraries = outdated unless outdated.nil?
|
24
|
+
|
25
|
+
array = @outdated_libraries.split(/\R/).map(&:strip)
|
27
26
|
index = array.find_index { |line| line.scan(/\ADependency\s+Current\s+/) != [] }
|
28
27
|
|
29
28
|
return [] if index.nil?
|
30
29
|
|
31
|
-
array[index + 1..array.size].reduce([]) do |acc, library|
|
30
|
+
@formatted_outdated_libraries = array[index + 1..array.size].reduce([]) do |acc, library|
|
32
31
|
break acc if library.empty?
|
33
32
|
|
34
33
|
array_lib = library.split(/\s+/)
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'octokit'
|
3
|
+
|
4
|
+
module Anticuado
|
5
|
+
class GitHub
|
6
|
+
attr_reader :repo_uri, :repo_name, :git, :client
|
7
|
+
|
8
|
+
def initialize(repository_name, enterprise: true, api_endpoint: nil)
|
9
|
+
@repo_name = repository_name
|
10
|
+
|
11
|
+
@client = if enterprise
|
12
|
+
::Octokit::Client.new(
|
13
|
+
access_token: ENV['GHE_ACCESS_TOKEN'] || 'dummy_token',
|
14
|
+
api_endpoint: api_endpoint || ENV['GHE_API_ENDPOINT'], # 'https://example.api.endpoint/api/v3/'
|
15
|
+
)
|
16
|
+
else
|
17
|
+
::Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])
|
18
|
+
end
|
19
|
+
@repo_uri = "git@#{URI.parse(enterprise ? @client.api_endpoint : @client.web_endpoint).host}:#{@repo_name}.git"
|
20
|
+
end
|
21
|
+
|
22
|
+
def clone_or_open_to(target_path)
|
23
|
+
@git = begin
|
24
|
+
::Git.clone(@repo_uri, target_path)
|
25
|
+
rescue
|
26
|
+
g = ::Git.open(target_path)
|
27
|
+
g.pull
|
28
|
+
g
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_a_new_pull_request(base_branch:, head_branch: (Time.now.strftime '%Y%m%d-%H%M%S'), update_libraries: nil)
|
33
|
+
remote_name = 'origin'
|
34
|
+
|
35
|
+
begin
|
36
|
+
create_a_branch_local head_branch
|
37
|
+
commit_all_changes
|
38
|
+
|
39
|
+
git_push_to_remote remote_name, head_branch
|
40
|
+
create_pull_request(base_branch: base_branch, head_branch: head_branch, title: github_pr_title(head_branch), body: github_pr_body(update_libraries))
|
41
|
+
|
42
|
+
delete_a_branch_local head_branch
|
43
|
+
rescue Git::GitExecuteError => e
|
44
|
+
puts "no changes: #{e}, #{e.message}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def github_pr_title(message)
|
51
|
+
"update #{message}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def github_pr_body(update_libraries)
|
55
|
+
return 'update libraries' if update_libraries.nil?
|
56
|
+
update_libraries.reduce("# Update libraries\n") do |acc, library|
|
57
|
+
acc << "- #{library}\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def commit_all_changes_message
|
62
|
+
"update libraries"
|
63
|
+
end
|
64
|
+
|
65
|
+
def commit_all_changes
|
66
|
+
@git.commit_all(commit_all_changes_message)
|
67
|
+
end
|
68
|
+
|
69
|
+
def create_a_branch_local(branch_name)
|
70
|
+
@git.branch(branch_name).checkout
|
71
|
+
end
|
72
|
+
|
73
|
+
def delete_a_branch_local(branch_name)
|
74
|
+
@git.checkout # We should change current branch first
|
75
|
+
@git.branch(branch_name).delete
|
76
|
+
end
|
77
|
+
|
78
|
+
def git_push_to_remote(remote_name, head_branch)
|
79
|
+
@git.push(remote_name, head_branch)
|
80
|
+
end
|
81
|
+
|
82
|
+
def create_pull_request(base_branch:, head_branch:, title:, body:)
|
83
|
+
@client.create_pull_request @repo_name, base_branch, head_branch, title, body
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end # module Anticuado
|
@@ -1,28 +1,29 @@
|
|
1
1
|
module Anticuado
|
2
2
|
module IOS
|
3
3
|
class Carthage < Anticuado::Base
|
4
|
-
# @param [String] project Path to project directory.
|
5
4
|
# @return [String] The result of command `carthage outdated`.
|
6
|
-
def
|
5
|
+
def outdated
|
7
6
|
return puts "have no carthage command" if `which carthage`.empty?
|
8
7
|
|
9
|
-
if
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
@outdated_libraries = if @project_dir
|
9
|
+
`carthage outdated --project-directory #{@project_dir}`
|
10
|
+
else
|
11
|
+
`carthage outdated`
|
12
|
+
end
|
14
13
|
end
|
15
14
|
|
16
15
|
# @param [String] outdated The result of command `carthage outdated`
|
17
16
|
# @return [Array] Array include outdated data.
|
18
17
|
# If target project have no outdated data, then return blank array such as `[]`
|
19
|
-
def
|
20
|
-
|
18
|
+
def format(outdated = nil)
|
19
|
+
@outdated_libraries = outdated unless outdated.nil?
|
20
|
+
|
21
|
+
array = @outdated_libraries.split(/\R/).map(&:strip)
|
21
22
|
index = array.find_index("The following dependencies are outdated:")
|
22
23
|
|
23
24
|
return [] if index.nil?
|
24
25
|
|
25
|
-
array[index + 1..array.size].map do |library|
|
26
|
+
@formatted_outdated_libraries = array[index + 1..array.size].map do |library|
|
26
27
|
versions = library.split(/[\s|"]/)
|
27
28
|
if versions[8] =~ /Latest/
|
28
29
|
# e.g. ["RxSwift", "", "4.1.0", "", "->", "", "4.1.2", "", "(Latest:", "", "4.1.2", ")"]
|
@@ -43,6 +44,23 @@ module Anticuado
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
47
|
+
|
48
|
+
# @param [Array] target_names: Name of library.
|
49
|
+
def update_lock(target_names = nil)
|
50
|
+
return puts "have no pod command" if `which pod`.empty?
|
51
|
+
do_update_lock target_names
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def do_update_lock(target_names = nil)
|
57
|
+
if target_names.nil?
|
58
|
+
`carthage update --project-directory=#{@project_dir}`
|
59
|
+
else
|
60
|
+
raise ArgumentError, "An argument should be Array like ['Result']" unless target_names.is_a? Array
|
61
|
+
`carthage update #{target_names.join(' ')} --project-directory=#{@project_dir}`
|
62
|
+
end
|
63
|
+
end
|
46
64
|
end # class Carthage
|
47
65
|
end # module IOS
|
48
66
|
end # module Anticuado
|
@@ -1,43 +1,31 @@
|
|
1
1
|
module Anticuado
|
2
2
|
module IOS
|
3
3
|
class CocoaPods < Anticuado::Base
|
4
|
-
# @param [String] project Name of library.
|
5
4
|
# @return [String] The result of command `pod outdated`.
|
6
|
-
def
|
7
|
-
return puts "have no pod command" if `which pod`.empty?
|
8
|
-
|
9
|
-
if library
|
10
|
-
`pod update #{library}`
|
11
|
-
else
|
12
|
-
`pod update`
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# @param [String] project Path to project directory.
|
17
|
-
# @return [String] The result of command `pod outdated`.
|
18
|
-
def self.outdated(project = nil)
|
5
|
+
def outdated
|
19
6
|
return puts "have no pod command" if `which pod`.empty?
|
20
7
|
|
21
|
-
if
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
8
|
+
@outdated_libraries = if @project_dir
|
9
|
+
`pod install --project-directory=#{@project_dir}`
|
10
|
+
`pod outdated --project-directory=#{@project_dir}`
|
11
|
+
else
|
12
|
+
`pod install`
|
13
|
+
`pod outdated`
|
14
|
+
end
|
29
15
|
end
|
30
16
|
|
31
17
|
# @param [String] outdated The result of command `pod outdated`
|
32
18
|
# @return [Array] Array include outdated data.
|
33
19
|
# If target project have no outdated data, then return blank array such as `[]`
|
34
|
-
def
|
35
|
-
|
20
|
+
def format(outdated = nil)
|
21
|
+
@outdated_libraries = outdated unless outdated.nil?
|
22
|
+
|
23
|
+
array = @outdated_libraries.split(/\R/).map(&:strip)
|
36
24
|
index = array.find_index("The following pod updates are available:")
|
37
25
|
|
38
26
|
return [] if index.nil?
|
39
27
|
|
40
|
-
array[index + 1..array.size].map { |library|
|
28
|
+
@formatted_outdated_libraries = array[index + 1..array.size].map { |library|
|
41
29
|
versions = library.split(/\s/) # e.g. ["-", "AFNetworking", "2.5.4", "->", "3.1.0", "(latest", "version", "3.1.0)"]
|
42
30
|
if versions[0] == "-"
|
43
31
|
{
|
@@ -50,15 +38,55 @@ module Anticuado
|
|
50
38
|
}.compact
|
51
39
|
end
|
52
40
|
|
41
|
+
# @param [Array] target_names: Name of library.
|
42
|
+
def update_lock(target_names = nil)
|
43
|
+
return puts "have no pod command" if `which pod`.empty?
|
44
|
+
do_update_lock target_names
|
45
|
+
end
|
46
|
+
|
47
|
+
# TODO: Should fix. (Not used)
|
53
48
|
# @param [String] pod_file_in The file path to Podfile you'd like to update
|
54
49
|
# @param [String] pod_file_out The file path to new Podfile updated. Default is nil and then `pod_file_in` is used
|
55
50
|
# as the file path
|
56
|
-
# @param [Hash]
|
51
|
+
# @param [Hash] libraries The library name you'd like to update
|
57
52
|
# {library_name: "version", library_name2: "version"}
|
58
53
|
# @return [String] new Podfile
|
59
|
-
def
|
54
|
+
def update(pod_file_in:, pod_file_out: nil, libraries:)
|
60
55
|
update_with_prefix(pod_file_in: pod_file_in, pod_file_out: pod_file_out, libraries: libraries, prefix: "pod ")
|
61
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def do_update_lock(target_names = nil)
|
61
|
+
if target_names.nil?
|
62
|
+
`pod update --project-directory=#{@project_dir}`
|
63
|
+
else
|
64
|
+
raise ArgumentError, "An argument should be Array like ['PromisesObjC']" unless target_names.is_a? Array
|
65
|
+
`pod update #{target_names.join(' ')} --project-directory=#{@project_dir}`
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def update_with_prefix(pod_file_in:, pod_file_out: nil, libraries:, prefix:)
|
70
|
+
pod_file_out = pod_file_in if pod_file_out.nil?
|
71
|
+
current_pod = File.read(pod_file_in)
|
72
|
+
|
73
|
+
result = current_pod.each_line.reduce("") do |memo, line|
|
74
|
+
memo << if line.strip.start_with?(prefix)
|
75
|
+
key = get_key libraries, line
|
76
|
+
key.nil? ? line : line.sub(/[0-9|.]+/, libraries[key])
|
77
|
+
else
|
78
|
+
line
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
File.write(pod_file_out, result)
|
83
|
+
result
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_key(libraries, line)
|
87
|
+
libraries.each_key { |k| return k if line.include?(k.to_s) }
|
88
|
+
nil
|
89
|
+
end
|
62
90
|
end # class CocoaPods
|
63
91
|
end # module IOS
|
64
92
|
end # module Anticuado
|
@@ -10,14 +10,13 @@ module Anticuado
|
|
10
10
|
# @param [Bool] wrapper Use gradle wrapper or use gradle directory.
|
11
11
|
# @param [String] format "plain", "json" or "xml". Default is "json".
|
12
12
|
# @param [String] outdir Path to output the result. Default is "build/dependencyUpdates".
|
13
|
-
def
|
13
|
+
def outdated(wrapper = false, revision = "release", format = "json", outdir = "build/dependencyUpdates")
|
14
14
|
return puts "have no gradle command" if !wrapper && `which gradle`.empty?
|
15
15
|
|
16
|
-
if
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Dir.chdir current_dir
|
16
|
+
if @project_dir
|
17
|
+
Dir.chdir(@project_dir) do
|
18
|
+
`#{gradle(wrapper)} dependencyUpdates -Drevision=#{revision} -DoutputFormatter=#{format} -DoutputDir=#{outdir}`
|
19
|
+
end
|
21
20
|
else
|
22
21
|
`#{gradle(wrapper)} dependencyUpdates -Drevision=#{revision} -DoutputFormatter=#{format} -DoutputDir=#{outdir}`
|
23
22
|
end
|
@@ -27,20 +26,22 @@ module Anticuado
|
|
27
26
|
|
28
27
|
# @param [String] file_path The result of command `gradle dependencyUpdates` with json format
|
29
28
|
# @return [JSON] JSON data
|
30
|
-
def
|
29
|
+
def parse_json(file_path)
|
31
30
|
str = File.read(file_path)
|
32
|
-
JSON.parse(str)
|
31
|
+
@outdated_libraries = JSON.parse(str)
|
33
32
|
end
|
34
33
|
|
35
34
|
# @param [String] outdated_parsed_json The result of command `gradle dependencyUpdates` and json parsed data
|
36
35
|
# @return [Array] Array include outdated data.
|
37
36
|
# If target project have no outdated data, then return blank array such as `[]`
|
38
|
-
def
|
39
|
-
|
37
|
+
def format(outdated_parsed_json = nil, filter = %w(alpha beta rc cr m))
|
38
|
+
@outdated_libraries = outdated_parsed_json unless outdated_parsed_json.nil?
|
39
|
+
|
40
|
+
outdted = @outdated_libraries["outdated"]
|
40
41
|
return [] if outdted.nil?
|
41
42
|
return [] if outdted["dependencies"].nil?
|
42
43
|
|
43
|
-
outdted["dependencies"].map { |library|
|
44
|
+
@formatted_outdated_libraries = outdted["dependencies"].map { |library|
|
44
45
|
available_version = filter(filter, library["available"]["release"])
|
45
46
|
latest_version = filter(filter, library["available"]["release"])
|
46
47
|
|
@@ -58,12 +59,12 @@ module Anticuado
|
|
58
59
|
|
59
60
|
private
|
60
61
|
|
61
|
-
def
|
62
|
+
def gradle(wrapper = false)
|
62
63
|
return "./gradlew" if wrapper
|
63
64
|
"gradle"
|
64
65
|
end
|
65
66
|
|
66
|
-
def
|
67
|
+
def filter(revisions, string)
|
67
68
|
result = revisions.find { |qualifier| string.match(/(?i).*[.-]#{qualifier}[.\d-]*/) }
|
68
69
|
return NO_VERSION if result
|
69
70
|
string
|
@@ -1,33 +1,32 @@
|
|
1
1
|
module Anticuado
|
2
2
|
module JavaScript
|
3
3
|
class Npm < Anticuado::Base
|
4
|
-
# @param [String] project Path to project directory.
|
5
4
|
# @return [String] The result of command `npm outdated`.
|
6
|
-
def
|
5
|
+
def outdated
|
7
6
|
return puts "have no npm command" if `which npm`.empty?
|
8
7
|
|
9
|
-
if
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
outdated_str = `npm outdated`
|
14
|
-
Dir.chdir current_dir
|
8
|
+
if @project_dir
|
9
|
+
Dir.chdir(@project_dir) do
|
10
|
+
@outdated_libraries = run_outdated
|
11
|
+
end
|
15
12
|
else
|
16
|
-
|
13
|
+
@outdated_libraries = run_outdated
|
17
14
|
end
|
18
|
-
|
15
|
+
@outdated_libraries
|
19
16
|
end
|
20
17
|
|
21
18
|
# @param [String] outdated The result of command `npm outdated`
|
22
19
|
# @return [Array] Array include outdated data.
|
23
20
|
# If target project have no outdated data, then return blank array such as `[]`
|
24
|
-
def
|
25
|
-
|
21
|
+
def format(outdated = nil)
|
22
|
+
@outdated_libraries = outdated unless outdated.nil?
|
23
|
+
|
24
|
+
array = @outdated_libraries.split(/\R/).map(&:strip)
|
26
25
|
index = array.find_index { |line| line.scan(/\APackage\s+Current\s+Wanted\s+Latest\s+Location\z/) != [] }
|
27
26
|
|
28
27
|
return [] if index.nil?
|
29
28
|
|
30
|
-
array[index + 1...array.size].map do |library|
|
29
|
+
@formatted_outdated_libraries = array[index + 1...array.size].map do |library|
|
31
30
|
versions = library.split(/\s+/) # e.g. ["babel-brunch", "6.0.2", "6.0.6", "6.0.6"]
|
32
31
|
{
|
33
32
|
library_name: versions[0],
|
@@ -37,6 +36,13 @@ module Anticuado
|
|
37
36
|
}
|
38
37
|
end
|
39
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def run_outdated
|
43
|
+
`npm install`
|
44
|
+
`npm outdated`
|
45
|
+
end
|
40
46
|
end # class Npm
|
41
47
|
end # module JavaScript
|
42
48
|
end # module Anticuado
|
@@ -1,33 +1,32 @@
|
|
1
1
|
module Anticuado
|
2
2
|
module JavaScript
|
3
3
|
class Yarn < Anticuado::Base
|
4
|
-
# @param [String] project Path to project directory.
|
5
4
|
# @return [String] The result of command `yarn outdated`.
|
6
|
-
def
|
5
|
+
def outdated
|
7
6
|
return puts "have no yarn command" if `which yarn`.empty?
|
8
7
|
|
9
|
-
if
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
outdated_str = `yarn outdated`
|
14
|
-
Dir.chdir current_dir
|
8
|
+
if @project_dir
|
9
|
+
Dir.chdir(@project_dir) do
|
10
|
+
@outdated_libraries = run_outdated
|
11
|
+
end
|
15
12
|
else
|
16
|
-
|
13
|
+
@outdated_libraries = run_outdated
|
17
14
|
end
|
18
|
-
|
15
|
+
@outdated_libraries
|
19
16
|
end
|
20
17
|
|
21
18
|
# @param [String] outdated The result of command `yarn outdated`
|
22
19
|
# @return [Array] Array include outdated data.
|
23
20
|
# If target project have no outdated data, then return blank array such as `[]`
|
24
|
-
def
|
25
|
-
|
21
|
+
def format(outdated = nil)
|
22
|
+
@outdated_libraries = outdated unless outdated.nil?
|
23
|
+
|
24
|
+
array = @outdated_libraries.split(/\R/).map(&:strip)
|
26
25
|
index = array.find_index { |line| line.scan(/Package\s+Current\s+Wanted\s+Latest/) != [] }
|
27
26
|
|
28
27
|
return [] if index.nil?
|
29
28
|
|
30
|
-
array[index + 1...(array.size - 1)].map do |library|
|
29
|
+
@formatted_outdated_libraries = array[index + 1...(array.size - 1)].map do |library|
|
31
30
|
versions = library.split(/\s+/) # e.g. ["babel-brunch", "6.0.2", "6.0.6", "6.0.6"]
|
32
31
|
{
|
33
32
|
library_name: versions[0],
|
@@ -37,6 +36,13 @@ module Anticuado
|
|
37
36
|
}
|
38
37
|
end
|
39
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def run_outdated
|
43
|
+
`yarn install`
|
44
|
+
`yarn outdated`
|
45
|
+
end
|
40
46
|
end # class Yarn
|
41
47
|
end # module JavaScript
|
42
48
|
end # module Anticuado
|
@@ -1,32 +1,31 @@
|
|
1
1
|
module Anticuado
|
2
2
|
module Ruby
|
3
3
|
class Bundler < Anticuado::Base
|
4
|
-
def
|
4
|
+
def outdated(option = '')
|
5
5
|
return puts "have no bundle command" if `which bundle`.empty?
|
6
6
|
|
7
|
-
if
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
outdated_str = `bundle outdated`
|
12
|
-
Dir.chdir current_dir
|
7
|
+
if @project_dir
|
8
|
+
Dir.chdir(@project_dir) do
|
9
|
+
@outdated_libraries = run_outdated option
|
10
|
+
end
|
13
11
|
else
|
14
|
-
|
15
|
-
outdated_str = `bundle outdated`
|
12
|
+
@outdated_libraries = run_outdated option
|
16
13
|
end
|
17
|
-
|
14
|
+
@outdated_libraries
|
18
15
|
end
|
19
16
|
|
20
|
-
# @param [String] outdated The result of command `bundle outdated`
|
17
|
+
# @param [String] outdated The result of command `bundle outdated`. If it's no argument, the method use the result of `outdated`.
|
21
18
|
# @return [Array] Array include outdated data.
|
22
19
|
# If target project have no outdated data, then return blank array such as `[]`
|
23
|
-
def
|
24
|
-
|
20
|
+
def format(outdated = nil)
|
21
|
+
@outdated_libraries = outdated unless outdated.nil?
|
22
|
+
|
23
|
+
array = @outdated_libraries.split(/\R/).map(&:strip)
|
25
24
|
index = array.find_index("Outdated gems included in the bundle:")
|
26
25
|
|
27
26
|
return [] if index.nil?
|
28
27
|
|
29
|
-
array[index + 1..array.size].map { |library|
|
28
|
+
@formatted_outdated_libraries = array[index + 1..array.size].map { |library|
|
30
29
|
versions = library.split(/\s/) # e.g. ["*", "jwt", "(newest", "1.5.6,", "installed", "1.5.5)"]
|
31
30
|
if versions[0] == "*"
|
32
31
|
{
|
@@ -38,6 +37,32 @@ module Anticuado
|
|
38
37
|
end
|
39
38
|
}.compact
|
40
39
|
end
|
40
|
+
|
41
|
+
def update_lock(target_names = nil)
|
42
|
+
if @project_dir
|
43
|
+
Dir.chdir(@project_dir) do
|
44
|
+
do_update_lock target_names
|
45
|
+
end
|
46
|
+
else
|
47
|
+
do_update_lock target_names
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def do_update_lock(target_names = nil)
|
54
|
+
if target_names.nil?
|
55
|
+
`bundle update`
|
56
|
+
else
|
57
|
+
raise ArgumentError, "An argument should be Array like ['cocoapod']" unless target_names.is_a? Array
|
58
|
+
`bundle update #{target_names.join(' ')}`
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def run_outdated(option)
|
63
|
+
`bundle install #{option}`
|
64
|
+
`bundle outdated`
|
65
|
+
end
|
41
66
|
end # class Bundler
|
42
67
|
end # module Ruby
|
43
68
|
end # module Anticuado
|
data/lib/anticuado/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anticuado
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuaki MATSUO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: git
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.7'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.7'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: octokit
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '4.8'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '4.17'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '4.8'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '4.17'
|
13
53
|
- !ruby/object:Gem::Dependency
|
14
54
|
name: bundler
|
15
55
|
requirement: !ruby/object:Gem::Requirement
|
16
56
|
requirements:
|
17
|
-
- - "
|
57
|
+
- - ">="
|
18
58
|
- !ruby/object:Gem::Version
|
19
59
|
version: '1.12'
|
20
60
|
type: :development
|
21
61
|
prerelease: false
|
22
62
|
version_requirements: !ruby/object:Gem::Requirement
|
23
63
|
requirements:
|
24
|
-
- - "
|
64
|
+
- - ">="
|
25
65
|
- !ruby/object:Gem::Version
|
26
66
|
version: '1.12'
|
27
67
|
- !ruby/object:Gem::Dependency
|
@@ -30,14 +70,14 @@ dependencies:
|
|
30
70
|
requirements:
|
31
71
|
- - "~>"
|
32
72
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
73
|
+
version: '12.3'
|
34
74
|
type: :development
|
35
75
|
prerelease: false
|
36
76
|
version_requirements: !ruby/object:Gem::Requirement
|
37
77
|
requirements:
|
38
78
|
- - "~>"
|
39
79
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
80
|
+
version: '12.3'
|
41
81
|
- !ruby/object:Gem::Dependency
|
42
82
|
name: minitest
|
43
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +92,20 @@ dependencies:
|
|
52
92
|
- - "~>"
|
53
93
|
- !ruby/object:Gem::Version
|
54
94
|
version: '5.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: pry
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
55
109
|
description: Collect and arrange some outdated libraries for several platforms
|
56
110
|
email:
|
57
111
|
- fly.49.89.over@gmail.com
|
@@ -59,8 +113,8 @@ executables: []
|
|
59
113
|
extensions: []
|
60
114
|
extra_rdoc_files: []
|
61
115
|
files:
|
116
|
+
- ".github/workflows/ruby.yml"
|
62
117
|
- ".gitignore"
|
63
|
-
- ".travis.yml"
|
64
118
|
- CODE_OF_CONDUCT.md
|
65
119
|
- Gemfile
|
66
120
|
- LICENSE
|
@@ -72,6 +126,7 @@ files:
|
|
72
126
|
- lib/anticuado.rb
|
73
127
|
- lib/anticuado/base.rb
|
74
128
|
- lib/anticuado/elixir/hex.rb
|
129
|
+
- lib/anticuado/github.rb
|
75
130
|
- lib/anticuado/ios/carthage.rb
|
76
131
|
- lib/anticuado/ios/cocoapods.rb
|
77
132
|
- lib/anticuado/java/gradle.rb
|
@@ -98,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
153
|
- !ruby/object:Gem::Version
|
99
154
|
version: '0'
|
100
155
|
requirements: []
|
101
|
-
|
102
|
-
rubygems_version: 2.5.2
|
156
|
+
rubygems_version: 3.1.2
|
103
157
|
signing_key:
|
104
158
|
specification_version: 4
|
105
159
|
summary: Collect and arrange some outdated libraries for several platforms
|