Created
February 15, 2018 13:42
-
-
Save mindspank/bf19359b9a3f3227643c2bb7fa6d2037 to your computer and use it in GitHub Desktop.
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
{ | |
"name": "apptofiles", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Tests?\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"enigma.js": "^2.2.0", | |
"fs-extra": "^5.0.0", | |
"promise": "^8.0.1", | |
"serializeapp": "^3.0.0", | |
"ws": "^4.0.0" | |
} | |
} |
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
const enigma = require('enigma.js') | |
const WebSocket = require('ws') | |
const serializeapp = require('serializeapp') | |
const schema = require('enigma.js/schemas/12.20.0.json') | |
const fs = require('fs-extra') | |
const APP_TO_SERIALIZE = 'Executive Dashboard.qvf' | |
// create a new session: | |
const session = enigma.create({ | |
schema, | |
url: 'ws://localhost:4848/app/engineData', | |
createSocket: url => new WebSocket(url), | |
}); | |
// open the socket and eventually receive the QIX global API, and then close | |
// the session: | |
session.open() | |
.then((global) => { | |
// Open a app | |
return global.openDoc(APP_TO_SERIALIZE) | |
}) | |
.then(app => { | |
// Pass the app into the serializer | |
return serializeapp(app) | |
}) | |
.then(result => { | |
// For each returned object, write to disk | |
return Promise.all(Object.keys(result).map(key => { | |
return fs.writeJson(key + '.json', result[key]) | |
})) | |
}) | |
.then(() => { | |
session.close() | |
console.log('All done') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment