From fe2deb146d1474a34db98066ba5fc02a70dd03de Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Tue, 17 Sep 2024 17:07:35 +0200 Subject: [PATCH] Reduce production gem size Include only files that are needed for the production gem. Also avoids to use git to allow to build the package in an environment that does not have git (on purpose). ### Before 173K ``` .dokaz .github/PULL_REQUEST_TEMPLATE.md .github/dependabot.yml .github/workflows/dependency-review.yml .github/workflows/main.yml .gitignore .rspec .rubocop.yml .ruby-version .yardopts CHANGELOG.md CODE_OF_CONDUCT.md Gemfile Gemfile.lock LICENSE.txt README.md Rakefile benchmarks/Gemfile benchmarks/benchmarks.rb bin/console bin/setup lib/memo_wise.rb lib/memo_wise/internal_api.rb lib/memo_wise/version.rb logo/logo.png memo_wise.gemspec ``` ### After 19K ``` CHANGELOG.md LICENSE.txt README.md lib/memo_wise.rb lib/memo_wise/internal_api.rb lib/memo_wise/version.rb ``` Ref: https://docs.rubocop.org/rubocop-packaging/cops_packaging.html#packaginggemspecgit --- CHANGELOG.md | 2 ++ memo_wise.gemspec | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56e4912..69375eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm **Gem enhancements:** +- Reduced production gem size by 9 times [[#345](https://github.com/panorama-ed/memo_wise/pull/345)] + _No breaking changes!_ **Project enhancements:** diff --git a/memo_wise.gemspec b/memo_wise.gemspec index 6c951a6..412c22c 100644 --- a/memo_wise.gemspec +++ b/memo_wise.gemspec @@ -26,13 +26,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0") # Specify which files should be added to the gem when it is released. - # The `git ls-files -z` loads the files in the RubyGem that have been added - # into git. - spec.files = Dir.chdir(File.expand_path(__dir__)) do - `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - end + spec.files = Dir.glob("{CHANGELOG.md,LICENSE.txt,README.md,lib/**/*.rb}") spec.require_paths = ["lib"] spec.metadata = {