diff --git a/CHANGELOG.md b/CHANGELOG.md index 649fc747..6b391f13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ All notable changes to the z/OS FTP Plug-in for Zowe CLI will be documented in t - For a full list of transfer modes, see [TransferMode by `zos-node-accessor`](https://github.com/IBM/zos-node-accessor/blob/faf55873f37cc40e927f1b1c19f697de8cf08b95/src/zosAccessor.ts#L67) - `IConnectionOption` - For a full list of transfer modes, see [ConnectionOption by `zos-node-accessor`](https://github.com/IBM/zos-node-accessor/blob/faf55873f37cc40e927f1b1c19f697de8cf08b95/src/interfaces/ConnectionOption.ts#L17) + - `IDatasetEntry` + - For a full list of transfer modes, see [DatasetEntry by `zos-node-accessor`](https://github.com/IBM/zos-node-accessor/blob/faf55873f37cc40e927f1b1c19f697de8cf08b95/src/interfaces/DatasetEntry.ts#L17) + - `IUSSEntry` + - For a full list of transfer modes, see [USSEntry by `zos-node-accessor`](https://github.com/IBM/zos-node-accessor/blob/faf55873f37cc40e927f1b1c19f697de8cf08b95/src/interfaces/USSEntry.ts#L19) - **Breaking**: - Removed the following constants, interfaces, and other values: - `IGetSpoolFileOption.jobName` @@ -36,7 +40,7 @@ All notable changes to the z/OS FTP Plug-in for Zowe CLI will be documented in t - `JobUtils.listJobs` - `JobUtils.deleteJob` - `UssUtils.listFiles` - - Return type changed: `Promise --> Promise` + - Return type changed: `Promise --> Promise` - `UssUtils.makeDirectory` - `UssUtils.renameFile` - `UssUtils.deleteFile` diff --git a/__tests__/__system__/cli/allocate/data-set/cli.allocate.data-set.test.ts b/__tests__/__system__/cli/allocate/data-set/cli.allocate.data-set.test.ts index 9a789f81..8bb63f64 100644 --- a/__tests__/__system__/cli/allocate/data-set/cli.allocate.data-set.test.ts +++ b/__tests__/__system__/cli/allocate/data-set/cli.allocate.data-set.test.ts @@ -58,9 +58,9 @@ describe("allocate data set command", () => { expect(result.stdout.toString()).toContain('Allocated dataset ' + destination + ' successfully!'); const attributes = await connection.listDatasets(destination); - expect(attributes[0].Dsorg).toEqual("PO"); - expect(attributes[0].Lrecl).toEqual("100"); - expect(attributes[0].Recfm).toEqual("FB"); + expect(attributes[0].dsOrg).toEqual("PO"); + expect(attributes[0].recordLength).toEqual(100); + expect(attributes[0].recordFormat).toEqual("FB"); }); it("should give a syntax error if the data set are omitted", async () => { diff --git a/__tests__/__system__/cli/download/all-spool-by-jobid/cli.download.all-spool-by-jobid.test.ts b/__tests__/__system__/cli/download/all-spool-by-jobid/cli.download.all-spool-by-jobid.test.ts index fd712dfe..9b6c7ea1 100644 --- a/__tests__/__system__/cli/download/all-spool-by-jobid/cli.download.all-spool-by-jobid.test.ts +++ b/__tests__/__system__/cli/download/all-spool-by-jobid/cli.download.all-spool-by-jobid.test.ts @@ -15,8 +15,9 @@ import { FTPConfig } from "../../../../../src/api/FTPConfig"; import { IO } from "@zowe/imperative"; import { CoreUtils } from "../../../../../src/api/CoreUtils"; import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets"; +import { ZosAccessor } from "zos-node-accessor"; -let connection: any; +let connection: ZosAccessor; let testEnvironment: ITestEnvironment; let iefbr14DataSet: string; @@ -42,7 +43,7 @@ describe("download all-spool-by-jobid command", () => { it("should be able to submit an IEFBR14 job and then download the jobid", async () => { // download the appropriate JCL content from the data set - const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString(); + const iefbr14Content = (await connection.downloadDataset(iefbr14DataSet)).toString(); const jobid = await connection.submitJCL(iefbr14Content.toString()); const JOB_WAIT = 2000; await CoreUtils.sleep(JOB_WAIT); @@ -60,7 +61,7 @@ describe("download all-spool-by-jobid command", () => { it("should be able to submit a job from a local file and then download the spool, omitting the jobid directory", async () => { // download the appropriate JCL content from the data set - const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString(); + const iefbr14Content = (await connection.downloadDataset(iefbr14DataSet)).toString(); const jobid = await connection.submitJCL(iefbr14Content.toString()); const JOB_WAIT = 2000; await CoreUtils.sleep(JOB_WAIT); diff --git a/__tests__/__system__/cli/list/spool-files-by-jobid/cli.list.spool-files-by-jobid.test.ts b/__tests__/__system__/cli/list/spool-files-by-jobid/cli.list.spool-files-by-jobid.test.ts index 1aaea3ee..5806991a 100644 --- a/__tests__/__system__/cli/list/spool-files-by-jobid/cli.list.spool-files-by-jobid.test.ts +++ b/__tests__/__system__/cli/list/spool-files-by-jobid/cli.list.spool-files-by-jobid.test.ts @@ -44,10 +44,10 @@ describe("list spool-files-by-jobid command", () => { // download the appropriate JCL content from the data set const iefbr14Content = (await connection.downloadDataset(iefbr14DataSet)).toString(); expect(iefbr14Content).toContain("IEFBR14"); - const jobid = await connection.submitJCL(iefbr14Content); + const jobId = await connection.submitJCL(iefbr14Content); const ONE_SECOND = 1000; await CoreUtils.sleep(ONE_SECOND); - const result = runCliScript(__dirname + "/__scripts__/command_list_spool_files_by_jobid.sh", testEnvironment, [jobid]); + const result = runCliScript(__dirname + "/__scripts__/command_list_spool_files_by_jobid.sh", testEnvironment, [jobId]); expect(result.stderr.toString()).toEqual(""); expect(result.status).toEqual(0); expect(result.stdout.toString()).toContain("JESJCL"); diff --git a/__tests__/__system__/cli/rename/data-set/cli.rename.data-set.test.ts b/__tests__/__system__/cli/rename/data-set/cli.rename.data-set.test.ts index a75603c8..949ba08c 100644 --- a/__tests__/__system__/cli/rename/data-set/cli.rename.data-set.test.ts +++ b/__tests__/__system__/cli/rename/data-set/cli.rename.data-set.test.ts @@ -79,7 +79,7 @@ describe("rename data set command", () => { const renameDataSetListResults: any[] = await connection.listDatasets(renameDestination); let renamedDataSet: any; for (const dataSet of renameDataSetListResults) { - if (dataSet.Dsname === renameDestination.toUpperCase()) { + if (dataSet.name === renameDestination.toUpperCase()) { renamedDataSet = dataSet; break; } @@ -97,7 +97,7 @@ describe("rename data set command", () => { const resetNameResults: any[] = await connection.listDatasets(originalName); let resetDataset: any; for (const dataSet of resetNameResults) { - if (dataSet.Dsname === originalName.toUpperCase()) { + if (dataSet.name === originalName.toUpperCase()) { resetDataset = dataSet; } } @@ -105,7 +105,7 @@ describe("rename data set command", () => { } catch (e) { throw new Error("Warning! Rename of data set from your custom_properties file did not succeed!\nAttempted to rename from '" + originalName - + "' to '" + renameDestination + "'You may have to manually rename " + + + "' to '" + renameDestination + "'\nYou may have to manually rename " + "or re-create the data set! Error encountered while renaming: \n" + inspect(e)); } }); diff --git a/__tests__/__system__/cli/view/job-status-by-jobid/cli.view.job-status-by-jobid.test.ts b/__tests__/__system__/cli/view/job-status-by-jobid/cli.view.job-status-by-jobid.test.ts index a2f43526..5d01a372 100644 --- a/__tests__/__system__/cli/view/job-status-by-jobid/cli.view.job-status-by-jobid.test.ts +++ b/__tests__/__system__/cli/view/job-status-by-jobid/cli.view.job-status-by-jobid.test.ts @@ -50,8 +50,8 @@ describe("view job-status-by-jobid command", () => { const result = runCliScript(__dirname + "/__scripts__/command_view_job_status_by_jobid.sh", testEnvironment, [jobID]); expect(result.stderr.toString()).toEqual(""); expect(result.status).toEqual(0); - expect(result.stdout.toString()).toContain("jobname"); - expect(result.stdout.toString()).toContain("jobid"); + expect(result.stdout.toString()).toContain("jobName"); + expect(result.stdout.toString()).toContain("jobId"); expect(result.stdout.toString()).toContain(jobID); }); @@ -59,7 +59,7 @@ describe("view job-status-by-jobid command", () => { const result = runCliScript(__dirname + "/__scripts__/command_view_job_status_by_jobid.sh", testEnvironment, []); const stderr = result.stderr.toString(); expect(stderr).toContain("Positional"); - expect(stderr).toContain("jobid"); + expect(stderr).toContain("jobId"); expect(stderr).toContain("Syntax"); expect(result.status).toEqual(1); }); diff --git a/__tests__/__system__/cli/view/spool-file-by-id/cli.view.spool-file-by-id.test.ts b/__tests__/__system__/cli/view/spool-file-by-id/cli.view.spool-file-by-id.test.ts index ac85fb31..db57d2d9 100644 --- a/__tests__/__system__/cli/view/spool-file-by-id/cli.view.spool-file-by-id.test.ts +++ b/__tests__/__system__/cli/view/spool-file-by-id/cli.view.spool-file-by-id.test.ts @@ -49,7 +49,7 @@ describe("view spool-file-by-id command", () => { const jobStatus = await connection.getJobStatus({jobId}); let jesJCLID; for (const file of jobStatus.spoolFiles ?? []) { - if (file.ddname === "JESJCL") { + if (file.ddName === "JESJCL") { jesJCLID = file.id; break; } diff --git a/package.json b/package.json index b69a5fd5..17602f82 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,6 @@ "setupFilesAfterEnv": [ "./__tests__/setUpJest.js" ], - "testResultsProcessor": "jest-stare", "transform": { ".(ts)": "ts-jest" }, diff --git a/src/api/UssUtils.ts b/src/api/UssUtils.ts index 69adbd51..34eee5ca 100644 --- a/src/api/UssUtils.ts +++ b/src/api/UssUtils.ts @@ -18,7 +18,7 @@ import { StreamUtils } from "./StreamUtils"; import { IDeleteFileOption, IDownloadFileOption, IUSSEntry, IUploadFileOption } from "./doc/UssInterface"; import { TransferMode, ZosAccessor } from "zos-node-accessor"; import { ReadStream } from "fs"; -import { ITransferMode } from "./doc/constants"; +import { IFileType, ITransferMode } from "./doc/constants"; export class UssUtils { @@ -92,10 +92,10 @@ export class UssUtils { public static async deleteFile(connection: ZosAccessor, fileOrDir: string, option?: IDeleteFileOption): Promise { this.log.debug("Deleting USS file '%s'", fileOrDir); - if (option && option.recursive) { + if (option?.recursive) { await UssUtils.deleteDirectory(connection, fileOrDir, option.console); } else { - await connection.deleteDataset(fileOrDir); + await connection.deleteFile(fileOrDir); } } @@ -147,7 +147,7 @@ export class UssUtils { // if we're in ascii mode, we need carriage returns to avoid errors content = Buffer.from(CoreUtils.addCarriageReturns(content.toString())); } - await connection.uploadDataset(content, ussFile, transferType); + await connection.uploadFile(content, ussFile, transferType); } /** @@ -185,19 +185,19 @@ export class UssUtils { } public static async deleteDirectory(connection: ZosAccessor, dir: string, response?: IHandlerResponseConsoleApi): Promise { - const files = await connection.listDatasets(dir); + const files = await connection.listFiles(dir); for (const file of files) { const filePath = PATH.posix.join(dir, file.name); - if (file.isDirectory) { + if (file.fileType === IFileType.DIRECTORY) { await this.deleteDirectory(connection, filePath, response); } else { - await connection.deleteDataset(filePath); + await connection.deleteFile(filePath); if (response) { response.log("Deleted %s", filePath); } } } - await connection.deleteDataset(dir); + await connection.deleteFile(dir); if (response) { response.log("Deleted %s", dir); } diff --git a/src/api/doc/constants.ts b/src/api/doc/constants.ts index 8ccaf7f2..5c9dcaef 100644 --- a/src/api/doc/constants.ts +++ b/src/api/doc/constants.ts @@ -10,12 +10,16 @@ */ import { TransferMode } from "zos-node-accessor"; +import { FileType } from "zos-node-accessor/lib/interfaces/USSEntry"; /** * Bytes per track. */ export const TRACK = 56664; +export const IFileType = { ...FileType }; +export type IFileType = typeof IFileType; + export const ITransferMode = { ...TransferMode }; export type ITransferMode = typeof ITransferMode; diff --git a/src/cli/delete/uss-file/UssFile.Handler.ts b/src/cli/delete/uss-file/UssFile.Handler.ts index cdcfdd80..f2a070cc 100644 --- a/src/cli/delete/uss-file/UssFile.Handler.ts +++ b/src/cli/delete/uss-file/UssFile.Handler.ts @@ -11,13 +11,13 @@ import { FTPBaseHandler } from "../../../FTPBase.Handler"; import { IFTPHandlerParams } from "../../../IFTPHandlerParams"; -import { UssUtils } from "../../../api"; +import { IDeleteFileOption, UssUtils } from "../../../api"; export default class DeleteUSSFileHandler extends FTPBaseHandler { public async processFTP(params: IFTPHandlerParams): Promise { const ussFile = UssUtils.normalizeUnixPath(params.arguments.ussFile); - const option = { + const option: IDeleteFileOption = { console: params.response.console, recursive: params.arguments.recursive, }; diff --git a/src/cli/list/data-set/DataSet.Handler.ts b/src/cli/list/data-set/DataSet.Handler.ts index 5fcbd4fe..9c1d3ebe 100644 --- a/src/cli/list/data-set/DataSet.Handler.ts +++ b/src/cli/list/data-set/DataSet.Handler.ts @@ -23,7 +23,7 @@ export default class ListDataSetsHandler extends FTPBaseHandler { params.response.format.output({ output: filteredFiles, format: "table", - fields: ["dsname"] + fields: ["name"] }); } } diff --git a/src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts b/src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts index e7cd51bc..2e181bd0 100644 --- a/src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts +++ b/src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts @@ -31,9 +31,9 @@ export default class ListSpoolFilesByJobidHandler extends FTPBaseHandler { // Format & print the response params.response.format.output({ - fields: ["id", "ddname", "procstep", "stepname"], + fields: ["id", "ddName", "procStep", "stepName"], output: files, - format: "table" + format: "table", }); } } diff --git a/src/cli/view/job-status-by-jobid/JobStatusByJobId.Handler.ts b/src/cli/view/job-status-by-jobid/JobStatusByJobId.Handler.ts index 810c4c82..64222a6e 100644 --- a/src/cli/view/job-status-by-jobid/JobStatusByJobId.Handler.ts +++ b/src/cli/view/job-status-by-jobid/JobStatusByJobId.Handler.ts @@ -15,12 +15,12 @@ import { JobUtils } from "../../../api"; export default class ViewJobStatusByJobIdHandler extends FTPBaseHandler { public async processFTP(params: IFTPHandlerParams): Promise { - this.log.debug("Viewing all spool files for job id: " + params.arguments.jobid); - const jobDetails = await JobUtils.findJobByID(params.connection, params.arguments.jobid); + this.log.debug("Viewing all spool files for job id: " + params.arguments.jobId); + const jobDetails = await JobUtils.findJobByID(params.connection, params.arguments.jobId); params.response.data.setObj(jobDetails); params.response.format.output( { - fields: ["jobname", "jobid", "owner", "status", "rc", "retcode"], + fields: ["jobName", "jobId", "owner", "status", "rc", "retcode"], output: jobDetails, format: "object" } diff --git a/src/cli/view/job-status-by-jobid/JobStatusByJobid.definition.ts b/src/cli/view/job-status-by-jobid/JobStatusByJobid.definition.ts index 78bb2c13..4b51b7e7 100644 --- a/src/cli/view/job-status-by-jobid/JobStatusByJobid.definition.ts +++ b/src/cli/view/job-status-by-jobid/JobStatusByJobid.definition.ts @@ -27,7 +27,7 @@ export const ViewJobStatusByJobidDefinition: ICommandDefinition = { ], positionals: [ { - name: "jobid", + name: "jobId", description: "The ID of the job" + "for which you would like to list spool files", type: "string",