Skip to content

Instantly share code, notes, and snippets.

@rachelgraves
Created August 26, 2024 11:52
Show Gist options
  • Save rachelgraves/e31d0cf14b5f507955a9a620b3696780 to your computer and use it in GitHub Desktop.
Save rachelgraves/e31d0cf14b5f507955a9a620b3696780 to your computer and use it in GitHub Desktop.
upgrade jumpstart
#!/usr/bin/env ruby
require "date"
# Configure the GitHub client
repository = `git config --get remote.origin.url`.split(":").last.strip.chomp(".git")
`gh repo set-default #{repository}`
# Do all the fun things
branch = "jumpstart-pro-upgrade-#{Date.today.strftime("%Y-%m-%d")}"
branch_exists = !!`git branch | grep -w #{branch}`
if branch_exists
`git branch -D #{branch}`
end
`git checkout -b #{branch}`
`git fetch jsp`
`git merge jsp/main`
`git status`
# Files to delete
paths_to_delete = [
"app/controllers/admin/", # We don't use their admin controllers
"app/views/admin/", # We don't use their admin views
"lib/templates/erb/scaffold/", # We've customized this already
"app/views/fields/", # We've don't use administrate
"config/initializers/assets.rb", # We don't use Sprockets
"app/views/layouts/admin/application.html.erb", # We don't use their admin layout
"app/views/components/_modal.html.erb", # We don't use their components
"app/javascript/administrate.js", # We don't use administrate
"app/dashboards/", # We don't use administrate
]
paths_to_delete.each do |path|
`git rm -rf #{path}`
end
# Changes to ignore
changes_to_ignore = [
".github/", # CI workflow is mine, thanks
".node-version", # Hopefully capable of updating this ourselves
"package.json", # Gets updated by yarn upgrade
"yarn.lock", # Gets updated by yarn upgrade
"app/views/shared/_error_messages.html.erb", # We've customized this already
"app/controllers/static_controller.rb", # We've customized this already
"app/views/static/pricing.html.erb", # We've customized this already
"esbuild.config.mjs", # We don't use esbuild
"lib/templates/erb/*", # We modified their templates
"lib/generators/scaffold/scaffold_generator.rb", # We modified their scaffold generator
"config/credentials/test.yml.enc", # We'll manage our own credentials thanks
"app/views/static/index.html.erb", # We've customized this already
"app/views/application/_flash.html.erb", # We've customized this already
"app/views/application/_impersonation_banner.html.erb", # We've customized this already
"app/views/application/_navbar.html.erb", # We've customized this already
"app/views/application/_left_nav.html.erb", # We've customized this already
"app/views/application/_footer.html.erb", # We've customized this already
"app/views/application/_flash.html.erb", # We've customized this already
]
changes_to_ignore.each do |path|
`git checkout --ours #{path}`
`git add #{path}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment