From 53bb0444f2652e3b6465aeb551d16fd684f6ff16 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 23 Aug 2024 11:36:01 +0200 Subject: [PATCH 01/10] Add job header Signed-off-by: Martin Zeithaml --- bin/commands/init/generate/index.ts | 8 +++++++- files/SZWESAMP/ZWECSRVS | 2 +- files/SZWESAMP/ZWECSVSM | 2 +- files/SZWESAMP/ZWEGENER | 2 +- files/SZWESAMP/ZWEIACF | 2 +- files/SZWESAMP/ZWEIACFZ | 2 +- files/SZWESAMP/ZWEIAPF | 2 +- files/SZWESAMP/ZWEIAPF2 | 2 +- files/SZWESAMP/ZWEIKRA1 | 2 +- files/SZWESAMP/ZWEIKRA2 | 2 +- files/SZWESAMP/ZWEIKRA3 | 2 +- files/SZWESAMP/ZWEIKRR1 | 2 +- files/SZWESAMP/ZWEIKRR2 | 2 +- files/SZWESAMP/ZWEIKRR3 | 2 +- files/SZWESAMP/ZWEIKRT1 | 2 +- files/SZWESAMP/ZWEIKRT2 | 2 +- files/SZWESAMP/ZWEIKRT3 | 2 +- files/SZWESAMP/ZWEIMVS | 2 +- files/SZWESAMP/ZWEIMVS2 | 2 +- files/SZWESAMP/ZWEINSTL | 2 +- files/SZWESAMP/ZWEIRAC | 2 +- files/SZWESAMP/ZWEIRACZ | 2 +- files/SZWESAMP/ZWEISTC | 2 +- files/SZWESAMP/ZWEITSS | 2 +- files/SZWESAMP/ZWEITSSZ | 2 +- files/SZWESAMP/ZWENOKRA | 2 +- files/SZWESAMP/ZWENOKRR | 2 +- files/SZWESAMP/ZWENOKRT | 2 +- files/SZWESAMP/ZWENOSEC | 2 +- files/SZWESAMP/ZWERMVS | 2 +- files/SZWESAMP/ZWERMVS2 | 2 +- files/SZWESAMP/ZWERSTC | 2 +- files/defaults.yaml | 2 ++ schemas/zowe-yaml-schema.json | 2 +- 34 files changed, 41 insertions(+), 33 deletions(-) diff --git a/bin/commands/init/generate/index.ts b/bin/commands/init/generate/index.ts index ef39f4245a..943bb35ed9 100644 --- a/bin/commands/init/generate/index.ts +++ b/bin/commands/init/generate/index.ts @@ -15,7 +15,6 @@ import * as xplatform from "xplatform"; import * as fs from '../../../libs/fs'; import * as config from '../../../libs/config'; import * as common from '../../../libs/common'; -import * as stringlib from '../../../libs/string'; import * as zosFs from '../../../libs/zos-fs'; import * as zosJes from '../../../libs/zos-jes'; @@ -33,6 +32,12 @@ export function execute(dryRun?: boolean) { common.printErrorAndExit(`Error ZWEL0157E: Zowe runtime directory (zowe.runtimeDirectory) is not defined in Zowe YAML configuration file.`, undefined, 157); } + let jclHeader = ZOWE_CONFIG.zowe.environments.jclHeader; + if (jclHeader.length > (71 - '//ZWEGENER JOB '.length)) { + common.printError(`Error ZWEL9999E: JOB statement too long: //ZWEGENER JOB ${jclHeader}`); + jclHeader = ''; + } + const tempFile = fs.createTmpFile(); if (zosFs.copyMvsToUss(ZOWE_CONFIG.zowe.setup.dataset.prefix + '.SZWESAMP(ZWEGENER)', tempFile) !== 0) { common.printErrorAndExit(`ZWEL0143E Cannot find data set member '${ZOWE_CONFIG.zowe.setup.dataset.prefix + '.SZWESAMP(ZWEGENER)'}'. You may need to re-run zwe install.`, undefined, 143); @@ -44,6 +49,7 @@ export function execute(dryRun?: boolean) { // $$ inserts a '$', replace(/[$]/g, '$$$$') => double each '$' occurence jclContents = jclContents.replace(/\{zowe\.setup\.dataset\.prefix\}/gi, prefix.replace(/[$]/g, '$$$$')); jclContents = jclContents.replace(/\{zowe\.runtimeDirectory\}/gi, runtimeDirectory.replace(/[$]/g, '$$$$')); + jclContents = jclContents.replace(/\{zowe\.environments\.jclHeader\}/i,jclHeader.replace(/[$]/g, '$$$$')); if (std.getenv('ZWE_PRIVATE_LOG_LEVEL_ZWELS') !== 'INFO') { jclContents = jclContents.replace('noverbose -', 'verbose -'); } diff --git a/files/SZWESAMP/ZWECSRVS b/files/SZWESAMP/ZWECSRVS index 9c5d83c92f..22fd52a446 100644 --- a/files/SZWESAMP/ZWECSRVS +++ b/files/SZWESAMP/ZWECSRVS @@ -1,4 +1,4 @@ -//ZWECSRVS JOB +//ZWECSRVS JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWECSVSM b/files/SZWESAMP/ZWECSVSM index 226b0dbd6f..633d84ceeb 100644 --- a/files/SZWESAMP/ZWECSVSM +++ b/files/SZWESAMP/ZWECSVSM @@ -1,4 +1,4 @@ -//ZWECSVSM JOB +//ZWECSVSM JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEGENER b/files/SZWESAMP/ZWEGENER index 75d8b165cd..8fcf8b78df 100644 --- a/files/SZWESAMP/ZWEGENER +++ b/files/SZWESAMP/ZWEGENER @@ -1,4 +1,4 @@ -//ZWEGENER JOB +//ZWEGENER JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIACF b/files/SZWESAMP/ZWEIACF index 62910ee95c..bd3f7a41c1 100644 --- a/files/SZWESAMP/ZWEIACF +++ b/files/SZWESAMP/ZWEIACF @@ -1,4 +1,4 @@ -//ZWEIACF JOB +//ZWEIACF JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIACFZ b/files/SZWESAMP/ZWEIACFZ index 1d613d4d6b..d5472aef8c 100644 --- a/files/SZWESAMP/ZWEIACFZ +++ b/files/SZWESAMP/ZWEIACFZ @@ -1,4 +1,4 @@ -//ZWEIACFZ JOB +//ZWEIACFZ JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIAPF b/files/SZWESAMP/ZWEIAPF index 604817d09f..58ede4a57e 100644 --- a/files/SZWESAMP/ZWEIAPF +++ b/files/SZWESAMP/ZWEIAPF @@ -1,4 +1,4 @@ -//ZWEIAPF JOB +//ZWEIAPF JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIAPF2 b/files/SZWESAMP/ZWEIAPF2 index 8d97849373..b1e9674d06 100644 --- a/files/SZWESAMP/ZWEIAPF2 +++ b/files/SZWESAMP/ZWEIAPF2 @@ -1,4 +1,4 @@ -//ZWEIAPF2 JOB +//ZWEIAPF2 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRA1 b/files/SZWESAMP/ZWEIKRA1 index 696a2c87b1..e55f4b9d9d 100644 --- a/files/SZWESAMP/ZWEIKRA1 +++ b/files/SZWESAMP/ZWEIKRA1 @@ -1,4 +1,4 @@ -//ZWEIKRA1 JOB +//ZWEIKRA1 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRA2 b/files/SZWESAMP/ZWEIKRA2 index f43a32322c..c66aa1e525 100644 --- a/files/SZWESAMP/ZWEIKRA2 +++ b/files/SZWESAMP/ZWEIKRA2 @@ -1,4 +1,4 @@ -//ZWEIKRA2 JOB +//ZWEIKRA2 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRA3 b/files/SZWESAMP/ZWEIKRA3 index bd27148a5a..1a6d5b34d6 100644 --- a/files/SZWESAMP/ZWEIKRA3 +++ b/files/SZWESAMP/ZWEIKRA3 @@ -1,4 +1,4 @@ -//ZWEIKRA3 JOB +//ZWEIKRA3 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRR1 b/files/SZWESAMP/ZWEIKRR1 index 952ea2107b..dc4c156b9a 100644 --- a/files/SZWESAMP/ZWEIKRR1 +++ b/files/SZWESAMP/ZWEIKRR1 @@ -1,4 +1,4 @@ -//ZWEIKRR1 JOB +//ZWEIKRR1 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRR2 b/files/SZWESAMP/ZWEIKRR2 index 4a301b49ff..69559bf14c 100644 --- a/files/SZWESAMP/ZWEIKRR2 +++ b/files/SZWESAMP/ZWEIKRR2 @@ -1,4 +1,4 @@ -//ZWEIKRR2 JOB +//ZWEIKRR2 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRR3 b/files/SZWESAMP/ZWEIKRR3 index 8d64126a26..9828644505 100644 --- a/files/SZWESAMP/ZWEIKRR3 +++ b/files/SZWESAMP/ZWEIKRR3 @@ -1,4 +1,4 @@ -//ZWEIKRR3 JOB +//ZWEIKRR3 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRT1 b/files/SZWESAMP/ZWEIKRT1 index 499ea9d1fa..a4b77acebd 100644 --- a/files/SZWESAMP/ZWEIKRT1 +++ b/files/SZWESAMP/ZWEIKRT1 @@ -1,4 +1,4 @@ -//ZWEIKRT1 JOB +//ZWEIKRT1 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRT2 b/files/SZWESAMP/ZWEIKRT2 index 255d692984..b73cb88563 100644 --- a/files/SZWESAMP/ZWEIKRT2 +++ b/files/SZWESAMP/ZWEIKRT2 @@ -1,4 +1,4 @@ -//ZWEIKRT2 JOB +//ZWEIKRT2 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIKRT3 b/files/SZWESAMP/ZWEIKRT3 index f4ed3e6ecb..0d41e54026 100644 --- a/files/SZWESAMP/ZWEIKRT3 +++ b/files/SZWESAMP/ZWEIKRT3 @@ -1,4 +1,4 @@ -//ZWEIKRT3 JOB +//ZWEIKRT3 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIMVS b/files/SZWESAMP/ZWEIMVS index e8e4b6caef..659b58870f 100644 --- a/files/SZWESAMP/ZWEIMVS +++ b/files/SZWESAMP/ZWEIMVS @@ -1,4 +1,4 @@ -//ZWEIMVS JOB +//ZWEIMVS JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIMVS2 b/files/SZWESAMP/ZWEIMVS2 index 93a3213a62..9bb7ec82ec 100644 --- a/files/SZWESAMP/ZWEIMVS2 +++ b/files/SZWESAMP/ZWEIMVS2 @@ -1,4 +1,4 @@ -//ZWEIMVS2 JOB +//ZWEIMVS2 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEINSTL b/files/SZWESAMP/ZWEINSTL index 3a02863936..d3d937dddc 100644 --- a/files/SZWESAMP/ZWEINSTL +++ b/files/SZWESAMP/ZWEINSTL @@ -1,4 +1,4 @@ -//ZWEINSTL JOB +//ZWEINSTL JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIRAC b/files/SZWESAMP/ZWEIRAC index 6ac0aadb89..07ecccb404 100644 --- a/files/SZWESAMP/ZWEIRAC +++ b/files/SZWESAMP/ZWEIRAC @@ -1,4 +1,4 @@ -//ZWEIRAC JOB +//ZWEIRAC JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEIRACZ b/files/SZWESAMP/ZWEIRACZ index 0c393bde43..5c4a0eb5c4 100644 --- a/files/SZWESAMP/ZWEIRACZ +++ b/files/SZWESAMP/ZWEIRACZ @@ -1,4 +1,4 @@ -//ZWEIRACZ JOB +//ZWEIRACZ JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEISTC b/files/SZWESAMP/ZWEISTC index 401e4510f4..3b399e4d6d 100644 --- a/files/SZWESAMP/ZWEISTC +++ b/files/SZWESAMP/ZWEISTC @@ -1,4 +1,4 @@ -//ZWEISTC JOB +//ZWEISTC JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEITSS b/files/SZWESAMP/ZWEITSS index 512ef8c8f6..089b64bed2 100644 --- a/files/SZWESAMP/ZWEITSS +++ b/files/SZWESAMP/ZWEITSS @@ -1,4 +1,4 @@ -//ZWEITSS JOB +//ZWEITSS JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWEITSSZ b/files/SZWESAMP/ZWEITSSZ index 6669c3b5c0..dfb1d0c00a 100644 --- a/files/SZWESAMP/ZWEITSSZ +++ b/files/SZWESAMP/ZWEITSSZ @@ -1,4 +1,4 @@ -//ZWEITSSZ JOB +//ZWEITSSZ JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWENOKRA b/files/SZWESAMP/ZWENOKRA index edd66603d8..d240a76ee2 100644 --- a/files/SZWESAMP/ZWENOKRA +++ b/files/SZWESAMP/ZWENOKRA @@ -1,4 +1,4 @@ -//ZWENOKRA JOB +//ZWENOKRA JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWENOKRR b/files/SZWESAMP/ZWENOKRR index db07aa46d5..3890902800 100644 --- a/files/SZWESAMP/ZWENOKRR +++ b/files/SZWESAMP/ZWENOKRR @@ -1,4 +1,4 @@ -//ZWENOKRR JOB +//ZWENOKRR JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWENOKRT b/files/SZWESAMP/ZWENOKRT index 9a14e5be05..d3e59707b5 100644 --- a/files/SZWESAMP/ZWENOKRT +++ b/files/SZWESAMP/ZWENOKRT @@ -1,4 +1,4 @@ -//ZWENOKRT JOB +//ZWENOKRT JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWENOSEC b/files/SZWESAMP/ZWENOSEC index 623b1e166e..7600e52b4e 100644 --- a/files/SZWESAMP/ZWENOSEC +++ b/files/SZWESAMP/ZWENOSEC @@ -1,4 +1,4 @@ -//ZWENOSEC JOB +//ZWENOSEC JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWERMVS b/files/SZWESAMP/ZWERMVS index 844e027dcf..8000d36c7a 100644 --- a/files/SZWESAMP/ZWERMVS +++ b/files/SZWESAMP/ZWERMVS @@ -1,4 +1,4 @@ -//ZWERMVS JOB +//ZWERMVS JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWERMVS2 b/files/SZWESAMP/ZWERMVS2 index 266f60099a..9a1a554920 100644 --- a/files/SZWESAMP/ZWERMVS2 +++ b/files/SZWESAMP/ZWERMVS2 @@ -1,4 +1,4 @@ -//ZWERMVS2 JOB +//ZWERMVS2 JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/SZWESAMP/ZWERSTC b/files/SZWESAMP/ZWERSTC index 80491c5d48..e20686af03 100644 --- a/files/SZWESAMP/ZWERSTC +++ b/files/SZWESAMP/ZWERSTC @@ -1,4 +1,4 @@ -//ZWERSTC JOB +//ZWERSTC JOB {zowe.environments.jclHeader} //* //* This program and the accompanying materials are made available //* under the terms of the Eclipse Public License v2.0 which diff --git a/files/defaults.yaml b/files/defaults.yaml index 8705166e9a..0440257270 100644 --- a/files/defaults.yaml +++ b/files/defaults.yaml @@ -27,6 +27,8 @@ zowe: #------------------------------------------------------------------------------- # These configurations are used by "zwe install" or "zwe init" commands. #------------------------------------------------------------------------------- + environments: + jclHeader: '' setup: # MVS data set related configurations dataset: diff --git a/schemas/zowe-yaml-schema.json b/schemas/zowe-yaml-schema.json index bd17532cd3..df7b978c92 100644 --- a/schemas/zowe-yaml-schema.json +++ b/schemas/zowe-yaml-schema.json @@ -197,7 +197,7 @@ "default": "local_ca_password" }, "lock": { - "type": [ "string", "null" ], + "type": [ "boolean", "null" ], "description": "Whether to restrict the permissions of the keystore after creation" }, "import": { From 2ccb9696bf21a7b5d715616f490c6115cdf6b374 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Tue, 3 Sep 2024 16:43:59 +0200 Subject: [PATCH 02/10] Postprocessing Signed-off-by: Martin Zeithaml --- bin/commands/init/generate/index.ts | 25 ++++++++++++++--- bin/libs/zos-dataset.ts | 43 +++++++++++++++++++++++++++++ files/SZWEEXEC/ZWEGEN00 | 4 +++ 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/bin/commands/init/generate/index.ts b/bin/commands/init/generate/index.ts index 943bb35ed9..0778d8868a 100644 --- a/bin/commands/init/generate/index.ts +++ b/bin/commands/init/generate/index.ts @@ -15,6 +15,9 @@ import * as xplatform from "xplatform"; import * as fs from '../../../libs/fs'; import * as config from '../../../libs/config'; import * as common from '../../../libs/common'; +import * as shell from '../../../libs/shell'; +import * as stringlib from '../../../libs/string'; +import * as zosDataset from '../../../libs/zos-dataset'; import * as zosFs from '../../../libs/zos-fs'; import * as zosJes from '../../../libs/zos-jes'; @@ -32,11 +35,12 @@ export function execute(dryRun?: boolean) { common.printErrorAndExit(`Error ZWEL0157E: Zowe runtime directory (zowe.runtimeDirectory) is not defined in Zowe YAML configuration file.`, undefined, 157); } + let jclPostProcessing = false; let jclHeader = ZOWE_CONFIG.zowe.environments.jclHeader; - if (jclHeader.length > (71 - '//ZWEGENER JOB '.length)) { - common.printError(`Error ZWEL9999E: JOB statement too long: //ZWEGENER JOB ${jclHeader}`); - jclHeader = ''; - } + // Is it multiline jclHeader? + if (jclHeader && (jclHeader.match(/\n/g)||[]).length) { + jclPostProcessing = true; + } const tempFile = fs.createTmpFile(); if (zosFs.copyMvsToUss(ZOWE_CONFIG.zowe.setup.dataset.prefix + '.SZWESAMP(ZWEGENER)', tempFile) !== 0) { @@ -109,6 +113,19 @@ export function execute(dryRun?: boolean) { common.printMessage(`Job completed with RC=${result.rc}`); if (result.rc == 0) { + if (jclPostProcessing) { + const memList = zosDataset.listDatasetMembers(ZOWE_CONFIG.zowe.setup.dataset.jcllib); + common.printDebug(` - Adding "${jclHeader}" to:`); + for (let m = 0; m < memList.length; m++) { + common.printDebug(` - Member ${ZOWE_CONFIG.zowe.setup.dataset.jcllib}(${memList[m]})`); + let catResult = shell.execOutSync('sh', '-c', `cat "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); + if (catResult.rc == 0) { + jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeader.replace(/[$]/g, '$$$$')); + xplatform.storeFileUTF8(tempFile, xplatform.AUTO_DETECT, jclContents); + shell.execSync('sh', '-c', `cp "${tempFile}" "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); + } + } + } common.printMessage("Zowe JCL generated successfully"); } else { common.printMessage(`Zowe JCL generated with errors, check job log. Job completion code=${result.jobcccode}, Job completion text=${result.jobcctext}`); diff --git a/bin/libs/zos-dataset.ts b/bin/libs/zos-dataset.ts index 6348b67b1e..222d529c73 100644 --- a/bin/libs/zos-dataset.ts +++ b/bin/libs/zos-dataset.ts @@ -181,3 +181,46 @@ export function isDatasetSmsManaged(dataset: string): { rc: number, smsManaged?: return { rc: 1 }; } } + +export function listDatasetMembers(dsName: string): string[] { + // LISTDS 'ZOWE.JCLLIB' MEMBERS + // ZOWE.JCLLIB + // --RECFM-LRECL-BLKSIZE-DSORG + // FB 80 27920 PO + // --VOLUMES-- + // VOL123 + // --MEMBERS-- + // ZWECSRVS + // ZWECSVSM + // ZWEIAPF + // ZWEIAPF2 + const listDSCommand = `LISTDS '${stringlib.escapeDollar(dsName)}' MEMBERS`; + common.printTrace(` * listDatasetMembers in: "${listDSCommand}"`); + const result = zoslib.tsoCommand(listDSCommand); + let listOfMembers = []; + if (result.rc == 0) { + common.printDebug(" * Succeeded"); + common.printTrace(` * Exit code: ${result.rc}`); + common.printTrace(" * Output:"); + common.printTrace(stringlib.paddingLeft(result.out, " ")); + let validMemberName = false; + let output = result.out.split("\n"); + for (let m = 0; m < output.length; m++) { + let member = output[m].trim(); + if (member && validMemberName) { + listOfMembers.push(member); + } + if (member == '--MEMBERS--') { + validMemberName = true; + } + } + } + else { + common.printDebug(" * Failed"); + common.printTrace(` * Exit code: ${result.rc}`); + common.printTrace(" * Output:"); + common.printError(stringlib.paddingLeft(result.out, " ")); + } + common.printTrace(` * listDatasetMembers out: "${listOfMembers}"`); + return listOfMembers; +} diff --git a/files/SZWEEXEC/ZWEGEN00 b/files/SZWEEXEC/ZWEGEN00 index 23012082aa..7304a2334e 100644 --- a/files/SZWEEXEC/ZWEGEN00 +++ b/files/SZWEEXEC/ZWEGEN00 @@ -326,6 +326,7 @@ say 'All of the substitutions were found.' /* ================================================================================ Invoke the edit macro on the substitutions for each member. + Skip zowe.environments.jclHeader if contains \n (x'15') ZWECHG: change all word1 word2 word1 is expected to be {zowe.something} word2 is anything, including spaces, single or double apostrophes @@ -341,6 +342,9 @@ do i = 1 to members.0 call Print 'Edit 'd'.' old = '{'members.i.substitutions.j'}' new = value('CFG.'members.i.substitutions.j) + if old = '{zowe.environments.jclHeader}' then + if pos(x2c('15'), new) > 0 then + iterate j apostrophes1 = "'" apostrophes2 = "'" if pos("'", new) > 0 & pos('"', new) = 0 then do From 0524784542db9b1d6869e4114ec770e4c44214c0 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 4 Sep 2024 09:17:05 +0200 Subject: [PATCH 03/10] Minor changes Signed-off-by: Martin Zeithaml --- bin/commands/init/generate/index.ts | 14 +++++++++----- bin/libs/zos-dataset.ts | 20 +++++--------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/bin/commands/init/generate/index.ts b/bin/commands/init/generate/index.ts index 0778d8868a..3873c991dd 100644 --- a/bin/commands/init/generate/index.ts +++ b/bin/commands/init/generate/index.ts @@ -109,22 +109,26 @@ export function execute(dryRun?: boolean) { common.printMessage('Submitting Job ZWEGENER'); const jobid = zosJes.submitJob(tempFile); const result = zosJes.waitForJob(jobid); - os.remove(tempFile); - + if (!jclPostProcessing) { + os.remove(tempFile); + } common.printMessage(`Job completed with RC=${result.rc}`); if (result.rc == 0) { if (jclPostProcessing) { const memList = zosDataset.listDatasetMembers(ZOWE_CONFIG.zowe.setup.dataset.jcllib); - common.printDebug(` - Adding "${jclHeader}" to:`); - for (let m = 0; m < memList.length; m++) { + if (!memList.length) { + common.printDebug(` - Adding "${jclHeader}" to:`); + for (let m = 0; m < memList.length; m++) { common.printDebug(` - Member ${ZOWE_CONFIG.zowe.setup.dataset.jcllib}(${memList[m]})`); let catResult = shell.execOutSync('sh', '-c', `cat "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); - if (catResult.rc == 0) { + if (catResult.rc == 0 && catResult.out) { jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeader.replace(/[$]/g, '$$$$')); xplatform.storeFileUTF8(tempFile, xplatform.AUTO_DETECT, jclContents); shell.execSync('sh', '-c', `cp "${tempFile}" "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); } + } } + os.remove(tempFile); } common.printMessage("Zowe JCL generated successfully"); } else { diff --git a/bin/libs/zos-dataset.ts b/bin/libs/zos-dataset.ts index 222d529c73..f80c4883f6 100644 --- a/bin/libs/zos-dataset.ts +++ b/bin/libs/zos-dataset.ts @@ -4,9 +4,9 @@ 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. */ @@ -115,7 +115,7 @@ export function isDatasetSmsManaged(dataset: string): { rc: number, smsManaged?: // listds 'IBMUSER.LOADLIB' label // IBMUSER.LOADLIB // --RECFM-LRECL-BLKSIZE-DSORG - // U ** 6144 PO + // U ** 6144 PO // --VOLUMES-- // VPMVSH // --FORMAT 1 DSCB-- @@ -197,12 +197,8 @@ export function listDatasetMembers(dsName: string): string[] { const listDSCommand = `LISTDS '${stringlib.escapeDollar(dsName)}' MEMBERS`; common.printTrace(` * listDatasetMembers in: "${listDSCommand}"`); const result = zoslib.tsoCommand(listDSCommand); - let listOfMembers = []; - if (result.rc == 0) { - common.printDebug(" * Succeeded"); - common.printTrace(` * Exit code: ${result.rc}`); - common.printTrace(" * Output:"); - common.printTrace(stringlib.paddingLeft(result.out, " ")); + let listOfMembers: string[] = []; + if (result.rc == 0 && result.out) { let validMemberName = false; let output = result.out.split("\n"); for (let m = 0; m < output.length; m++) { @@ -215,12 +211,6 @@ export function listDatasetMembers(dsName: string): string[] { } } } - else { - common.printDebug(" * Failed"); - common.printTrace(` * Exit code: ${result.rc}`); - common.printTrace(" * Output:"); - common.printError(stringlib.paddingLeft(result.out, " ")); - } common.printTrace(` * listDatasetMembers out: "${listOfMembers}"`); return listOfMembers; } From 0686ee8085edf2303ffb4d1c5108f0bdb0fa120f Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 4 Sep 2024 11:12:37 +0200 Subject: [PATCH 04/10] Help and support for array Signed-off-by: Martin Zeithaml --- bin/commands/init/generate/.help | 30 +++++++++++++++++++++++++++++ bin/commands/init/generate/index.ts | 16 ++++++++++----- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/bin/commands/init/generate/.help b/bin/commands/init/generate/.help index 3435621e50..711eb39944 100644 --- a/bin/commands/init/generate/.help +++ b/bin/commands/init/generate/.help @@ -2,6 +2,8 @@ Generate ready to execute JCL samples from zowe.yaml configuration values. This command executes the job ZWEGENER which copies the JCL templates from Zowe's SZWESAMP dataset, except those not valid for your system ESM, and creates resolved, ready to execute JCL content within the dataset defined by the zowe.yaml property `zowe.setup.dataset.jcllib` (such as `zowe.setup.dataset.prefix` + "CUST.JCLLIB") +If you need to customize the JOB statements, set the zowe.yaml property `zowe.environments.jclHeader`. See examples at the end of this help. + These JCL files can be run by any means desired afterward. The actions of `zwe init` will run them automatically if desired. Each `zwe init` action has a `--dry-run` command which will print the value of the particular JCL file used, but not submit it. @@ -64,3 +66,31 @@ If you want to use a premade keyring with Zowe, do not run these. These are for The above datasets can be run to set up a Zowe instance. You can also use `zwe init` or `zwe init` subcommands to have them run automatically. + +JCL JOB statement customization: +- Each JOB statement is defined as `//ZWEnnnnn JOB {zowe.environments.jclHeader}`, where `nnnnn` identifies each job +- Default setting is empty string causing no additional JOB fields will be used - if your site or External Security Manager does not require additional fields, you can skip this +- Otherwise you can use `zwe init generate` to set additional JOB fields +- Note: JCL syntax is not checked by `zwe init generate` command + +Accounting information only: +```yaml +zowe: + environments: + jclHeader: 123456 +``` +Additional fields as one string: +```yaml +zowe: + environments: + jclHeader: "123456,\n// 'Zowe User',\n// NOTIFY=&SYSUID" +``` +Additional fields as an array: +```yaml +zowe: + environments: + jclHeader: + - "123456," + - "// 'Zowe User'," + - "// NOTIFY=&SYSUID" +``` diff --git a/bin/commands/init/generate/index.ts b/bin/commands/init/generate/index.ts index 3873c991dd..67c1996e27 100644 --- a/bin/commands/init/generate/index.ts +++ b/bin/commands/init/generate/index.ts @@ -36,11 +36,17 @@ export function execute(dryRun?: boolean) { } let jclPostProcessing = false; + let jclHeaderAsOneLine = ''; let jclHeader = ZOWE_CONFIG.zowe.environments.jclHeader; - // Is it multiline jclHeader? - if (jclHeader && (jclHeader.match(/\n/g)||[]).length) { + if (Array.isArray(jclHeader)) { + jclPostProcessing = true; + jclHeaderAsOneLine = jclHeader.join("\n"); + } else { + jclHeaderAsOneLine = jclHeader; + if (jclHeader && (jclHeader.match(/\n/g) || []).length) { jclPostProcessing = true; } + } const tempFile = fs.createTmpFile(); if (zosFs.copyMvsToUss(ZOWE_CONFIG.zowe.setup.dataset.prefix + '.SZWESAMP(ZWEGENER)', tempFile) !== 0) { @@ -53,7 +59,7 @@ export function execute(dryRun?: boolean) { // $$ inserts a '$', replace(/[$]/g, '$$$$') => double each '$' occurence jclContents = jclContents.replace(/\{zowe\.setup\.dataset\.prefix\}/gi, prefix.replace(/[$]/g, '$$$$')); jclContents = jclContents.replace(/\{zowe\.runtimeDirectory\}/gi, runtimeDirectory.replace(/[$]/g, '$$$$')); - jclContents = jclContents.replace(/\{zowe\.environments\.jclHeader\}/i,jclHeader.replace(/[$]/g, '$$$$')); + jclContents = jclContents.replace(/\{zowe\.environments\.jclHeader\}/i,jclHeaderAsOneLine.replace(/[$]/g, '$$$$')); if (std.getenv('ZWE_PRIVATE_LOG_LEVEL_ZWELS') !== 'INFO') { jclContents = jclContents.replace('noverbose -', 'verbose -'); } @@ -117,12 +123,12 @@ export function execute(dryRun?: boolean) { if (jclPostProcessing) { const memList = zosDataset.listDatasetMembers(ZOWE_CONFIG.zowe.setup.dataset.jcllib); if (!memList.length) { - common.printDebug(` - Adding "${jclHeader}" to:`); + common.printDebug(` - Adding "${jclHeaderAsOneLine}" to:`); for (let m = 0; m < memList.length; m++) { common.printDebug(` - Member ${ZOWE_CONFIG.zowe.setup.dataset.jcllib}(${memList[m]})`); let catResult = shell.execOutSync('sh', '-c', `cat "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); if (catResult.rc == 0 && catResult.out) { - jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeader.replace(/[$]/g, '$$$$')); + jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeaderAsOneLine.replace(/[$]/g, '$$$$')); xplatform.storeFileUTF8(tempFile, xplatform.AUTO_DETECT, jclContents); shell.execSync('sh', '-c', `cp "${tempFile}" "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); } From 54fe6c9aeafd26dcc1e3f31e368ddf96ffa7be0b Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 5 Sep 2024 15:06:58 +0200 Subject: [PATCH 05/10] Skip members if change not needed Signed-off-by: Martin Zeithaml --- bin/commands/init/generate/index.ts | 33 ++++++++++++++++++----------- files/SZWEEXEC/ZWEGEN00 | 7 ++++-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/bin/commands/init/generate/index.ts b/bin/commands/init/generate/index.ts index 67c1996e27..ee211ae37c 100644 --- a/bin/commands/init/generate/index.ts +++ b/bin/commands/init/generate/index.ts @@ -36,15 +36,15 @@ export function execute(dryRun?: boolean) { } let jclPostProcessing = false; - let jclHeaderAsOneLine = ''; - let jclHeader = ZOWE_CONFIG.zowe.environments.jclHeader; + let jclHeaderJoined = ''; + const jclHeader = ZOWE_CONFIG.zowe.environments.jclHeader; if (Array.isArray(jclHeader)) { jclPostProcessing = true; - jclHeaderAsOneLine = jclHeader.join("\n"); + jclHeaderJoined = jclHeader.join("\n"); } else { - jclHeaderAsOneLine = jclHeader; - if (jclHeader && (jclHeader.match(/\n/g) || []).length) { - jclPostProcessing = true; + jclHeaderJoined = jclHeader.toString(); + if (jclHeaderJoined && (jclHeaderJoined.match(/\n/g) || []).length) { + jclPostProcessing = true; } } @@ -59,7 +59,7 @@ export function execute(dryRun?: boolean) { // $$ inserts a '$', replace(/[$]/g, '$$$$') => double each '$' occurence jclContents = jclContents.replace(/\{zowe\.setup\.dataset\.prefix\}/gi, prefix.replace(/[$]/g, '$$$$')); jclContents = jclContents.replace(/\{zowe\.runtimeDirectory\}/gi, runtimeDirectory.replace(/[$]/g, '$$$$')); - jclContents = jclContents.replace(/\{zowe\.environments\.jclHeader\}/i,jclHeaderAsOneLine.replace(/[$]/g, '$$$$')); + jclContents = jclContents.replace(/\{zowe\.environments\.jclHeader\}/i,jclHeaderJoined.replace(/[$]/g, '$$$$')); if (std.getenv('ZWE_PRIVATE_LOG_LEVEL_ZWELS') !== 'INFO') { jclContents = jclContents.replace('noverbose -', 'verbose -'); } @@ -122,21 +122,30 @@ export function execute(dryRun?: boolean) { if (result.rc == 0) { if (jclPostProcessing) { const memList = zosDataset.listDatasetMembers(ZOWE_CONFIG.zowe.setup.dataset.jcllib); - if (!memList.length) { + if (memList.length) { common.printDebug(` - Adding "${jclHeaderAsOneLine}" to:`); for (let m = 0; m < memList.length; m++) { - common.printDebug(` - Member ${ZOWE_CONFIG.zowe.setup.dataset.jcllib}(${memList[m]})`); let catResult = shell.execOutSync('sh', '-c', `cat "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); if (catResult.rc == 0 && catResult.out) { - jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeaderAsOneLine.replace(/[$]/g, '$$$$')); + jclContents = null; + if (memList[m] == 'ZWESECUR') { + jclContents = catResult.out.replace(/^\/\/ZWESECUR JOB/i, '//ZWESECUR JOB ' + jclHeaderAsOneLine.replace(/[$]/g, '$$$$')); + } else { + if (catResult.out.match(/\{zowe\.environments\.jclHeader\}/i)) { + jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeaderAsOneLine.replace(/[$]/g, '$$$$')); + } + } + if (jclContents) { xplatform.storeFileUTF8(tempFile, xplatform.AUTO_DETECT, jclContents); shell.execSync('sh', '-c', `cp "${tempFile}" "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); + common.printDebug(` - ${ZOWE_CONFIG.zowe.setup.dataset.jcllib}(${memList[m]})`); + } } } } os.remove(tempFile); - } - common.printMessage("Zowe JCL generated successfully"); + } + common.printMessage("Zowe JCL generated successfully"); } else { common.printMessage(`Zowe JCL generated with errors, check job log. Job completion code=${result.jobcccode}, Job completion text=${result.jobcctext}`); } diff --git a/files/SZWEEXEC/ZWEGEN00 b/files/SZWEEXEC/ZWEGEN00 index 7304a2334e..8aac2ee6a7 100644 --- a/files/SZWEEXEC/ZWEGEN00 +++ b/files/SZWEEXEC/ZWEGEN00 @@ -326,7 +326,7 @@ say 'All of the substitutions were found.' /* ================================================================================ Invoke the edit macro on the substitutions for each member. - Skip zowe.environments.jclHeader if contains \n (x'15') + Skip zowe.environments.jclHeader if contains \n (x'15') or not initialized ZWECHG: change all word1 word2 word1 is expected to be {zowe.something} word2 is anything, including spaces, single or double apostrophes @@ -342,9 +342,12 @@ do i = 1 to members.0 call Print 'Edit 'd'.' old = '{'members.i.substitutions.j'}' new = value('CFG.'members.i.substitutions.j) - if old = '{zowe.environments.jclHeader}' then + if old = '{zowe.environments.jclHeader}' then do if pos(x2c('15'), new) > 0 then iterate j + if symbol('CFG.'members.i.substitutions.j) = 'LIT' then + iterate j + end apostrophes1 = "'" apostrophes2 = "'" if pos("'", new) > 0 & pos('"', new) = 0 then do From 8fff672a4572205c34552b690b2e89df32ba16d5 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 5 Sep 2024 15:58:05 +0200 Subject: [PATCH 06/10] Variable name typo Signed-off-by: Martin Zeithaml --- bin/commands/init/generate/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/commands/init/generate/index.ts b/bin/commands/init/generate/index.ts index ee211ae37c..19d15f7483 100644 --- a/bin/commands/init/generate/index.ts +++ b/bin/commands/init/generate/index.ts @@ -123,16 +123,16 @@ export function execute(dryRun?: boolean) { if (jclPostProcessing) { const memList = zosDataset.listDatasetMembers(ZOWE_CONFIG.zowe.setup.dataset.jcllib); if (memList.length) { - common.printDebug(` - Adding "${jclHeaderAsOneLine}" to:`); + common.printDebug(` - Adding "${jclHeaderJoined}" to:`); for (let m = 0; m < memList.length; m++) { let catResult = shell.execOutSync('sh', '-c', `cat "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); if (catResult.rc == 0 && catResult.out) { jclContents = null; if (memList[m] == 'ZWESECUR') { - jclContents = catResult.out.replace(/^\/\/ZWESECUR JOB/i, '//ZWESECUR JOB ' + jclHeaderAsOneLine.replace(/[$]/g, '$$$$')); + jclContents = catResult.out.replace(/^\/\/ZWESECUR JOB/i, '//ZWESECUR JOB ' + jclHeaderJoined.replace(/[$]/g, '$$$$')); } else { if (catResult.out.match(/\{zowe\.environments\.jclHeader\}/i)) { - jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeaderAsOneLine.replace(/[$]/g, '$$$$')); + jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeaderJoined.replace(/[$]/g, '$$$$')); } } if (jclContents) { From 19339e41884d68720f8dd65f3ca6afa0c8dd8d31 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 6 Sep 2024 17:02:04 +0200 Subject: [PATCH 07/10] replaceInMember function Signed-off-by: Martin Zeithaml --- bin/commands/init/generate/index.ts | 40 ++++++++++++----------------- bin/libs/zos-dataset.ts | 27 +++++++++++++++++++ 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/bin/commands/init/generate/index.ts b/bin/commands/init/generate/index.ts index 19d15f7483..888df108b4 100644 --- a/bin/commands/init/generate/index.ts +++ b/bin/commands/init/generate/index.ts @@ -37,7 +37,7 @@ export function execute(dryRun?: boolean) { let jclPostProcessing = false; let jclHeaderJoined = ''; - const jclHeader = ZOWE_CONFIG.zowe.environments.jclHeader; + const jclHeader = ZOWE_CONFIG.zowe.environments.jclHeader == null ? '' : ZOWE_CONFIG.zowe.environments.jclHeader; if (Array.isArray(jclHeader)) { jclPostProcessing = true; jclHeaderJoined = jclHeader.join("\n"); @@ -120,32 +120,24 @@ export function execute(dryRun?: boolean) { } common.printMessage(`Job completed with RC=${result.rc}`); if (result.rc == 0) { + let jobHeaderResult = 0; + if (jclHeaderJoined != '') { + let replaceRC = zosDataset.replaceInMember(`${ZOWE_CONFIG.zowe.setup.dataset.jcllib}(ZWESECUR)`, tempFile, /^\/\/ZWESECUR JOB/i, '//ZWESECUR JOB ' + jclHeaderJoined); + jobHeaderResult += replaceRC; + } if (jclPostProcessing) { const memList = zosDataset.listDatasetMembers(ZOWE_CONFIG.zowe.setup.dataset.jcllib); - if (memList.length) { - common.printDebug(` - Adding "${jclHeaderJoined}" to:`); - for (let m = 0; m < memList.length; m++) { - let catResult = shell.execOutSync('sh', '-c', `cat "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); - if (catResult.rc == 0 && catResult.out) { - jclContents = null; - if (memList[m] == 'ZWESECUR') { - jclContents = catResult.out.replace(/^\/\/ZWESECUR JOB/i, '//ZWESECUR JOB ' + jclHeaderJoined.replace(/[$]/g, '$$$$')); - } else { - if (catResult.out.match(/\{zowe\.environments\.jclHeader\}/i)) { - jclContents = catResult.out.replace(/\{zowe\.environments\.jclHeader\}/i, jclHeaderJoined.replace(/[$]/g, '$$$$')); - } - } - if (jclContents) { - xplatform.storeFileUTF8(tempFile, xplatform.AUTO_DETECT, jclContents); - shell.execSync('sh', '-c', `cp "${tempFile}" "//'${stringlib.escapeDollar(ZOWE_CONFIG.zowe.setup.dataset.jcllib)}(${memList[m]})'"`); - common.printDebug(` - ${ZOWE_CONFIG.zowe.setup.dataset.jcllib}(${memList[m]})`); - } - } - } + for (let m = 0; m < memList.length; m++) { + let replaceRC = zosDataset.replaceInMember(`${ZOWE_CONFIG.zowe.setup.dataset.jcllib}(${memList[m]})`, tempFile, /\{zowe\.environments\.jclHeader\}/i, jclHeaderJoined); + jobHeaderResult += replaceRC; } - os.remove(tempFile); - } - common.printMessage("Zowe JCL generated successfully"); + os.remove(tempFile); + } + if (jobHeaderResult) { + common.printMessage("Zowe JCL JOB statement update failed. Review the JOBs before submitting."); + } else { + common.printMessage("Zowe JCL generated successfully"); + } } else { common.printMessage(`Zowe JCL generated with errors, check job log. Job completion code=${result.jobcccode}, Job completion text=${result.jobcctext}`); } diff --git a/bin/libs/zos-dataset.ts b/bin/libs/zos-dataset.ts index f80c4883f6..17ad541484 100644 --- a/bin/libs/zos-dataset.ts +++ b/bin/libs/zos-dataset.ts @@ -11,6 +11,7 @@ */ import * as std from 'cm_std'; +import * as xplatform from 'xplatform'; import * as common from './common'; import * as stringlib from './string'; @@ -214,3 +215,29 @@ export function listDatasetMembers(dsName: string): string[] { common.printTrace(` * listDatasetMembers out: "${listOfMembers}"`); return listOfMembers; } + +export function replaceInMember(member: string, tempFile: string, regexFind: string, replaceTo: string): number { + common.printTrace(` * replaceInMember: ${member}, ${tempFile}, ${regexFind} -> ${replaceTo}`); + const catCommand = `cat "//'${stringlib.escapeDollar(member)}'"`; + const catResult = shell.execOutSync('sh', '-c', catCommand); + if (catResult.rc == 0 && catResult.out != undefined) { + if (catResult.out.match(regexFind)) { + const memberContents = catResult.out.replace(regexFind, replaceTo.replace(/[$]/g, '$$$$')); + let storeResult = xplatform.storeFileUTF8(tempFile, xplatform.AUTO_DETECT, memberContents); + if (storeResult) { + common.printTrace(` * replaceInMember: xplatform.storeFileUTF8 failed with: ${storeResult}`); + return 2; + } + const cpCommand = `cp "${stringlib.escapeDollar(tempFile)}" "//'${stringlib.escapeDollar(member)}'"` + let cpResult = shell.execSync('sh', '-c', cpCommand); + if (cpResult.rc) { + common.printTrace(` * replaceInMember: shell.execSync(${cpCommand}) failed with: ${cpResult.rc}`); + return 3; + } + } + return 0; + } else { + common.printTrace(` * replaceInMember: shell.execOutSync(${catCommand}) failed with: ${catResult.rc}`); + return 1; + } +} From c3a5ca40488bcb8c500bb831255474fa24177ff9 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 6 Sep 2024 17:08:01 +0200 Subject: [PATCH 08/10] Parm datatype change Signed-off-by: Martin Zeithaml --- bin/libs/zos-dataset.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/libs/zos-dataset.ts b/bin/libs/zos-dataset.ts index 17ad541484..ea249d9b8c 100644 --- a/bin/libs/zos-dataset.ts +++ b/bin/libs/zos-dataset.ts @@ -216,7 +216,7 @@ export function listDatasetMembers(dsName: string): string[] { return listOfMembers; } -export function replaceInMember(member: string, tempFile: string, regexFind: string, replaceTo: string): number { +export function replaceInMember(member: string, tempFile: string, regexFind: RegExp, replaceTo: string): number { common.printTrace(` * replaceInMember: ${member}, ${tempFile}, ${regexFind} -> ${replaceTo}`); const catCommand = `cat "//'${stringlib.escapeDollar(member)}'"`; const catResult = shell.execOutSync('sh', '-c', catCommand); From 972cca04b55f42e5c74c498869050b054fa74cc6 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 9 Oct 2024 11:06:15 +0200 Subject: [PATCH 09/10] Remove unused imports Signed-off-by: Martin Zeithaml --- bin/commands/init/generate/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/commands/init/generate/index.ts b/bin/commands/init/generate/index.ts index 888df108b4..36ae8a9f81 100644 --- a/bin/commands/init/generate/index.ts +++ b/bin/commands/init/generate/index.ts @@ -15,8 +15,6 @@ import * as xplatform from "xplatform"; import * as fs from '../../../libs/fs'; import * as config from '../../../libs/config'; import * as common from '../../../libs/common'; -import * as shell from '../../../libs/shell'; -import * as stringlib from '../../../libs/string'; import * as zosDataset from '../../../libs/zos-dataset'; import * as zosFs from '../../../libs/zos-fs'; import * as zosJes from '../../../libs/zos-jes'; From 48506f2dd8580b2fea6e8a6c3e12ad108e29dbb2 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 8 Jan 2025 13:37:18 +0100 Subject: [PATCH 10/10] Type update Signed-off-by: Martin Zeithaml --- bin/commands/init/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/commands/init/index.ts b/bin/commands/init/index.ts index 0756935fa5..5ac7f36e9a 100644 --- a/bin/commands/init/index.ts +++ b/bin/commands/init/index.ts @@ -41,7 +41,7 @@ export function execute(allowOverwrite?: boolean, dryRun?: boolean, ignoreSecuri common.printLevel1Message(`Check if need to update runtime directory, Java and/or node.js settings in Zowe YAML configuration`); // node.home - let newNodeHome; + let newNodeHome: string; const configNodeHome=zoweConfig.node?.home; // only try to update if it's not defined if (!configNodeHome || configNodeHome == 'DETECT') { @@ -50,7 +50,7 @@ export function execute(allowOverwrite?: boolean, dryRun?: boolean, ignoreSecuri } // java.home - let newJavaHome; + let newJavaHome: string; const configJavaHome=zoweConfig.java?.home; // only try to update if it's not defined if (!configJavaHome || configJavaHome == 'DETECT') { @@ -59,7 +59,7 @@ export function execute(allowOverwrite?: boolean, dryRun?: boolean, ignoreSecuri } // zowe.runtimeDirectory - let newZoweRuntimeDir; + let newZoweRuntimeDir: string; // do we have zowe.runtimeDirectory defined in zowe.yaml? const configRuntimeDir = zoweConfig.zowe?.runtimeDirectory; if (configRuntimeDir) {