-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51880 from Shopify/devcontainer-generator
Make devcontainers opt in and create a devcontainer command
- Loading branch information
Showing
18 changed files
with
290 additions
and
165 deletions.
There are no files selected for viewing
This file contains 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 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 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
34 changes: 34 additions & 0 deletions
34
railties/lib/rails/commands/devcontainer/devcontainer_command.rb
This file contains 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,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails/generators" | ||
require "rails/generators/rails/devcontainer/devcontainer_generator" | ||
|
||
module Rails | ||
module Command | ||
class DevcontainerCommand < Base # :nodoc: | ||
desc "devcontainer", "Generate a Dev Container setup based on current application configuration" | ||
def perform(*) | ||
boot_application! | ||
|
||
say "Generating Dev Container with the following options:" | ||
devcontainer_options.each do |option, value| | ||
say "#{option}: #{value}" | ||
end | ||
|
||
Rails::Generators::DevcontainerGenerator.new([], devcontainer_options).invoke_all | ||
end | ||
|
||
private | ||
def devcontainer_options | ||
@devcontainer_options ||= { | ||
app_name: Rails.application.railtie_name.chomp("_application"), | ||
database: !!defined?(ActiveRecord) && ActiveRecord::Base.connection_db_config.adapter, | ||
active_storage: !!defined?(ActiveStorage), | ||
redis: !!(defined?(ActionCable) || defined?(ActiveJob)), | ||
system_test: File.exist?("test/application_system_test_case.rb"), | ||
node: File.exist?(".node-version"), | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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
13 changes: 0 additions & 13 deletions
13
railties/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb.tt
This file contains 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,18 +1,5 @@ | ||
require "test_helper" | ||
|
||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase | ||
<% if skip_devcontainer? -%> | ||
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] | ||
<% else -%> | ||
if ENV["CAPYBARA_SERVER_PORT"] | ||
served_by host: "rails-app", port: ENV["CAPYBARA_SERVER_PORT"] | ||
|
||
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: { | ||
browser: :remote, | ||
url: "http://#{ENV["SELENIUM_HOST"]}:4444" | ||
} | ||
else | ||
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] | ||
end | ||
<% end -%> | ||
end |
This file contains 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.