Skip to content

Instantly share code, notes, and snippets.

@zellio
Created July 9, 2020 21:53
Show Gist options
  • Save zellio/e0306f7569c16c6e494527f65dced599 to your computer and use it in GitHub Desktop.
Save zellio/e0306f7569c16c6e494527f65dced599 to your computer and use it in GitHub Desktop.
Rebuild AppScript files from JSON export blob
#!/usr/bin/env ruby
# Download the json blob from here: https://script.google.com/feeds/download/export?format=json&id=[fileId]
require 'json'
path = ARGV[1]
str = File.open(path) { |fh| fh.read }
data = JSON.parse(str, symbolize_names: true)
data[:files].each do |file|
name = file[:name]
f_type = file[:type]
source = file[:source]
extention = Hash({ "server_js" => "js", "json" => "json" })[f_type]
filename = "#{name}.#{extention}"
File.open(filename, "w").write("#{source}\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment