2023-05-19 10:48:39 +00:00
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path')
|
2023-05-24 13:07:55 +00:00
|
|
|
var http = require('http');
|
2023-05-19 10:48:39 +00:00
|
|
|
var https = require('https');
|
2023-05-24 13:07:55 +00:00
|
|
|
var urlModule = require('url');
|
2023-05-19 10:48:39 +00:00
|
|
|
|
|
|
|
var defaultEnvironmentJsonURL = 'http://localhost:8080/ui/console/assets/environment.json'
|
|
|
|
var devEnvFile = path.join(__dirname, "src", "assets", "environment.json")
|
|
|
|
var url = process.env["ENVIRONMENT_JSON_URL"] || defaultEnvironmentJsonURL;
|
|
|
|
|
2023-05-24 13:07:55 +00:00
|
|
|
var protocol = urlModule.parse(url).protocol;
|
|
|
|
var getter = protocol === 'https:' ? https.get : http.get;
|
|
|
|
|
|
|
|
getter(url, function (res) {
|
2023-05-19 10:48:39 +00:00
|
|
|
var body = '';
|
|
|
|
|
|
|
|
res.on('data', function (chunk) {
|
|
|
|
body += chunk;
|
|
|
|
});
|
|
|
|
|
|
|
|
res.on('end', function () {
|
|
|
|
fs.writeFileSync(devEnvFile, body);
|
|
|
|
console.log("Developing against the following environment")
|
|
|
|
console.log(JSON.stringify(JSON.parse(body), null, 4))
|
|
|
|
});
|
|
|
|
}).on('error', function (e) {
|
|
|
|
console.error("Got an error: ", e);
|
|
|
|
});
|