danger-package_json_lockdown 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 894abee3dcc4df1aceba34f5157d8ddad837fa61
4
+ data.tar.gz: 6f0d383ce604afe65df176189d8e0ed23051b3f1
5
+ SHA512:
6
+ metadata.gz: 56ed239a7d12794d780dc64c860f47a12c070f6c6e215c73added89935eee5f06b7fed23f8ee1d27401da151f8b7353fd18ba378a32991a73f0fbd58dd90fd33
7
+ data.tar.gz: 8bfcd36e851f2dba8e49725fa340331cac2020bb651eda41b83f14c5488c6aac84b1ecf0f528df7ec1112c675bd2a7997e1035327b7a25ebd10d486219a4bcf0
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ .yardoc
3
+ pkg
4
+ .idea/
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.3
9
+ - 2.3.1
10
+
11
+ script:
12
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-package_json_lockdown.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,139 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-package_json_lockdown (0.0.1)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.4.0)
11
+ ast (2.3.0)
12
+ claide (1.0.1)
13
+ claide-plugins (0.9.2)
14
+ cork
15
+ nap
16
+ open4 (~> 1.3)
17
+ coderay (1.1.1)
18
+ colored (1.2)
19
+ cork (0.2.0)
20
+ colored (~> 1.2)
21
+ danger (3.5.3)
22
+ claide (~> 1.0)
23
+ claide-plugins (>= 0.9.2)
24
+ colored (~> 1.2)
25
+ cork (~> 0.1)
26
+ faraday (~> 0.9)
27
+ faraday-http-cache (~> 1.0)
28
+ git (~> 1)
29
+ gitlab (~> 3.7.0)
30
+ kramdown (~> 1.5)
31
+ octokit (~> 4.2)
32
+ terminal-table (~> 1)
33
+ danger-plugin-api (1.0.0)
34
+ danger (> 2.0)
35
+ diff-lcs (1.2.5)
36
+ faraday (0.9.2)
37
+ multipart-post (>= 1.2, < 3)
38
+ faraday-http-cache (1.3.1)
39
+ faraday (~> 0.8)
40
+ ffi (1.9.14)
41
+ formatador (0.2.5)
42
+ git (1.3.0)
43
+ gitlab (3.7.0)
44
+ httparty (~> 0.13.0)
45
+ terminal-table
46
+ guard (2.14.0)
47
+ formatador (>= 0.2.4)
48
+ listen (>= 2.7, < 4.0)
49
+ lumberjack (~> 1.0)
50
+ nenv (~> 0.1)
51
+ notiffany (~> 0.0)
52
+ pry (>= 0.9.12)
53
+ shellany (~> 0.0)
54
+ thor (>= 0.18.1)
55
+ guard-compat (1.2.1)
56
+ guard-rspec (4.7.3)
57
+ guard (~> 2.1)
58
+ guard-compat (~> 1.1)
59
+ rspec (>= 2.99.0, < 4.0)
60
+ httparty (0.13.7)
61
+ json (~> 1.8)
62
+ multi_xml (>= 0.5.2)
63
+ json (1.8.3)
64
+ kramdown (1.12.0)
65
+ listen (3.0.7)
66
+ rb-fsevent (>= 0.9.3)
67
+ rb-inotify (>= 0.9.7)
68
+ lumberjack (1.0.10)
69
+ method_source (0.8.2)
70
+ multi_xml (0.5.5)
71
+ multipart-post (2.0.0)
72
+ nap (1.1.0)
73
+ nenv (0.3.0)
74
+ notiffany (0.1.1)
75
+ nenv (~> 0.1)
76
+ shellany (~> 0.0)
77
+ octokit (4.3.0)
78
+ sawyer (~> 0.7.0, >= 0.5.3)
79
+ open4 (1.3.4)
80
+ parser (2.3.1.4)
81
+ ast (~> 2.2)
82
+ powerpack (0.1.1)
83
+ pry (0.10.4)
84
+ coderay (~> 1.1.0)
85
+ method_source (~> 0.8.1)
86
+ slop (~> 3.4)
87
+ rainbow (2.1.0)
88
+ rake (10.5.0)
89
+ rb-fsevent (0.9.7)
90
+ rb-inotify (0.9.7)
91
+ ffi (>= 0.5.0)
92
+ rspec (3.5.0)
93
+ rspec-core (~> 3.5.0)
94
+ rspec-expectations (~> 3.5.0)
95
+ rspec-mocks (~> 3.5.0)
96
+ rspec-core (3.5.4)
97
+ rspec-support (~> 3.5.0)
98
+ rspec-expectations (3.5.0)
99
+ diff-lcs (>= 1.2.0, < 2.0)
100
+ rspec-support (~> 3.5.0)
101
+ rspec-mocks (3.5.0)
102
+ diff-lcs (>= 1.2.0, < 2.0)
103
+ rspec-support (~> 3.5.0)
104
+ rspec-support (3.5.0)
105
+ rubocop (0.43.0)
106
+ parser (>= 2.3.1.1, < 3.0)
107
+ powerpack (~> 0.1)
108
+ rainbow (>= 1.99.1, < 3.0)
109
+ ruby-progressbar (~> 1.7)
110
+ unicode-display_width (~> 1.0, >= 1.0.1)
111
+ ruby-progressbar (1.8.1)
112
+ sawyer (0.7.0)
113
+ addressable (>= 2.3.5, < 2.5)
114
+ faraday (~> 0.8, < 0.10)
115
+ shellany (0.0.1)
116
+ slop (3.6.0)
117
+ terminal-table (1.7.3)
118
+ unicode-display_width (~> 1.1.1)
119
+ thor (0.19.1)
120
+ unicode-display_width (1.1.1)
121
+ yard (0.9.5)
122
+
123
+ PLATFORMS
124
+ ruby
125
+
126
+ DEPENDENCIES
127
+ bundler (~> 1.3)
128
+ danger-package_json_lockdown!
129
+ guard (~> 2.14)
130
+ guard-rspec (~> 4.7)
131
+ listen (= 3.0.7)
132
+ pry
133
+ rake (~> 10.0)
134
+ rspec (~> 3.4)
135
+ rubocop (~> 0.41)
136
+ yard (~> 0.8)
137
+
138
+ BUNDLED WITH
139
+ 1.13.1
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) 2016 Joshua May <josh@notjosh.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,64 @@
1
+
2
+
3
+ ### package_json_lockdown
4
+
5
+ Force locking down of version numbers in package.json
6
+
7
+ Shrinkwrap isn't the solution you want it to be, and none of the other tools
8
+ quite do what you want. So you'll get fed up and force manual management of
9
+ your dependencies (after all, `npm outdated` is fairly easy to deal with.)
10
+
11
+ This plugin will warn you if you're commiting anything that looks like:
12
+
13
+ - "^1.0.0"
14
+ - "~1.0.0"
15
+ - "<=1.0.0"
16
+ - "<1.0.0"
17
+ - ">=1.0.0"
18
+ - ">1.0.0"
19
+ - "1.0.x"
20
+ - "*"
21
+ - ""
22
+
23
+ So you can still specify a git hash, a tag, or a URL (and so on), and, most
24
+ importantly, you can specify a version number.
25
+
26
+ <blockquote>Basic operation, throwing warnings in specified package.json(s)
27
+ <pre>
28
+ package_json_lockdown.verify('package.json')
29
+ package_json_lockdown.verify('path/to/sub/package.json')</pre>
30
+ </blockquote>
31
+
32
+ <blockquote>Blacklisting specific dependencies nodes
33
+ <pre>
34
+ # Will only check the `dependencies` node, but allow
35
+ # `devDependencies` to contain non-specific versions
36
+ package_json_lockdown.dependency_keys = ['dependencies']
37
+ package_json_lockdown.verify('package.json')</pre>
38
+ </blockquote>
39
+
40
+ <blockquote>Returning values to handle manually
41
+ <pre>
42
+ problems = package_json_lockdown.inspect('package.json')
43
+ puts(problems)</pre>
44
+ </blockquote>
45
+
46
+
47
+
48
+ #### Attributes
49
+
50
+ `dependency_keys` - Allows you to specify dependency nodes to check. By default it will check
51
+ all nodes known to contain dependencies.
52
+
53
+
54
+
55
+
56
+ #### Methods
57
+
58
+ `verify` - Verifies the supplied `package.json` file
59
+
60
+ `inspect` - Inspects the supplied `package.json` file and returns problems
61
+
62
+
63
+
64
+
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
@@ -0,0 +1,49 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'package_json_lockdown/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-package_json_lockdown'
8
+ spec.version = PackageJsonLockdown::VERSION
9
+ spec.authors = ['Joshua May']
10
+ spec.email = ['josh@notjosh.com']
11
+ spec.description = %q{Force locking down of version numbers in package.json.}
12
+ spec.summary = %q{A plugin for Danger that allows locking down of version numbers found in package.json}
13
+ spec.homepage = 'https://github.com/notjosh/danger-package_json_lockdown'
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
+ # Linting code and docs
31
+ spec.add_development_dependency "rubocop", "~> 0.41"
32
+ spec.add_development_dependency "yard", "~> 0.8"
33
+
34
+ # Makes testing easy via `bundle exec guard`
35
+ spec.add_development_dependency 'guard', '~> 2.14'
36
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
37
+
38
+ # If you want to work on older builds of ruby
39
+ spec.add_development_dependency 'listen', '3.0.7'
40
+
41
+ # This gives you the chance to run a REPL inside your tests
42
+ # via:
43
+ #
44
+ # require 'pry'
45
+ # binding.pry
46
+ #
47
+ # This will stop test execution and let you inspect the results
48
+ spec.add_development_dependency 'pry'
49
+ end
@@ -0,0 +1 @@
1
+ require 'package_json_lockdown/gem_version'
@@ -0,0 +1 @@
1
+ require 'package_json_lockdown/plugin'
@@ -0,0 +1,3 @@
1
+ module PackageJsonLockdown
2
+ VERSION = '0.9.9'.freeze
3
+ end
@@ -0,0 +1,123 @@
1
+ module Danger
2
+ # Force locking down of version numbers in package.json
3
+ #
4
+ # Shrinkwrap isn't the solution you want it to be, and none of the other tools
5
+ # quite do what you want. So you'll get fed up and force manual management of
6
+ # your dependencies (after all, `npm outdated` is fairly easy to deal with.)
7
+ #
8
+ # This plugin will warn you if you're commiting anything that looks like:
9
+ #
10
+ # - "^1.0.0"
11
+ # - "~1.0.0"
12
+ # - "<=1.0.0"
13
+ # - "<1.0.0"
14
+ # - ">=1.0.0"
15
+ # - ">1.0.0"
16
+ # - "1.0.x"
17
+ # - "*"
18
+ # - ""
19
+ #
20
+ # So you can still specify a git hash, a tag, or a URL (and so on), and, most
21
+ # importantly, you can specify a version number.
22
+ #
23
+ # @example Basic operation, throwing warnings in specified package.json(s)
24
+ #
25
+ # package_json_lockdown.verify('package.json')
26
+ # package_json_lockdown.verify('path/to/sub/package.json')
27
+ #
28
+ # @example Blacklisting specific dependencies nodes
29
+ #
30
+ # # Will only check the `dependencies` node, but allow
31
+ # # `devDependencies` to contain non-specific versions
32
+ # package_json_lockdown.dependency_keys = ['dependencies']
33
+ # package_json_lockdown.verify('package.json')
34
+ #
35
+ # @example Returning values to handle manually
36
+ #
37
+ # problems = package_json_lockdown.inspect('package.json')
38
+ # puts(problems)
39
+ #
40
+ # @tags npm, package.json, node, nodejs
41
+ #
42
+ class DangerPackageJsonLockdown < Plugin
43
+ # Allows you to specify dependency nodes to check. By default it will check
44
+ # all nodes known to contain dependencies.
45
+ #
46
+ # @return [Array<String>]
47
+ attr_accessor :dependency_keys
48
+
49
+ def dependency_keys
50
+ @dependency_keys || %w(
51
+ dependencies
52
+ devDependencies
53
+ peerDependencies
54
+ bundleDependencies
55
+ bundledDependencies
56
+ optionalDependencies
57
+ )
58
+ end
59
+
60
+ # Verifies the supplied `package.json` file
61
+ # @param [string] package_json
62
+ # Path to `package.json`, relative to current directory
63
+ # @return [void]
64
+ def verify(package_json)
65
+ inspect(package_json).each do |suspicious|
66
+ warn(
67
+ "`#{suspicious[:package]}` doesn't specify fixed version number",
68
+ file: package_json,
69
+ line: suspicious[:line]
70
+ )
71
+ end
72
+ end
73
+
74
+ # Inspects the supplied `package.json` file and returns problems
75
+ # @param [string] package_json
76
+ # Path to `package.json`, relative to current directory
77
+ # @return [Array<{Symbol => String}>]
78
+ # - `:package`: the offending package name
79
+ # - `:version`: the version as written in `package.json`
80
+ # - `:line`: (probably) the line number.
81
+ def inspect(package_json)
82
+ json = JSON.parse(File.read(package_json))
83
+
84
+ suspicious_packages = []
85
+
86
+ dependency_keys.each do |dependency_key|
87
+ next unless json.key?(dependency_key)
88
+
89
+ results = find_something_suspicious(json[dependency_key], package_json)
90
+ suspicious_packages.push(*results)
91
+ end
92
+
93
+ suspicious_packages
94
+ end
95
+
96
+ private
97
+
98
+ def find_something_suspicious(dependency_node, package_json)
99
+ suspicious_packages = []
100
+
101
+ dependency_node.each do |package, version|
102
+ obj = {
103
+ package: package,
104
+ version: version,
105
+ line: line_number_of_package(package, package_json)
106
+ }
107
+ suspicious_packages.push(obj) if suspicious?(version)
108
+ end
109
+
110
+ suspicious_packages
111
+ end
112
+
113
+ def suspicious?(version)
114
+ version =~ /^[\^<>\*~]/ ||
115
+ version =~ /\.x/ ||
116
+ version == ''
117
+ end
118
+
119
+ def line_number_of_package(package, package_json)
120
+ `grep -n '\"#{package}\":' #{package_json} | cut -f1 -d:`.strip
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "danger-package_json_lockdown",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@shoutem/ui": "0.9.1",
6
+ "react": "15.3.2",
7
+ "react-intl": "2.1.5"
8
+ },
9
+ "devDependencies": {
10
+ "@kadira/react-native-storybook": "^2.1.3",
11
+ "babel-jest": ">=15.0.0",
12
+ "babel-plugin-flow-react-proptypes": "<0.12.2",
13
+ "babel-preset-react-native": "~1.9.0",
14
+ "eslint-config-airbnb-flow": "1.0.x",
15
+ "eslint-plugin-import": "",
16
+ "eslint-plugin-jsx-a11y": "*",
17
+ "eslint-plugin-react": "6.3.0"
18
+ }
19
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "danger-package_json_lockdown",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@shoutem/ui": "0.9.1",
6
+ "react": "15.3.2",
7
+ "react-intl": "2.1.5",
8
+ "react-native": "0.35.0-rc.0"
9
+ },
10
+ "devDependencies": {
11
+ "@kadira/react-native-storybook": "2.1.3",
12
+ "babel-jest": "15.0.0",
13
+ "babel-plugin-flow-react-proptypes": "0.12.2",
14
+ "babel-preset-react-native": "1.9.0",
15
+ "eslint-config-airbnb-flow": "1.0.2",
16
+ "eslint-plugin-import": "1.16.0",
17
+ "eslint-plugin-jsx-a11y": "2.2.2",
18
+ "eslint-plugin-react": "6.3.0"
19
+ }
20
+ }
@@ -0,0 +1,90 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerPackageJsonLockdown, use: :ci_helper do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerPackageJsonLockdown.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ describe 'with Dangerfile' do
10
+ before do
11
+ @dangerfile = testing_dangerfile
12
+ @package_json_lockdown = @dangerfile.package_json_lockdown
13
+ end
14
+
15
+ it 'Accepts valid package.json' do
16
+ @package_json_lockdown.verify('spec/fixtures/valid.json')
17
+ expect(@dangerfile.status_report[:warnings]).to eq([])
18
+ end
19
+
20
+ it 'Warns on package.json with non-specific versions' do
21
+ @package_json_lockdown.verify('spec/fixtures/invalid.json')
22
+
23
+ warnings = [
24
+ '`@kadira/react-native-storybook` doesn\'t specify fixed version ' \
25
+ 'number',
26
+ '`babel-jest` doesn\'t specify fixed version number',
27
+ '`babel-plugin-flow-react-proptypes` doesn\'t specify fixed ' \
28
+ 'version number',
29
+ '`babel-preset-react-native` doesn\'t specify fixed version number',
30
+ '`eslint-config-airbnb-flow` doesn\'t specify fixed version number',
31
+ '`eslint-plugin-import` doesn\'t specify fixed version number',
32
+ '`eslint-plugin-jsx-a11y` doesn\'t specify fixed version number'
33
+ ]
34
+ expect(@dangerfile.status_report[:warnings]).to eq(warnings)
35
+ end
36
+
37
+ it 'Allows specifying dependency JSON keys' do
38
+ @package_json_lockdown.dependency_keys = ['dependencies']
39
+ @package_json_lockdown.verify('spec/fixtures/invalid.json')
40
+
41
+ expect(@dangerfile.status_report[:warnings]).to eq([])
42
+ end
43
+
44
+ it 'Returns suspicious packages without warning if inspecting' do
45
+ suspicious = @package_json_lockdown.inspect(
46
+ 'spec/fixtures/invalid.json'
47
+ )
48
+
49
+ expected = [
50
+ {
51
+ package: '@kadira/react-native-storybook',
52
+ version: '^2.1.3',
53
+ line: '10'
54
+ },
55
+ {
56
+ package: 'babel-jest',
57
+ version: '>=15.0.0',
58
+ line: '11'
59
+ },
60
+ {
61
+ package: 'babel-plugin-flow-react-proptypes',
62
+ version: '<0.12.2',
63
+ line: '12'
64
+ },
65
+ {
66
+ package: 'babel-preset-react-native',
67
+ version: '~1.9.0',
68
+ line: '13'
69
+ },
70
+ {
71
+ package: 'eslint-config-airbnb-flow',
72
+ version: '1.0.x',
73
+ line: '14'
74
+ },
75
+ {
76
+ package: 'eslint-plugin-import',
77
+ version: '',
78
+ line: '15'
79
+ },
80
+ {
81
+ package: 'eslint-plugin-jsx-a11y',
82
+ version: '*',
83
+ line: '16'
84
+ }
85
+ ]
86
+ expect(suspicious).to eq(expected)
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,59 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
4
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'pry'
8
+
9
+ require 'rspec'
10
+ require 'danger'
11
+
12
+ # Use coloured output, it's the best.
13
+ RSpec.configure do |config|
14
+ config.filter_gems_from_backtrace 'bundler'
15
+ config.color = true
16
+ config.tty = true
17
+ end
18
+
19
+ require 'danger_plugin'
20
+
21
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
22
+ # If you are expanding these files, see if it's already been done ^.
23
+
24
+ # A silent version of the user interface,
25
+ # it comes with an extra function `.string` which will
26
+ # strip all ANSI colours from the string.
27
+
28
+ # rubocop:disable Lint/NestedMethodDefinition
29
+ def testing_ui
30
+ @output = StringIO.new
31
+ def @output.winsize
32
+ [20, 9999]
33
+ end
34
+
35
+ cork = Cork::Board.new(out: @output)
36
+ def cork.string
37
+ out.string.gsub(/\e\[([;\d]+)?m/, '')
38
+ end
39
+ cork
40
+ end
41
+ # rubocop:enable Lint/NestedMethodDefinition
42
+
43
+ # Example environment (ENV) that would come from
44
+ # running a PR on TravisCI
45
+ def testing_env
46
+ {
47
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
48
+ 'TRAVIS_PULL_REQUEST' => '800',
49
+ 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
50
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
51
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
52
+ }
53
+ end
54
+
55
+ # A stubbed out Dangerfile for use in tests
56
+ def testing_dangerfile
57
+ env = Danger::EnvironmentManager.new(testing_env)
58
+ Danger::Dangerfile.new(env, testing_ui)
59
+ end
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-package_json_lockdown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.9
5
+ platform: ruby
6
+ authors:
7
+ - Joshua May
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-10 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: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.41'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.41'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: listen
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.0.7
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Force locking down of version numbers in package.json.
154
+ email:
155
+ - josh@notjosh.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".travis.yml"
162
+ - Gemfile
163
+ - Gemfile.lock
164
+ - Guardfile
165
+ - LICENSE.txt
166
+ - README.md
167
+ - Rakefile
168
+ - danger-package_json_lockdown.gemspec
169
+ - lib/danger_package_json_lockdown.rb
170
+ - lib/danger_plugin.rb
171
+ - lib/package_json_lockdown/gem_version.rb
172
+ - lib/package_json_lockdown/plugin.rb
173
+ - spec/fixtures/invalid.json
174
+ - spec/fixtures/valid.json
175
+ - spec/package_json_lockdown_spec.rb
176
+ - spec/spec_helper.rb
177
+ homepage: https://github.com/notjosh/danger-package_json_lockdown
178
+ licenses:
179
+ - MIT
180
+ metadata: {}
181
+ post_install_message:
182
+ rdoc_options: []
183
+ require_paths:
184
+ - lib
185
+ required_ruby_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ requirements: []
196
+ rubyforge_project:
197
+ rubygems_version: 2.4.5
198
+ signing_key:
199
+ specification_version: 4
200
+ summary: A plugin for Danger that allows locking down of version numbers found in
201
+ package.json
202
+ test_files:
203
+ - spec/fixtures/invalid.json
204
+ - spec/fixtures/valid.json
205
+ - spec/package_json_lockdown_spec.rb
206
+ - spec/spec_helper.rb