Last active
January 21, 2019 20:27
-
-
Save mindspank/5eaf5889db82f4acac3f to your computer and use it in GitHub Desktop.
Sample use of serializeapp and buildapp #serializer #engineapi
This file contains 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
var qsocks = require('qsocks') | |
var serializeApp = require('serializeapp') | |
var fs = require('fs-extra') | |
var Promise = require('promise') | |
function create(docname) { | |
qsocks.Connect({appname: docname}) | |
.then(function(global) { | |
return global.openDoc(docname) | |
}) | |
.then(function(app) { | |
return serializeApp(app) | |
}) | |
.then(function(data) { | |
return writeJson(data) | |
}) | |
.then(function() { | |
return console.log('Done') | |
}) | |
.catch(function(error) { | |
console.log(error) | |
}).done(function() { | |
process.exit(1) | |
}); | |
}; | |
function writeJson(data) { | |
return new Promise(function(resolve, reject) { | |
fs.writeJson(data.properties.qTitle + '.json', data, function (err) { | |
if(err) { return reject(err); } | |
return resolve(); | |
}) | |
}); | |
}; | |
create(process.argv[2] || 'Executive Dashboard'); |
This file contains 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
var qsocks = require('qsocks') | |
var buildapp = require('buildapp') | |
var fs = require('fs-extra') | |
var Promise = require('promise') | |
function read(filename) { | |
return qsocks.Connect().then(function(global) { | |
return readJson(filename).then(function(data) { | |
return buildapp(global, data, { | |
filename: data.properties.qTitle + Date.now(), | |
reload: true | |
}); | |
}); | |
}) | |
}; | |
function readJson(filename) { | |
return new Promise(function(resolve, reject) { | |
return fs.readJson(filename, function (err, data) { | |
return resolve(data) | |
}) | |
}); | |
}; | |
read(process.argv[2] || 'Telecom Customer Retention.json').then(function() { | |
console.log('Done') | |
}) | |
.catch(function(error) { | |
console.log(error) | |
}) | |
.done(function() { | |
process.exit(1) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment