cleanup_vendor 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24cac3d82b1d43e2442215768b8537b1f09f6a5fbaf5ddcd2d7ff9956ed363c1
4
- data.tar.gz: 229cec236efa8bc3a7b8bf1bbe2fc5e1c974168aceec2420b386656f731de1b2
3
+ metadata.gz: eba65f3da4adaa212b9caf6fb3821e66c6460ced2f6f21a62fdb291bda286fc4
4
+ data.tar.gz: 547e614403d033939588b3fb26ee1382656fe5d9ae10345253d12aaf1fc93e37
5
5
  SHA512:
6
- metadata.gz: ed7a4eefbed3e5b8682fcf0181a47778d6292d40827ad5441820080a6c9a64c16a32798adcad3b71b316fa7cf3bc7f29d56ddd5a972ae35cca446209dbb41765
7
- data.tar.gz: 7ac1613c439b7dcf2d44a5b782612fbceb55e77702077dc30e79372094c9194e703c60fc6cc430e87083b8d6d62a384f68dbbd627b23845d7ac151d1c3f2be35
6
+ metadata.gz: 6d9e1d4067aac018e4daf4ccd5dfcfd6317a95e1f8e90f6aaeae4a176e70f92193f7ae0fa543dfac6376d9ceff2247e47e5f85b95ec29965fe2f355158d101fc
7
+ data.tar.gz: 7eaa95c21c8bbde09677cf0270679baf38494f77c16ada25ee7b0090864e390e45320060633bd549bb624b623968c15cd00fb030ac9013adca485c310042c912
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+
8
+ - package-ecosystem: "github-actions"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "daily"
@@ -0,0 +1,31 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ ruby: [2.5, 2.6, 2.7]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+ - name: Update the RubyGems system software
25
+ run: gem update --system
26
+ - name: Update Bundler
27
+ run: bundle update --bundler
28
+ - name: Install dependencies
29
+ run: bundle install
30
+ - name: Run tests
31
+ run: bundle exec rspec
@@ -1,19 +1,23 @@
1
+ require:
2
+ - rubocop-rspec
3
+
1
4
  AllCops:
2
5
  TargetRubyVersion: 2.5
6
+ NewCops: enable
3
7
  Exclude:
4
- - 'bin/**/*'
5
- - 'vendor/**/*'
6
- - 'vendor.test/**/*'
8
+ - "bin/**/*"
9
+ - "vendor/**/*"
10
+ - "vendor.test/**/*"
7
11
 
8
12
  Layout/LineLength:
9
13
  Exclude:
10
- - 'exe/cleanup_vendor'
14
+ - "exe/cleanup_vendor"
11
15
  Max: 128
12
16
 
13
17
  Metrics/BlockLength:
14
18
  Exclude:
15
- - 'exe/cleanup_vendor'
16
- - 'spec/**/*'
19
+ - "exe/cleanup_vendor"
20
+ - "spec/**/*"
17
21
 
18
22
  Style/AccessModifierDeclarations:
19
23
  Enabled: false
@@ -27,4 +31,7 @@ Style/HashTransformValues:
27
31
  Enabled: true
28
32
  Style/StderrPuts:
29
33
  Exclude:
30
- - 'lib/cleanup_vendor.rb'
34
+ - "lib/cleanup_vendor.rb"
35
+
36
+ RSpec/MultipleMemoizedHelpers:
37
+ Enabled: false
@@ -1,76 +1,83 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cleanup_vendor (0.4.0)
4
+ cleanup_vendor (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.0)
10
- byebug (11.1.1)
11
- coderay (1.1.2)
12
- diff-lcs (1.3)
9
+ ast (2.4.1)
10
+ byebug (11.1.3)
11
+ coderay (1.1.3)
12
+ diff-lcs (1.4.4)
13
13
  docile (1.3.2)
14
- gem-release (2.1.1)
15
- jaro_winkler (1.5.4)
14
+ gem-release (2.2.0)
16
15
  json (2.3.0)
17
- method_source (0.9.2)
18
- parallel (1.19.1)
19
- parser (2.7.0.4)
20
- ast (~> 2.4.0)
21
- pry (0.12.2)
22
- coderay (~> 1.1.0)
23
- method_source (~> 0.9.0)
24
- pry-byebug (3.8.0)
16
+ method_source (1.0.0)
17
+ parallel (1.20.1)
18
+ parser (2.7.2.0)
19
+ ast (~> 2.4.1)
20
+ pry (0.13.1)
21
+ coderay (~> 1.1)
22
+ method_source (~> 1.0)
23
+ pry-byebug (3.9.0)
25
24
  byebug (~> 11.0)
26
- pry (~> 0.10)
27
- pry-doc (1.0.0)
25
+ pry (~> 0.13.0)
26
+ pry-doc (1.1.0)
28
27
  pry (~> 0.11)
29
28
  yard (~> 0.9.11)
30
29
  rainbow (3.0.0)
30
+ regexp_parser (2.0.0)
31
31
  rexml (3.2.4)
32
- rspec (3.9.0)
33
- rspec-core (~> 3.9.0)
34
- rspec-expectations (~> 3.9.0)
35
- rspec-mocks (~> 3.9.0)
36
- rspec-core (3.9.1)
37
- rspec-support (~> 3.9.1)
38
- rspec-expectations (3.9.1)
32
+ rspec (3.10.0)
33
+ rspec-core (~> 3.10.0)
34
+ rspec-expectations (~> 3.10.0)
35
+ rspec-mocks (~> 3.10.0)
36
+ rspec-core (3.10.0)
37
+ rspec-support (~> 3.10.0)
38
+ rspec-expectations (3.10.0)
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-mocks (3.9.1)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-mocks (3.10.0)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-support (3.9.2)
45
- rubocop (0.80.1)
46
- jaro_winkler (~> 1.5.1)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-support (3.10.0)
45
+ rubocop (1.5.2)
47
46
  parallel (~> 1.10)
48
- parser (>= 2.7.0.1)
47
+ parser (>= 2.7.1.5)
49
48
  rainbow (>= 2.2.2, < 4.0)
49
+ regexp_parser (>= 1.8, < 3.0)
50
50
  rexml
51
+ rubocop-ast (>= 1.2.0, < 2.0)
51
52
  ruby-progressbar (~> 1.7)
52
- unicode-display_width (>= 1.4.0, < 1.7)
53
+ unicode-display_width (>= 1.4.0, < 2.0)
54
+ rubocop-ast (1.3.0)
55
+ parser (>= 2.7.1.5)
56
+ rubocop-rspec (2.0.1)
57
+ rubocop (~> 1.0)
58
+ rubocop-ast (>= 1.1.0)
53
59
  ruby-progressbar (1.10.1)
54
60
  simplecov (0.17.1)
55
61
  docile (~> 1.1)
56
62
  json (>= 1.8, < 3)
57
63
  simplecov-html (~> 0.10.0)
58
64
  simplecov-html (0.10.2)
59
- unicode-display_width (1.6.1)
60
- yard (0.9.24)
65
+ unicode-display_width (1.7.0)
66
+ yard (0.9.25)
61
67
 
62
68
  PLATFORMS
63
69
  ruby
64
70
 
65
71
  DEPENDENCIES
66
- bundler (~> 1.17)
72
+ bundler (~> 2.1)
67
73
  cleanup_vendor!
68
74
  gem-release (~> 2.1)
69
75
  pry-byebug (~> 3.8)
70
76
  pry-doc (~> 1.0)
71
77
  rspec (~> 3.0)
72
- rubocop (~> 0.80.1)
73
- simplecov (~> 0.17.1)
78
+ rubocop (~> 1.5.2)
79
+ rubocop-rspec (~> 2.0, >= 2.0.1)
80
+ simplecov (= 0.17.1)
74
81
 
75
82
  BUNDLED WITH
