Skip to content
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

Move generators into ViewComponent namespace #2130

Open
wants to merge 3 commits into
base: v4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ nav_order: 5

*Joel Hawksley*

* BREAKING: Move generators to a ViewComponent namespace.

*Paul Sadauskas*

* Add basic internal testing for memory allocations.

*Joel Hawksley*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require "rails/generators/abstract_generator"
require "generators/view_component/abstract_generator"

module Rails
module ViewComponent
module Generators
class ComponentGenerator < Rails::Generators::NamedBase
include ViewComponent::AbstractGenerator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require "rails/generators/erb"
require "rails/generators/abstract_generator"
require "generators/view_component/abstract_generator"

module Erb
module ViewComponent
module Generators
class ComponentGenerator < Base
class ErbGenerator < Rails::Generators::NamedBase
include ViewComponent::AbstractGenerator

source_root File.expand_path("templates", __dir__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require "rails/generators/erb/component_generator"
require "generators/view_component/erb/erb_generator"

module Haml
module ViewComponent
module Generators
class ComponentGenerator < Erb::Generators::ComponentGenerator
class HamlGenerator < ViewComponent::Generators::ErbGenerator
include ViewComponent::AbstractGenerator

source_root File.expand_path("templates", __dir__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require "rails/generators/abstract_generator"
require "generators/view_component/abstract_generator"

module Locale
module ViewComponent
module Generators
class ComponentGenerator < ::Rails::Generators::NamedBase
class LocaleGenerator < ::Rails::Generators::NamedBase
include ViewComponent::AbstractGenerator

source_root File.expand_path("templates", __dir__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

module Preview
module ViewComponent
module Generators
class ComponentGenerator < ::Rails::Generators::NamedBase
class PreviewGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
class_option :preview_path, type: :string, desc: "Path for previews, required when multiple preview paths are configured", default: ViewComponent::Base.config.generate.preview_path

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require "rails/generators/abstract_generator"
require "generators/view_component/abstract_generator"

module Rspec
module ViewComponent
module Generators
class ComponentGenerator < ::Rails::Generators::NamedBase
class RspecGenerator < ::Rails::Generators::NamedBase
include ViewComponent::AbstractGenerator

source_root File.expand_path("templates", __dir__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require "rails/generators/erb/component_generator"
require "generators/view_component/erb/erb_generator"

module Slim
module ViewComponent
module Generators
class ComponentGenerator < Erb::Generators::ComponentGenerator
class SlimGenerator < ViewComponent::Generators::ErbGenerator
include ViewComponent::AbstractGenerator

source_root File.expand_path("templates", __dir__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require "rails/generators/abstract_generator"
require "generators/view_component/abstract_generator"

module Stimulus
module ViewComponent
module Generators
class ComponentGenerator < ::Rails::Generators::NamedBase
class StimulusGenerator < ::Rails::Generators::NamedBase
include ViewComponent::AbstractGenerator

source_root File.expand_path("templates", __dir__)
Expand Down
11 changes: 11 additions & 0 deletions lib/generators/view_component/tailwindcss/tailwindcss_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require "generators/view_component/erb/erb_generator"

module ViewComponent
module Generators
class TailwindcssGenerator < ViewComponent::Generators::ErbGenerator
source_root File.expand_path("templates", __dir__)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

module TestUnit
module ViewComponent
module Generators
class ComponentGenerator < ::Rails::Generators::NamedBase
class TestUnitGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
check_class_collision suffix: "ComponentTest"

Expand Down
11 changes: 0 additions & 11 deletions lib/rails/generators/tailwindcss/component_generator.rb

This file was deleted.

4 changes: 2 additions & 2 deletions test/sandbox/test/generators/component_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/component/component_generator"
require "generators/view_component/component/component_generator"

Rails.application.load_generators

class ComponentGeneratorTest < Rails::Generators::TestCase
tests Rails::Generators::ComponentGenerator
tests ViewComponent::Generators::ComponentGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/test/generators/erb_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/erb/component_generator"
require "generators/view_component/erb/erb_generator"

Rails.application.load_generators

class ErbGeneratorTest < Rails::Generators::TestCase
tests Erb::Generators::ComponentGenerator
tests ViewComponent::Generators::ErbGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/test/generators/haml_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/haml/component_generator"
require "generators/view_component/haml/haml_generator"

Rails.application.load_generators

class HamlGeneratorTest < Rails::Generators::TestCase
tests Haml::Generators::ComponentGenerator
tests ViewComponent::Generators::HamlGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/test/generators/locale_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/locale/component_generator"
require "generators/view_component/locale/locale_generator"

Rails.application.load_generators

class LocaleGeneratorTest < Rails::Generators::TestCase
tests Locale::Generators::ComponentGenerator
tests ViewComponent::Generators::LocaleGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/test/generators/preview_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/preview/component_generator"
require "generators/view_component/preview/preview_generator"

# See: https://github.com/rails/rails/pull/47752#issuecomment-1720256371
require "active_record"

Rails.application.load_generators

class PreviewGeneratorTest < Rails::Generators::TestCase
tests Preview::Generators::ComponentGenerator
tests ViewComponent::Generators::PreviewGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/test/generators/rspec_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/rspec/component_generator"
require "generators/view_component/rspec/rspec_generator"

Rails.application.load_generators

class RSpecGeneratorTest < Rails::Generators::TestCase
tests Rspec::Generators::ComponentGenerator
tests ViewComponent::Generators::RspecGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/test/generators/slim_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/slim/component_generator"
require "generators/view_component/slim/slim_generator"

Rails.application.load_generators

class SlimGeneratorTest < Rails::Generators::TestCase
tests Slim::Generators::ComponentGenerator
tests ViewComponent::Generators::SlimGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/test/generators/stimulus_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/stimulus/component_generator"
require "generators/view_component/stimulus/stimulus_generator"

Rails.application.load_generators

class StimulusGeneratorTest < Rails::Generators::TestCase
tests Stimulus::Generators::ComponentGenerator
tests ViewComponent::Generators::StimulusGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
5 changes: 2 additions & 3 deletions test/sandbox/test/generators/tailwindcss_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/test_case"
require "rails/generators/tailwindcss/component_generator"
require "generators/view_component/tailwindcss/tailwindcss_generator"

Rails.application.load_generators

class TailwindcssGeneratorTest < Rails::Generators::TestCase
tests Tailwindcss::Generators::ComponentGenerator
tests ViewComponent::Generators::TailwindcssGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/sandbox/test/generators/test_unit_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "rails/generators/test_unit/component_generator"
require "generators/view_component/test_unit/test_unit_generator"

Rails.application.load_generators

class TestUnitGeneratorTest < Rails::Generators::TestCase
tests TestUnit::Generators::ComponentGenerator
tests ViewComponent::Generators::TestUnitGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/test_engine/test/generators/component_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative "../../test_helper"
require "rails/generators/component/component_generator"
require "generators/view_component/component/component_generator"

class ComponentGeneratorTest < Rails::Generators::TestCase
tests Rails::Generators::ComponentGenerator
tests ViewComponent::Generators::ComponentGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/test_engine/test/generators/preview_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative "../../test_helper"
require "rails/generators/preview/component_generator"
require "generators/view_component/preview/preview_generator"

class PreviewGeneratorTest < Rails::Generators::TestCase
tests Preview::Generators::ComponentGenerator
tests ViewComponent::Generators::PreviewGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
4 changes: 2 additions & 2 deletions test/test_engine/test/generators/test_unit_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative "../../test_helper"
require "rails/generators/test_unit/component_generator"
require "generators/view_component/test_unit/test_unit_generator"

class TestUnitGeneratorTest < Rails::Generators::TestCase
tests TestUnit::Generators::ComponentGenerator
tests ViewComponent::Generators::TestUnitGenerator
destination Dir.mktmpdir
setup :prepare_destination

Expand Down
Loading