Skip to content

Commit

Permalink
Merge branch 'master' into deferred-promise
Browse files Browse the repository at this point in the history
Signed-off-by: Jace Roell <[email protected]>
  • Loading branch information
jace-roell authored Jan 7, 2025
2 parents b4cbaca + bf77e64 commit 9e574aa
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to the Zowe CLI package will be documented in this file.

## Recent Changes

- 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`

- 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)
Expand Down
17 changes: 12 additions & 5 deletions packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({ task: status });

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) {
Expand Down
1 change: 1 addition & 0 deletions packages/imperative/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to the Imperative package will be documented in this file.
## Recent Changes

- Enhancement: Added `DeferredPromise` class to Imperative to provide utilities for data synchronization. [#2405](https://github.com/zowe/zowe-cli/pull/2405)
- 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.3`

Expand Down
2 changes: 1 addition & 1 deletion packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -525,6 +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 = "^\\w+$";
ValidationTestCommand.positionals = [{
name: invalidPositional,
type: "string",
description: "Invalid positional",
regex: regexForPositional,
}];

return tryOptions.bind(this)(
minValidOptions + "inv@lid",
false,
[
"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: [],
Expand Down

0 comments on commit 9e574aa

Please sign in to comment.