rondabot 1.0.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab845481999c484ecd45896fd99b6f296b58b09943684c78ec874c19e70006d4
4
- data.tar.gz: 61a104ab19b98feb442cf07d54281456772f390bd6bc56da9292bf03357f2b23
3
+ metadata.gz: 950eb5a191650e0e0b1935b34bdf5eb251d908df604b8225f6c8c2cd06e264f7
4
+ data.tar.gz: 9f36e7afbc04fe8a3ecf64a4f4671b4fdb0eadceffb2848fed1c2a62b609cd3f
5
5
  SHA512:
6
- metadata.gz: 9709cc0c08f032d92c356ecbca9f80473fe1128c96f4f2cddf04940242917270abcc3bd40d3b4a2379753849727f78d1f3d39efe0c90cfadfbf8db69c92eb32c
7
- data.tar.gz: a718ccd264dfe96d4f2ab8608907198eb25807ac679a7792cf9d042a8d367a49f9d65e123de5aa7c44004f2f0f57d185b5cb64508601d7c9084952239c98d05e
6
+ metadata.gz: 0a32928624a26886eab26cb81c64ee2a7a29b759a486ff92047e424e36fc997d2355ddc38fc90a7ccdc74bdcd8e056c17fd51416a769e296d01b30e8a2358010
7
+ data.tar.gz: d0cfc6c44c3ec5b06880e65fda10a37389649239806a3ce03dd1dba5a0801e057fff9d97ff5d4d6b91d64237559eee041e0c5bb7a9a3bbd8e9a2a0c7d0130da1
data/README.md CHANGED
@@ -53,11 +53,13 @@ core.start()
53
53
  | **organization** | Name of your organization on azure devops |
54
54
  | **project** | Name of your project on azure devops |
55
55
  | **repository** | Name of your project to using for clone and create pull requests |
56
- | **credentials** | A user credentials (_username_ and _password_) permission to clone e create pull requests |
56
+ | **access_token** | A git credentials to clone e create pull requests |
57
57
  | **feed_id** | Your feed id npm/yarn on azure devops. Go to Azure Devops, your project _Artifacts_ > _Connect to feed_ > _npm_ and then you can find feed id in the url looks like `https://pkgs.dev.azure.com/your organization name/you feed id to be right here/_packaging/npm-packages/npm/registry/` |
58
- | **github_public_token** | A GitHub access token with read access to public repos. Go to your GitHub account _Settings_ > _Developer settings_ > _Personal access tokens_ and then _Generate new token_ |
58
+ | **github_token** | Allows passing in a GitHub access token so that the API rate limiting is not exceeded. When the repository's visibility is public, the `github_token` must be an access token with read access to the public repositories. When repository visibility is private, the `github_token` must be an access token with full control of private repositories. |
59
59
 
60
- ## Example
60
+ ## Examples
61
+
62
+ ### Azure Devops
61
63
 
