Advertisement
Guest User

upload sage theme assets

a guest
Jan 4th, 2022
40
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.08 KB | None
  1. #
  2. # Generate theme production assets & upload them to the server
  3. namespace :deploy do
  4.   set :local_app_path, Pathname.new(Dir.pwd)
  5.   set :local_theme_path, fetch(:local_app_path).join('web/app/themes/', fetch(:theme_dir))
  6.   set :local_dist_path, fetch(:local_theme_path).join('dist')
  7.  
  8.   task :generate do
  9.     run_locally do
  10.       within fetch(:local_theme_path) do
  11.         execute :yarn, 'build:production'
  12.       end
  13.     end
  14.   end
  15.  
  16.   task :upload do
  17.     on roles(:web) do
  18.       set :theme_path, fetch(:release_path).join('web/app/themes/', fetch(:theme_dir))
  19.       set :remote_dist_path, -> { release_path.join(fetch(:theme_path)).join('dist') }
  20.  
  21.       puts "Your local distribution path: #{fetch(:local_dist_path)} "
  22.       puts "Your remote distribution path: #{fetch(:remote_dist_path)} "
  23.       puts "Uploading files to remote "
  24.       upload! fetch(:local_dist_path).to_s, fetch(:remote_dist_path), recursive: true
  25.     end
  26.   end
  27.  
  28.   task assets: %w(generate upload)
  29.  
  30. end
  31. ## Runs the above task before the deploy is updated
  32. after 'deploy:updated', 'deploy:assets'
  33. ###
  34.  
Advertisement
RAW Paste Data Copied
Advertisement