Created
July 9, 2020 21:53
-
-
Save zellio/e0306f7569c16c6e494527f65dced599 to your computer and use it in GitHub Desktop.
Rebuild AppScript files from JSON export blob
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 | |
# 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