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

Use 'yarn link' in the test app #3381

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
9 changes: 0 additions & 9 deletions lib/generators/spotlight/assets/generator_common_utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ def bootstrap_version
def bootstrap_yarn_version
bootstrap_version.match(/(\d+(\.\d+)*)/)[0]
end

# Yarn link was including so many files (and a circular reference) that Propshaft was having a bad time.
def link_spotlight_frontend
empty_directory 'node_modules/spotlight-frontend'
empty_directory 'node_modules/spotlight-frontend/app'
File.symlink Spotlight::Engine.root.join('package.json'), 'node_modules/spotlight-frontend/package.json'
File.symlink Spotlight::Engine.root.join('vendor'), 'node_modules/spotlight-frontend/vendor'
File.symlink Spotlight::Engine.root.join('app/assets'), 'node_modules/spotlight-frontend/app/assets'
end
end
end
end
2 changes: 1 addition & 1 deletion lib/generators/spotlight/assets/importmap_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def add_frontend
if ENV['CI']
run "yarn add file:#{Spotlight::Engine.root}"
elsif options[:test]
link_spotlight_frontend
run 'yarn link spotlight-frontend'

# If a branch was specified (e.g. you are running a template.rb build
# against a test branch), use the latest version available on npm
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/spotlight/assets/propshaft_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def add_frontend
if ENV['CI']
run "yarn add file:#{Spotlight::Engine.root}"
elsif options[:test]
link_spotlight_frontend
run 'yarn link spotlight-frontend'

# If a branch was specified (e.g. you are running a template.rb build
# against a test branch), use the latest version available on npm
Expand Down
6 changes: 6 additions & 0 deletions spec/test_app_templates/lib/generators/test_app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def add_gems
end
end

# This makes the assets available in the test app so that changes made in
# local development can be picked up automatically
def link_frontend
run 'yarn link'
end

def run_blacklight_generator
say_status('warning', 'GENERATING BL', :yellow)

Expand Down
Loading