-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supports removing webpacker and adding jsbundling-rails
- Loading branch information
Showing
3 changed files
with
63 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require "thor" | ||
|
||
module Alchemy | ||
class Upgrader::SevenPointZero < Upgrader | ||
include Thor::Base | ||
include Thor::Actions | ||
|
||
class << self | ||
def update_admin_entrypoint | ||
if File.exist? "app/javascript/packs/alchemy/admin.js" | ||
FileUtils.mv "app/javascript/packs/alchemy/admin.js", "app/javascript/alchemy_admin.js" | ||
else | ||
log "Skipping. No alchemy/admin entrypoint found. Maybe already migrated from Webpacker?", :info | ||
end | ||
if Dir.exist? "app/javascript/packs/alchemy" | ||
if Dir.empty? "app/javascript/packs/alchemy" | ||
FileUtils.rm_r "app/javascript/packs/alchemy" | ||
end | ||
end | ||
if File.exist? "config/importmap.rb" | ||
# We want the bundled package if using importmaps | ||
task.gsub_file "app/javascript/alchemy_admin.js", 'import "@alchemy_cms/admin"', 'import "@alchemy_cms/dist/admin"' | ||
end | ||
if task.ask("Do you want to remove webpacker now? (y/N)", default: "N") == "y" | ||
task.run "yarn remove @rails/webpacker webpack webpack-cli webpack-dev-server" | ||
FileUtils.rm_r "app/javascript/packs" | ||
FileUtils.rm_r "config/webpack" | ||
FileUtils.rm "config/webpacker.yml" | ||
FileUtils.rm "bin/webpack" | ||
FileUtils.rm "bin/webpack-dev-server" | ||
end | ||
if task.ask("Do you want to add jsbundling-rails now? (Y/n)", default: "Y") == "Y" | ||
task.run "bundle add jsbundling-rails" | ||
task.run "bin/rails javascript:install:esbuild" | ||
end | ||
end | ||
|
||
private | ||
|
||
def task | ||
@_task || new | ||
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