62
64
  ```ruby
63
65
  require "dependabot/omnibus"
@@ -68,12 +70,30 @@ core = Rondabot::Core.new(
68
70
  organization: "Akatsuki",
69
71
  project: "Digital%20Channel",
70
72
  repository: "akatsuki-website",
71
- credentials: {
72
- :username => "Ronda.Bot",
73
- :password => "cm9uZGluZWxsaW1vcmFpcwcm9uZGFib3Q"
74
- },
73
+ access_token: "cm9uZGluZWxsaW1vcmFpcwcm9uZGFib3Q"
75
74
  feed_id: "11db190-e3b1872-1e6e6e-c97f2dd-49253",
76
- github_public_token: "11db190e3b18721e6e6ec97f2dd49253"
75
+ github_token: "11db190e3b18721e6e6ec97f2dd49253"
76
+ )
77
+
78
+ core.start()
79
+ ```
80
+
81
+ ### GitHub
82
+
83
+ > **WARNING**
84
+ >
85
+ > When the repository's visibility is public, the `github_token` must be an access token with read access to the public repositories.
86
+ >
87
+ > When repository visibility is private, the `github_token` must be an access token with full control of private repositories.
88
+
89
+ ```ruby
90
+ require "dependabot/omnibus"
91
+ require "rondabot"
92
+
93
+ core = Rondabot::Core.new(
94
+ provider: "github",
95
+ repository: "rondinellimorais/rondabot",
96
+ github_token: "11db190e3b18721e6e6ec97f2dd49253"
77
97
  )
78
98
 
79
99
  core.start()
@@ -2,15 +2,17 @@ module Rondabot
2
2
  class Azure < SourceControl
3
3
  def initialize params
4
4
  super(params)
5
- @repository = params[:repository]
6
5
  @project = params[:project]
7
6
 
8
- user_credentials = get_user_credentials(params)
7
+ if params[:access_token].nil?
8
+ raise ArgumentError.new("'access_token' param is missing!")
9
+ end
10
+
9
11
  @credentials << {
10
12
  "type" => "git_source",
11
13
  "host" => "dev.azure.com",
12
- "username" => user_credentials[:username],
13
- "password" => user_credentials[:password]
14
+ "username" => "x-access-token",
15
+ "password" => params[:access_token]
14
16
  }
15
17
 
16
18
  # get organization
@@ -28,7 +30,7 @@ module Rondabot
28
30
  @credentials << {
29
31
  "type" => "npm_registry",
30
32
  "registry" => "https://pkgs.dev.azure.com/#{@organization}/#{@feed_id}/_packaging/npm-packages/npm/registry/",
31
- "token" => "#{@feed_id}:#{user_credentials[:password]}"
33
+ "token" => "#{@feed_id}:#{params[:access_token]}"
32
34
  }
33
35
  end
34
36
 
@@ -43,5 +45,16 @@ module Rondabot
43
45
 
44
46
  return "#{@organization}/#{@project}/_git/#{@repository}"
45
47
  end
48
+
49
+ def create_pull_request params
50
+ pull_request = super(params)
51
+
52
+ if pull_request&.status == 201
53
+ content = JSON[pull_request.body]
54
+ puts " PR ##{content["pullRequestId"]} submitted"
55
+ else
56
+ puts " PR already exists or an error has occurred"
57
+ end
58
+ end
46
59
  end
47
60
  end
@@ -13,8 +13,7 @@ module Rondabot
13
13
  # @source_control = Rondabot::GitLab.new(params)
14
14
  raise ArgumentError.new("gitlab available soon :)")
15
15
  when 'github'
16
- # @source_control = Rondabot::GitHub.new(params)
17
- raise ArgumentError.new("github available soon :)")
16
+ @source_control = Rondabot::GitHub.new(params)
18
17
  else
19
18
  raise ArgumentError.new("'provider' param is missing! The available values are: azure, gitlab or github.")
20
19
  end
@@ -2,13 +2,23 @@ module Rondabot
2
2
  class GitHub < SourceControl
3
3
  def initialize params
4
4
  super(params)
5
-
6
- # get the user credentials
7
- # user_credentials = get_user_credentials(params)
8
5
  end
9
6
 
10
7
  def repository_uri
11
- raise "not implemented"
8
+ if @repository.nil?
9
+ raise ArgumentError.new("'repository' param is missing!")
10
+ end
11
+ return @repository
12
+ end
13
+
14
+ def create_pull_request params
15
+ pull_request = super(params)
16
+
17
+ if pull_request.state == 'open'
18
+ puts " PR ##{pull_request.number} submitted"
19
+ else
20
+ puts " PR already exists or an error has occurred"
21
+ end
12
22
  end
13
23
  end
14
24
  end
@@ -2,9 +2,6 @@ module Rondabot
2
2
  class GitLab < SourceControl
3
3
  def initialize params
4
4
  super(params)
5
-
6
- # get the user credentials
7
- # user_credentials = get_user_credentials(params)
8
5
  end
9
6
 
10
7
  def repository_uri
@@ -7,17 +7,22 @@ module Rondabot
7
7
  def initialize params
8
8
  @credentials = []
9
9
  @provider = params[:provider]
10
-
11
- # A GitHub access token with read access to public repos
12
- if params[:github_public_token].nil?
13
- raise ArgumentError.new("'github_public_token' param is missing!")
10
+ @repository = params[:repository]
11
+
12
+ # When the repository's visibility is public,
13
+ # the `github_token` must be an access token with read access to the public repositories.
14
+ #
15
+ # When repository visibility is private,
16
+ # the `github_token` must be an access token with full control of private repositories.
17
+ if params[:github_token].nil?
18
+ raise ArgumentError.new("'github_token' param is missing!")
14
19
  end
15
20
 
16
21
  @credentials << {
17
22
  "type" => "git_source",
18
23
  "host" => "github.com",
19
24
  "username" => "x-access-token",
20
- "password" => "#{params[:github_public_token]}"
25
+ "password" => "#{params[:github_token]}"
21
26
  }
22
27
  end
23
28
 
@@ -43,23 +48,7 @@ module Rondabot
43
48
  label_language: true
44
49
  )
45
50
 
46
- pull_request = pr_creator.create
47
-
48
- if pull_request&.status == 201
49
- content = JSON[pull_request.body]
50
- puts " PR ##{content["pullRequestId"]} submitted"
51
- else
52
- puts " PR already exists or an error has occurred"
53
- end
54
- end
55
-
56
- private
57
- def get_user_credentials(params)
58
- _credentials = params[:credentials]
59
- if _credentials.nil? || _credentials[:username].nil? || _credentials[:password].nil?
60
- raise ArgumentError.new("'credentials' param is missing! Check your credentials parameter")
61
- end
62
- return _credentials
51
+ return pr_creator.create
63
52
  end
64
53
  end
65
54
  end
@@ -1,5 +1,5 @@
1
1
  module Rondabot
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  autoload :Option, File.join(File.dirname(__FILE__), 'module/Option')
4
4
  autoload :Core, File.join(File.dirname(__FILE__), 'module/Core')
5
5
  autoload :Version, File.join(File.dirname(__FILE__), 'module/Version')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rondabot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rondinelli Morais
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-14 00:00:00.000000000 Z
11
+ date: 2020-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake