Skip to content

Commit f4a507a

Browse files
committed
default .zosattributes
1 parent 1e37f7e commit f4a507a

File tree

3 files changed

+89
-27
lines changed

3 files changed

+89
-27
lines changed

__tests__/api/BundlePush/BundlePusher.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,50 @@ describe("BundlePusher01", () => {
324324
expect(existsSpy).toHaveBeenCalledTimes(1);
325325
expect(readSpy).toHaveBeenCalledTimes(2);
326326
});
327+
it("should load zosattribs file", async () => {
328+
existsSpy.mockImplementation((data: string) => {
329+
if (data.indexOf(".zosattributes") > -1) {
330+
return true;
331+
}
332+
});
333+
readSpy.mockImplementation((data: string) => {
334+
if (data.indexOf(".zosattributes") > -1) {
335+
return "";
336+
}
337+
else if (data.indexOf("cics.xml") > -1) {
338+
return "<manifest xmlns=\"http://www.ibm.com/xmlns/prod/cics/bundle\"></manifest>";
339+
}
340+
});
341+
342+
await runPushTest("__tests__/__resources__/ExampleBundle01", true,
343+
"PUSH operation completed.");
344+
345+
expect(consoleText).not.toContain("WARNING: No .zosAttributes file found in the bundle directory, default values will be applied.");
346+
expect(zosMFSpy).toHaveBeenCalledTimes(1);
347+
expect(sshSpy).toHaveBeenCalledTimes(1);
348+
expect(createSpy).toHaveBeenCalledTimes(1);
349+
expect(listSpy).toHaveBeenCalledTimes(1);
350+
expect(shellSpy).toHaveBeenCalledTimes(1);
351+
expect(membersSpy).toHaveBeenCalledTimes(2);
352+
expect(submitSpy).toHaveBeenCalledTimes(2);
353+
expect(existsSpy).toHaveBeenCalledTimes(2);
354+
expect(readSpy).toHaveBeenCalledTimes(2);
355+
});
356+
it("should use a default zosattribs file", async () => {
357+
await runPushTest("__tests__/__resources__/ExampleBundle01", true,
358+
"PUSH operation completed.");
359+
360+
expect(consoleText).toContain("WARNING: No .zosAttributes file found in the bundle directory, default values will be applied.");
361+
expect(zosMFSpy).toHaveBeenCalledTimes(1);
362+
expect(sshSpy).toHaveBeenCalledTimes(1);
363+
expect(createSpy).toHaveBeenCalledTimes(1);
364+
expect(listSpy).toHaveBeenCalledTimes(1);
365+
expect(shellSpy).toHaveBeenCalledTimes(1);
366+
expect(membersSpy).toHaveBeenCalledTimes(2);
367+
expect(submitSpy).toHaveBeenCalledTimes(2);
368+
expect(existsSpy).toHaveBeenCalledTimes(2);
369+
expect(readSpy).toHaveBeenCalledTimes(1);
370+
});
327371
it("should handle error with bundle upload", async () => {
328372
uploadSpy.mockImplementationOnce(() => { throw new Error("Injected upload error"); });
329373

src/api/BundleContent/Bundle.ts

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,37 @@ import { NodejsappBundlePart } from "./NodejsappBundlePart";
2323
*/
2424
export class Bundle {
2525

26+
/**
27+
* Get a template version of the .zosattributes file
28+
* @returns {string}
29+
* @memberof Bundle
30+
*/
31+
public static getTemplateZosAttributesFile(): string {
32+
return `#z/OS File Attributes Document
33+
#-----------------------------
34+
# This document specfies the encodings for the files within
35+
# the project in a form that is compatible with the
36+
# 'Zowe files upload dir-to-uss' command.
37+
#
38+
# Don't upload node_modules
39+
node_modules -
40+
# Don't upload things that start with dots
41+
.* -
42+
43+
# Upload the following file types in binary
44+
*.jpg binary binary
45+
*.png binary binary
46+
*.gif binary binary
47+
*.zip binary binary
48+
*.eot binary binary
49+
*.svg binary binary
50+
*.ttf binary binary
51+
*.woff binary binary
52+
53+
# Convert CICS Node.js profiles to EBCDIC
54+
*.profile ISO8859-1 IBM-1047`;
55+
}
56+
2657
private path = require("path");
2758
private fs = require("fs");
2859
private manifest: Manifest;
@@ -254,30 +285,7 @@ export class Bundle {
254285
return;
255286
}
256287

257-
const contents = "" +
258-
"#z/OS File Attributes Document\n" +
259-
"#-----------------------------\n" +
260-
"# This document specfies the encodings for the files within\n" +
261-
"# the project in a form that is compatible with the\n" +
262-
"# 'Zowe files upload dir-to-uss' command.\n" +
263-
"#\n" +
264-
"# Don't upload node_modules\n" +
265-
"node_modules -\n" +
266-
"# Don't upload things that start with dots\n" +
267-
".* -\n" +
268-
"\n" +
269-
"# Upload the following file types in binary\n" +
270-
"*.jpg binary binary\n" +
271-
"*.png binary binary\n" +
272-
"*.gif binary binary\n" +
273-
"*.zip binary binary\n" +
274-
"*.eot binary binary\n" +
275-
"*.svg binary binary\n" +
276-
"*.ttf binary binary\n" +
277-
"*.woff binary binary\n" +
278-
"\n" +
279-
"# Convert CICS Node.js profiles to EBCDIC\n" +
280-
"*.profile ISO8859-1 IBM-1047";
288+
const contents = Bundle.getTemplateZosAttributesFile();
281289

282290
// Write the zosattributes file
283291
try {

src/api/BundlePush/BundlePusher.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ export class BundlePusher {
306306
const shell = await Shell.executeSshCwd(sshSession, sshCommand, directory, this.sshOutput.bind(this));
307307

308308
// Did the SSH command work? It's unclear how to tell, but for starters let's look for common
309-
// signifiers in the output text. Note that FSUM9195 implies that we've tried to delete an
310-
// empty directory - that's permitted.
309+
// signifiers in the output text. Note that FSUM9195 implies that we've tried to delete the
310+
// contents of an empty directory - that's not a problem.
311311
const upperCaseOutputText = this.sshOutputText.toUpperCase();
312312
if (upperCaseOutputText.indexOf("ERROR ") > -1 ||
313313
(upperCaseOutputText.indexOf("FSUM") > -1 &&
@@ -354,7 +354,17 @@ export class BundlePusher {
354354
"'. Problem is: " + error.message);
355355
}
356356
}
357-
return undefined;
357+
358+
// A project specific .zosattributes has not been found, so use a default
359+
const warningMsg = "WARNING: No .zosAttributes file found in the bundle directory, default values will be applied.";
360+
this.params.response.progress.endBar();
361+
this.params.response.console.log(warningMsg);
362+
if (this.params.arguments.silent === undefined) {
363+
const logger = Logger.getAppLogger();
364+
logger.warn(warningMsg);
365+
}
366+
this.params.response.progress.startBar({task: this.progressBar});
367+
return new ZosFilesAttributes(Bundle.getTemplateZosAttributesFile());
358368
}
359369

360370
private updateStatus(status: string) {

0 commit comments

Comments
 (0)