Last active
July 26, 2017 14:24
-
-
Save mikkpr/ecc63578b6d2c31b3df2 to your computer and use it in GitHub Desktop.
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
require 'voog_api' | |
if ARGV | |
if ARGV[0] | |
SITE = ARGV[0] | |
else | |
SITE = 'voog.local' | |
end | |
if ARGV[1] | |
TOKEN = ARGV[1] | |
else | |
TOKEN = 'b27f2c3f6193d99cc5d3604a54934c32' | |
end | |
end | |
begin | |
client = Voog::Client.new(SITE, TOKEN) | |
assets = client.layout_assets | |
layouts = client.layouts | |
asset_ids = assets.map(&:id) | |
layout_ids = layouts.map(&:id) | |
puts "Found #{assets.count} assets and #{layouts.count} layouts." | |
asset_ids.each do |id| | |
asset = assets.find{|a| a.id == id} | |
print "Deleting asset '#{asset.filename}'." | |
begin | |
client.delete_layout_asset(id) | |
rescue | |
print " <- deleting failed!" | |
ensure | |
print "\n" | |
end | |
end | |
layout_ids.each do |id| | |
layout = layouts.find{|a| a.id == id} | |
print "Deleting #{layout.component ? 'component' : 'layout'} '#{layout.title}'." | |
begin | |
client.delete_layout(id) | |
rescue | |
print " <- deleting failed!" | |
ensure | |
print "\n" | |
end | |
end | |
rescue => e | |
puts e.inspect | |
puts "Something went wrong!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment