Skip to content

Instantly share code, notes, and snippets.

@chrisortman
Created March 22, 2019 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisortman/e20eeef47f4a8ef9b3115029f1f111c7 to your computer and use it in GitHub Desktop.
Save chrisortman/e20eeef47f4a8ef9b3115029f1f111c7 to your computer and use it in GitHub Desktop.
Splits SIP v1 palette file to separate files you can import into SIP v2
#Run these in your terminal first to copy the file and make the output folder
#cp ~/.sip_v1/.palettes.json ~/Desktop/old_sip.palette
#mkdir -p ~/Desktop/sip
#then run this script with ruby
require 'json'
require 'securerandom'
color_ids = Hash.new { |h,k| h[k] = SecureRandom.uuid }
data = JSON.parse(File.read("#{ENV["HOME"]}/Desktop/old_sip.palette"))
data["palettes"].each_with_index do |p, index|
puts p["name"]
temp = p.dup
temp["index"] = index
temp["like"] = false
temp["dock"] = true
temp["id"] = SecureRandom.uuid
temp["createdAt"] = "2019-03-22 03:34:07"
temp["lock"] = false
temp["originalName"] = temp["name"]
temp["sip"] = {
"build" => "203",
"version" => "2.0.3"
}
temp["readonly"] = false
temp["colors"].each do |color|
name = color["name"]
color["id"] = color_ids[name]
color["createdAt"] = "2019-03-22 03:34:07"
end
File.open("#{ENV["HOME"]}/Desktop/sip/#{p["name"]}.palette","w") do |f|
f.write JSON.generate(temp)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment