Skip to content

Commit fd5a698

Browse files
committed
linewrap for sysin
1 parent 2550714 commit fd5a698

File tree

3 files changed

+52
-31
lines changed

3 files changed

+52
-31
lines changed

__tests__/api/BundleDeploy/__snapshots__/BundleDeployer.test.ts.snap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ UNDEPLOY BUNDLE(12345678)
242242
RESGROUP(12345678);
243243
*
244244
DEPLOY BUNDLE(12345678)
245-
BUNDLEDIR(123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345)
245+
BUNDLEDIR(123456789012345678901234567890123456789012345678901234
246+
567890123456789012345678901234567890123456789012345678901234567
247+
890123456789012345678901234567890123456789012345678901234567890
248+
123456789012345678901234567890123456789012345678901234567890123
249+
456789012345)
246250
SCOPE(12345678)
247251
STATE(AVAILABLE)
248252
RESGROUP(12345678);

src/api/BundleDeploy/BundleDeployer.ts

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ export class BundleDeployer {
8686
return this.submitJCL(jcl, session);
8787
}
8888

89+
private wrapLongLineForJCL(lineOfText: string): string {
90+
const MAX_LINE_LEN = 71;
91+
92+
let tempVal = lineOfText;
93+
let returnVal = "";
94+
while (tempVal.length > MAX_LINE_LEN) {
95+
returnVal = returnVal + tempVal.substring(0, MAX_LINE_LEN) + "\n";
96+
tempVal = " " + tempVal.substring(MAX_LINE_LEN);
97+
}
98+
returnVal = returnVal + tempVal;
99+
return returnVal;
100+
}
101+
89102
/**
90103
* Construct the DFHDPLOY DEPLOY BUNDLE JCL.
91104
* @returns {string}
@@ -101,19 +114,19 @@ export class BundleDeployer {
101114
jcl = jcl + "*\n";
102115

103116
// Now generate the deploy statement.
104-
jcl = jcl + "DEPLOY BUNDLE(" + this.params.arguments.name + ")\n" +
105-
" BUNDLEDIR(" + this.params.arguments.bundledir + ")\n" +
106-
" SCOPE(" + this.params.arguments.scope + ")\n" +
107-
" STATE(AVAILABLE)\n";
117+
jcl = jcl + this.wrapLongLineForJCL("DEPLOY BUNDLE(" + this.params.arguments.name + ")\n") +
118+
this.wrapLongLineForJCL(" BUNDLEDIR(" + this.params.arguments.bundledir + ")\n") +
119+
this.wrapLongLineForJCL(" SCOPE(" + this.params.arguments.scope + ")\n") +
120+
this.wrapLongLineForJCL(" STATE(AVAILABLE)\n");
108121

109122
if (this.params.arguments.timeout !== undefined) {
110-
jcl = jcl + " TIMEOUT(" + this.params.arguments.timeout + ")\n";
123+
jcl = jcl + this.wrapLongLineForJCL(" TIMEOUT(" + this.params.arguments.timeout + ")\n");
111124
}
112125
if (this.params.arguments.csdgroup !== undefined) {
113-
jcl = jcl + " CSDGROUP(" + this.params.arguments.csdgroup + ");\n";
126+
jcl = jcl + this.wrapLongLineForJCL(" CSDGROUP(" + this.params.arguments.csdgroup + ");\n");
114127
}
115128
if (this.params.arguments.resgroup !== undefined) {
116-
jcl = jcl + " RESGROUP(" + this.params.arguments.resgroup + ");\n";
129+
jcl = jcl + this.wrapLongLineForJCL(" RESGROUP(" + this.params.arguments.resgroup + ");\n");
117130
}
118131

119132
// finally add a terminator
@@ -147,20 +160,20 @@ export class BundleDeployer {
147160
"//SYSTSPRT DD SYSOUT=*\n" +
148161
"//SYSIN DD *\n" +
149162
"*\n" +
150-
"SET CICSPLEX(" + this.params.arguments.cicsplex + ");\n" +
151-
"*\n" +
152-
"UNDEPLOY BUNDLE(" + this.params.arguments.name + ")\n" +
153-
" SCOPE(" + this.params.arguments.scope + ")\n" +
154-
" STATE(DISCARDED)\n";
163+
this.wrapLongLineForJCL("SET CICSPLEX(" + this.params.arguments.cicsplex + ");\n") +
164+
this.wrapLongLineForJCL("*\n") +
165+
this.wrapLongLineForJCL("UNDEPLOY BUNDLE(" + this.params.arguments.name + ")\n") +
166+
this.wrapLongLineForJCL(" SCOPE(" + this.params.arguments.scope + ")\n") +
167+
this.wrapLongLineForJCL(" STATE(DISCARDED)\n");
155168

156169
if (this.params.arguments.timeout !== undefined) {
157-
jcl = jcl + " TIMEOUT(" + this.params.arguments.timeout + ")\n";
170+
jcl = jcl + this.wrapLongLineForJCL(" TIMEOUT(" + this.params.arguments.timeout + ")\n");
158171
}
159172
if (this.params.arguments.csdgroup !== undefined) {
160-
jcl = jcl + " CSDGROUP(" + this.params.arguments.csdgroup + ");\n";
173+
jcl = jcl + this.wrapLongLineForJCL(" CSDGROUP(" + this.params.arguments.csdgroup + ");\n");
161174
}
162175
if (this.params.arguments.resgroup !== undefined) {
163-
jcl = jcl + " RESGROUP(" + this.params.arguments.resgroup + ");\n";
176+
jcl = jcl + this.wrapLongLineForJCL(" RESGROUP(" + this.params.arguments.resgroup + ");\n");
164177
}
165178

166179
return jcl;

src/api/BundleDeploy/ParmValidator.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -267,21 +267,7 @@ export class ParmValidator {
267267
}
268268
}
269269

270-
private static validateJobcard(params: IHandlerParameters) {
271-
// jobcard is mandatory
272-
if (params.arguments.jobcard === undefined) {
273-
throw new Error("--jobcard parameter is not set");
274-
}
275-
276-
if (typeof params.arguments.jobcard !== "string") {
277-
throw new Error("--jobcard parameter is not a string");
278-
}
279-
280-
if (params.arguments.jobcard === "") {
281-
throw new Error("--jobcard parameter is empty");
282-
}
283-
284-
// handle long jobcards
270+
private static wrapJobcard(params: IHandlerParameters) {
285271
if (params.arguments.jobcard.indexOf("\\n") === -1) {
286272
// if the user hasn't embedded new-line characters into the jobcard
287273
// then we'll have to do that ourselves if the value is too long
@@ -307,6 +293,24 @@ export class ParmValidator {
307293
// line breaks are in suitable places.
308294
params.arguments.jobcard = params.arguments.jobcard.replace("\\n", "\n");
309295
}
296+
}
297+
298+
private static validateJobcard(params: IHandlerParameters) {
299+
// jobcard is mandatory
300+
if (params.arguments.jobcard === undefined) {
301+
throw new Error("--jobcard parameter is not set");
302+
}
303+
304+
if (typeof params.arguments.jobcard !== "string") {
305+
throw new Error("--jobcard parameter is not a string");
306+
}
307+
308+
if (params.arguments.jobcard === "") {
309+
throw new Error("--jobcard parameter is empty");
310+
}
311+
312+
// handle long jobcards
313+
ParmValidator.wrapJobcard(params);
310314

311315
// split the jobcard into a comma separated list
312316
const jobcardParts = params.arguments.jobcard.split(",");

0 commit comments

Comments
 (0)