Created
June 30, 2020 14:34
-
-
Save SeanSith/a91530d15eb7749295b2c052ba9ae54c to your computer and use it in GitHub Desktop.
Migrate from Sequel Pro to Sequel Ace
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'plist' | |
end | |
preferences_file_source = "#{ENV['HOME']}/Library/Preferences/com.sequelpro.SequelPro.plist" | |
preferences_file_destination = "#{ENV['HOME']}/Library/Containers/com.sequel-ace.sequel-ace/Data/Library/Preferences/com.sequel-ace.sequel-ace.plist" | |
favorites_file_source = "#{ENV['HOME']}/Library/Application\ Support/Sequel\ Pro/Data/Favorites.plist" | |
favorites_file_destination = "#{ENV['HOME']}/Library/Containers/com.sequel-ace.sequel-ace/Data/Library/Application\ Support/Sequel\ Ace/Data/Favorites.plist" | |
if File.exist?(preferences_file_destination) | |
print "I see that you have already opened Sequel Ace once. Do you wish to copy preferences from Sequel Pro? [y|n] " | |
exit unless gets.chomp == 'y' | |
FileUtils.cp preferences_file_source, preferences_file_destination | |
else | |
puts "You have not opened Sequel Ace. I would recommend you do this at least once to initialize all of the directories needed." | |
exit | |
end | |
if File.exist?(favorites_file_destination) | |
puts "Please note that this migration file will not merge your saved connections if you've already started using Sequel Ace." | |
puts "" | |
print "Do you wish to copy your saved connections from Sequel Pro into Sequel Ace? [y|n] " | |
exit unless gets.chomp == 'y' | |
end | |
FileUtils.cp favorites_file_source, favorites_file_destination | |
result = Plist.parse_xml(favorites_file_destination) | |
result['Favorites Root']['Children'].each do |favorite| | |
favorite_identifier = "#{favorite['name']} (#{favorite['id']})" | |
account_name = `security find-generic-password -l "Sequel Pro : #{favorite_identifier}" 2>/dev/null| grep "acct"`.split('"')[3] | |
password = `security find-generic-password -l "Sequel Pro : #{favorite_identifier}" -w 2>/dev/null` | |
next if password.empty? | |
password.chomp! | |
puts "Migrating entry for \"Sequel Pro : #{favorite_identifier}\"..." | |
puts account_name + ' : ' + password | |
`security add-generic-password -a #{ENV['USER']} -a #{account_name} -s "Sequel Ace : #{favorite_identifier}" -T "/Applications/Sequel Ace.app" -w #{password}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment