-
Notifications
You must be signed in to change notification settings - Fork 0
Rework to be a proper Rails plugin #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
90e87b1
Rework to be a proper Rails plugin
OutlawAndy 2ceee34
ci
OutlawAndy 5ec30b6
Apply PR review feedback: frozen string literals and file handle fix …
Copilot d960888
test dummy apps should not use their own Gemfiles
OutlawAndy f1751c8
resolve example app generation
OutlawAndy 4f554ca
Rolemodel::Rails v1.0.0
OutlawAndy 0817800
switch back to postgres for dummy app generation (fix failing specs)
OutlawAndy 94a0241
update README
OutlawAndy 26004ee
remove duplicate gems from plugin gemfile
OutlawAndy 5a4ddd2
Rename Example apps
OutlawAndy 47fed89
update to Rails 8.1.3
OutlawAndy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,5 @@ log | |
|
|
||
| *.gem | ||
| .history | ||
|
|
||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,16 @@ | |
|
|
||
| source 'https://rubygems.org' | ||
|
|
||
| git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } | ||
|
|
||
| # Specify your gem's dependencies in rolemodel_rails.gemspec | ||
| # Specify your gem's dependencies in rolemodel-rails.gemspec. | ||
| gemspec | ||
|
|
||
| # Gems which are necessary to boot the included test applications, | ||
| # but should not be bundled with this gem may be added here. | ||
| gem 'pg' | ||
| gem 'propshaft' | ||
| gem 'puma' | ||
| gem 'stimulus-rails' | ||
| gem 'turbo-rails' | ||
|
|
||
| # Start debugger with binding.b [https://github.com/ruby/debug] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use the alias or keep it long form ( |
||
| gem 'debug', '>= 1.0.0' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| require "rails/generators/rails/app/app_generator" | ||
|
|
||
| Rails::Generators::AppGenerator.define_method(:rails_version_specifier) do | ||
| "~> #{RAILS_VERSION}" | ||
| end | ||
|
|
||
| class BuilderClass < Rails::AppBuilder | ||
| # inherit these from Rolemodel::Rails | ||
| def ruby_version = nil | ||
| def node_version = nil | ||
|
|
||
| def generate_test_dummy | ||
| invoke Rails::Generators::AppGenerator, [ File.expand_path(dummy_path) ], { | ||
| dummy_app: true, | ||
| force: true, | ||
| database: 'postgresql', | ||
| javascript: 'webpack', | ||
| skip_bootsnap: true, | ||
| skip_brakeman: true, | ||
| skip_bundler_audit: true, | ||
| skip_ci: true, | ||
| skip_git: true, | ||
| skip_jbuilder: true, | ||
| skip_kamal: true, | ||
| skip_rubocop: true, | ||
| skip_solid: true, | ||
| skip_test: true, | ||
| skip_thruster: true, | ||
OutlawAndy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| end | ||
|
|
||
| def test_dummy_config | ||
| template 'boot.rb', "#{dummy_path}/config/boot.rb", force: true | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/usr/bin/env ruby | ||
| # This command will automatically be run when you run "rails" with Rails gems | ||
| # installed from the root of your application. | ||
|
|
||
| ENGINE_ROOT = File.expand_path("..", __dir__) | ||
| ENGINE_PATH = File.expand_path("../lib/rolemodel/engine", __dir__) | ||
| APP_PATH = File.expand_path("../example_rails8/config/application", __dir__) | ||
|
|
||
| # Set up gems listed in the Gemfile. | ||
| ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) | ||
| require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) | ||
|
|
||
| require "rails/all" | ||
| require "rails/engine/commands" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,27 @@ | ||
| #!/usr/bin/env bash | ||
| RAILS_VERSION=`gem search ^rails$ --remote | grep -oE 'rails \((\d\.[0-9]+\.[0-9]+)\)' | head -1 | cut -d' ' -f2 | tr -d '()'` | ||
| MAJOR_VERSION_NUMBER=${RAILS_VERSION%%.*} | ||
| #!/usr/bin/env ruby | ||
|
|
||
| set -euo pipefail | ||
| IFS=$'\n\t' | ||
| set -vx | ||
| RAILS_VERSION = ARGV[0] || '8.1.2' | ||
OutlawAndy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if ! gem list rails -i -v $RAILS_VERSION --silent; then | ||
| gem install rails -v $RAILS_VERSION | ||
| fi | ||
| require_relative 'dummy_app_builder' | ||
| RAILS_MAJOR_VERSION_NUMBER = Gem::Version.new(RAILS_VERSION).segments.first | ||
|
|
||
| rm -fr example_rails$MAJOR_VERSION_NUMBER | ||
| class RecreateCurrentExample < Rails::Generators::AppBase | ||
| source_root File.expand_path('templates', __dir__) | ||
|
|
||
| rails _"$RAILS_VERSION"_ new --skip-keeps --skip-git --skip-jbuilder -j webpack -d postgresql example_rails$MAJOR_VERSION_NUMBER | ||
| def recreate_example | ||
| shell.mute do | ||
| build(:generate_test_dummy) | ||
| build(:test_dummy_config) | ||
| end | ||
| end | ||
|
|
||
| cd example_rails$MAJOR_VERSION_NUMBER | ||
| private | ||
|
|
||
| bundle add --group development --path '..' --version '> 0.20' rolemodel_rails | ||
| bundle install | ||
| def dummy_path | ||
| @dummy_path ||= "./example_rails#{RAILS_MAJOR_VERSION_NUMBER}" | ||
| end | ||
|
|
||
| rm config/credentials.yml.enc | ||
| rm config/master.key | ||
| def get_builder_class = BuilderClass | ||
| end | ||
|
|
||
| cd - | ||
| RecreateCurrentExample.start(["--app-path=example_rails#{RAILS_MAJOR_VERSION_NUMBER}"]) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OutlawAndy Since this is public repo and running on Github, do we need to (or want to) switch to Blacksmith?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question. I don't know. blacksmith is significantly faster, but might be safest to switch back. 👍