rails_engine_toolkit 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +54 -0
- data/.github/workflows/release.yml +22 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +21 -0
- data/README.md +83 -0
- data/Rakefile +7 -0
- data/docs/ARCHITECTURE.md +18 -0
- data/docs/COMPATIBILITY.md +18 -0
- data/docs/CONTRIBUTING.md +26 -0
- data/docs/END_TO_END.md +26 -0
- data/docs/PUBLISHING.md +24 -0
- data/docs/RELEASE.md +32 -0
- data/docs/RELEASE_CHECKLIST.md +49 -0
- data/docs/TESTING.md +21 -0
- data/exe/engine-toolkit +6 -0
- data/lib/rails_engine_toolkit/actions/delete_engine_migration.rb +46 -0
- data/lib/rails_engine_toolkit/actions/init.rb +54 -0
- data/lib/rails_engine_toolkit/actions/install_engine_migrations.rb +83 -0
- data/lib/rails_engine_toolkit/actions/new_engine.rb +127 -0
- data/lib/rails_engine_toolkit/actions/new_engine_migration.rb +30 -0
- data/lib/rails_engine_toolkit/actions/new_engine_model.rb +30 -0
- data/lib/rails_engine_toolkit/actions/remove_engine.rb +78 -0
- data/lib/rails_engine_toolkit/actions/uninstall_engine_migrations.rb +79 -0
- data/lib/rails_engine_toolkit/actions/update_engine_readme.rb +60 -0
- data/lib/rails_engine_toolkit/cli.rb +110 -0
- data/lib/rails_engine_toolkit/config.rb +98 -0
- data/lib/rails_engine_toolkit/errors.rb +7 -0
- data/lib/rails_engine_toolkit/file_editor.rb +40 -0
- data/lib/rails_engine_toolkit/generators/install/install_generator.rb +67 -0
- data/lib/rails_engine_toolkit/project.rb +71 -0
- data/lib/rails_engine_toolkit/railtie.rb +9 -0
- data/lib/rails_engine_toolkit/route_inspector.rb +44 -0
- data/lib/rails_engine_toolkit/routes_rewriter.rb +63 -0
- data/lib/rails_engine_toolkit/templates/engine_readme.erb +37 -0
- data/lib/rails_engine_toolkit/templates/engine_toolkit_yml.erb +35 -0
- data/lib/rails_engine_toolkit/templates/gemspec.erb +25 -0
- data/lib/rails_engine_toolkit/templates/license.erb +3 -0
- data/lib/rails_engine_toolkit/templates.rb +12 -0
- data/lib/rails_engine_toolkit/utils.rb +56 -0
- data/lib/rails_engine_toolkit/version.rb +5 -0
- data/lib/rails_engine_toolkit.rb +33 -0
- data/rails_engine_toolkit.gemspec +31 -0
- data/spec/rails_engine_toolkit/cli_spec.rb +11 -0
- data/spec/rails_engine_toolkit/config_spec.rb +52 -0
- data/spec/rails_engine_toolkit/file_editor_spec.rb +26 -0
- data/spec/rails_engine_toolkit/install_engine_migrations_spec.rb +36 -0
- data/spec/rails_engine_toolkit/install_generator_spec.rb +26 -0
- data/spec/rails_engine_toolkit/new_engine_integration_spec.rb +59 -0
- data/spec/rails_engine_toolkit/new_engine_spec.rb +54 -0
- data/spec/rails_engine_toolkit/project_spec.rb +19 -0
- data/spec/rails_engine_toolkit/remove_engine_integration_spec.rb +40 -0
- data/spec/rails_engine_toolkit/remove_engine_spec.rb +72 -0
- data/spec/rails_engine_toolkit/route_inspector_spec.rb +20 -0
- data/spec/rails_engine_toolkit/routes_rewriter_spec.rb +36 -0
- data/spec/rails_engine_toolkit/uninstall_engine_migrations_spec.rb +35 -0
- data/spec/rails_engine_toolkit/update_engine_readme_spec.rb +32 -0
- data/spec/spec_helper.rb +30 -0
- data/test/fixtures/host_app/Gemfile +5 -0
- data/test/fixtures/host_app/config/application.rb +11 -0
- data/test/fixtures/host_app/config/boot.rb +3 -0
- data/test/fixtures/host_app/config/environment.rb +3 -0
- data/test/fixtures/host_app/config/routes.rb +2 -0
- metadata +140 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::Actions::NewEngine do
|
|
6
|
+
def config_yaml
|
|
7
|
+
<<~YAML
|
|
8
|
+
project:
|
|
9
|
+
name: "Transport System"
|
|
10
|
+
slug: "transport_system"
|
|
11
|
+
url: "https://example.test/repo"
|
|
12
|
+
author:
|
|
13
|
+
name: "Juan"
|
|
14
|
+
email: "juan@example.com"
|
|
15
|
+
defaults:
|
|
16
|
+
database: "postgresql"
|
|
17
|
+
api_only: true
|
|
18
|
+
mount_routes: true
|
|
19
|
+
create_ddd_structure: true
|
|
20
|
+
metadata:
|
|
21
|
+
license: "MIT"
|
|
22
|
+
ruby_version: ">= 3.2"
|
|
23
|
+
rails_version: ">= 8.1.2"
|
|
24
|
+
YAML
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'inserts the mount line only once and creates DDD folders' do
|
|
28
|
+
in_tmpdir do |dir|
|
|
29
|
+
write(dir.join('Gemfile'), "source \"https://rubygems.org\"\n")
|
|
30
|
+
write(dir.join('config/routes.rb'), "Rails.application.routes.draw do\nend\n")
|
|
31
|
+
write(dir.join('config/engine_toolkit.yml'), config_yaml)
|
|
32
|
+
|
|
33
|
+
input = StringIO.new("\n")
|
|
34
|
+
output = StringIO.new
|
|
35
|
+
action = described_class.new(['auth'], stdin: input, stdout: output, stderr: StringIO.new, root: dir)
|
|
36
|
+
|
|
37
|
+
allow(RailsEngineToolkit::Utils).to receive(:safe_system) do |*args, **_kwargs|
|
|
38
|
+
if args[0..4] == %w[bundle exec rails plugin new]
|
|
39
|
+
FileUtils.mkdir_p(dir.join('engines/auth'))
|
|
40
|
+
FileUtils.mkdir_p(dir.join('engines/auth/lib/auth'))
|
|
41
|
+
write(dir.join('engines/auth/Gemfile'), '')
|
|
42
|
+
write(dir.join('engines/auth/auth.gemspec'), '')
|
|
43
|
+
write(dir.join('engines/auth/MIT-LICENSE'), '')
|
|
44
|
+
write(dir.join('engines/auth/README.md'), '')
|
|
45
|
+
end
|
|
46
|
+
true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
action.call
|
|
50
|
+
|
|
51
|
+
routes = dir.join('config/routes.rb').read
|
|
52
|
+
expect(routes.scan('mount Auth::Engine, at: "/auth"').size).to eq(1)
|
|
53
|
+
|
|
54
|
+
expect(dir.join('engines/auth/app/use_cases')).to exist
|
|
55
|
+
expect(dir.join('engines/auth/app/services')).to exist
|
|
56
|
+
expect(dir.join('engines/auth/app/policies')).to exist
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::Actions::NewEngine do
|
|
6
|
+
it 'asks to remove broken engine references before creating a new engine' do
|
|
7
|
+
in_tmpdir do |dir|
|
|
8
|
+
write(dir.join('Gemfile'), <<~RUBY)
|
|
9
|
+
source "https://rubygems.org"
|
|
10
|
+
gem "missing", path: "engines/missing"
|
|
11
|
+
RUBY
|
|
12
|
+
write(dir.join('config/routes.rb'), "Rails.application.routes.draw do\nend\n")
|
|
13
|
+
write(dir.join('config/engine_toolkit.yml'), <<~YAML)
|
|
14
|
+
project:
|
|
15
|
+
name: "Transport System"
|
|
16
|
+
slug: "transport_system"
|
|
17
|
+
url: "https://example.test/repo"
|
|
18
|
+
author:
|
|
19
|
+
name: "Juan"
|
|
20
|
+
email: "juan@example.com"
|
|
21
|
+
defaults:
|
|
22
|
+
database: "postgresql"
|
|
23
|
+
api_only: true
|
|
24
|
+
mount_routes: true
|
|
25
|
+
create_ddd_structure: true
|
|
26
|
+
metadata:
|
|
27
|
+
license: "MIT"
|
|
28
|
+
ruby_version: ">= 3.2"
|
|
29
|
+
rails_version: ">= 8.1.2"
|
|
30
|
+
YAML
|
|
31
|
+
|
|
32
|
+
input = StringIO.new("y\n\n")
|
|
33
|
+
output = StringIO.new
|
|
34
|
+
action = described_class.new(['auth'], stdin: input, stdout: output, stderr: StringIO.new, root: dir)
|
|
35
|
+
|
|
36
|
+
allow(RailsEngineToolkit::Utils).to receive(:safe_system) do |*args, **_kwargs|
|
|
37
|
+
if args[0..4] == %w[bundle exec rails plugin new]
|
|
38
|
+
FileUtils.mkdir_p(dir.join('engines/auth/lib/auth'))
|
|
39
|
+
FileUtils.mkdir_p(dir.join('engines/auth'))
|
|
40
|
+
write(dir.join('engines/auth/Gemfile'), '')
|
|
41
|
+
write(dir.join('engines/auth/auth.gemspec'), '')
|
|
42
|
+
write(dir.join('engines/auth/MIT-LICENSE'), '')
|
|
43
|
+
write(dir.join('engines/auth/README.md'), '')
|
|
44
|
+
end
|
|
45
|
+
true
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
action.call
|
|
49
|
+
|
|
50
|
+
expect(dir.join('Gemfile').read).not_to include('path: "engines/missing"')
|
|
51
|
+
expect(dir.join('config/routes.rb').read).to include('mount Auth::Engine, at: "/auth"')
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::Project do
|
|
6
|
+
it 'detects broken engine references from Gemfile' do
|
|
7
|
+
in_tmpdir do |dir|
|
|
8
|
+
write(dir.join('Gemfile'), <<~RUBY)
|
|
9
|
+
source "https://rubygems.org"
|
|
10
|
+
gem "auth", path: "engines/auth"
|
|
11
|
+
gem "billing", path: "engines/billing"
|
|
12
|
+
RUBY
|
|
13
|
+
FileUtils.mkdir_p(dir.join('engines/auth'))
|
|
14
|
+
|
|
15
|
+
project = described_class.new(dir)
|
|
16
|
+
expect(project.broken_engine_references).to eq(['billing'])
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::Actions::RemoveEngine do
|
|
6
|
+
def build_project(dir, routes_content:)
|
|
7
|
+
write(dir.join('Gemfile'), <<~RUBY)
|
|
8
|
+
source "https://rubygems.org"
|
|
9
|
+
gem "auth", path: "engines/auth"
|
|
10
|
+
RUBY
|
|
11
|
+
write(dir.join('config/routes.rb'), routes_content)
|
|
12
|
+
write(dir.join('engines/auth/README.md'), "# Auth\n")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'removes all supported mount variants when present in multiple lines' do
|
|
16
|
+
in_tmpdir do |dir|
|
|
17
|
+
build_project(dir, routes_content: <<~RUBY)
|
|
18
|
+
Rails.application.routes.draw do
|
|
19
|
+
mount Auth::Engine, at: "/auth"
|
|
20
|
+
mount(Auth::Engine, at: "/auth")
|
|
21
|
+
mount Auth::Engine => "/auth"
|
|
22
|
+
end
|
|
23
|
+
RUBY
|
|
24
|
+
|
|
25
|
+
input = StringIO.new("auth\n")
|
|
26
|
+
output = StringIO.new
|
|
27
|
+
action = described_class.new(['auth'], stdin: input, stdout: output, stderr: StringIO.new, root: dir)
|
|
28
|
+
allow(RailsEngineToolkit::Utils).to receive(:safe_system).and_return(true)
|
|
29
|
+
|
|
30
|
+
action.call
|
|
31
|
+
|
|
32
|
+
routes = dir.join('config/routes.rb').read
|
|
33
|
+
expect(routes).not_to include('mount Auth::Engine, at: "/auth"')
|
|
34
|
+
expect(routes).not_to include('mount(Auth::Engine, at: "/auth")')
|
|
35
|
+
expect(routes).not_to include('mount Auth::Engine => "/auth"')
|
|
36
|
+
expect(dir.join('engines/auth')).not_to exist
|
|
37
|
+
expect(dir.join('Gemfile').read).not_to include('path: "engines/auth"')
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::Actions::RemoveEngine do
|
|
6
|
+
def build_action(dir, routes_content:)
|
|
7
|
+
write(dir.join('Gemfile'), <<~RUBY)
|
|
8
|
+
source "https://rubygems.org"
|
|
9
|
+
gem "auth", path: "engines/auth"
|
|
10
|
+
RUBY
|
|
11
|
+
write(dir.join('config/routes.rb'), routes_content)
|
|
12
|
+
write(dir.join('engines/auth/README.md'), "# Auth\n")
|
|
13
|
+
|
|
14
|
+
described_class.new(
|
|
15
|
+
['auth'],
|
|
16
|
+
stdin: StringIO.new("auth\n"),
|
|
17
|
+
stdout: StringIO.new,
|
|
18
|
+
stderr: StringIO.new,
|
|
19
|
+
root: dir
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'removes standard mount lines' do
|
|
24
|
+
in_tmpdir do |dir|
|
|
25
|
+
routes_content = <<~RUBY
|
|
26
|
+
Rails.application.routes.draw do
|
|
27
|
+
mount Auth::Engine, at: "/auth"
|
|
28
|
+
end
|
|
29
|
+
RUBY
|
|
30
|
+
action = build_action(dir, routes_content: routes_content)
|
|
31
|
+
allow(RailsEngineToolkit::Utils).to receive(:safe_system)
|
|
32
|
+
|
|
33
|
+
action.call
|
|
34
|
+
|
|
35
|
+
expect(dir.join('config/routes.rb').read).not_to include('mount Auth::Engine, at: "/auth"')
|
|
36
|
+
expect(dir.join('Gemfile').read).not_to include('path: "engines/auth"')
|
|
37
|
+
expect(dir.join('engines/auth')).not_to exist
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'removes hash rocket mount lines' do
|
|
42
|
+
in_tmpdir do |dir|
|
|
43
|
+
routes_content = <<~RUBY
|
|
44
|
+
Rails.application.routes.draw do
|
|
45
|
+
mount Auth::Engine => "/auth"
|
|
46
|
+
end
|
|
47
|
+
RUBY
|
|
48
|
+
action = build_action(dir, routes_content: routes_content)
|
|
49
|
+
allow(RailsEngineToolkit::Utils).to receive(:safe_system)
|
|
50
|
+
|
|
51
|
+
action.call
|
|
52
|
+
|
|
53
|
+
expect(dir.join('config/routes.rb').read).not_to include('mount Auth::Engine => "/auth"')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'removes parenthesized mount lines' do
|
|
58
|
+
in_tmpdir do |dir|
|
|
59
|
+
routes_content = <<~RUBY
|
|
60
|
+
Rails.application.routes.draw do
|
|
61
|
+
mount(Auth::Engine, at: "/auth")
|
|
62
|
+
end
|
|
63
|
+
RUBY
|
|
64
|
+
action = build_action(dir, routes_content: routes_content)
|
|
65
|
+
allow(RailsEngineToolkit::Utils).to receive(:safe_system)
|
|
66
|
+
|
|
67
|
+
action.call
|
|
68
|
+
|
|
69
|
+
expect(dir.join('config/routes.rb').read).not_to include('mount(Auth::Engine, at: "/auth")')
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::RouteInspector do
|
|
6
|
+
it 'detects supported mount variants' do
|
|
7
|
+
content = <<~RUBY
|
|
8
|
+
Rails.application.routes.draw do
|
|
9
|
+
mount Auth::Engine, at: "/auth"
|
|
10
|
+
mount(Auth::Engine, at: "/auth")
|
|
11
|
+
mount Auth::Engine => "/auth"
|
|
12
|
+
end
|
|
13
|
+
RUBY
|
|
14
|
+
|
|
15
|
+
inspector = described_class.new(content)
|
|
16
|
+
expect(inspector.syntax_valid?).to be(true)
|
|
17
|
+
expect(inspector.mounts.size).to eq(3)
|
|
18
|
+
expect(inspector.includes_mount?('Auth', '/auth')).to be(true)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::RoutesRewriter do
|
|
6
|
+
it 'adds a mount only once' do
|
|
7
|
+
in_tmpdir do |dir|
|
|
8
|
+
path = dir.join('config/routes.rb')
|
|
9
|
+
write(path, "Rails.application.routes.draw do\nend\n")
|
|
10
|
+
|
|
11
|
+
rewriter = described_class.new(path)
|
|
12
|
+
expect(rewriter.add_mount(engine_class: 'Auth', mount_path: '/auth')).to be(true)
|
|
13
|
+
expect(rewriter.add_mount(engine_class: 'Auth', mount_path: '/auth')).to be(false)
|
|
14
|
+
|
|
15
|
+
content = path.read
|
|
16
|
+
expect(content.scan('mount Auth::Engine, at: "/auth"').size).to eq(1)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'removes all supported mount variants for one engine path' do
|
|
21
|
+
in_tmpdir do |dir|
|
|
22
|
+
path = dir.join('config/routes.rb')
|
|
23
|
+
write(path, <<~RUBY)
|
|
24
|
+
Rails.application.routes.draw do
|
|
25
|
+
mount Auth::Engine, at: "/auth"
|
|
26
|
+
mount(Auth::Engine, at: "/auth")
|
|
27
|
+
mount Auth::Engine => "/auth"
|
|
28
|
+
end
|
|
29
|
+
RUBY
|
|
30
|
+
|
|
31
|
+
rewriter = described_class.new(path)
|
|
32
|
+
expect(rewriter.remove_mount(engine_class: 'Auth', mount_path: '/auth')).to be(true)
|
|
33
|
+
expect(path.read).not_to include('mount Auth::Engine')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::Actions::UninstallEngineMigrations do
|
|
6
|
+
it 'removes copied root migration files matching one engine' do
|
|
7
|
+
in_tmpdir do |dir|
|
|
8
|
+
write(dir.join('Gemfile'), "source \"https://rubygems.org\"\n")
|
|
9
|
+
write(dir.join('engines/auth/db/migrate/20260101000000_create_auth_credentials.rb'),
|
|
10
|
+
'class CreateAuthCredentials; end')
|
|
11
|
+
root_file = dir.join('db/migrate/20260102000000_create_auth_credentials.rb')
|
|
12
|
+
write(root_file, 'class CreateAuthCredentials; end')
|
|
13
|
+
|
|
14
|
+
input = StringIO.new("auth\n")
|
|
15
|
+
out = StringIO.new
|
|
16
|
+
described_class.new(['auth'], stdin: input, stdout: out, stderr: StringIO.new, root: dir).call
|
|
17
|
+
|
|
18
|
+
expect(root_file).not_to exist
|
|
19
|
+
expect(out.string).to include('does NOT rollback the database automatically')
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'does nothing when there are no installed root migrations for that engine' do
|
|
24
|
+
in_tmpdir do |dir|
|
|
25
|
+
write(dir.join('Gemfile'), "source \"https://rubygems.org\"\n")
|
|
26
|
+
write(dir.join('engines/auth/db/migrate/20260101000000_create_auth_credentials.rb'),
|
|
27
|
+
'class CreateAuthCredentials; end')
|
|
28
|
+
|
|
29
|
+
out = StringIO.new
|
|
30
|
+
described_class.new(['auth'], stdin: StringIO.new, stdout: out, stderr: StringIO.new, root: dir).call
|
|
31
|
+
|
|
32
|
+
expect(out.string).to include('No installed root migrations found')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RailsEngineToolkit::Actions::UpdateEngineReadme do
|
|
6
|
+
it 'updates owned tables using migrations only' do
|
|
7
|
+
in_tmpdir do |dir|
|
|
8
|
+
write(dir.join('Gemfile'), "source \"https://rubygems.org\"\n")
|
|
9
|
+
write(dir.join('engines/auth/README.md'), <<~MD)
|
|
10
|
+
# Auth
|
|
11
|
+
|
|
12
|
+
## Owned tables
|
|
13
|
+
- None defined yet.
|
|
14
|
+
|
|
15
|
+
## Public endpoints
|
|
16
|
+
- None defined yet.
|
|
17
|
+
MD
|
|
18
|
+
write(dir.join('engines/auth/db/migrate/20260101000000_create_auth_credentials.rb'), <<~RB)
|
|
19
|
+
class CreateAuthCredentials < ActiveRecord::Migration[8.1]
|
|
20
|
+
def change
|
|
21
|
+
create_table :auth_credentials do |t|
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
RB
|
|
26
|
+
|
|
27
|
+
described_class.new(['auth'], stdin: StringIO.new, stdout: StringIO.new, stderr: StringIO.new, root: dir).call
|
|
28
|
+
|
|
29
|
+
expect(dir.join('engines/auth/README.md').read).to include('- auth_credentials')
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'tmpdir'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'stringio'
|
|
6
|
+
require 'yaml'
|
|
7
|
+
|
|
8
|
+
require 'rails_engine_toolkit'
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
config.order = :random
|
|
12
|
+
Kernel.srand config.seed
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module SpecHelpers
|
|
16
|
+
def in_tmpdir
|
|
17
|
+
Dir.mktmpdir do |dir|
|
|
18
|
+
Dir.chdir(dir) { yield Pathname(dir) }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def write(path, content)
|
|
23
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
24
|
+
File.write(path, content)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
RSpec.configure do |config|
|
|
29
|
+
config.include SpecHelpers
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rails_engine_toolkit
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.6.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Your Name
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-03-13 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: railties
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 8.1.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 8.1.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: thor
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.3'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.3'
|
|
41
|
+
description: Creates and manages internal Rails engines with configurable conventions,
|
|
42
|
+
safe file mutations, parser-assisted route inspection, engine-specific migration
|
|
43
|
+
installation, and Rails install generators.
|
|
44
|
+
email:
|
|
45
|
+
- you@example.com
|
|
46
|
+
executables:
|
|
47
|
+
- engine-toolkit
|
|
48
|
+
extensions: []
|
|
49
|
+
extra_rdoc_files: []
|
|
50
|
+
files:
|
|
51
|
+
- ".github/workflows/ci.yml"
|
|
52
|
+
- ".github/workflows/release.yml"
|
|
53
|
+
- Gemfile
|
|
54
|
+
- LICENSE.txt
|
|
55
|
+
- README.md
|
|
56
|
+
- Rakefile
|
|
57
|
+
- docs/ARCHITECTURE.md
|
|
58
|
+
- docs/COMPATIBILITY.md
|
|
59
|
+
- docs/CONTRIBUTING.md
|
|
60
|
+
- docs/END_TO_END.md
|
|
61
|
+
- docs/PUBLISHING.md
|
|
62
|
+
- docs/RELEASE.md
|
|
63
|
+
- docs/RELEASE_CHECKLIST.md
|
|
64
|
+
- docs/TESTING.md
|
|
65
|
+
- exe/engine-toolkit
|
|
66
|
+
- lib/rails_engine_toolkit.rb
|
|
67
|
+
- lib/rails_engine_toolkit/actions/delete_engine_migration.rb
|
|
68
|
+
- lib/rails_engine_toolkit/actions/init.rb
|
|
69
|
+
- lib/rails_engine_toolkit/actions/install_engine_migrations.rb
|
|
70
|
+
- lib/rails_engine_toolkit/actions/new_engine.rb
|
|
71
|
+
- lib/rails_engine_toolkit/actions/new_engine_migration.rb
|
|
72
|
+
- lib/rails_engine_toolkit/actions/new_engine_model.rb
|
|
73
|
+
- lib/rails_engine_toolkit/actions/remove_engine.rb
|
|
74
|
+
- lib/rails_engine_toolkit/actions/uninstall_engine_migrations.rb
|
|
75
|
+
- lib/rails_engine_toolkit/actions/update_engine_readme.rb
|
|
76
|
+
- lib/rails_engine_toolkit/cli.rb
|
|
77
|
+
- lib/rails_engine_toolkit/config.rb
|
|
78
|
+
- lib/rails_engine_toolkit/errors.rb
|
|
79
|
+
- lib/rails_engine_toolkit/file_editor.rb
|
|
80
|
+
- lib/rails_engine_toolkit/generators/install/install_generator.rb
|
|
81
|
+
- lib/rails_engine_toolkit/project.rb
|
|
82
|
+
- lib/rails_engine_toolkit/railtie.rb
|
|
83
|
+
- lib/rails_engine_toolkit/route_inspector.rb
|
|
84
|
+
- lib/rails_engine_toolkit/routes_rewriter.rb
|
|
85
|
+
- lib/rails_engine_toolkit/templates.rb
|
|
86
|
+
- lib/rails_engine_toolkit/templates/engine_readme.erb
|
|
87
|
+
- lib/rails_engine_toolkit/templates/engine_toolkit_yml.erb
|
|
88
|
+
- lib/rails_engine_toolkit/templates/gemspec.erb
|
|
89
|
+
- lib/rails_engine_toolkit/templates/license.erb
|
|
90
|
+
- lib/rails_engine_toolkit/utils.rb
|
|
91
|
+
- lib/rails_engine_toolkit/version.rb
|
|
92
|
+
- rails_engine_toolkit.gemspec
|
|
93
|
+
- spec/rails_engine_toolkit/cli_spec.rb
|
|
94
|
+
- spec/rails_engine_toolkit/config_spec.rb
|
|
95
|
+
- spec/rails_engine_toolkit/file_editor_spec.rb
|
|
96
|
+
- spec/rails_engine_toolkit/install_engine_migrations_spec.rb
|
|
97
|
+
- spec/rails_engine_toolkit/install_generator_spec.rb
|
|
98
|
+
- spec/rails_engine_toolkit/new_engine_integration_spec.rb
|
|
99
|
+
- spec/rails_engine_toolkit/new_engine_spec.rb
|
|
100
|
+
- spec/rails_engine_toolkit/project_spec.rb
|
|
101
|
+
- spec/rails_engine_toolkit/remove_engine_integration_spec.rb
|
|
102
|
+
- spec/rails_engine_toolkit/remove_engine_spec.rb
|
|
103
|
+
- spec/rails_engine_toolkit/route_inspector_spec.rb
|
|
104
|
+
- spec/rails_engine_toolkit/routes_rewriter_spec.rb
|
|
105
|
+
- spec/rails_engine_toolkit/uninstall_engine_migrations_spec.rb
|
|
106
|
+
- spec/rails_engine_toolkit/update_engine_readme_spec.rb
|
|
107
|
+
- spec/spec_helper.rb
|
|
108
|
+
- test/fixtures/host_app/Gemfile
|
|
109
|
+
- test/fixtures/host_app/config/application.rb
|
|
110
|
+
- test/fixtures/host_app/config/boot.rb
|
|
111
|
+
- test/fixtures/host_app/config/environment.rb
|
|
112
|
+
- test/fixtures/host_app/config/routes.rb
|
|
113
|
+
homepage: https://github.com/your-org/rails_engine_toolkit
|
|
114
|
+
licenses:
|
|
115
|
+
- MIT
|
|
116
|
+
metadata:
|
|
117
|
+
homepage_uri: https://github.com/your-org/rails_engine_toolkit
|
|
118
|
+
source_code_uri: https://github.com/your-org/rails_engine_toolkit
|
|
119
|
+
changelog_uri: https://github.com/your-org/rails_engine_toolkit/releases
|
|
120
|
+
rubygems_mfa_required: 'true'
|
|
121
|
+
post_install_message:
|
|
122
|
+
rdoc_options: []
|
|
123
|
+
require_paths:
|
|
124
|
+
- lib
|
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '3.2'
|
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
|
+
requirements:
|
|
132
|
+
- - ">="
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: '0'
|
|
135
|
+
requirements: []
|
|
136
|
+
rubygems_version: 3.4.1
|
|
137
|
+
signing_key:
|
|
138
|
+
specification_version: 4
|
|
139
|
+
summary: Reusable CLI and generators for Rails engines
|
|
140
|
+
test_files: []
|