76
- 1.17.3
83
+ 2.1.4
data/README.md CHANGED
@@ -5,7 +5,9 @@
5
5
  [![Test Coverage](https://codeclimate.com/github/raszi/cleanup_vendor/badges/coverage.svg)](https://codeclimate.com/github/raszi/cleanup_vendor)
6
6
  [![Gem Version](https://badge.fury.io/rb/cleanup_vendor.svg)](https://badge.fury.io/rb/cleanup_vendor)
7
7
 
8
- This gem was created to help minimizing the size of your docker images.
8
+ This gem was created to help minimizing the size of your Docker images by removing the unnecessary files in the production environment.
9
+
10
+ Files like build leftovers, test files, CI configurations, etc. You can check the [`defaults.yml`](lib/defaults.yml) for the exact list.
9
11
 
10
12
  ## Installation
11
13
 
@@ -34,11 +36,66 @@ RUN bundle install --deployment --frozen --jobs 4 --no-cache --retry 5 --without
34
36
  bundle exec cleanup_vendor --summary
35
37
  ```
36
38
 
37
- ## Development
39
+ To make it even smaller you can create a separate group in your `Gemfile` for this gem and remove that in the next step:
40
+
41
+ ```ruby
42
+ group :build do
43
+ gem 'cleanup_vendor'
44
+ end
45
+ ```
46
+
47
+ Then modify the previous command to something like this:
48
+
49
+ ```Dockerfile
50
+ RUN bundle install --deployment --frozen --jobs 4 --no-cache --retry 5 --without development test && \
51
+ bundle exec cleanup_vendor --summary && \
52
+ bundle install --deployment --frozen --jobs 4 --no-cache --retry 5 --without build development test && \
53
+ bundle clean --force
54
+ ```
55
+
56
+ If you are using multi-stage builds then you don't need to combine the commands into one `RUN` procedure:
57
+
58
+ ```Dockerfile
59
+ RUN bundle install --deployment --frozen --jobs 4 --no-cache --retry 5 --without development test
60
+ RUN bundle exec cleanup_vendor --summary
61
+ RUN bundle install --deployment --frozen --jobs 4 --no-cache --retry 5 --without build development test
62
+ RUN bundle clean --force
63
+ ```
64
+
65
+ ### Defaults
66
+
67
+ Please consult the [`defaults.yml`](lib/defaults.yml) file to see what files will be removed if the command executed without overrides.
68
+
69
+ Please note that patterns like `**/*.rb` will match every file with `.rb` extension recursively but a pattern like `Makefile` or `*.txt*` will be only applied if there is a gemspec file in that directory.
38
70
 
39
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
71
+ ### Overrides
72
+
73
+ The CLI supports multiple convenient options:
74
+
75
+ ```
76
+ Usage: cleanup_vendor [options]
77
+
78
+ Specific options:
79
+ -v, --[no-]verbose Run verbosely
80
+ -0, --null Print the pathname of the removed file to standard output, followed by an ASCII NUL character (character code 0).
81
+ --dry-run Do not delete files
82
+ -s, --summary Display a summary after execution
83
+ -d, --directory PATTERN Match on directory
84
+ -f, --extension PATTERN Match on file
85
+ -e --exclude pattern Exclude pattern from matching
86
+ -h, --help Show this message
87
+ -V, --version Show version
88
+ ```
89
+
90
+ ### Override Examples
91
+
92
+ This example excludes a file from the Password Strength gem
93
+ ```
94
+ bundle exec cleanup_vendor --dry-run --verbose -e '**/password_strength*/*/common.txt'
95
+ ```
96
+ ## Development
40
97
 
41
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
98
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
99
 
43
100
  ## Contributing
44
101
 
@@ -23,11 +23,14 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ['lib']
25
25
 
26
- spec.add_development_dependency 'bundler', '~> 1.17'
26
+ spec.required_ruby_version = '~> 2.5'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 2.1'
27
29
  spec.add_development_dependency 'gem-release', '~> 2.1'
28
30
  spec.add_development_dependency 'pry-byebug', '~> 3.8'
29
31
  spec.add_development_dependency 'pry-doc', '~> 1.0'
30
32
  spec.add_development_dependency 'rspec', '~> 3.0'
31
- spec.add_development_dependency 'rubocop', '~> 0.80.1'
32
- spec.add_development_dependency 'simplecov', '~> 0.17.1'
33
+ spec.add_development_dependency 'rubocop', '~> 1.5.2'
34
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.0', '>= 2.0.1'
35
+ spec.add_development_dependency 'simplecov', '= 0.17.1'
33
36
  end
@@ -39,6 +39,11 @@ opt_parser = OptionParser.new do |opts|
39
39
  options[:files] << pattern
40
40
  end
41
41
 
42
+ opts.on('-e', '--exclude PATTERN', 'Exclude pattern from matching') do |pattern|
43
+ options[:exclude] ||= []
44
+ options[:exclude] << pattern
45
+ end
46
+
42
47
  opts.on_tail('-h', '--help', 'Show this message') do
43
48
  puts opts
44
49
  exit
@@ -32,9 +32,10 @@ module CleanupVendor
32
32
  raise Error, 'Not a directory' unless File.directory?(dir.to_s)
33
33
  return to_enum(:filter, dir, opts) unless block_given?
34
34
 
35
- files, directories, filtered = get_options(opts)
35
+ files, directories, filtered, exclude = get_options(opts)
36
36
 
37
37
  Path.new(dir).recursive_entries do |path|
38
+ next if path.match?(exclude)
38
39
  next if path.include?(filtered)
39
40
  next unless path.file? && path.match?(files) || path.directory? && path.match?(directories)
40
41
 
@@ -45,7 +46,7 @@ module CleanupVendor
45
46
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
46
47
 
47
48
  def get_options(options)
48
- options.values_at(:files, :directories, :filtered).map do |v|
49
+ options.values_at(:files, :directories, :filtered, :exclude).map do |v|
49
50
  (v || []).to_set
50
51
  end
51
52
  end
@@ -14,7 +14,9 @@ module CleanupVendor
14
14
 
15
15
  def match?(patterns)
16
16
  patterns.any? do |p|
17
- p.start_with?('**') && fnmatch?(p, File::FNM_EXTGLOB) || basename.fnmatch?(p, File::FNM_EXTGLOB) && gem_level?
17
+ p.eql?(self) ||
18
+ p.start_with?('**') && fnmatch?(p, File::FNM_EXTGLOB) ||
19
+ basename.fnmatch?(p, File::FNM_EXTGLOB) && gem_level?
18
20
  end
19
21
  end
20
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CleanupVendor
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -1,12 +1,15 @@
1
1
  directories:
2
- - "spec"
3
- - "coverage"
4
2
  - "**/.circleci"
5
3
  - "**/.config"
6
- - "**/.{git,github}"
7
4
  - "**/.idea"
8
- - "**/.{npm,yarn}"
9
5
  - "**/.yardoc"
6
+ - "**/.{git,github}"
7
+ - "**/.{npm,yarn}"
8
+ - "Gemfile"
9
+ - "Rakefile"
10
+ - "coverage"
11
+ - "spec"
12
+ - "test"
10
13
  files:
11
14
  - "**/.DS_Store"
12
15
  - "**/*.{c,cpp,h,hpp,java,log,markdown,md,mk,o,orig,rdoc,txt}"
@@ -16,10 +19,11 @@ files:
16
19
  - "**/*.{gcov,gem}"
17
20
  - "**/*.{log,markdown,md,rdoc,txt,yardopts}"
18
21
  - "**/*.{bak,orig}"
19
- - "**/{CHANGELOG,LICENSE,MIT-LICENSE,NEWS,README,TODO}"
22
+ - "**/{CHANGELOG,CHANGES,LICENSE,MIT-LICENSE,NEWS,README,TODO}"
20
23
  - "**/.{gitkeep,gitignore,gitmodules}"
21
24
  - "**/.keep"
22
25
  - "**/{Dockerfile,.dockerignore}"
26
+ - "**/Guardfile"
23
27
  - "**/.{appveyor,codeclimate,hound,travis}.yml"
24
28
  - "**/.{ruby-gemset,ruby-version,rvm}"
25
29
  - "**/.{rspec,rspec_status}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cleanup_vendor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KARASZI István
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-15 00:00:00.000000000 Z
11
+ date: 2020-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gem-release
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,26 +86,46 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.80.1
89
+ version: 1.5.2
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.80.1
96
+ version: 1.5.2
97
97
  - !ruby/object:Gem::Dependency
98
- name: simplecov
98
+ name: rubocop-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.17.1
103
+ version: '2.0'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.0.1
104
107
  type: :development
105
108
  prerelease: false
106
109
  version_requirements: !ruby/object:Gem::Requirement
107
110
  requirements:
108
111
  - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '2.0'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 2.0.1
117
+ - !ruby/object:Gem::Dependency
118
+ name: simplecov
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '='
122
+ - !ruby/object:Gem::Version
123
+ version: 0.17.1
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '='
109
129
  - !ruby/object:Gem::Version
110
130
  version: 0.17.1
111
131
  description: Removes unnecessary files which are not required in production environment.
@@ -116,6 +136,8 @@ executables:
116
136
  extensions: []
117
137
  extra_rdoc_files: []
118
138
  files:
139
+ - ".github/dependabot.yml"
140
+ - ".github/workflows/ruby.yml"
119
141
  - ".gitignore"
120
142
  - ".rspec"
121
143
  - ".rubocop.yml"
@@ -142,16 +164,16 @@ require_paths:
142
164
  - lib
143
165
  required_ruby_version: !ruby/object:Gem::Requirement
144
166
  requirements:
145
- - - ">="
167
+ - - "~>"
146
168
  - !ruby/object:Gem::Version
147
- version: '0'
169
+ version: '2.5'
148
170
  required_rubygems_version: !ruby/object:Gem::Requirement
149
171
  requirements:
150
172
  - - ">="
151
173
  - !ruby/object:Gem::Version
152
174
  version: '0'
153
175
  requirements: []
154
- rubygems_version: 3.0.8
176
+ rubygems_version: 3.1.4
155
177
  signing_key:
156
178
  specification_version: 4
157
179
  summary: This gem helps to cleanup vendor directory