Skip to content

Commit

Permalink
Use 'yarn link' in the test app
Browse files Browse the repository at this point in the history
  • Loading branch information
taylor-steve committed Dec 19, 2024
1 parent f7a4498 commit 53cb8a6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
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

0 comments on commit 53cb8a6

Please sign in to comment.