@jtff/miztemplate-lib 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/jtff-lib-ci.js +13 -13
- package/package.json +1 -1
package/lib/jtff-lib-ci.js
CHANGED
|
@@ -357,28 +357,29 @@ class MizTemplateCI{
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
uploadMizFiles(credentials) {
|
|
360
|
-
const
|
|
360
|
+
const destFtpServer = new ftpClient();
|
|
361
|
+
const configObject = this.config;
|
|
361
362
|
|
|
362
|
-
|
|
363
|
+
destFtpServer.connect({
|
|
363
364
|
host: credentials.host,
|
|
364
365
|
secure: false,
|
|
365
366
|
user: credentials.user,
|
|
366
367
|
password: credentials.password
|
|
367
368
|
});
|
|
368
|
-
|
|
369
|
-
|
|
369
|
+
destFtpServer.on('ready', function () {
|
|
370
|
+
destFtpServer.cwd(credentials.folder, function (err, curDir) {
|
|
370
371
|
if (err) throw err;
|
|
371
372
|
Promise.all(
|
|
372
|
-
fs.readdirSync(
|
|
373
|
+
fs.readdirSync(configObject.general.missionFolder)
|
|
373
374
|
.filter(file => file.endsWith('.pub.json'))
|
|
374
375
|
.map(file => {
|
|
375
376
|
return new Promise((resolve, reject) => {
|
|
376
|
-
// console.log(
|
|
377
|
-
fs.readFile(
|
|
377
|
+
// console.log(configObject.general.missionFolder+'/'+file);
|
|
378
|
+
fs.readFile(configObject.general.missionFolder + '/' + file, function (err, data) {
|
|
378
379
|
if (err) reject(err);
|
|
379
380
|
data = JSON.parse(data.toString());
|
|
380
381
|
// console.log(data);
|
|
381
|
-
|
|
382
|
+
destFtpServer.put(data.mizFiles, path.basename(data.mizFiles), false, function (err) {
|
|
382
383
|
if (err) reject(err);
|
|
383
384
|
console.log('file ' + path.basename(data.mizFiles) + ' uploaded on DCS Server');
|
|
384
385
|
resolve(path.basename(data.mizFiles));
|
|
@@ -387,20 +388,20 @@ class MizTemplateCI{
|
|
|
387
388
|
})
|
|
388
389
|
})
|
|
389
390
|
).then(() => {
|
|
390
|
-
|
|
391
|
+
destFtpServer.end();
|
|
391
392
|
});
|
|
392
393
|
});
|
|
393
394
|
});
|
|
394
395
|
}
|
|
395
396
|
|
|
396
397
|
publishMizFiles(credentials) {
|
|
398
|
+
const configObject = this.config;
|
|
397
399
|
const jwtClient = new google.auth.JWT(
|
|
398
400
|
credentials.client_email,
|
|
399
401
|
null,
|
|
400
402
|
credentials.private_key,
|
|
401
|
-
|
|
403
|
+
configObject.google.scopes
|
|
402
404
|
);
|
|
403
|
-
const configObject = this.config;
|
|
404
405
|
jwtClient.authorize(function (err, tokens) {
|
|
405
406
|
if (err) {
|
|
406
407
|
console.log(err);
|
|
@@ -411,7 +412,7 @@ class MizTemplateCI{
|
|
|
411
412
|
fs.readdirSync(configObject.general.missionFolder)
|
|
412
413
|
.filter(file => file.endsWith('.pub.json'))
|
|
413
414
|
.map(file => {
|
|
414
|
-
// console.log(
|
|
415
|
+
// console.log(configObject.general.missionFolder+'/'+file);
|
|
415
416
|
fs.readFile(configObject.general.missionFolder + '/' + file, function (err, data) {
|
|
416
417
|
if (err) throw err;
|
|
417
418
|
data = JSON.parse(data.toString());
|
|
@@ -464,7 +465,6 @@ class MizTemplateCI{
|
|
|
464
465
|
}
|
|
465
466
|
});
|
|
466
467
|
}
|
|
467
|
-
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
module.exports = MizTemplateCI;
|