From beff3d6a1fdf099b31c1721808f2c7f2c63568ff Mon Sep 17 00:00:00 2001 From: MAVRICK-1 Date: Thu, 12 Dec 2024 01:19:24 +0530 Subject: [PATCH 01/11] fix: correct regex match condition in SyntaxValidator Signed-off-by: MAVRICK-1 --- packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts b/packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts index ea0b0be56b..b95dad3974 100644 --- a/packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts +++ b/packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts @@ -226,7 +226,7 @@ export class SyntaxValidator { if (!(commandArguments[positional.name] == null)) { if (positional.regex) { if (commandArguments[positional.name] - .toString().match(new RegExp(positional.regex) == null)) { + .toString().match(new RegExp(positional.regex)) == null) { valid = false; this.positionalParameterInvalid(positional, commandArguments[positional.name], responseObject); From 4b477da8dd4a2dac6f1d23e65fc732cbd3afa4d4 Mon Sep 17 00:00:00 2001 From: MAVRICK-1 Date: Sat, 14 Dec 2024 00:35:35 +0530 Subject: [PATCH 02/11] changelog: update for version 8.8.4 with bug fix and enhancement for positional argument validation test: add unit test for invalid positional argument regex validation Signed-off-by: MAVRICK-1 --- packages/imperative/CHANGELOG.md | 5 +++++ .../syntax/__tests__/SyntaxValidator.unit.test.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index ded21b7c84..3331852dc4 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the Imperative package will be documented in this file. +## `8.8.4` + +- BugFix: Broken validation of positional arguments. [#2384](https://github.com/zowe/zowe-cli/pull/2384) +- Enhancement: Added a test to validate it . [#2384](https://github.com/zowe/zowe-cli/pull/2384) + ## `8.8.3` - BugFix: Modified 8.8.2 bugfix to correct web help alias. [#2361](https://github.com/zowe/zowe-cli/pull/2361) diff --git a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts index 58bf12a29c..92f8c74379 100644 --- a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts +++ b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts @@ -525,6 +525,19 @@ describe("Imperative should provide advanced syntax validation rules", () => { expect(svResponse.valid).toEqual(true); }); + it.only("If a positional argument does not match the defined regex, the command should fail", async () => { + const invalidPositional = "invalid_value"; + const regexForPositional = "^[a-zA-Z0-9_]+$"; + + return tryOptions.bind( + this, + `${minValidOptions} ${invalidPositional}`, + false, + [`Positional argument '${invalidPositional}' does not match the regex: ${regexForPositional}`] + )(); + }); + + describe("We should be able to validate positional arguments of type 'number'", () => { const numberCommand: ICommandDefinition = { name: "gimme-number", aliases: [], From 2850f3b18e4ef99b8343746e103ad4ecdea9fee2 Mon Sep 17 00:00:00 2001 From: MAVRICK-1 Date: Fri, 20 Dec 2024 03:28:31 +0530 Subject: [PATCH 03/11] Fix typo in syntax validation for positional arguments and add regression test Signed-off-by: MAVRICK-1 --- packages/imperative/CHANGELOG.md | 5 +++++ .../cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 0ba57c37bf..14224c3985 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the Imperative package will be documented in this file. +## `8.10.2` + +- bugfix: fixed a typo in the syntax validation code for positional arguments. the bug caused the validation to never fail. [#2384](https://github.com/zowe/zowe-cli/pull/2384) +- enhancement: added a regression test to validate the fix. [#2384](https://github.com/zowe/zowe-cli/pull/2384) + (note: non-user-facing items like regression tests are typically not included in the changelog). ## `8.10.1` diff --git a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts index 92f8c74379..76759b6b51 100644 --- a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts +++ b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts @@ -525,7 +525,7 @@ describe("Imperative should provide advanced syntax validation rules", () => { expect(svResponse.valid).toEqual(true); }); - it.only("If a positional argument does not match the defined regex, the command should fail", async () => { + it("should fail if a positional argument does not match the defined regex", async () => { const invalidPositional = "invalid_value"; const regexForPositional = "^[a-zA-Z0-9_]+$"; From d4d94bf21e93f8cbe246c6dd219931371908bcc6 Mon Sep 17 00:00:00 2001 From: Rishi Mondal Date: Fri, 27 Dec 2024 01:40:31 +0530 Subject: [PATCH 04/11] Update packages/imperative/CHANGELOG.md Co-authored-by: Timothy Johnson Signed-off-by: Rishi Mondal --- packages/imperative/CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 14224c3985..16579208e8 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -4,9 +4,7 @@ All notable changes to the Imperative package will be documented in this file. ## `8.10.2` -- bugfix: fixed a typo in the syntax validation code for positional arguments. the bug caused the validation to never fail. [#2384](https://github.com/zowe/zowe-cli/pull/2384) -- enhancement: added a regression test to validate the fix. [#2384](https://github.com/zowe/zowe-cli/pull/2384) - (note: non-user-facing items like regression tests are typically not included in the changelog). +- BugFix: Fixed a typo in the syntax validation code for positional arguments which caused the validation to never fail. [#2375](https://github.com/zowe/zowe-cli/issues/2375) ## `8.10.1` From ae834ef1ea02ba755b3478bb782cb41ebc4b31fa Mon Sep 17 00:00:00 2001 From: Rishi Mondal Date: Fri, 27 Dec 2024 01:40:44 +0530 Subject: [PATCH 05/11] Update packages/imperative/CHANGELOG.md Co-authored-by: Timothy Johnson Signed-off-by: Rishi Mondal --- packages/imperative/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 16579208e8..44265cddd8 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Imperative package will be documented in this file. -## `8.10.2` +## Recent Changes - BugFix: Fixed a typo in the syntax validation code for positional arguments which caused the validation to never fail. [#2375](https://github.com/zowe/zowe-cli/issues/2375) From 972a2150871ca90ffbc73642071b35eda350a107 Mon Sep 17 00:00:00 2001 From: MAVRICK-1 Date: Fri, 27 Dec 2024 16:41:40 +0530 Subject: [PATCH 06/11] Enhancement: Add progress tracking to DirToUSSDirHandler for file uploads Signed-off-by: MAVRICK-1 --- .../zosfiles/upload/dtu/DirToUSSDir.handler.ts | 17 ++++++++++++----- packages/imperative/CHANGELOG.md | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts index f5c406ac37..2f37a11abf 100644 --- a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts @@ -54,12 +54,19 @@ export default class DirToUSSDirHandler extends ZosFilesBaseHandler { uploadOptions.filesMap = this.buildFilesMap(commandParameters); } - const uploadApi = commandParameters.arguments.recursive ? Upload.dirToUSSDirRecursive : Upload.dirToUSSDir; - const response = await uploadApi.bind(Upload)(session, inputDir, commandParameters.arguments.USSDir, uploadOptions); + commandParameters.response.progress.startBar("Uploading files..."); - const formatMessage = TextUtils.prettyJson(response.apiResponse); - commandParameters.response.console.log(formatMessage); - return response; + try { + const uploadApi = commandParameters.arguments.recursive ? Upload.dirToUSSDirRecursive : Upload.dirToUSSDir; + const response = await uploadApi.bind(Upload)(session, inputDir, commandParameters.arguments.USSDir, uploadOptions); + + const formatMessage = TextUtils.prettyJson(response.apiResponse); + commandParameters.response.console.log(formatMessage); + + return response; + } finally { + commandParameters.response.progress.endBar(); + } } private buildFilesMap(commandParameters: IHandlerParameters) { diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 0ba57c37bf..536b05870e 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Imperative package will be documented in this file. +## Recent Changes + +- Enhancement: Added progress tracking to the `DirToUSSDirHandler` by using `commandParameters.response.progress` to show progress bars during file uploads. [#2334](https://github.com/zowe/zowe-cli/issues/2344) + ## `8.10.1` From 0eb2639f776ae274087397907be90ab96700d889 Mon Sep 17 00:00:00 2001 From: MAVRICK-1 Date: Fri, 3 Jan 2025 23:22:13 +0530 Subject: [PATCH 07/11] Enhancement: Update progress bar to include task status in DirToUSSDirHandler Signed-off-by: MAVRICK-1 --- packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts index 2f37a11abf..44bf308634 100644 --- a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts @@ -54,7 +54,7 @@ export default class DirToUSSDirHandler extends ZosFilesBaseHandler { uploadOptions.filesMap = this.buildFilesMap(commandParameters); } - commandParameters.response.progress.startBar("Uploading files..."); + commandParameters.response.progress.startBar({ task: status }); try { const uploadApi = commandParameters.arguments.recursive ? Upload.dirToUSSDirRecursive : Upload.dirToUSSDir; From f63f865fedec8d49f71b53fff01884befa762f57 Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:24:36 -0500 Subject: [PATCH 08/11] review: move changelog updates ot cli package Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- packages/cli/CHANGELOG.md | 4 ++++ packages/imperative/CHANGELOG.md | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 2a7c9fc4a8..b8ce6a3936 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log All notable changes to the Zowe CLI package will be documented in this file. +## Recent Changes + +- Enhancement: Added progress tracking to the `DirToUSSDirHandler` by using `commandParameters.response.progress` to show progress bars during file uploads. [#2334](https://github.com/zowe/zowe-cli/issues/2344) + ## `8.10.3` - BugFix: The `zowe files copy data-set` command no longer copies all partitioned data set members if a member is specified. [#2402](https://github.com/zowe/zowe-cli/pull/2402) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 916c5aae5c..490e36fcb8 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,10 +2,6 @@ All notable changes to the Imperative package will be documented in this file. -## Recent Changes - -- Enhancement: Added progress tracking to the `DirToUSSDirHandler` by using `commandParameters.response.progress` to show progress bars during file uploads. [#2334](https://github.com/zowe/zowe-cli/issues/2344) - ## `8.10.3` - BugFix: Resolved an issue where extraneous base profiles were created in project configurations when a nested profile property was updated. [#2400](https://github.com/zowe/zowe-cli/pull/2400) From bb9324f690cb0427d024091fa8a203af7794c41b Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 7 Jan 2025 11:28:56 -0500 Subject: [PATCH 09/11] Fix SyntaxValidator unit test Signed-off-by: Timothy Johnson --- .../__tests__/SyntaxValidator.unit.test.ts | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts index 76759b6b51..477f18cd78 100644 --- a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts +++ b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts @@ -46,6 +46,9 @@ describe("Imperative should provide advanced syntax validation rules", () => { function tryOptions(optionString: string, shouldSucceed: boolean, expectedText?: string[]) { const options = yargsParser.detailed(optionString, configuration).argv; + ValidationTestCommand.positionals?.forEach((p) => { + options[p.name] = options._.shift(); // fake out named positionals + }); options._ = ["test", "validation-test"].concat(options._ || []); // fake out command structure options[Constants.JSON_OPTION] = true; delete options["--"]; // delete extra yargs parse field @@ -525,19 +528,28 @@ describe("Imperative should provide advanced syntax validation rules", () => { expect(svResponse.valid).toEqual(true); }); - it("should fail if a positional argument does not match the defined regex", async () => { - const invalidPositional = "invalid_value"; - const regexForPositional = "^[a-zA-Z0-9_]+$"; - - return tryOptions.bind( - this, - `${minValidOptions} ${invalidPositional}`, + it("should fail if a positional argument does not match the defined regex", async () => { + const invalidPositional = "invalid_value"; + const regexForPositional = "^\w+$"; + ValidationTestCommand.positionals = [{ + name: invalidPositional, + type: "string", + description: "Invalid positional", + regex: regexForPositional, + }]; + + return tryOptions.bind(this)( + minValidOptions + "inv@lid", false, - [`Positional argument '${invalidPositional}' does not match the regex: ${regexForPositional}`] - )(); + [ + "Invalid format specified for positional option:", + invalidPositional, + "Option must match the following regular expression:", + regexForPositional + ] + ); }); - - + describe("We should be able to validate positional arguments of type 'number'", () => { const numberCommand: ICommandDefinition = { name: "gimme-number", aliases: [], From e2f3084d3d58289dd325f8a66a456662c27cf73f Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 7 Jan 2025 13:39:45 -0500 Subject: [PATCH 10/11] Fix lint error in unit test Signed-off-by: Timothy Johnson --- .../src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts index 477f18cd78..db03e257c3 100644 --- a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts +++ b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts @@ -530,7 +530,7 @@ describe("Imperative should provide advanced syntax validation rules", () => { it("should fail if a positional argument does not match the defined regex", async () => { const invalidPositional = "invalid_value"; - const regexForPositional = "^\w+$"; + const regexForPositional = "^\\w+$"; ValidationTestCommand.positionals = [{ name: invalidPositional, type: "string", From 83f1e449efbe04e0d1bc8186da1b5ac3b9673690 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 7 Jan 2025 14:11:06 -0500 Subject: [PATCH 11/11] Update CHANGELOG.md Signed-off-by: Timothy Johnson --- packages/cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index b8ce6a3936..600caf7f87 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to the Zowe CLI package will be documented in this file. ## Recent Changes -- Enhancement: Added progress tracking to the `DirToUSSDirHandler` by using `commandParameters.response.progress` to show progress bars during file uploads. [#2334](https://github.com/zowe/zowe-cli/issues/2344) +- BugFix: Fixed an issue where the `zowe files upload dir-to-uss` command was missing progress bar to track progress of file uploads. [#2344](https://github.com/zowe/zowe-cli/issues/2344) ## `8.10.3`