Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Update Extension Generator for Spree 4.3 (#11272)

Damian Legawiec282b2264fae3
diff --git a/cmd/lib/spree_cmd/extension.rb b/cmd/lib/spree_cmd/extension.rb
index 2efeeaea6d..9aa035a196 100644
--- a/cmd/lib/spree_cmd/extension.rb
+++ b/cmd/lib/spree_cmd/extension.rb
@@ -16,7 +16,6 @@ module SpreeCmd
directory 'lib', "#{file_name}/lib"
directory 'bin', "#{file_name}/bin"
directory 'spec', "#{file_name}/spec"
- directory 'gemfiles', "#{file_name}/gemfiles"
chmod "#{file_name}/bin/rails", 0o755
@@ -30,7 +29,6 @@ module SpreeCmd
template 'config/locales/en.yml', "#{file_name}/config/locales/en.yml"
template 'rspec', "#{file_name}/.rspec"
template 'travis.yml', "#{file_name}/.travis.yml"
- template 'Appraisals', "#{file_name}/Appraisals"
template '.rubocop.yml', "#{file_name}/.rubocop.yml"
end
@@ -38,7 +36,11 @@ module SpreeCmd
say %{
#{'*' * 80}
- Your extension has been generated with a gemspec dependency on Spree #{spree_version}.
+ Congrats, Your extension has been generated :rocket:
+
+ Next steps:
+ * Read Spree Developer Documentation at: https://dev-docs.spreecommerce.org/customization
+ * Start your extension at: https://dev-docs.spreecommerce.org/extensions/extensions
#{'*' * 80}
}
@@ -49,10 +51,6 @@ module SpreeCmd
Thor::Util.camel_case file_name
end
- def spree_version
- Gem.loaded_specs['spree_cmd'].version.to_s
- end
-
def use_prefix(prefix)
@file_name = prefix + Thor::Util.snake_case(file_name) unless file_name =~ /^#{prefix}/
end
diff --git a/cmd/lib/spree_cmd/templates/extension/Appraisals b/cmd/lib/spree_cmd/templates/extension/Appraisals
deleted file mode 100644
index 155af568d6..0000000000
--- a/cmd/lib/spree_cmd/templates/extension/Appraisals
+++ /dev/null
@@ -1,9 +0,0 @@
-appraise 'spree-4' do
- gem 'spree', '~> 4.2'
- gem 'rails-controller-testing'
-end
-
-appraise 'spree-master' do
- gem 'spree', github: 'spree/spree', branch: 'master'
- gem 'rails-controller-testing'
-end
diff --git a/cmd/lib/spree_cmd/templates/extension/Gemfile b/cmd/lib/spree_cmd/templates/extension/Gemfile
index 60179f21be..f0dfe1903f 100644
--- a/cmd/lib/spree_cmd/templates/extension/Gemfile
+++ b/cmd/lib/spree_cmd/templates/extension/Gemfile
@@ -5,7 +5,8 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end
-gem 'spree', github: 'spree/spree', branch: 'master'
+gem 'spree', github: 'spree/spree', branch: 'main'
+# gem 'spree_backend', github: 'spree/spree', branch: 'main'
gem 'rails-controller-testing'
gemspec
diff --git a/cmd/lib/spree_cmd/templates/extension/README.md b/cmd/lib/spree_cmd/templates/extension/README.md
index 09cafc0c1f..8b01710dfa 100644
--- a/cmd/lib/spree_cmd/templates/extension/README.md
+++ b/cmd/lib/spree_cmd/templates/extension/README.md
@@ -31,7 +31,7 @@ Introduction goes here.
First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
```shell
-bundle
+bundle update
bundle exec rake
```
diff --git a/cmd/lib/spree_cmd/templates/extension/app/models/%file_name%/configuration.rb.tt b/cmd/lib/spree_cmd/templates/extension/app/models/%file_name%/configuration.rb.tt
index 214f716596..4e13f5c19a 100644
--- a/cmd/lib/spree_cmd/templates/extension/app/models/%file_name%/configuration.rb.tt
+++ b/cmd/lib/spree_cmd/templates/extension/app/models/%file_name%/configuration.rb.tt
@@ -4,7 +4,7 @@ module <%= class_name %>
# Some example preferences are shown below, for more information visit:
# https://dev-docs.spreecommerce.org/internals/preferences
- # preference :visible, :boolean
+ preference :enabled, :boolean, default: true
# preference :dark_chocolate, :boolean, default: true
# preference :color, :string, default: 'Red'
# preference :favorite_number, :integer
diff --git a/cmd/lib/spree_cmd/templates/extension/app/views/.gitkeep b/cmd/lib/spree_cmd/templates/extension/app/serializers/.gitkeep
similarity index 100%
rename from cmd/lib/spree_cmd/templates/extension/app/views/.gitkeep
rename to cmd/lib/spree_cmd/templates/extension/app/serializers/.gitkeep
diff --git a/cmd/lib/spree_cmd/templates/extension/extension.gemspec b/cmd/lib/spree_cmd/templates/extension/extension.gemspec
index 39e4b89e34..ae8010260f 100644
--- a/cmd/lib/spree_cmd/templates/extension/extension.gemspec
+++ b/cmd/lib/spree_cmd/templates/extension/extension.gemspec
@@ -7,7 +7,7 @@ require '<%= file_name %>/version'
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = '<%= file_name %>'
- s.version = '<%= class_name %>.version'
+ s.version = <%= class_name %>.version
s.summary = 'Add extension summary here'
s.description = 'Add (optional) extension description here'
s.required_ruby_version = '>= 2.5'
@@ -21,9 +21,8 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency 'spree', '>= <%= Spree.version %>'
- # s.add_dependency 'spree_backend' # uncomment to include Admin Panel changes
- # s.add_dependency 'spree_frontend' # uncomment to include Storefront changes
+ s.add_dependency 'spree', '>= <%= Gem.loaded_specs['spree_cmd'].version %>'
+ # s.add_dependency 'spree_backend' # uncomment to include Admin Panel changes
s.add_dependency 'spree_extension'
s.add_development_dependency 'spree_dev_tools'
diff --git a/cmd/lib/spree_cmd/templates/extension/gemfiles/spree_4.gemfile b/cmd/lib/spree_cmd/templates/extension/gemfiles/spree_4.gemfile
deleted file mode 100644
index ca5873e08e..0000000000
--- a/cmd/lib/spree_cmd/templates/extension/gemfiles/spree_4.gemfile
+++ /dev/null
@@ -1,8 +0,0 @@
-# This file was generated by Appraisal
-
-source "https://rubygems.org"
-
-gem "rails-controller-testing"
-gem "spree", "~> 4.3"
-
-gemspec path: "../"
diff --git a/cmd/lib/spree_cmd/templates/extension/gemfiles/spree_master.gemfile b/cmd/lib/spree_cmd/templates/extension/gemfiles/spree_master.gemfile
deleted file mode 100644
index c3f8398e5d..0000000000
--- a/cmd/lib/spree_cmd/templates/extension/gemfiles/spree_master.gemfile
+++ /dev/null
@@ -1,8 +0,0 @@
-# This file was generated by Appraisal
-
-source "https://rubygems.org"
-
-gem "rails-controller-testing"
-gem "spree", github: "spree/spree", branch: "master"
-
-gemspec path: "../"
diff --git a/cmd/lib/spree_cmd/templates/extension/gitignore b/cmd/lib/spree_cmd/templates/extension/gitignore
index 0212033d39..59090efdd7 100644
--- a/cmd/lib/spree_cmd/templates/extension/gitignore
+++ b/cmd/lib/spree_cmd/templates/extension/gitignore
@@ -19,5 +19,5 @@ spec/dummy
public/spree
.ruby-version
.ruby-gemset
-gemfiles/*.gemfile.lock
*.gem
+*/*.gem
diff --git a/cmd/lib/spree_cmd/templates/extension/travis.yml b/cmd/lib/spree_cmd/templates/extension/travis.yml
index f90906b071..48c74ab5f6 100644
--- a/cmd/lib/spree_cmd/templates/extension/travis.yml
+++ b/cmd/lib/spree_cmd/templates/extension/travis.yml
@@ -22,14 +22,6 @@ env:
- DB=mysql
- DB=postgres
-gemfile:
- - gemfiles/spree_4.gemfile
- - gemfiles/spree_master.gemfile
-
-jobs:
- allow_failures:
- - gemfile: gemfiles/spree_master.gemfile
-
before_install:
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
@@ -38,8 +30,8 @@ before_script:
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
- curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
- unzip chromedriver_linux64.zip -d ~/bin
- - nvm install 14
+ - nvm install 16
script:
- bundle exec rake test_app
- - bundle exec rake spec
+ - bundle exec rspec
diff --git a/cmd/spree_cmd.gemspec b/cmd/spree_cmd.gemspec
index deb6eacb6f..54462e4d28 100644
--- a/cmd/spree_cmd.gemspec
+++ b/cmd/spree_cmd.gemspec
@@ -5,10 +5,10 @@ require_relative '../core/lib/spree/core/version.rb'
Gem::Specification.new do |s|
s.name = "spree_cmd"
s.version = Spree.version
- s.authors = ['Chris Mar']
- s.email = ['[email protected]']
- s.summary = 'Spree Commerce command line utility'
- s.description = 'tools to create new Spree stores and extensions'
+ s.authors = ['Chris Mar', 'Spark Solutions']
+ s.email = ['[email protected]']
+ s.summary = 'Spree Commerce CLI'
+ s.description = 'Spree Commerce command line interface'
s.homepage = 'https://spreecommerce.org'
s.license = 'BSD-3-Clause'