solidus_dev_support 0.4.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.gem_release.yml +5 -0
  3. data/.gitignore +2 -1
  4. data/.rubocop-https---relaxed-ruby-style-rubocop-yml +3 -24
  5. data/CHANGELOG.md +75 -6
  6. data/Gemfile +4 -0
  7. data/README.md +69 -9
  8. data/lib/solidus_dev_support/extension.rb +54 -9
  9. data/lib/solidus_dev_support/rake_tasks.rb +15 -0
  10. data/lib/solidus_dev_support/rspec/rails_helper.rb +3 -1
  11. data/lib/solidus_dev_support/templates/extension/Gemfile +7 -0
  12. data/lib/solidus_dev_support/templates/extension/LICENSE +1 -1
  13. data/lib/solidus_dev_support/templates/extension/README.md +25 -2
  14. data/lib/solidus_dev_support/templates/extension/Rakefile +1 -1
  15. data/lib/solidus_dev_support/templates/extension/bin/r.tt +13 -0
  16. data/lib/solidus_dev_support/templates/extension/bin/rake +7 -0
  17. data/lib/solidus_dev_support/templates/extension/bin/sandbox.tt +83 -0
  18. data/lib/solidus_dev_support/templates/extension/bin/sandbox_rails +18 -0
  19. data/lib/solidus_dev_support/templates/extension/bin/setup +1 -1
  20. data/lib/solidus_dev_support/templates/extension/extension.gemspec.tt +36 -0
  21. data/lib/solidus_dev_support/templates/extension/gem_release.yml.tt +1 -1
  22. data/lib/solidus_dev_support/templates/extension/gitignore +1 -0
  23. data/lib/solidus_dev_support/templates/extension/lib/%file_name%/engine.rb.tt +2 -1
  24. data/lib/solidus_dev_support/templates/extension/lib/%file_name%/version.rb.tt +1 -1
  25. data/lib/solidus_dev_support/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt +8 -8
  26. data/lib/solidus_dev_support/templates/extension/rspec +2 -1
  27. data/lib/solidus_dev_support/templates/extension/rubocop.yml +5 -0
  28. data/lib/solidus_dev_support/version.rb +1 -1
  29. metadata +8 -4
  30. data/lib/solidus_dev_support/templates/extension/bin/rails +0 -15
  31. data/lib/solidus_dev_support/templates/extension/extension.gemspec.erb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f4ada48e2b717475858e999ee0213884dc6c7e1278c0aff52e2354fbff9dfd4
4
- data.tar.gz: a5bc55ea29042ba0b93ad730e0535db489ce2b2a2a1c02800074e6f86590c440
3
+ metadata.gz: ba24e6dd743046ef4acfa3d5a9f1fe1308f4d2ff5175ca6ace8b537529e4309d
4
+ data.tar.gz: 0716f96e176e807aa910408e62b930da5719cd7bc2703b03a1a764230f90b76c
5
5
  SHA512:
6
- metadata.gz: 8e6c316d2fc4adb87df988951edf3566f1badb89944ed345becc1e509cd369f7c875bd7fc8d2f03038a1459c93000cf27f661103d2a8c8b158e4fbe57f475c41
7
- data.tar.gz: 7f26dab435fd9cc08982bae324a162fe14e2bcb388d0998cf29bbc1e27e68f749e688fe49065186a0c4169a4a8a0e36d5aa51c546d465f25c1b3ad490b3124c8
6
+ metadata.gz: 1b9bf1dc55fb744fe1f0aa39ef72a01bb6abc3429530d1b11122afdf71b8ff135e1be280465077f68590eb84c505588cb258602e8ce36ede76511a5008dc075d
7
+ data.tar.gz: f73be0985dc2937ffd5380019834b578533f31e014c6d22296c0b52b04e4bee12d2b3c8747ddb6114115e8f1c03afe3880bb6ec4befbe63d01da2aa42a337963
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_dev_support/version.rb'
4
+ message: Bump SolidusDevSupport to %{version}
5
+ tag: true
data/.gitignore CHANGED
@@ -7,7 +7,8 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  /vendor/bundle/
10
- Gemfile.lock
10
+ /Gemfile.lock
11
+ /Gemfile-local*
11
12
 
12
13
  # rspec failure tracking
13
14
  .rspec_status
@@ -1,5 +1,5 @@
1
1
  # Relaxed.Ruby.Style
2
- ## Version 2.4
2
+ ## Version 2.5
3
3
 
4
4
  Style/Alias:
5
5
  Enabled: false
@@ -145,30 +145,9 @@ Lint/AssignmentInCondition:
145
145
  Enabled: false
146
146
  StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
147
147
 
148
- Metrics/AbcSize:
148
+ Layout/LineLength:
149
149
  Enabled: false
150
150
 
151
- Metrics/BlockNesting:
152
- Enabled: false
153
-
154
- Metrics/ClassLength:
155
- Enabled: false
156
-
157
- Metrics/ModuleLength:
158
- Enabled: false
159
-
160
- Metrics/CyclomaticComplexity:
161
- Enabled: false
162
-
163
- Metrics/LineLength:
164
- Enabled: false
165
-
166
- Metrics/MethodLength:
167
- Enabled: false
168
-
169
- Metrics/ParameterLists:
170
- Enabled: false
171
-
172
- Metrics/PerceivedComplexity:
151
+ Metrics:
173
152
  Enabled: false
174
153
 
@@ -7,10 +7,74 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Made Git ignore `sandbox` in generated extensions
13
+ - Added support for specifying `SOLIDUS_BRANCH` in the sandbox
14
+
15
+ ### Changed
16
+
17
+ - Split `bin/rails` into `bin/r` and `bin/sandbox_rails`
18
+
19
+ ### Fixed
20
+
21
+ - Fixed the sandbox Gemfile not including Solidus
22
+
23
+ ## [1.0.1] - 2020-02-17
24
+
25
+ ### Fixed
26
+
27
+ - Fixed missing factory definitions when using `modify` on Solidus factories
28
+
29
+ ## [1.0.0] - 2020-02-07
30
+
31
+ ### Added
32
+
33
+ - Added a binstub for `rake` to the extension generator
34
+ - Added the ability for the generator to reuse existing data for the gemspec
35
+
36
+ ### Fixed
37
+
38
+ - Fixed Dependabot throwing an error because of `eval_gemfile` in the Gemfile
39
+
40
+ ## [0.6.0] - 2020-01-20
41
+
42
+ ### Added
43
+
44
+ - Added support for a local Gemfile for local development dependencies (e.g. 'pry-debug')
45
+ - Added a `bin/sandbox` script to all extension for local development with `bin/rails` support.
46
+
47
+ ### Changed
48
+
49
+ - The default rake task no longer re-generates the `test_app` each time it runs.
50
+ In order to get that behavior back simply call clobber before launching it:
51
+ `bin/rake clobber default`
52
+
53
+ ### Fixed
54
+
55
+ - Fixed generated extensions isolating the wrong namespace
56
+
57
+ ## [0.5.0] - 2020-01-16
58
+
59
+ ### Added
60
+
61
+ - Added `--require spec_helper` to the generated `.rspec`
62
+
63
+ ### Fixed
64
+
65
+ - Replaced "Spree" with "Solidus" in the license of generated extensions
66
+
67
+ ### Changed
68
+
69
+ - Updated gem-release to use tags instead of branches for new releases
70
+
71
+ ## [0.4.1] - 2020-01-15
72
+
10
73
  ### Fixed
11
74
 
12
75
  - Fixed the generated RuboCop config inheriting from this gem's dev-only config
13
76
  - Fixed the generated extension not requiring the `version` file
77
+ - Fixed the generator not properly marking `bin/` files as executable
14
78
 
15
79
  ## [0.4.0] - 2020-01-10
16
80
 
@@ -87,9 +151,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
87
151
 
88
152
  Initial release.
89
153
 
90
- [Unreleased]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.4.0...HEAD
91
- [0.4.0]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.3.0...v0.4.0
92
- [0.3.0]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.2.0...v0.3.0
93
- [0.2.0]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.1.1...v0.2.0
94
- [0.1.1]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.1.0...v0.1.1
95
- [0.1.0]: https://github.com/solidusio-contrib/solidus_dev_support/releases/tag/v0.1.0
154
+ [Unreleased]: https://github.com/solidusio/solidus_dev_support/compare/v1.0.1...HEAD
155
+ [1.0.1]: https://github.com/solidusio/solidus_dev_support/compare/v1.0.0...v1.0.1
156
+ [1.0.0]: https://github.com/solidusio/solidus_dev_support/compare/v0.6.0...v1.0.0
157
+ [0.6.0]: https://github.com/solidusio/solidus_dev_support/compare/v0.5.0...v0.6.0
158
+ [0.5.0]: https://github.com/solidusio/solidus_dev_support/compare/v0.4.1...v0.5.0
159
+ [0.4.1]: https://github.com/solidusio/solidus_dev_support/compare/v0.4.0...v0.4.1
160
+ [0.4.0]: https://github.com/solidusio/solidus_dev_support/compare/v0.3.0...v0.4.0
161
+ [0.3.0]: https://github.com/solidusio/solidus_dev_support/compare/v0.2.0...v0.3.0
162
+ [0.2.0]: https://github.com/solidusio/solidus_dev_support/compare/v0.1.1...v0.2.0
163
+ [0.1.1]: https://github.com/solidusio/solidus_dev_support/compare/v0.1.0...v0.1.1
164
+ [0.1.0]: https://github.com/solidusio/solidus_dev_support/releases/tag/v0.1.0
data/Gemfile CHANGED
@@ -21,3 +21,7 @@ group :test do
21
21
  gem 'pg'
22
22
  gem 'sqlite3'
23
23
  end
24
+
25
+ # Use a local Gemfile to include development dependencies that might not be
26
+ # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
27
+ eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # solidus_dev_support
2
2
 
