diff --git a/CHANGELOG.md b/CHANGELOG.md index 09b5905d..51557473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Adopted Ruby 2.4+ as the minimum Ruby version in generated extensions - Added `bin/console`, `bin/rails` and `bin/setup` to generated extensions +- Added some Bundler gemspec defaults to generated extensions ### Changed diff --git a/lib/solidus_dev_support/templates/extension/extension.gemspec.erb b/lib/solidus_dev_support/templates/extension/extension.gemspec.erb index 3f52e445..ac44c36a 100644 --- a/lib/solidus_dev_support/templates/extension/extension.gemspec.erb +++ b/lib/solidus_dev_support/templates/extension/extension.gemspec.erb @@ -4,20 +4,31 @@ $:.push File.expand_path('lib', __dir__) require '<%= file_name %>/version' Gem::Specification.new do |s| - s.name = '<%= file_name %>' - s.version = <%= class_name %>::VERSION - s.summary = 'TODO' + s.name = '<%= file_name %>' + s.version = <%= class_name %>::VERSION + s.summary = 'TODO' s.description = 'TODO' - s.license = 'BSD-3-Clause' + s.license = 'BSD-3-Clause' - # s.author = 'You' - # s.email = 'you@example.com' - # s.homepage = 'http://www.example.com' + # s.author = 'You' + # s.email = 'you@example.com' + # s.homepage = 'http://www.example.com' + + if s.respond_to?(:metadata) + s.metadata["homepage_uri"] = s.homepage if s.homepage + s.metadata["source_code_uri"] = s.homepage if s.homepage + s.metadata["changelog_uri"] = 'TODO' + end s.required_ruby_version = '~> 2.4' - s.files = Dir["{app,config,db,lib}/**/*", 'LICENSE', 'Rakefile', 'README.md'] + s.files = Dir.chdir(File.expand_path(__dir__)) do + `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + end s.test_files = Dir['spec/**/*'] + s.bindir = "exe" + s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) } + s.require_paths = ["lib"] s.add_dependency 'solidus_core', ['>= 2.0.0', '< 3'] s.add_dependency 'solidus_support', '~> 0.4.0' diff --git a/spec/features/create_extension_spec.rb b/spec/features/create_extension_spec.rb index 8e9d8d9b..cc2233fb 100644 --- a/spec/features/create_extension_spec.rb +++ b/spec/features/create_extension_spec.rb @@ -13,7 +13,8 @@ let(:gemspec_name) { "solidus_#{extension_name}.gemspec" } let(:tmp_path) { Pathname.new(ext_root).join('spec', 'tmp') } let(:install_path) { tmp_path.join("solidus_#{extension_name}") } - let(:command_failed) { Class.new(StandardError) } + + class CommandFailed < StandardError; end around do |example| rm_rf(tmp_path) @@ -48,11 +49,11 @@ def check_bundle_install cd(install_path) do sh('bundle install') end - }.to raise_error(command_failed, /invalid gemspec/) + }.to raise_error(CommandFailed, /invalid gemspec/) # Update gemspec with the required fields gemspec_path = install_path.join(gemspec_name) - new_content = gemspec_path.read.gsub(/\n.*s.author[^\n]+/, "\n s.author = 'someone'").gsub(/TODO/, 'something') + new_content = gemspec_path.read.gsub(/\n.*s.author[^\n]+/, "\n s.author = 'someone'").gsub(/TODO/, 'https://example.com') gemspec_path.write(new_content) cd(install_path) do @@ -84,7 +85,7 @@ def check_run_specs def sh(*args) command = args.size == 1 ? args.first : args.shelljoin stdout, stderr, status = Bundler.with_clean_env { Open3.capture3(command) } - status.success? ? stdout : raise(command_failed, "command failed: #{command}\n#{stderr}\n#{stdout}") + status.success? ? stdout : raise(CommandFailed, "command failed: #{command}\n#{stderr}\n#{stdout}") end it 'checks the create extension process' do