Skip to content

Commit

Permalink
Merge pull request #538 from zowe/feature/update-libraries
Browse files Browse the repository at this point in the history
Updated libraries to latest non-breaking versions
  • Loading branch information
1000TurquoisePogs authored Jun 18, 2024
2 parents 1f5d923 + 3284682 commit 7252bc1
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 2,719 deletions.
4 changes: 2 additions & 2 deletions lib/swagger-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Promise = require('bluebird');
const zLuxUrl = require('./url')
const path = require('path');
const fs = require('fs');
const jsyaml = require('js-yaml');
const yaml = require('yaml');
const swaggerParser = require('swagger-parser')
const os = require('os');
const zluxUtil = require('./util');
Expand Down Expand Up @@ -201,7 +201,7 @@ function readSingleSwaggerFile (dirName, serviceName, serviceVersion) {
if (err) {
return reject(err);
}
let swaggerJson = jsyaml.safeLoad(fileContent);
let swaggerJson = yaml.parse(fileContent);
swaggerParser.validate(swaggerJson).then(function(valid) {
return resolve(swaggerJson)
}).catch(function(err) {
Expand Down
10 changes: 4 additions & 6 deletions lib/tomcatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ unpack the wars ahead of time, so the symbolic links are the unpacked dirs
import { Path, TomcatConfig, TomcatShutdown, TomcatHttps, JavaServerManager, AppServerInfo } from './javaTypes';
import * as fs from 'graceful-fs';
import * as path from 'path';
import * as mkdirp from 'mkdirp';
import * as child_process from 'child_process';
//import * as xml2js from 'xml2js';
import * as yauzl from 'yauzl';
import * as utils from './util';
import * as rimraf from 'rimraf';

const log = utils.loggers.langManager;
const spawn = child_process.spawn;
Expand Down Expand Up @@ -63,7 +61,7 @@ export class TomcatManager implements JavaServerManager {

private makeRoot():Promise<void> {
return new Promise((resolve,reject)=> {
mkdirp(this.appdir, {mode: DIR_WRITE_MODE}, (err)=> {
fs.mkdir(this.appdir, {recursive: true, mode: DIR_WRITE_MODE}, (err)=> {
if (err) {
reject(err);
} else {
Expand Down Expand Up @@ -279,7 +277,7 @@ export class TomcatManager implements JavaServerManager {
log.info(`ZWED0092I`, this.id); //log.info(`Tomcat Manager ID=${this.id} stopping`);
TomcatManager.isWindows ? this.stopForWindows() : this.stopForUnix();
return new Promise((resolve, reject) => {
rimraf(this.appdir, (error)=> {
fs.rm(this.appdir, { recursive: true, force: true }, (error)=> {
if (error) {
reject(error);
} else {
Expand Down Expand Up @@ -368,7 +366,7 @@ export class TomcatManager implements JavaServerManager {
zipfile.on("entry", function(entry) {
if (entry.fileName.endsWith('/')) {
//directory
mkdirp(path.join(destPath,entry.fileName), {mode: DIR_WRITE_MODE}, (err)=> {
fs.mkdir(path.join(destPath,entry.fileName), {recursive: true, mode: DIR_WRITE_MODE}, (err)=> {
if (err) {
error = err;
zipfile.close();
Expand All @@ -380,7 +378,7 @@ export class TomcatManager implements JavaServerManager {
zipfile.readEntry(); //TODO is it correct to skip this?
} else {
//file
mkdirp(path.join(destPath,path.dirname(entry.fileName)), {mode: DIR_WRITE_MODE}, (err)=> {
fs.mkdir(path.join(destPath,path.dirname(entry.fileName)), {recursive: true, mode: DIR_WRITE_MODE}, (err)=> {
if (err) {
error = err;
zipfile.close();
Expand Down
23 changes: 15 additions & 8 deletions lib/translation-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';
const path = require('path');
const fs = require('fs');
const jsonUtils = require('./jsonUtils.js');
const glob = require('glob');
const zluxUtil = require('./util');
const acceptLanguageParser = require('accept-language-parser');

Expand All @@ -31,15 +31,22 @@ const utilLog = zluxUtil.loggers.utilLogger;
*/
function loadTranslations(pluginLocation) {
const translationMaps = {};
const relativePath = 'web/assets/i18n';
const filePrefix = 'pluginDefinition.i18n.';
const fileExt = '.json';
const pattern = path.join(
pluginLocation,
relativePath,
`${filePrefix}*${fileExt}`
);
const files = glob.sync(pattern, {});
const folder = path.join(pluginLocation, 'web/assets/i18n');
let files = [];
try {
files = fs.readdirSync(folder)
.filter((filename)=> {
return filename.startsWith(filePrefix) && filename.endsWith(fileExt);
})
.map((filename)=> {
return path.join(folder, filename);
});
} catch (e) {
//A plugin may not have translations and that is OK.
return translationMaps;
}
for (const file of files) {
const basename = path.basename(file);
const languageCountry = basename.substring(
Expand Down
10 changes: 8 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ if (!global.COM_RS_COMMON_LOGGER) {

const path = require('path');
const fs = require('fs');
const util = require('node:util');
const Promise = require('bluebird');
const ipaddr = require('ipaddr.js');
const dns = require('dns');
const dnsLookup = Promise.promisify(dns.lookup);
const dnsLookup = util.promisify(dns.lookup);
const mergeUtils = require('../utils/mergeUtils');
const forge = require('node-forge');

Expand Down Expand Up @@ -361,7 +362,12 @@ module.exports.uniqueIps = Promise.coroutine(function *uniqueIps(hostnames) {
if (typeof hostname == 'string') { //really... dnsLookup would not throw on a non-string such as false
try {
const ipAddress = yield dnsLookup(hostname);
set.add(ipAddress);
//This used to yield a string and now yields an object that contains a string within.
if (typeof ipAddress == 'string') {
set.add(ipAddress);
} else {
set.add(ipAddress.address);
}
} catch (e) {
loggers.network.warn(`ZWED0054W`, hostname); //loggers.network.warn(`Skipping invalid listener address=${hostname}`);
}
Expand Down
Loading

0 comments on commit 7252bc1

Please sign in to comment.