danger-lock_library_versions 0.0.1
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 +7 -0
- data/.gitignore +7 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +10 -0
- data/danger-lock_library_versions.gemspec +31 -0
- data/lib/danger_lock_library_versions.rb +1 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/lock_library_versions/gem_version.rb +3 -0
- data/lib/lock_library_versions/plugin.rb +36 -0
- data/spec/lock_library_versions_spec.rb +69 -0
- data/spec/spec_helper.rb +65 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1a2121a7236876cff95460a2abf0043621d79fbb
|
4
|
+
data.tar.gz: 7af87196175b88ee145aebe8e5ed8ed368545ead
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 207c16fc2f8dac1eeea3390a4a990bc422986d178956c0c0395fdb86bb27fc4956803800a85fb39cecf95d5af7b0731204a5f2cfccb9eefc669e951c485e50c8
|
7
|
+
data.tar.gz: 47d8907ab68c51ad1b2479068794b9c4b73463d46db49b5974ab565cf475752f727c197c49c61d6a73d4c64da3c643954d34351cb70b294f0899d8889b2e84a1
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# A guardfile for making Danger Plugins
|
2
|
+
# For more info see https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
# To run, use `bundle exec guard`.
|
5
|
+
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
7
|
+
require 'guard/rspec/dsl'
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
9
|
+
|
10
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2017 Takuma Homma <nagomimatcha@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# danger-lock_library_versions
|
2
|
+
|
3
|
+
A [Danger](http://danger.systems/ruby/) plugin for managing library versions.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your Gemfile:
|
8
|
+
|
9
|
+
```
|
10
|
+
$ gem install danger-lock_library_versions
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```
|
16
|
+
lock_library_versions.check
|
17
|
+
```
|
18
|
+
|
19
|
+
if lock file has not committed to version control, post a failure comment by Danger.
|
20
|
+
|
21
|
+
### methods
|
22
|
+
|
23
|
+
```
|
24
|
+
check(warning: boolean)
|
25
|
+
```
|
26
|
+
|
27
|
+
if `warning: true`, set comment status to warning. (default: false)
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lock_library_versions/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'danger-lock_library_versions'
|
8
|
+
spec.version = LockLibraryVersions::VERSION
|
9
|
+
spec.authors = ['mataku']
|
10
|
+
spec.email = ['nagomimatcha@gmail.com']
|
11
|
+
spec.description = %q{A Danger plugin to check whether version lockfile is committed or not}
|
12
|
+
spec.summary = %q{A Danger plugin to check whether version lockfile is committed or not}
|
13
|
+
spec.homepage = 'https://github.com/mataku/danger-lock_library_versions'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
22
|
+
|
23
|
+
# General ruby development
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
|
27
|
+
# Testing support
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
29
|
+
|
30
|
+
spec.add_development_dependency 'pry'
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "lock_library_versions/gem_version"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "lock_library_versions/plugin"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Danger
|
2
|
+
class DangerLockLibraryVersions < Plugin
|
3
|
+
def check(config = nil)
|
4
|
+
config = config.is_a?(Hash) ? config : { }
|
5
|
+
warning_mode = config[:warning] || false
|
6
|
+
files = git.modified_files
|
7
|
+
lock_list.keys.each do |file|
|
8
|
+
if files.include?(file.to_s) && !(files.include?(lock_list[file]))
|
9
|
+
comment(warning_mode, file)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def comment(warning_mode, file)
|
17
|
+
if warning_mode
|
18
|
+
warn(error_message(file))
|
19
|
+
else
|
20
|
+
fail(error_message(file))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def error_message(file)
|
25
|
+
"`#{file.to_s}` has changed. `#{lock_list[file]}` should be committed."
|
26
|
+
end
|
27
|
+
|
28
|
+
def lock_list
|
29
|
+
{
|
30
|
+
'Gemfile': 'Gemfile.lock',
|
31
|
+
'Cartfile': 'Cartfile.resolved',
|
32
|
+
'Podfile': 'Podfile.lock'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
describe Danger::DangerLockLibraryVersions do
|
5
|
+
let(:git_plugin) { Danger::DangerfileGitPlugin }
|
6
|
+
let(:dangerfile) { testing_dangerfile }
|
7
|
+
let(:plugin) { dangerfile.lock_library_versions }
|
8
|
+
|
9
|
+
it "should be a plugin" do
|
10
|
+
expect(Danger::DangerLockLibraryVersions < Danger::Plugin).to be_truthy
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#check" do
|
14
|
+
before do
|
15
|
+
allow_any_instance_of(git_plugin).to receive(:modified_files).and_return(modified_files)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'files which managed library versions are not included' do
|
19
|
+
let(:modified_files) { ['README.md'] }
|
20
|
+
|
21
|
+
it 'no errors' do
|
22
|
+
plugin.check
|
23
|
+
expect(dangerfile.status_report[:errors].length).to be == 0
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'file which managed library versions are included' do
|
28
|
+
let(:modified_files) { ['README.md', 'Gemfile'] }
|
29
|
+
|
30
|
+
it 'error' do
|
31
|
+
plugin.check
|
32
|
+
expect(dangerfile.status_report[:errors].length).to be == 1
|
33
|
+
expect(dangerfile.status_report[:errors][0]).to eq '`Gemfile` has changed. `Gemfile.lock` should be committed.'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'files which managed library versions are included' do
|
38
|
+
let(:modified_files) { ['Cartfile', 'Gemfile'] }
|
39
|
+
|
40
|
+
it 'multiple errors' do
|
41
|
+
plugin.check
|
42
|
+
expect(dangerfile.status_report[:errors].length).to be == 2
|
43
|
+
expect(dangerfile.status_report[:errors]).to include '`Gemfile` has changed. `Gemfile.lock` should be committed.'
|
44
|
+
expect(dangerfile.status_report[:errors]).to include '`Cartfile` has changed. `Cartfile.resolved` should be committed.'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'with lock file' do
|
49
|
+
let(:modified_files) { ['Gemfile', 'Gemfile.lock'] }
|
50
|
+
|
51
|
+
it 'no errors' do
|
52
|
+
plugin.check
|
53
|
+
expect(dangerfile.status_report[:errors].length).to be == 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'warning: true' do
|
58
|
+
let(:modified_files) { ['Gemfile'] }
|
59
|
+
|
60
|
+
it 'should warning, not error' do
|
61
|
+
plugin.check(warning: true)
|
62
|
+
expect(dangerfile.status_report[:warnings].length).to be == 1
|
63
|
+
expect(dangerfile.status_report[:errors].length).to be == 0
|
64
|
+
expect(dangerfile.status_report[:warnings][0]).to eq '`Gemfile` has changed. `Gemfile.lock` should be committed.'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require "pathname"
|
2
|
+
ROOT = Pathname.new(File.expand_path("../../", __FILE__))
|
3
|
+
$:.unshift((ROOT + "lib").to_s)
|
4
|
+
$:.unshift((ROOT + "spec").to_s)
|
5
|
+
|
6
|
+
require "bundler/setup"
|
7
|
+
require "pry"
|
8
|
+
|
9
|
+
require "rspec"
|
10
|
+
require "danger"
|
11
|
+
|
12
|
+
if `git remote -v` == ''
|
13
|
+
puts "You cannot run tests without setting a local git remote on this repo"
|
14
|
+
puts "It's a weird side-effect of Danger's internals."
|
15
|
+
exit(0)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Use coloured output, it's the best.
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.filter_gems_from_backtrace "bundler"
|
21
|
+
config.color = true
|
22
|
+
config.tty = true
|
23
|
+
end
|
24
|
+
|
25
|
+
require "danger_plugin"
|
26
|
+
|
27
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
28
|
+
# If you are expanding these files, see if it's already been done ^.
|
29
|
+
|
30
|
+
# A silent version of the user interface,
|
31
|
+
# it comes with an extra function `.string` which will
|
32
|
+
# strip all ANSI colours from the string.
|
33
|
+
|
34
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
35
|
+
def testing_ui
|
36
|
+
@output = StringIO.new
|
37
|
+
def @output.winsize
|
38
|
+
[20, 9999]
|
39
|
+
end
|
40
|
+
|
41
|
+
cork = Cork::Board.new(out: @output)
|
42
|
+
def cork.string
|
43
|
+
out.string.gsub(/\e\[([;\d]+)?m/, "")
|
44
|
+
end
|
45
|
+
cork
|
46
|
+
end
|
47
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
48
|
+
|
49
|
+
# Example environment (ENV) that would come from
|
50
|
+
# running a PR on TravisCI
|
51
|
+
def testing_env
|
52
|
+
{
|
53
|
+
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
|
54
|
+
"TRAVIS_PULL_REQUEST" => "800",
|
55
|
+
"TRAVIS_REPO_SLUG" => "artsy/eigen",
|
56
|
+
"TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
|
57
|
+
"DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# A stubbed out Dangerfile for use in tests
|
62
|
+
def testing_dangerfile
|
63
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
64
|
+
Danger::Dangerfile.new(env, testing_ui)
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-lock_library_versions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mataku
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger-plugin-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A Danger plugin to check whether version lockfile is committed or not
|
84
|
+
email:
|
85
|
+
- nagomimatcha@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- Guardfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- danger-lock_library_versions.gemspec
|
98
|
+
- lib/danger_lock_library_versions.rb
|
99
|
+
- lib/danger_plugin.rb
|
100
|
+
- lib/lock_library_versions/gem_version.rb
|
101
|
+
- lib/lock_library_versions/plugin.rb
|
102
|
+
- spec/lock_library_versions_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/mataku/danger-lock_library_versions
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.6.13
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: A Danger plugin to check whether version lockfile is committed or not
|
128
|
+
test_files:
|
129
|
+
- spec/lock_library_versions_spec.rb
|
130
|
+
- spec/spec_helper.rb
|