Skip to content

Commit

Permalink
[plugin_generator] move development dependencies from *.gemspec.erb
Browse files Browse the repository at this point in the history
… to `Gemfile.erb` (fastlane#21726)

* Make Gemfile a template and move dev dependencies to it, in plugin generator.

* Remove now-unnecessary rule exception on RuboCop.

* Update comments.
  • Loading branch information
rogerluan authored and SubhrajyotiSen committed Jan 17, 2024
1 parent fcdee27 commit 7bd6c48
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 36 deletions.
4 changes: 0 additions & 4 deletions fastlane.gemspec
Expand Up @@ -15,10 +15,6 @@ config['require'] = [
config.delete('inherit_from')
config.delete('CrossPlatform/ForkUsage')
config.delete('Lint/IsStringUsage')
# We declare development dependencies in the Gemspec file because we use dynamic values in its template
config['Gemspec/DevelopmentDependencies'] = {
'Enabled' => false
}

File.write("#{lib}/fastlane/plugins/template/.rubocop.yml", YAML.dump(config))

Expand Down
11 changes: 0 additions & 11 deletions fastlane/lib/fastlane/plugins/template/%gem_name%.gemspec.erb
Expand Up @@ -21,15 +21,4 @@ Gem::Specification.new do |spec|
# since this would cause a circular dependency

# spec.add_dependency 'your-dependency', '~> 1.0.0'

spec.add_development_dependency('bundler')
spec.add_development_dependency('fastlane', '>= <%= Fastlane::VERSION %>')
spec.add_development_dependency('pry')
spec.add_development_dependency('rake')
spec.add_development_dependency('rspec')
spec.add_development_dependency('rspec_junit_formatter')
spec.add_development_dependency('rubocop', '<%= Fastlane::RUBOCOP_REQUIREMENT %>')
spec.add_development_dependency('rubocop-performance')
spec.add_development_dependency('rubocop-require_tools')
spec.add_development_dependency('simplecov')
end
6 changes: 0 additions & 6 deletions fastlane/lib/fastlane/plugins/template/Gemfile

This file was deleted.

27 changes: 27 additions & 0 deletions fastlane/lib/fastlane/plugins/template/Gemfile.erb
@@ -0,0 +1,27 @@
source('https://rubygems.org')

# Provides a consistent environment for Ruby projects by tracking and installing exact gem versions.
gem 'bundler'
# Automation tool for mobile developers.
gem 'fastlane', '>= <%= Fastlane::VERSION %>'
# Provides an interactive debugging environment for Ruby.
gem 'pry'
# A simple task automation tool.
gem 'rake'
# Behavior-driven testing tool for Ruby.
gem 'rspec'
# Formatter for RSpec to generate JUnit compatible reports.
gem 'rspec_junit_formatter'
# A Ruby static code analyzer and formatter.
gem 'rubocop', '<%= Fastlane::RUBOCOP_REQUIREMENT %>'
# A collection of RuboCop cops for performance optimizations.
gem 'rubocop-performance'
# A RuboCop extension focused on enforcing tools.
gem 'rubocop-require_tools'
# SimpleCov is a code coverage analysis tool for Ruby.
gem 'simplecov'

gemspec

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
30 changes: 15 additions & 15 deletions fastlane/spec/plugins_specs/plugin_generator_spec.rb
Expand Up @@ -103,10 +103,21 @@
gemfile_lines = File.read(gemfile).lines

[
"source('https://rubygems.org')\n",
"gemspec\n"
"source('https://rubygems.org')",
"gem 'bundler'",
"gem 'fastlane', '>= #{Fastlane::VERSION}'",
"gem 'pry'",
"gem 'rake'",
"gem 'rspec'",
"gem 'rspec_junit_formatter'",
"gem 'rubocop', '#{Fastlane::RUBOCOP_REQUIREMENT}'",
"gem 'rubocop-performance'",
"gem 'rubocop-require_tools'",
"gem 'simplecov'",
"gemspec"
].each do |line|
expect(gemfile_lines).to include(line)
# Expect them to match approximately, e.g. using regex
expect(gemfile_lines).to include("#{line}\n")
end
end

Expand Down Expand Up @@ -224,18 +235,7 @@
expect(gemspec.version).to eq(Gem::Version.new('0.1.0'))
expect(gemspec.email).to eq(email)
expect(gemspec.summary).to eq(summary)
expect(gemspec.development_dependencies).to contain_exactly(
Gem::Dependency.new("pry", Gem::Requirement.new([">= 0"]), :development),
Gem::Dependency.new("bundler", Gem::Requirement.new([">= 0"]), :development),
Gem::Dependency.new("rspec", Gem::Requirement.new([">= 0"]), :development),
Gem::Dependency.new("rspec_junit_formatter", Gem::Requirement.new([">= 0"]), :development),
Gem::Dependency.new("rake", Gem::Requirement.new([">= 0"]), :development),
Gem::Dependency.new("rubocop", Gem::Requirement.new([Fastlane::RUBOCOP_REQUIREMENT]), :development),
Gem::Dependency.new("rubocop-require_tools", Gem::Requirement.new([">= 0"]), :development),
Gem::Dependency.new("rubocop-performance", Gem::Requirement.new([">= 0"]), :development),
Gem::Dependency.new("simplecov", Gem::Requirement.new([">= 0"]), :development),
Gem::Dependency.new("fastlane", Gem::Requirement.new([">= #{Fastlane::VERSION}"]), :development)
)
expect(gemspec.development_dependencies).to eq([])
end
end

Expand Down

0 comments on commit 7bd6c48

Please sign in to comment.