-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ef6299
commit 07bd986
Showing
6 changed files
with
184 additions
and
1,678 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
|
||
# dependencies | ||
/node_modules | ||
/src | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,89 @@ | ||
#! /usr/bin/env node | ||
|
||
var pjson = require('../package.json'); | ||
var args = require('minimist')(process.argv.slice(2)); | ||
var request = require('superagent'); | ||
require('superagent-proxy')(request); | ||
var admZip = require('adm-zip'); | ||
var fs = require('fs'); | ||
var utils = require('./utils'); | ||
var pjson = require("../package.json"); | ||
var args = require("minimist")(process.argv.slice(2)); | ||
var axios = require("axios"); | ||
var admZip = require("adm-zip"); | ||
var fs = require("fs"); | ||
var utils = require("./utils"); | ||
|
||
console.log("POWO CLI load-by-features Version", pjson.version); | ||
|
||
var proxy = args && args.proxy; | ||
var location = args && args.location; | ||
|
||
var project = args && args.project; | ||
var country = args && args.country || 'XX'; | ||
var country = (args && args.country) || "XX"; | ||
var platform = args && args.platform; | ||
var version = args && args.version; | ||
|
||
location = utils.checkLocationPath(location); | ||
project = utils.checkProjectName(project); | ||
|
||
console.log('proxy', proxy); | ||
console.log('location', location); | ||
console.log('project', project); | ||
console.log('country', country); | ||
console.log('platform', platform); | ||
console.log('version', version); | ||
console.log("proxy", proxy); | ||
console.log("location", location); | ||
console.log("project", project); | ||
console.log("country", country); | ||
console.log("platform", platform); | ||
console.log("version", version); | ||
|
||
var url = 'https://oss.eu-west-0.prod-cloud-ocb.orange-business.com/powo-prod-dist/' + | ||
project + '/' + country + '/' + platform + '/' + version + '/Configuration.zip'; | ||
var url = | ||
"https://oss.eu-west-0.prod-cloud-ocb.orange-business.com/powo-prod-dist/" + | ||
project + | ||
"/" + | ||
country + | ||
"/" + | ||
platform + | ||
"/" + | ||
version + | ||
"/Configuration.zip"; | ||
|
||
if (project && location) { | ||
var zipFile = location + "Configuration.zip"; | ||
|
||
var zipFile = location + 'Configuration.zip'; | ||
if (!fs.existsSync(location)) { | ||
fs.mkdirSync( | ||
location, | ||
{ | ||
recursive: true, | ||
}, | ||
function (err) { | ||
if (err) throw err; | ||
} | ||
); | ||
} | ||
|
||
if (!fs.existsSync(location)) { | ||
fs.mkdirSync(location, { | ||
recursive: true | ||
}, function (err) { | ||
if (err) | ||
throw err; | ||
}); | ||
} | ||
var axiosConfig = { | ||
responseType: "stream", | ||
}; | ||
|
||
request | ||
.get(url) | ||
.proxy(proxy) | ||
.on('error', function (error) { | ||
// console.error(error); | ||
console.e('Request error'); | ||
}) | ||
.pipe(fs.createWriteStream(zipFile)) | ||
.on('finish', function (e) { | ||
console.log('finished downloading'); | ||
var zip = new admZip(zipFile); | ||
console.log('start unzip'); | ||
zip.extractAllTo( /*target path*/ location, /*overwrite*/ true); | ||
if (proxy) { | ||
axiosConfig.httpAgent = new require("http-proxy-agent")(proxy); | ||
axiosConfig.httpsAgent = new require("https-proxy-agent")(proxy); | ||
} | ||
|
||
// Remove temp files | ||
// fs.unlinkSync(location + 'Config.json'); | ||
// fs.unlinkSync(location + 'Configuration.zip'); | ||
if (fs.existsSync(location + 'Config.json')) { | ||
fs.unlink(location + 'Config.json', function (err) { | ||
if (err) throw err; | ||
console.log('file Config deleted!'); | ||
}); | ||
} | ||
if (fs.existsSync(location + 'Configuration.json')) { | ||
fs.unlink(location + 'Configuration.json', function (err) { | ||
if (err) throw err; | ||
console.log('file Configuration deleted!'); | ||
}); | ||
} | ||
axios | ||
.get(url, axiosConfig) | ||
.then(function (response) { | ||
response.data.pipe(fs.createWriteStream(zipFile)); | ||
response.data.on("end", function () { | ||
console.log("finished downloading"); | ||
var zip = new admZip(zipFile); | ||
console.log("start unzip"); | ||
zip.extractAllTo(location, true); | ||
|
||
console.log('finished unzip'); | ||
}); | ||
// Remove temp files | ||
if (fs.existsSync(location + "Config.json")) { | ||
fs.unlinkSync(location + "Config.json"); | ||
} | ||
if (fs.existsSync(location + "Configuration.json")) { | ||
fs.unlinkSync(location + "Configuration.json"); | ||
} | ||
|
||
} | ||
console.log("finished unzip"); | ||
}); | ||
}) | ||
.catch(function (error) { | ||
console.error("Request error", error); | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,77 @@ | ||
#! /usr/bin/env node | ||
var pjson = require('../package.json'); | ||
var args = require('minimist')(process.argv.slice(2)); | ||
var request = require('request'); | ||
var fs = require('fs'); | ||
var utils = require('./utils'); | ||
var pjson = require("../package.json"); | ||
var args = require("minimist")(process.argv.slice(2)); | ||
var axios = require("axios"); | ||
var fs = require("fs"); | ||
var utils = require("./utils"); | ||
|
||
console.log("POWO CLI load-locales Version", pjson.version); | ||
|
||
var proxy = args && args.proxy; | ||
var location = args && args.location; | ||
|
||
var project = args && args.project; | ||
var country = args && args.country || 'XX'; | ||
var country = (args && args.country) || "XX"; | ||
var platform = args && args.platform; | ||
var version = args && args.version; | ||
var languages = args && args.languages; | ||
|
||
languages = languages.split(','); | ||
languages = languages.split(","); | ||
location = utils.checkLocationPath(location); | ||
project = utils.checkProjectName(project); | ||
|
||
console.log('proxy', proxy); | ||
console.log('project', project); | ||
console.log('country', country); | ||
console.log('platform', platform); | ||
console.log('version', version); | ||
console.log('languages', languages); | ||
console.log('location', location); | ||
console.log("proxy", proxy); | ||
console.log("project", project); | ||
console.log("country", country); | ||
console.log("platform", platform); | ||
console.log("version", version); | ||
console.log("languages", languages); | ||
console.log("location", location); | ||
|
||
for (var i = 0; i < languages.length; i++){ | ||
(function() { | ||
for (var i = 0; i < languages.length; i++) { | ||
(function () { | ||
var language = languages[i]; | ||
|
||
var language = languages[i]; | ||
var url = | ||
"https://oss.eu-west-0.prod-cloud-ocb.orange-business.com/powo-prod-dist/" + | ||
project + | ||
"/" + | ||
country + | ||
"/" + | ||
platform + | ||
"/" + | ||
version + | ||
"/" + | ||
language + | ||
"/Wording.json"; | ||
|
||
var url = 'https://oss.eu-west-0.prod-cloud-ocb.orange-business.com/powo-prod-dist/' + | ||
project + '/' + country + '/' + platform + '/' + version + '/' + language + '/Wording.json'; | ||
|
||
if (project && location) { | ||
|
||
var options = {}; | ||
options.url = url; | ||
options.method = "GET"; | ||
if (proxy) { | ||
options.proxy = proxy; | ||
} | ||
|
||
request(options, function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
// console.log(body); | ||
if (!fs.existsSync(location)) { | ||
fs.mkdirSync(location, { | ||
recursive: true | ||
}, function (err) { | ||
if (err) | ||
throw err; | ||
} | ||
); | ||
} | ||
fs.writeFileSync(location + language + '.json', body); | ||
} else { | ||
console.error(error, response, body); | ||
console.log('Request error'); | ||
} | ||
}); | ||
|
||
} | ||
})(i); | ||
if (project && location) { | ||
var axiosConfig = {}; | ||
if (proxy) { | ||
axiosConfig.proxy = false; | ||
axiosConfig.httpAgent = new require("http-proxy-agent")(proxy); | ||
axiosConfig.httpsAgent = new require("https-proxy-agent")(proxy); | ||
} | ||
|
||
axios | ||
.get(url, axiosConfig) | ||
.then(function (response) { | ||
if (!fs.existsSync(location)) { | ||
fs.mkdirSync( | ||
location, | ||
{ | ||
recursive: true, | ||
}, | ||
function (err) { | ||
if (err) throw err; | ||
} | ||
); | ||
} | ||
fs.writeFileSync(location + language + ".json", response.data); | ||
}) | ||
.catch(function (error) { | ||
console.error("Request error", error); | ||
}); | ||
} | ||
})(i); | ||
} |
Oops, something went wrong.