3
- [![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_dev_support.svg?style=svg)](https://circleci.com/gh/solidusio-contrib/solidus_dev_support)
3
+ [![CircleCI](https://circleci.com/gh/solidusio/solidus_dev_support.svg?style=svg)](https://circleci.com/gh/solidusio/solidus_dev_support)
4
4
 
5
5
  This gem contains common development functionality for Solidus extensions.
6
6
 
@@ -34,6 +34,61 @@ $ solidus extension my_awesome_extension
34
34
  This will generate the basic extension structure, already configured to use all the shiny helpers
35
35
  in solidus_dev_support.
36
36
 
37
+ #### Updating existing extensions
38
+
39
+ If you have an existing extension and want to update it to use the latest standards from this gem,
40
+ you can run the following in the extension's directory:
41
+
42
+ ```console
43
+ $ solidus extension .
44
+ ```
45
+
46
+ In case of conflicting files, you will be prompted for an action. You can overwrite the files with
47
+ the new version, keep the current version or view the diff and only apply the adjustments that make
48
+ sense to you.
49
+
50
+ ### Sandbox app
51
+
52
+ When developing an extension you will surely need to try it out within a Rails app with Solidus
53
+ installed. Using solidus_dev_support your extension will have a `bin/sandbox_rails` executable that will
54
+ operate on a _sandbox_ app (creating it if necessary).
55
+
56
+ The path for the sandbox app is `./sandbox` and `bin/sandbox_rails` will forward any Rails command
57
+ to `sandbox/bin/rails`.
58
+
59
+ Example:
60
+
61
+ ```bash
62
+ $ bin/sandbox_rails server
63
+ => Booting Puma
64
+ => Rails 6.0.2.1 application starting in development
65
+ * Listening on tcp://127.0.0.1:3000
66
+ Use Ctrl-C to stop
67
+ ```
68
+
69
+ #### Rebuilding the sandbox app
70
+
71
+ To rebuild the sandbox app just remove the `./sandbox` folder or run `bin/sandbox`.
72
+ You can control the DB adapter and Solidus version used with the sandbox by providing
73
+ the `DB` and `SOLIDUS_BRANCH` env variables.
74
+
75
+ ```bash
76
+ DB=[postgres|mysql|sqlite] SOLIDUS_BRANCH=<BRANCH-NAME> bin/sandbox
77
+ ```
78
+
79
+ By default we use sqlite3 and the master branch.
80
+
81
+ ### Rails generators
82
+
83
+ Your extension will have a `bin/r` executable that you can use for generating models, migrations
84
+ etc. It's the same as the default `rails` command in Rails engines.
85
+
86
+ Example:
87
+
88
+ ```bash
89
+ $ bin/r generate migration AddStoreIdToProducts
90
+ ```
91
+
37
92
  ### RSpec helpers
38
93
 
39
94
  This gem provides some useful helpers for RSpec to setup an extension's test environment easily.
@@ -123,15 +178,16 @@ releases for your gem.
123
178
  For instance, you can run the following to release a new minor version:
124
179
 
125
180
  ```console
126
- $ gem bump --version minor --tag --release
181
+ $ gem bump -v minor -r
127
182
  ```
128
183
 
129
184
  The above command will:
130
185
 
131
- * bump the gem version to the next minor;
132
- * commit the change and push it to `upstream/master`;
186
+ * bump the gem version to the next minor (you can also use `patch`, `major` or a specific version
187
+ number);
188
+ * commit the change and push it to `origin/master`;
133
189
  * create a Git tag;
134
- * push the tag to the `upstream` remote;
190
+ * push the tag to the `origin` remote;
135
191
  * release the new version on RubyGems.
136
192
 
137
193
  You can refer to
@@ -146,7 +202,7 @@ To install extension-related Rake tasks, add this to your `Rakefile`:
146
202
  require 'solidus_dev_support/rake_tasks'
147
203
  SolidusDevSupport::RakeTasks.install
148
204
 
149
- task default: %w[extension:test_app extension:specs]
205
+ task default: 'extension:specs'
150
206
  ```
151
207
 
152
208
  (If your extension used the legacy extension Rakefile, then you should completely replace its
@@ -157,7 +213,11 @@ This will provide the following tasks:
157
213
  - `extension:test_app`, which generates a dummy app for your extension
158
214
  - `extension:specs` (default), which runs the specs for your extension
159
215
 
160
- It also allows you to run `rake` to, respectively, generate a test app and run all tests.
216
+ If your extension requires the `test_app` to be always recreated you can do so by running:
217
+
218
+ ```rb
219
+ bin/rake extension:test_app extension:specs
220
+ ```
161
221
 
162
222
  ## Development
163
223
 
@@ -165,8 +225,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
165
225
  the tests. You can also run `bin/console` for an interactive prompt that will allow you to
166
226
  experiment.
167
227
 
168
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new
169
- version, update the version number in `version.rb`, and then run `bundle exec rake release`, which
228
+ To install this gem onto your local machine, run `bin/rake install`. To release a new
229
+ version, update the version number in `version.rb`, and then run `bin/rake release`, which
170
230
  will create a git tag for the version, push git commits and tags, and push the `.gem` file to
171
231
  [rubygems.org](https://rubygems.org).
172
232
 
@@ -22,16 +22,11 @@ module SolidusDevSupport
22
22
  directory '.circleci', "#{path}/.circleci"
23
23
  directory '.github', "#{path}/.github"
24
24
 
25
- %w[
26
- bin/console
27
- bin/rails
28
- bin/setup
29
- ].each do |bin|
30
- template bin, "#{path}/#{bin}"
31
- make_executable "#{path}/#{bin}"
25
+ Dir["#{path}/bin/*"].each do |bin|
26
+ make_executable bin
32
27
  end
33
28
 
34
- template 'extension.gemspec.erb', "#{path}/#{file_name}.gemspec"
29
+ template 'extension.gemspec', "#{path}/#{file_name}.gemspec"
35
30
  template 'Gemfile', "#{path}/Gemfile"
36
31
  template 'gitignore', "#{path}/.gitignore"
37
32
  template 'gem_release.yml.tt', "#{path}/.gem_release.yml"
@@ -56,6 +51,56 @@ module SolidusDevSupport
56
51
 
57
52
  @root = File.dirname(path)
58
53
  @path = File.join(@root, @file_name)
54
+
55
+ @gemspec = existing_gemspec || default_gemspec
56
+ end
57
+
58
+ def gemspec_path
59
+ @gemspec_path ||= File.join(path, "#{file_name}.gemspec")
60
+ end
61
+
62
+ def default_gemspec
63
+ @default_gemspec ||= Gem::Specification.new(@file_name, '0.0.1') do |gem|
64
+ gem.author = git('config user.name', 'TODO: Write your name')
65
+ gem.description = 'TODO: Write a longer description or delete this line.'
66
+ gem.email = git('config user.email', 'TODO: Write your email address')
67
+ gem.homepage = default_homepage
68
+ gem.license = 'BSD-3-Clause'
69
+ gem.metadata['changelog_uri'] = default_homepage + '/releases'
70
+ gem.summary = 'TODO: Write a short summary, because RubyGems requires one.'
71
+ end
72
+ end
73
+
74
+ def existing_gemspec
75
+ return unless File.exist?(gemspec_path)
76
+
77
+ @existing_gemspec ||= Gem::Specification.load(gemspec_path).tap do |spec|
78
+ spec.author ||= default_gemspec.author
79
+ spec.email ||= default_gemspec.email
80
+ spec.homepage ||= default_gemspec.homepage
81
+ spec.license ||= default_gemspec.license
82
+ spec.metadata['changelog_uri'] ||= default_gemspec.metadata[:changelog_uri]
83
+ spec.summary ||= default_gemspec.summary
84
+ end
85
+ end
86
+
87
+ def default_homepage
88
+ @default_homepage ||= git(
89
+ 'remote get-url origin',
90
+ "git@github.com:#{github_user}/#{file_name}.git"
91
+ ).sub(
92
+ %r{^.*github\.com.([^/]+)/([^/\.]+).*$},
93
+ 'https://github.com/\1/\2'
94
+ )
95
+ end
96
+
97
+ def github_user
98
+ @github_user ||= git('config github.user', '[USERNAME]')
99
+ end
100
+
101
+ def git(command, default)
102
+ result = `git #{command} 2> /dev/null`.strip
103
+ result.empty? ? default : result
59
104
  end
60
105
 
61
106
  def make_executable(path)
@@ -64,7 +109,7 @@ module SolidusDevSupport
64
109
  path.chmod(executable)
65
110
  end
66
111
 
67
- attr_reader :root, :path, :file_name, :class_name
112
+ attr_reader :root, :path, :file_name, :class_name, :gemspec
68
113
  end
69
114
 
70
115
  def self.source_root
@@ -21,6 +21,7 @@ module SolidusDevSupport
21
21
 
22
22
  def install
23
23
  install_test_app_task
24
+ install_dev_app_task
24
25
  install_rspec_task
25
26
  end
26
27
 
@@ -34,10 +35,24 @@ module SolidusDevSupport
34
35
  ::CLOBBER.include test_app_path
35
36
 
36
37
  namespace :extension do
38
+ # We need to go back to the gem root since the upstream
39
+ # extension:test_app changes the working directory to be the dummy app.
37
40
  task :test_app do
38
41
  Rake::Task['extension:test_app'].invoke
39
42
  cd root
40
43
  end
44
+
45
+ directory ENV['DUMMY_PATH'] do
46
+ Rake::Task['extension:test_app'].invoke
47
+ end
48
+ end
49
+ end
50
+
51
+ def install_dev_app_task
52
+ desc "Creates a sandbox application for simulating the Extension code in a deployed Rails app"
53
+ task :sandbox do
54
+ warn "DEPRECATED TASK: This task is here just for parity with solidus, please use bin/sandbox directly."
55
+ exec("bin/sandbox", gemspec.name)
41
56
  end
42
57
  end
43
58
 
@@ -12,7 +12,7 @@ require 'solidus_dev_support'
12
12
 
13
13
  require 'rspec/rails'
14
14
  require 'database_cleaner'
15
- require 'factory_bot_rails'
15
+ require 'factory_bot'
16
16
  require 'ffaker'
17
17
 
18
18
  require 'spree/testing_support/authorization_helpers'
@@ -22,6 +22,8 @@ require 'spree/testing_support/preferences'
22
22
  require 'spree/testing_support/controller_requests'
23
23
  require 'solidus_dev_support/testing_support/preferences'
24
24
 
25
+ FactoryBot.find_definitions
26
+
25
27
  RSpec.configure do |config|
26
28
  config.infer_spec_type_from_file_location!
27
29
 
@@ -24,3 +24,10 @@ else
24
24
  end
25
25
 
26
26
  gemspec
27
+
28
+ # Use a local Gemfile to include development dependencies that might not be
29
+ # relevant for the project or for other contributors, e.g. pry-byebug.
30
+ #
31
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
32
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
33
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
@@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
9
9
  * Redistributions in binary form must reproduce the above copyright notice,
10
10
  this list of conditions and the following disclaimer in the documentation
11
11
  and/or other materials provided with the distribution.
12
- * Neither the name Spree nor the names of its contributors may be used to
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
13
  endorse or promote products derived from this software without specific
14
14
  prior written permission.
15
15
 
@@ -22,11 +22,17 @@ bundle exec rails g <%= file_name %>:install
22
22
  Testing
23
23
  -------
24
24
 
25
- 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, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
25
+ First bundle your dependencies, then run `bin/rake`. `bin/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 `bin/rake extension:test_app`.
26
26
 
27
27
  ```shell
28
28
  bundle
29
- bundle exec rake
29
+ bin/rake
30
+ ```
31
+
32
+ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
33
+
34
+ ```shell
35
+ bundle exec rubocop
30
36
  ```
31
37
 
32
38
  When testing your application's integration with this extension you may use its factories.
@@ -36,6 +42,23 @@ Simply add this require statement to your spec_helper:
36
42
  require '<%= file_name %>/factories'
37
43
  ```
38
44
 
45
+ Sandbox app
46
+ -----------
47
+
48
+ To run this extension in a sandboxed Solidus application you can run `bin/sandbox`
49
+ The path for the sandbox app is `./sandbox` and `bin/rails` will forward any Rails command
50
+ to `sandbox/bin/rails`.
51
+
52
+ Example:
53
+
54
+ ```shell
55
+ $ bin/rails server
56
+ => Booting Puma
57
+ => Rails 6.0.2.1 application starting in development
58
+ * Listening on tcp://127.0.0.1:3000
59
+ Use Ctrl-C to stop
60
+ ```
61
+
39
62
  Releasing
40
63
  ---------
41
64
 
@@ -3,4 +3,4 @@
3
3
  require 'solidus_dev_support/rake_tasks'
4
4
  SolidusDevSupport::RakeTasks.install
5
5
 
6
- task default: %w[extension:test_app extension:specs]
6
+ task default: 'extension:specs'
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/<%=file_name%>/engine', __dir__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "rubygems"
5
+ require "bundler/setup"
6
+
7
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ case "$DB" in
6
+ postgres|postgresql)
7
+ RAILSDB="postgresql"
8
+ ;;
9
+ mysql)
10
+ RAILSDB="mysql"
11
+ ;;
12
+ sqlite|'')
13
+ RAILSDB="sqlite3"
14
+ ;;
15
+ *)
16
+ echo "Invalid DB specified: $DB"
17
+ exit 1
18
+ ;;
19
+ esac
20
+
21
+ if [ ! -z $SOLIDUS_BRANCH ]
22
+ then
23
+ BRANCH=$SOLIDUS_BRANCH
24
+ else
25
+ BRANCH="master"
26
+ fi
27
+
28
+ extension_name="<%= file_name %>"
29
+
30
+ # Stay away from the bundler env of the containing extension.
31
+ function unbundled {
32
+ ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
33
+ }
34
+
35
+ rm -rf ./sandbox
36
+ unbundled bundle exec rails new sandbox --database="$RAILSDB" \
37
+ --skip-bundle \
38
+ --skip-git \
39
+ --skip-keeps \
40
+ --skip-rc \
41
+ --skip-spring \
42
+ --skip-test \
43
+ --skip-javascript
44
+
45
+ if [ ! -d "sandbox" ]; then
46
+ echo 'sandbox rails application failed'
47
+ exit 1
48
+ fi
49
+
50
+ cd ./sandbox
51
+ cat <<RUBY >> Gemfile
52
+ gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
53
+ gem 'solidus_auth_devise', '>= 2.1.0'
54
+ gem 'rails-i18n'
55
+ gem 'solidus_i18n'
56
+
57
+ gem '$extension_name', path: '..'
58
+
59
+ group :test, :development do
60
+ platforms :mri do
61
+ gem 'pry-byebug'
62
+ end
63
+ end
64
+ RUBY
65
+
66
+ unbundled bundle install --gemfile Gemfile
67
+
68
+ unbundled bundle exec rake db:drop db:create
69
+
70
+ unbundled bundle exec rails generate spree:install \
71
+ --auto-accept \
72
+ --user_class=Spree::User \
73
+ --enforce_available_locales=true \
74
+ $@
75
+
76
+ unbundled bundle exec rails generate solidus:auth:install
77
+
78
+ echo
79
+ echo "🚀 Sandbox app successfully created for $extension_name!"
80
+ echo "🚀 Using $RAILSDB and Solidus $BRANCH"
81
+ echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
82
+ echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
83
+ echo "🚀 This app is intended for test purposes."
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ app_root = 'sandbox'
6
+
7
+ unless File.exist? "#{app_root}/bin/rails"
8
+ warn 'Creating the sandbox app...'
9
+ Dir.chdir "#{__dir__}/.." do
10
+ system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
11
+ warn 'Automatic creation of the sandbox app failed'
12
+ exit 1
13
+ end
14
+ end
15
+ end
16
+
17
+ Dir.chdir app_root
18
+ exec 'bin/rails', *ARGV
@@ -5,4 +5,4 @@ set -vx
5
5
 
