Skip to content

Commit

Permalink
few fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Himani1519 <[email protected]>
  • Loading branch information
Himani1519 committed Nov 7, 2023
1 parent 99b06b2 commit 9efca25
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"build": "tsc",
"start": "tsc --watch",
"test:storage": "mocha --timeout 10000 ./test/storage/*.js",
"lint": "eslint --ext .js ."
"lint": "eslint --ext .js,.mjs ."
},
"dependencies": {
"@rocketsoftware/eureka-js-client": "~4.5.6",
Expand Down
4 changes: 2 additions & 2 deletions test/docker/appServerHandshake.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

Expand Down
4 changes: 2 additions & 2 deletions test/plugin-loader/depgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

Expand Down
4 changes: 2 additions & 2 deletions test/plugin-loader/plugin-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

Expand Down
2 changes: 2 additions & 0 deletions test/webapp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Copyright Contributors to the Zowe Project.
*/



// start with uncommenting these once a test fails
global.COM_RS_COMMON_LOGGER.setLogLevelForComponentPattern("_zsf.install", 0);
global.COM_RS_COMMON_LOGGER.setLogLevelForComponentPattern("_zsf.utils", 0);
Expand Down
4 changes: 2 additions & 2 deletions utils/install-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

Expand Down
6 changes: 3 additions & 3 deletions utils/packaging-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

import path from 'path';

Check failure on line 11 in utils/packaging-utils.js

View workflow job for this annotation

GitHub Actions / lint

incorrect header
import Promise from 'bluebird';
import fs from 'graceful-fs';
//assuming that this is file isnt being called from another that is already using the logger... else expect strange logs
import type { logging } from '../../zlux-shared/src/logging/logger.js';
import { logging } from '../../zlux-shared/src/logging/logger.js';

Check failure on line 15 in utils/packaging-utils.js

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module '../../zlux-shared/src/logging/logger.js'
const coreLogger = new logging.Logger();
//simple program, no need for logger names to be displayed
coreLogger.addDestination(coreLogger.makeDefaultDestination(true,false,false));
Expand Down
36 changes: 21 additions & 15 deletions utils/yamlConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
Copyright Contributors to the Zowe Project.
*/







import * as fs from 'fs';
import * as path from 'path';
import * as _ from 'lodash';
import * as YAML from 'yaml';
import * as mergeUtils from './mergeUtils';
import * as mergeUtils from './mergeUtils.mjs';

let debugLog:boolean = false;

Expand All @@ -37,8 +43,8 @@ export function getDefaultZoweDotYamlFile() {

// formats either /my/zowe.yaml or FILE(/my/zowe.yaml):FILE(/my/defaults.yaml)
function getJsonForYamls(configYamls: string) {
let configs = [];
let yamls = configYamls.split('FILE(');
const configs = [];
const yamls = configYamls.split('FILE(');
yamls.forEach((yaml:string)=> {
if (yaml.length>0) {
if (yaml.endsWith(')')) {
Expand All @@ -61,7 +67,7 @@ function getJsonForYamls(configYamls: string) {

let finalConfig = {};
for (let i = configs.length-1; i >= 0; i--) {
let config = configs[i];
const config = configs[i];
finalConfig = mergeUtils.deepAssign(finalConfig, config);
}
return finalConfig;
Expand All @@ -80,12 +86,12 @@ export function parseZoweDotYaml(zoweYamlPaths:string, haInstanceIdOrUndefined?:
}
const mergedConfig = mergeUtils.deepAssign(config, instanceLevelConfig ? instanceLevelConfig : {});
config = mergedConfig;
if (debugLog===true) {console.log("Merged HA instance as=\n",config)};
if (debugLog===true) {console.log("Merged HA instance as=\n",config)}
}

let resolveTries = 0;
while (resolveTries < RESOLVE_ATTEMPTS_MAX) {
let resolveResult = resolveTemplates(config, config);
const resolveResult = resolveTemplates(config, config);
config = resolveResult.property;
if (resolveResult.templates) {
resolveTries++;
Expand All @@ -108,10 +114,10 @@ export function parseZoweDotYaml(zoweYamlPaths:string, haInstanceIdOrUndefined?:
The code will attempt to resolve each template a maximum of 5 times, such that the resolver will loop over the config 5 times
And allowing templates that are 5 references deep. If the template never resolves, it is replaced with undefined.
*/
function resolveTemplates(property: any, topObj: any): {property: any, templates: boolean} {
function resolveTemplates(property: unknown, topObj: unknown): {property: unknown, templates: boolean} {
let templateFound: boolean = false;
let result = property;
let topObjKeys = Object.keys(topObj);
const topObjKeys = Object.keys(topObj);
let evalGlobalString = `var os = require('os'); `;
topObjKeys.forEach((key)=> {
evalGlobalString+=`var ${key} = topObj.${key}; `
Expand All @@ -120,14 +126,14 @@ function resolveTemplates(property: any, topObj: any): {property: any, templates
if (typeof property == 'string') {
//Array(3) [ "a/", "one }}/b/", "two }}" ]

let parts = property.split("${{ ");
const parts = property.split("${{ ");
result = '';
for (let i = 0; i < parts.length; i++) {
let partParts = parts[i].split(' }}');
const partParts = parts[i].split(' }}');
if (partParts.length > 1) {
templateFound = true;
let count = 0;
var trimmed = partParts[0];
let trimmed = partParts[0];
if (trimmed.startsWith("__ZOWE_UNRESOLVED_")) {
count = Number(partParts[0].charAt(18));
trimmed = partParts[0].substring(19);
Expand Down Expand Up @@ -169,7 +175,7 @@ function resolveTemplates(property: any, topObj: any): {property: any, templates
}
}
if (templateFound) {
let asNumber = Number(result);
const asNumber = Number(result);
if (!Number.isNaN(asNumber)) {
result = asNumber;
} else if (result === 'false') {
Expand All @@ -183,7 +189,7 @@ function resolveTemplates(property: any, topObj: any): {property: any, templates
// console.log('iterate');
result = property;
for (let i = 0; i < property.length; i++) {
let item = resolveTemplates(property[i], topObj);
const item = resolveTemplates(property[i], topObj);
if (debugLog===true && (item.property != property[i])) {
console.log(`resolved ${JSON.stringify(property[i])} as ${JSON.stringify(item.property,null,2)}`);
}
Expand All @@ -198,8 +204,8 @@ function resolveTemplates(property: any, topObj: any): {property: any, templates
const keys: string[] = Object.keys(property);
keys.forEach((key:string)=> {
// console.log('key='+key);
let value = property[key];
let update = resolveTemplates(value, topObj);
const value = property[key];
const update = resolveTemplates(value, topObj);
property[key] = update.property;
templateFound = templateFound || update.templates;
});
Expand Down

0 comments on commit 9efca25

Please sign in to comment.