Skip to content

Commit

Permalink
minor updated
Browse files Browse the repository at this point in the history
Signed-off-by: hpathak <[email protected]>
  • Loading branch information
hpathak committed Oct 10, 2024
1 parent e5677b5 commit 74134f4
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 132 deletions.
107 changes: 0 additions & 107 deletions playwright_test/setup.js

This file was deleted.

122 changes: 122 additions & 0 deletions playwright_test/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { submitJcl } from '../src/services/SubmitJcl';
import { startBPXBATCHAndShellSession } from '../src/services/ServiceUtils';
import { JCL_UNIX_SCRIPT_OK } from '../src/renderer/components/common/Utils';
import config from './utils/config';

// Define the response type based on what submitJcl returns
interface Response {
rc: number;
jobOutput?: { [key: string]: string };
}

// Define the type for the result that this function returns
interface CommandResult {
status: boolean;
details: string;
}

// Initialize the config object directly from the imported config
const connectArgs = {
jobStatement: `//ZWEJOB01 JOB IZUACCT,'SYSPROG',CLASS=A,\n// MSGLEVEL=(1,1),MSGCLASS=A`,
host: config.SSH_HOST,
port: config.SSH_PORT,
user: config.SSH_USER,
password: config.SSH_PASSWD
};

class Script {

async runCommand(command: string): Promise<CommandResult> {
const jcl = `${connectArgs.jobStatement}
${startBPXBATCHAndShellSession("ZNCKNOD")}
${command} &&
echo "${JCL_UNIX_SCRIPT_OK}"
/* `;
console.log(`Connecting to host: ${connectArgs.host} on port: ${connectArgs.port || 21}`);


const resp: Response = await submitJcl({
jobStatement: connectArgs.jobStatement,
host: connectArgs.host,
port: connectArgs.port || 21,
user: connectArgs.user,
password: connectArgs.password
}, jcl, ["STDOUT", "STDERR"]);

if (resp.rc === 0) {
const output = resp.jobOutput && resp.jobOutput["3"] ? resp.jobOutput["3"] : "No output found";
return { status: true, details: output };
} else {
return { status: false, details: `${resp.rc}: ${resp.jobOutput}` };
}
}


async unpax(installDir: string): Promise<CommandResult> {
const script = `cd ${installDir};\npax -ppx -rf zowe.pax;\nrm zowe.pax`;
return this.runCommand(script);
}

async download(installDir) {
try {
const { status, details: version } = await Script.getZoweVersion();
if (!status) {
throw new Error('Failed to retrieve Zowe version.');
}
const script = `URL="https://zowe.jfrog.io/zowe/list/libs-release-local/org/zowe";
curl $URL/${version}/zowe-${version}.pax
-k
-o ${installDir}/zowe.pax`
return this.run(script);
} catch (error) {
console.error('Error:', error);
return null;
}
}

static getZoweVersion() {
return new Promise((resolve, reject) => {
https.get('https://raw.githubusercontent.com/zowe/zowe-install-packaging/v2.x/master/manifest.json.template', (res) => {
let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
try {
const parsedData = JSON.parse(data);
resolve({ status: true, details: parsedData.version });
} catch (error) {
reject({ status: false, details: { error } });
}
});

}).on('error', (error) => {
reject({ status: false, details: { error } });
});
});
}
async mkdir(installDir) {
const script = `mkdir -p ${installDir}`;
return this.run(script);
}

async remove(installDir) {
const script = `rm -rf ${installDir}`;
return this.run(script);
}

async install(installDir) {
try {
await this.mkdir(installDir);
await this.download(installDir);
await this.unpax(installDir);
console.log('Installation completed successfully.');
} catch (error) {
console.error('Installation failed:', error);
}
}
}

export { connectArgs, Script };
25 changes: 0 additions & 25 deletions playwright_test/utils/sshUtils.ts

This file was deleted.

0 comments on commit 74134f4

Please sign in to comment.