6
6
  gem install bundler --conservative
7
7
  bundle update
8
- bundle exec rake extension:test_app
8
+ bin/rake clobber
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/<%= file_name %>/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = '<%= file_name %>'
7
+ spec.version = <%= class_name %>::VERSION
8
+ spec.authors = <%= gemspec.authors.inspect.gsub('"', "'") %>
9
+ spec.email = '<%= gemspec.email %>'
10
+
11
+ spec.summary = '<%= gemspec.summary %>'
12
+ spec.description = '<%= gemspec.description %>'
13
+ spec.homepage = '<%= gemspec.homepage %>'
14
+ spec.license = '<%= gemspec.license %>'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = '<%= gemspec.homepage %>'
18
+ spec.metadata['changelog_uri'] = '<%= gemspec.metadata["changelog_uri"] %>'
19
+
20
+ spec.required_ruby_version = Gem::Requirement.new('~> 2.4')
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
25
+
26
+ spec.files = files.grep_v(%r{^(test|spec|features)/})
27
+ spec.test_files = files.grep(%r{^(test|spec|features)/})
28
+ spec.bindir = "exe"
29
+ spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
33
+ spec.add_dependency 'solidus_support', '~> 0.4.0'
34
+
35
+ spec.add_development_dependency 'solidus_dev_support'
36
+ end
@@ -2,4 +2,4 @@ bump:
2
2
  recurse: false
3
3
  file: 'lib/<%=file_name%>/version.rb'
4
4
  message: Bump <%=class_name%> to %{version}
5
- branch: true
5
+ tag: true
@@ -14,3 +14,4 @@ pkg
14
14
  *.swp
15
15
  spec/dummy
16
16
  spec/examples.txt
17
+ /sandbox
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'spree/core'
4
+ require '<%= file_name %>'
4
5
 
5
6
  module <%= class_name %>
6
7
  class Engine < Rails::Engine
7
8
  include SolidusSupport::EngineExtensions::Decorators
8
9
 
9
- isolate_namespace Spree
10
+ isolate_namespace ::Spree
10
11
 
11
12
  engine_name '<%= file_name %>'
12
13
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module <%= class_name %>
4
- VERSION = '0.0.1'
4
+ VERSION = '<%= gemspec.version %>'
5
5
  end
@@ -6,25 +6,25 @@ module <%= class_name %>
6
6
  class_option :auto_run_migrations, type: :boolean, default: false
7
7
 
8
8
  def add_javascripts
9
- append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/<%= file_name %>\n"
10
- append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/<%= file_name %>\n"
9
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/<%= file_name %>\n" # rubocop:disable Metrics/LineLength
10
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/<%= file_name %>\n" # rubocop:disable Metrics/LineLength
11
11
  end
12
12
 
13
13
  def add_stylesheets
14
- inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/<%= file_name %>\n", before: %r{\*/}, verbose: true
15
- inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/<%= file_name %>\n", before: %r{\*/}, verbose: true
14
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/<%= file_name %>\n", before: %r{\*/}, verbose: true # rubocop:disable Metrics/LineLength
15
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/<%= file_name %>\n", before: %r{\*/}, verbose: true # rubocop:disable Metrics/LineLength
16
16
  end
17
17
 
18
18
  def add_migrations
19
- run 'bundle exec rake railties:install:migrations FROM=<%= file_name %>'
19
+ run 'bin/rails railties:install:migrations FROM=<%= file_name %>'
20
20
  end
21
21
 
22
22
  def run_migrations
23
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
23
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Metrics/LineLength
24
24
  if run_migrations
25
- run 'bundle exec rake db:migrate'
25
+ run 'bin/rails db:migrate'
26
26
  else
27
- puts 'Skipping rake db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
27
+ puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
28
28
  end
29
29
  end
30
30
  end
@@ -1 +1,2 @@
1
- --color
1
+ --color
2
+ --require spec_helper
@@ -1,2 +1,7 @@
1
1
  require:
2
2
  - solidus_dev_support/rubocop
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - sandbox/**/*
7
+ - spec/dummy/**/*
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusDevSupport
4
- VERSION = "0.4.1"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_dev_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Desantis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apparition
@@ -291,6 +291,7 @@ extensions: []
291
291
  extra_rdoc_files: []
292
292
  files:
293
293
  - ".circleci/config.yml"
294
+ - ".gem_release.yml"
294
295
  - ".github/PULL_REQUEST_TEMPLATE.md"
295
296
  - ".github/stale.yml"
296
297
  - ".gitignore"
@@ -329,11 +330,14 @@ files:
329
330
  - lib/solidus_dev_support/templates/extension/app/assets/stylesheets/spree/backend/%file_name%.css
330
331
  - lib/solidus_dev_support/templates/extension/app/assets/stylesheets/spree/frontend/%file_name%.css
331
332
  - lib/solidus_dev_support/templates/extension/bin/console.tt
332
- - lib/solidus_dev_support/templates/extension/bin/rails
333
+ - lib/solidus_dev_support/templates/extension/bin/r.tt
334
+ - lib/solidus_dev_support/templates/extension/bin/rake
335
+ - lib/solidus_dev_support/templates/extension/bin/sandbox.tt
336
+ - lib/solidus_dev_support/templates/extension/bin/sandbox_rails
333
337
  - lib/solidus_dev_support/templates/extension/bin/setup
334
338
  - lib/solidus_dev_support/templates/extension/config/locales/en.yml
335
339
  - lib/solidus_dev_support/templates/extension/config/routes.rb
336
- - lib/solidus_dev_support/templates/extension/extension.gemspec.erb
340
+ - lib/solidus_dev_support/templates/extension/extension.gemspec.tt
337
341
  - lib/solidus_dev_support/templates/extension/gem_release.yml.tt
338
342
  - lib/solidus_dev_support/templates/extension/gitignore
339
343
  - lib/solidus_dev_support/templates/extension/lib/%file_name%.rb.tt
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # frozen_string_literal: true
4
-
5
- app_root = 'spec/dummy'
6
-
7
- unless File.exist? "#{app_root}/bin/rails"
8
- system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
9
- warn "Automatic creation of the dummy app failed"
10
- exit 1
11
- end
12
- end
13
-
14
- Dir.chdir app_root
15
- exec 'bin/rails', *ARGV
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $:.push File.expand_path('lib', __dir__)
4
- require '<%= file_name %>/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.name = '<%= file_name %>'
8
- s.version = <%= class_name %>::VERSION
9
- s.summary = 'TODO'
10
- s.description = 'TODO'
11
- s.license = 'BSD-3-Clause'
12
-
13
- # s.author = 'You'
14
- # s.email = 'you@example.com'
15
- # s.homepage = 'http://www.example.com'
16
-
17
- if s.respond_to?(:metadata)
18
- s.metadata["homepage_uri"] = s.homepage if s.homepage
19
- s.metadata["source_code_uri"] = s.homepage if s.homepage
20
- s.metadata["changelog_uri"] = 'TODO'
21
- end
22
-
23
- s.required_ruby_version = '~> 2.4'
24
-
25
- s.files = Dir.chdir(File.expand_path(__dir__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
- end
28
- s.test_files = Dir['spec/**/*']
29
- s.bindir = "exe"
30
- s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
- s.require_paths = ["lib"]
32
-
33
- s.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
34
- s.add_dependency 'solidus_support', '~> 0.4.0'
35
-
36
- s.add_development_dependency 'solidus_dev_support'
37
- end