merci 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +25 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/merci.rb +106 -0
- data/lib/merci/version.rb +3 -0
- data/merci.gemspec +31 -0
- data/plugins.rb +3 -0
- data/shipit.rubygems.yml +1 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b40512bc39d7203d10176ce3e881f4264ac4ee4dd97b05c368d27c71c2eb51e
|
4
|
+
data.tar.gz: 348bc083a0a1e7258d3741d50e15bcb90964333c74169ca6f60d8d4a545af6c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c15c0098122843fcfe1136ca2750bd0312d7ebbe983503bf93ec0560aeca5882ff4fb85d3621c8a86041b37fc3c21ebbb993ec7441b49f96cb7cba5c5ef20b01
|
7
|
+
data.tar.gz: 5f7bba256e9b1dc0cd9d1aa3d7cf005c5129c82e92a6c58146b94b7c2c0ef23a118da424c98bc0604a7a0eec75261379e85decb51e088706890daaf68f0c4b36
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at edouard.chin@shopify.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
merci (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
minitest (5.13.0)
|
10
|
+
rake (10.5.0)
|
11
|
+
|
12
|
+
PLATFORMS
|
13
|
+
ruby
|
14
|
+
|
15
|
+
DEPENDENCIES
|
16
|
+
bundler
|
17
|
+
merci!
|
18
|
+
minitest (~> 5.0)
|
19
|
+
rake (~> 10.0)
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Shopify
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#### Merci :bow: :heart:
|
2
|
+
|
3
|
+
Give thanks (in the form of github stars) to your fellow Rubyist.
|
4
|
+
Inspired by [cargo thanks](https://github.com/softprops/cargo-thanks) from [Doug](https://github.com/softprops) which was inspired in part by medium's clapping button as a way to show thanks for someone elses work you've found enjoyment in.
|
5
|
+
|
6
|
+
### Installation
|
7
|
+
|
8
|
+
```sh
|
9
|
+
bundle plugin install merci
|
10
|
+
```
|
11
|
+
|
12
|
+
### Usage
|
13
|
+
|
14
|
+
```sh
|
15
|
+
bundle merci
|
16
|
+
```
|
17
|
+
|
18
|
+
### What does it do
|
19
|
+
|
20
|
+
`bundle merci` will gather all the direct dependencies (not the traversal ones) listed in your Gemfile and Star the project on GitHub.
|
21
|
+
|
22
|
+
### Limitation
|
23
|
+
|
24
|
+
- Only project hosted on GitHub are supported (Will be happy to have someone implement other VCS providers).
|
25
|
+
- If a gem doesn't specify where to find its source, we can't star it.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "merci"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/merci.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require "merci/version"
|
2
|
+
require "erb"
|
3
|
+
require "json"
|
4
|
+
require "net/http"
|
5
|
+
|
6
|
+
module Merci
|
7
|
+
class Command < Bundler::Plugin::API
|
8
|
+
command('merci')
|
9
|
+
|
10
|
+
def exec(_cmd, _args)
|
11
|
+
unless Bundler.settings['BUNDLE_MERCI_GITHUB_TOKEN']
|
12
|
+
token = Bundler.ui.ask("Please input a valid github token. You can generate a token using this link https://github.com/settings/tokens/new?scopes=public_repo&description=Token%20for%20Bundler%20merci\n")
|
13
|
+
Bundler.settings.set_global('BUNDLE_MERCI_GITHUB_TOKEN', token)
|
14
|
+
end
|
15
|
+
|
16
|
+
sources = Bundler.definition.specs.each_with_object([]) do |spec, github_sources|
|
17
|
+
next unless direct_dependency?(spec) && hosted_on_rubygem?(spec)
|
18
|
+
|
19
|
+
source_code = source_code_uri(spec)
|
20
|
+
github_sources << source_code if source_code
|
21
|
+
end
|
22
|
+
|
23
|
+
Bundler.ui.info('Starring dependencies your project depends on. Hold tight!')
|
24
|
+
|
25
|
+
repo_ids = execute_graphql_request(graphql_repo_template(sources))
|
26
|
+
execute_graphql_request(graphql_add_star_template(repo_ids))
|
27
|
+
|
28
|
+
Bundler.ui.info('Successfully starred all the repo your project depends on!')
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def execute_graphql_request(query)
|
34
|
+
@client ||= Net::HTTP.new('api.github.com', Net::HTTP.https_default_port).tap do |client|
|
35
|
+
client.use_ssl = true
|
36
|
+
client.read_timeout = 30
|
37
|
+
client.ssl_timeout = 15
|
38
|
+
end
|
39
|
+
|
40
|
+
response = @client.post('/graphql', { query: query }.to_json, "Authorization" => "bearer #{Bundler.settings['BUNDLE_MERCI_GITHUB_TOKEN']}")
|
41
|
+
raise(response.body) unless response.code_type < Net::HTTPSuccess
|
42
|
+
|
43
|
+
response.body
|
44
|
+
end
|
45
|
+
|
46
|
+
def graphql_add_star_template(repo_ids)
|
47
|
+
template = <<~EOM
|
48
|
+
mutation StarRepo {
|
49
|
+
<% repo_ids.each do |index, values| %>
|
50
|
+
<% next unless values && values['id'] %>
|
51
|
+
<%= index %>: addStar(input: {clientMutationId: "<%= index %>", starrableId: "<%= values['id'] %>"}) {
|
52
|
+
clientMutationId
|
53
|
+
}
|
54
|
+
<% end %>
|
55
|
+
}
|
56
|
+
EOM
|
57
|
+
|
58
|
+
repo_ids = JSON.load(repo_ids)['data']
|
59
|
+
repo_ids.delete('errors')
|
60
|
+
ERB.new(template).result(binding)
|
61
|
+
end
|
62
|
+
|
63
|
+
def graphql_repo_template(sources)
|
64
|
+
template = <<~EOM
|
65
|
+
query FindRepoIds {
|
66
|
+
<% sources.each_with_index do |source, index| %>
|
67
|
+
<% owner, repo = source.split('/') %>
|
68
|
+
_<%= index + 1 %>: repository(owner: "<%= owner %>", name: "<%= repo %>") {
|
69
|
+
id
|
70
|
+
}
|
71
|
+
<% end %>
|
72
|
+
}
|
73
|
+
EOM
|
74
|
+
|
75
|
+
sources.map! do |source|
|
76
|
+
source.to_s.match(/github.com\/([\w\-\.]+)\/([\w\-\.]+)\/?/) { "#{$1}/#{$2}" }
|
77
|
+
end
|
78
|
+
|
79
|
+
ERB.new(template).result(binding)
|
80
|
+
end
|
81
|
+
|
82
|
+
def direct_dependency?(spec)
|
83
|
+
Bundler.locked_gems.dependencies.key?(spec.name)
|
84
|
+
end
|
85
|
+
|
86
|
+
def hosted_on_rubygem?(spec)
|
87
|
+
return false unless spec.source.is_a?(Bundler::Source::Rubygems)
|
88
|
+
|
89
|
+
spec.source.remotes.any? do |remote|
|
90
|
+
remote.respond_to?(:host) && remote.host == 'rubygems.org'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def source_code_uri(spec)
|
95
|
+
homepage = URI(spec.homepage || '')
|
96
|
+
return homepage if homepage.host == 'github.com'
|
97
|
+
|
98
|
+
metadata = %w(source_code_uri homepage_uri bug_tracker_uri).find do |key|
|
99
|
+
uri = URI(spec.metadata.fetch(key, ''))
|
100
|
+
uri.host == 'github.com'
|
101
|
+
end
|
102
|
+
|
103
|
+
spec.metadata[metadata] if metadata
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
data/merci.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "merci/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "merci"
|
7
|
+
spec.version = Merci::VERSION
|
8
|
+
spec.authors = ["Rails"]
|
9
|
+
spec.email = ["rails@shopify.com"]
|
10
|
+
|
11
|
+
spec.summary = "Give thanks (in the form of github stars) to your fellow Rubyist"
|
12
|
+
spec.description = "Automatically star ruby gem your project depend on"
|
13
|
+
spec.homepage = "https://github.com/shopify/merci"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/shopify/merci"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
31
|
+
end
|
data/plugins.rb
ADDED
data/shipit.rubygems.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# using the default shipit config
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merci
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rails
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: Automatically star ruby gem your project depend on
|
56
|
+
email:
|
57
|
+
- rails@shopify.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/merci.rb
|
72
|
+
- lib/merci/version.rb
|
73
|
+
- merci.gemspec
|
74
|
+
- plugins.rb
|
75
|
+
- shipit.rubygems.yml
|
76
|
+
homepage: https://github.com/shopify/merci
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata:
|
80
|
+
homepage_uri: https://github.com/shopify/merci
|
81
|
+
source_code_uri: https://github.com/shopify/merci
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubygems_version: 3.0.3
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Give thanks (in the form of github stars) to your fellow Rubyist
|
101
|
+
test_files: []
|