Skip to content

Commit

Permalink
Merge pull request #446 from alleycat-at-git/hotfix/assets_heroku
Browse files Browse the repository at this point in the history
Fixed assets symlinking for Heroku
  • Loading branch information
justin808 committed Jun 7, 2016
2 parents e462223 + eb7d710 commit 118cd06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
All notable changes to this project will be documented in this file. Items under `Unreleased` is upcoming features that will be out in next version.

Contributors: please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.

## [Unreleased]

## [6.0.3]
##### Fixed
- Added assets symlinking support on Heroku [#446](https://github.com/shakacode/react_on_rails/pull/446) by [Alexey Karasev](https://github.com/alleycat-at-git).

## [6.0.2]
##### Fixed
- Fix colisions in ids of DOM nodes generated by `react_component` by indexing in using an UUID rather than an auto-increment value. This means that it should be overriden using the `id` parameter of `react_component` if one wants to generate a predictable id (_e.g._ for testing purpose). See [Issue #437](https://github.com/shakacode/react_on_rails/issues/437). Fixed in [#438](https://github.com/shakacode/react_on_rails/pull/438) by [Michael Baudino](https://github.com/michaelbaudino).
Expand Down Expand Up @@ -340,7 +345,8 @@ Best done with Object destructing:
##### Fixed
- Fix several generator related issues.
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.0.2...master
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.0.3...master
[6.0.3]: https://github.com/shakacode/react_on_rails/compare/6.0.2...6.0.3
[6.0.2]: https://github.com/shakacode/react_on_rails/compare/6.0.1...6.0.2
[6.0.1]: https://github.com/shakacode/react_on_rails/compare/6.0.0...6.0.1
[6.0.0]: https://github.com/shakacode/react_on_rails/compare/5.2.0...6.0.0
Expand Down
31 changes: 11 additions & 20 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ module ReactOnRails
end

def symlink_file(target, symlink)
if not File.exist?(symlink) or File.lstat(symlink).symlink?
if File.exist?(target)
puts "React On Rails: Symlinking #{target} to #{symlink}"
FileUtils.ln_s target, symlink, force: true
target_path = ReactOnRails::assets_path.join(target)
symlink_path = ReactOnRails::assets_path.join(symlink)
if not File.exist?(symlink_path) or File.lstat(symlink_path).symlink?
if File.exist?(target_path)
puts "React On Rails: Symlinking #{target_path} to #{symlink_path}"
`cd #{ReactOnRails::assets_path} && ln -s #{target} #{symlink}`
end
else
puts "React On Rails: File #{symlink} already exists. Failed to symlink #{target}"
puts "React On Rails: File #{symlink_path} already exists. Failed to symlink #{target_path}"
end
end
end
Expand All @@ -37,13 +39,10 @@ namespace :react_on_rails do
manifest_data["assets"].each do |logical_path, digested_path|
regex = ReactOnRails.configuration.symlink_non_digested_assets_regex
if logical_path =~ regex
full_digested_path = ReactOnRails::assets_path.join(digested_path)
full_nondigested_path = ReactOnRails::assets_path.join(logical_path)
extension = full_digested_path.extname
full_digested_gz_path = full_digested_path.sub_ext("#{extension}.gz")
full_nondigested_gz_path = full_nondigested_path.sub_ext("#{extension}.gz")
ReactOnRails::symlink_file(full_digested_path, full_nondigested_path)
ReactOnRails::symlink_file(full_digested_gz_path, full_nondigested_gz_path)
digested_gz_path = "#{digested_path}.gz"
logical_gz_path = "#{logical_path}.gz"
ReactOnRails::symlink_file(digested_path, logical_path)
ReactOnRails::symlink_file(digested_gz_path, logical_gz_path)
end
end
end
Expand Down Expand Up @@ -115,11 +114,3 @@ Rake::Task["assets:precompile"]
Rake::Task["react_on_rails:assets:delete_broken_symlinks"].invoke
end

# puts "Enhancing assets:precompile with react_on_rails:assets:compile_environment"
# Rake::Task["assets:precompile"]
# .clear_prerequisites
# .enhance([:environment]) do
# Rake::Task["react_on_rails:assets:compile_environment"].invoke
# Rake::Task["react_on_rails:assets:symlink_non_digested_assets"].invoke
# Rake::Task["react_on_rails:assets:delete_broken_symlinks"].invoke
# end

0 comments on commit 118cd06

Please sign in to comment.