diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 8bfca62e1c..745d689594 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe CLI package will be documented in this file. +## Recent Changes + +- BugFix: Added support for the `--encoding` flag to the `zowe upload dir-to-uss` to allow for encoding uploaded directories for command group consistency. [#2337](https://github.com/zowe/zowe-cli/issues/2337) + ## `8.7.0` - Enhancement: Added --wait-for-active and --wait-for-output to download options on zosjobs. [#2328](https://github.com/zowe/zowe-cli/pull/2328) diff --git a/packages/cli/__tests__/zosfiles/__integration__/upload/dtu/__snapshots__/cli.files.upload.dtu.integration.test.ts.snap b/packages/cli/__tests__/zosfiles/__integration__/upload/dtu/__snapshots__/cli.files.upload.dtu.integration.test.ts.snap index 1d9522bdb2..9495f46858 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/upload/dtu/__snapshots__/cli.files.upload.dtu.integration.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__integration__/upload/dtu/__snapshots__/cli.files.upload.dtu.integration.test.ts.snap @@ -114,6 +114,11 @@ exports[`Upload local dir to uss dir should display the help 1`] = ` Include hidden files and folders that have names beginning with a dot. + --encoding | --ec (string) + + Data content in encoding mode, which means that data conversion is performed + according to the encoding specified. + --response-timeout | --rto (number) The maximum amount of time in seconds the z/OSMF Files TSO servlet should run @@ -246,8 +251,8 @@ exports[`Upload local dir to uss dir should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: dir-to-uss.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n dir-to-uss | dtu\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Upload a local directory to a USS directory.\\\\n\\\\n An optional .zosattributes file in the source directory can be used to control\\\\n file conversion and tagging.\\\\n\\\\n An example .zosattributes file:\\\\n # pattern local-encoding remote-encoding\\\\n # Don't upload the node_modules directory\\\\n node_modules -\\\\n # Don't upload files that start with periods\\\\n .* -\\\\n # Upload jpg images in binary\\\\n *.jpg binary binary\\\\n # Convert CICS Node.js profiles to EBCDIC\\\\n *.profile ISO8859-1 EBCDIC\\\\n\\\\n Lines starting with the ‘#’ character are comments. Each line can specify up to\\\\n three positional attributes:\\\\n A pattern to match a set of files. Pattern-matching syntax follows\\\\n the same rules as those that apply in .gitignore files (note that negated\\\\n patterns that begin with ‘!’ are not supported). See\\\\n https://git-scm.com/docs/gitignore#_pattern_format.\\\\n A local-encoding to identify a file’s encoding on the local\\\\n workstation. If '-' is specified for local-encoding,files that match the pattern\\\\n are not transferred.\\\\n A remote-encoding to specify the file’s desired character set on USS.\\\\n This attribute must either match the local encoding or be set to EBCDIC. If set\\\\n to EBCDIC, files are transferred in text mode and converted, otherwise they are\\\\n transferred in binary mode. Remote files are tagged either with the remote\\\\n encoding or as binary.\\\\n\\\\n A .zosattributes file can either be placed in the top-level directory you want\\\\n to upload, or its location can be specified by using the --attributes parameter.\\\\n .zosattributes files that are placed in nested directories are ignored.\\\\n\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files upload dir-to-uss [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n inputDir\\\\t\\\\t (string)\\\\n\\\\n The local directory path that you want to upload to a USS directory\\\\n\\\\n USSDir\\\\t\\\\t (string)\\\\n\\\\n The name of the USS directory to which you want to upload the local directory\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --binary | -b (boolean)\\\\n\\\\n Data content in binary mode, which means that no data conversion is performed.\\\\n The data transfer process returns each record as-is, without translation. No\\\\n delimiters are added between records.\\\\n\\\\n --recursive | -r (boolean)\\\\n\\\\n Upload all directories recursively.\\\\n\\\\n --binary-files | --bf (string)\\\\n\\\\n Comma separated list of file names to be uploaded in binary mode. Use this\\\\n option when you upload a directory in default ASCII mode, but you want to\\\\n specify certain files to be uploaded in binary mode. All files matching\\\\n specified file names will be uploaded in binary mode. If a .zosattributes file\\\\n (or equivalent file specified via --attributes) is present, --binary-files will\\\\n be ignored.\\\\n\\\\n --ascii-files | --af (string)\\\\n\\\\n Comma separated list of file names to be uploaded in ASCII mode. Use this option\\\\n when you upload a directory with --binary/-b flag, but you want to specify\\\\n certain files to be uploaded in ASCII mode. All files matching specified file\\\\n names will be uploaded in ASCII mode. If a .zosattributes file (or equivalent\\\\n file specified via --attributes) is present, --ascii-files will be ignored.\\\\n\\\\n --attributes | --attrs (string)\\\\n\\\\n Path of an attributes file to control how files are uploaded.\\\\n\\\\n --max-concurrent-requests | --mcr (number)\\\\n\\\\n Specifies the maximum number of concurrent z/OSMF REST API requests to upload\\\\n files. Increasing the value results in faster uploads. However, increasing the\\\\n value increases resource consumption on z/OS and can be prone to errors caused\\\\n by making too many concurrent requests. If the upload process encounters an\\\\n error, the following message displays:\\\\n The maximum number of TSO address spaces have been created. When you specify 0,\\\\n Zowe CLI attempts to upload all members at once without a maximum number of\\\\n concurrent requests.\\\\n\\\\n Default value: 1\\\\n\\\\n --include-hidden | --ih (boolean)\\\\n\\\\n Include hidden files and folders that have names beginning with a dot.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\"\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory and all its\\\\n sub-directories, to the \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --recursive\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory in default ASCII mode, while specifying a list\\\\n of file names (without path) to be uploaded in binary mode:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --binary-files \\\\\\"myFile1.exe,myFile2.exe,myFile3.exe\\\\\\"\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory in binary mode, while specifying a list of\\\\n file names (without path) to be uploaded in ASCII mode:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --binary --ascii-files \\\\\\"myFile1.txt,myFile2.txt,myFile3.txt\\\\\\"\\\\n\\\\n - Recursively upload all files from the \\\\\\"local_dir\\\\\\" directory\\\\n to the \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory, specifying files to ignore and file\\\\n encodings in the local file my_global_attributes:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --recursive --attributes my_global_attributes\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n dir-to-uss | dtu\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Upload a local directory to a USS directory.\\\\n\\\\n An optional .zosattributes file in the source directory can be used to control\\\\n file conversion and tagging.\\\\n\\\\n An example .zosattributes file:\\\\n # pattern local-encoding remote-encoding\\\\n # Don't upload the node_modules directory\\\\n node_modules -\\\\n # Don't upload files that start with periods\\\\n .* -\\\\n # Upload jpg images in binary\\\\n *.jpg binary binary\\\\n # Convert CICS Node.js profiles to EBCDIC\\\\n *.profile ISO8859-1 EBCDIC\\\\n\\\\n Lines starting with the ‘#’ character are comments. Each line can specify up to\\\\n three positional attributes:\\\\n A pattern to match a set of files. Pattern-matching syntax follows\\\\n the same rules as those that apply in .gitignore files (note that negated\\\\n patterns that begin with ‘!’ are not supported). See\\\\n https://git-scm.com/docs/gitignore#_pattern_format.\\\\n A local-encoding to identify a file’s encoding on the local\\\\n workstation. If '-' is specified for local-encoding,files that match the pattern\\\\n are not transferred.\\\\n A remote-encoding to specify the file’s desired character set on USS.\\\\n This attribute must either match the local encoding or be set to EBCDIC. If set\\\\n to EBCDIC, files are transferred in text mode and converted, otherwise they are\\\\n transferred in binary mode. Remote files are tagged either with the remote\\\\n encoding or as binary.\\\\n\\\\n A .zosattributes file can either be placed in the top-level directory you want\\\\n to upload, or its location can be specified by using the --attributes parameter.\\\\n .zosattributes files that are placed in nested directories are ignored.\\\\n\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files upload dir-to-uss [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n inputDir\\\\t\\\\t (string)\\\\n\\\\n The local directory path that you want to upload to a USS directory\\\\n\\\\n USSDir\\\\t\\\\t (string)\\\\n\\\\n The name of the USS directory to which you want to upload the local directory\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --binary | -b (boolean)\\\\n\\\\n Data content in binary mode, which means that no data conversion is performed.\\\\n The data transfer process returns each record as-is, without translation. No\\\\n delimiters are added between records.\\\\n\\\\n --recursive | -r (boolean)\\\\n\\\\n Upload all directories recursively.\\\\n\\\\n --binary-files | --bf (string)\\\\n\\\\n Comma separated list of file names to be uploaded in binary mode. Use this\\\\n option when you upload a directory in default ASCII mode, but you want to\\\\n specify certain files to be uploaded in binary mode. All files matching\\\\n specified file names will be uploaded in binary mode. If a .zosattributes file\\\\n (or equivalent file specified via --attributes) is present, --binary-files will\\\\n be ignored.\\\\n\\\\n --ascii-files | --af (string)\\\\n\\\\n Comma separated list of file names to be uploaded in ASCII mode. Use this option\\\\n when you upload a directory with --binary/-b flag, but you want to specify\\\\n certain files to be uploaded in ASCII mode. All files matching specified file\\\\n names will be uploaded in ASCII mode. If a .zosattributes file (or equivalent\\\\n file specified via --attributes) is present, --ascii-files will be ignored.\\\\n\\\\n --attributes | --attrs (string)\\\\n\\\\n Path of an attributes file to control how files are uploaded.\\\\n\\\\n --max-concurrent-requests | --mcr (number)\\\\n\\\\n Specifies the maximum number of concurrent z/OSMF REST API requests to upload\\\\n files. Increasing the value results in faster uploads. However, increasing the\\\\n value increases resource consumption on z/OS and can be prone to errors caused\\\\n by making too many concurrent requests. If the upload process encounters an\\\\n error, the following message displays:\\\\n The maximum number of TSO address spaces have been created. When you specify 0,\\\\n Zowe CLI attempts to upload all members at once without a maximum number of\\\\n concurrent requests.\\\\n\\\\n Default value: 1\\\\n\\\\n --include-hidden | --ih (boolean)\\\\n\\\\n Include hidden files and folders that have names beginning with a dot.\\\\n\\\\n --encoding | --ec (string)\\\\n\\\\n Data content in encoding mode, which means that data conversion is performed\\\\n according to the encoding specified.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\"\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory and all its\\\\n sub-directories, to the \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --recursive\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory in default ASCII mode, while specifying a list\\\\n of file names (without path) to be uploaded in binary mode:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --binary-files \\\\\\"myFile1.exe,myFile2.exe,myFile3.exe\\\\\\"\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory in binary mode, while specifying a list of\\\\n file names (without path) to be uploaded in ASCII mode:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --binary --ascii-files \\\\\\"myFile1.txt,myFile2.txt,myFile3.txt\\\\\\"\\\\n\\\\n - Recursively upload all files from the \\\\\\"local_dir\\\\\\" directory\\\\n to the \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory, specifying files to ignore and file\\\\n encodings in the local file my_global_attributes:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --recursive --attributes my_global_attributes\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n dir-to-uss | dtu\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Upload a local directory to a USS directory.\\\\n\\\\n An optional .zosattributes file in the source directory can be used to control\\\\n file conversion and tagging.\\\\n\\\\n An example .zosattributes file:\\\\n # pattern local-encoding remote-encoding\\\\n # Don't upload the node_modules directory\\\\n node_modules -\\\\n # Don't upload files that start with periods\\\\n .* -\\\\n # Upload jpg images in binary\\\\n *.jpg binary binary\\\\n # Convert CICS Node.js profiles to EBCDIC\\\\n *.profile ISO8859-1 EBCDIC\\\\n\\\\n Lines starting with the ‘#’ character are comments. Each line can specify up to\\\\n three positional attributes:\\\\n A pattern to match a set of files. Pattern-matching syntax follows\\\\n the same rules as those that apply in .gitignore files (note that negated\\\\n patterns that begin with ‘!’ are not supported). See\\\\n https://git-scm.com/docs/gitignore#_pattern_format.\\\\n A local-encoding to identify a file’s encoding on the local\\\\n workstation. If '-' is specified for local-encoding,files that match the pattern\\\\n are not transferred.\\\\n A remote-encoding to specify the file’s desired character set on USS.\\\\n This attribute must either match the local encoding or be set to EBCDIC. If set\\\\n to EBCDIC, files are transferred in text mode and converted, otherwise they are\\\\n transferred in binary mode. Remote files are tagged either with the remote\\\\n encoding or as binary.\\\\n\\\\n A .zosattributes file can either be placed in the top-level directory you want\\\\n to upload, or its location can be specified by using the --attributes parameter.\\\\n .zosattributes files that are placed in nested directories are ignored.\\\\n\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files upload dir-to-uss [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n inputDir\\\\t\\\\t (string)\\\\n\\\\n The local directory path that you want to upload to a USS directory\\\\n\\\\n USSDir\\\\t\\\\t (string)\\\\n\\\\n The name of the USS directory to which you want to upload the local directory\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --binary | -b (boolean)\\\\n\\\\n Data content in binary mode, which means that no data conversion is performed.\\\\n The data transfer process returns each record as-is, without translation. No\\\\n delimiters are added between records.\\\\n\\\\n --recursive | -r (boolean)\\\\n\\\\n Upload all directories recursively.\\\\n\\\\n --binary-files | --bf (string)\\\\n\\\\n Comma separated list of file names to be uploaded in binary mode. Use this\\\\n option when you upload a directory in default ASCII mode, but you want to\\\\n specify certain files to be uploaded in binary mode. All files matching\\\\n specified file names will be uploaded in binary mode. If a .zosattributes file\\\\n (or equivalent file specified via --attributes) is present, --binary-files will\\\\n be ignored.\\\\n\\\\n --ascii-files | --af (string)\\\\n\\\\n Comma separated list of file names to be uploaded in ASCII mode. Use this option\\\\n when you upload a directory with --binary/-b flag, but you want to specify\\\\n certain files to be uploaded in ASCII mode. All files matching specified file\\\\n names will be uploaded in ASCII mode. If a .zosattributes file (or equivalent\\\\n file specified via --attributes) is present, --ascii-files will be ignored.\\\\n\\\\n --attributes | --attrs (string)\\\\n\\\\n Path of an attributes file to control how files are uploaded.\\\\n\\\\n --max-concurrent-requests | --mcr (number)\\\\n\\\\n Specifies the maximum number of concurrent z/OSMF REST API requests to upload\\\\n files. Increasing the value results in faster uploads. However, increasing the\\\\n value increases resource consumption on z/OS and can be prone to errors caused\\\\n by making too many concurrent requests. If the upload process encounters an\\\\n error, the following message displays:\\\\n The maximum number of TSO address spaces have been created. When you specify 0,\\\\n Zowe CLI attempts to upload all members at once without a maximum number of\\\\n concurrent requests.\\\\n\\\\n Default value: 1\\\\n\\\\n --include-hidden | --ih (boolean)\\\\n\\\\n Include hidden files and folders that have names beginning with a dot.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\"\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory and all its\\\\n sub-directories, to the \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --recursive\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory in default ASCII mode, while specifying a list\\\\n of file names (without path) to be uploaded in binary mode:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --binary-files \\\\\\"myFile1.exe,myFile2.exe,myFile3.exe\\\\\\"\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory in binary mode, while specifying a list of\\\\n file names (without path) to be uploaded in ASCII mode:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --binary --ascii-files \\\\\\"myFile1.txt,myFile2.txt,myFile3.txt\\\\\\"\\\\n\\\\n - Recursively upload all files from the \\\\\\"local_dir\\\\\\" directory\\\\n to the \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory, specifying files to ignore and file\\\\n encodings in the local file my_global_attributes:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --recursive --attributes my_global_attributes\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n dir-to-uss | dtu\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Upload a local directory to a USS directory.\\\\n\\\\n An optional .zosattributes file in the source directory can be used to control\\\\n file conversion and tagging.\\\\n\\\\n An example .zosattributes file:\\\\n # pattern local-encoding remote-encoding\\\\n # Don't upload the node_modules directory\\\\n node_modules -\\\\n # Don't upload files that start with periods\\\\n .* -\\\\n # Upload jpg images in binary\\\\n *.jpg binary binary\\\\n # Convert CICS Node.js profiles to EBCDIC\\\\n *.profile ISO8859-1 EBCDIC\\\\n\\\\n Lines starting with the ‘#’ character are comments. Each line can specify up to\\\\n three positional attributes:\\\\n A pattern to match a set of files. Pattern-matching syntax follows\\\\n the same rules as those that apply in .gitignore files (note that negated\\\\n patterns that begin with ‘!’ are not supported). See\\\\n https://git-scm.com/docs/gitignore#_pattern_format.\\\\n A local-encoding to identify a file’s encoding on the local\\\\n workstation. If '-' is specified for local-encoding,files that match the pattern\\\\n are not transferred.\\\\n A remote-encoding to specify the file’s desired character set on USS.\\\\n This attribute must either match the local encoding or be set to EBCDIC. If set\\\\n to EBCDIC, files are transferred in text mode and converted, otherwise they are\\\\n transferred in binary mode. Remote files are tagged either with the remote\\\\n encoding or as binary.\\\\n\\\\n A .zosattributes file can either be placed in the top-level directory you want\\\\n to upload, or its location can be specified by using the --attributes parameter.\\\\n .zosattributes files that are placed in nested directories are ignored.\\\\n\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files upload dir-to-uss [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n inputDir\\\\t\\\\t (string)\\\\n\\\\n The local directory path that you want to upload to a USS directory\\\\n\\\\n USSDir\\\\t\\\\t (string)\\\\n\\\\n The name of the USS directory to which you want to upload the local directory\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --binary | -b (boolean)\\\\n\\\\n Data content in binary mode, which means that no data conversion is performed.\\\\n The data transfer process returns each record as-is, without translation. No\\\\n delimiters are added between records.\\\\n\\\\n --recursive | -r (boolean)\\\\n\\\\n Upload all directories recursively.\\\\n\\\\n --binary-files | --bf (string)\\\\n\\\\n Comma separated list of file names to be uploaded in binary mode. Use this\\\\n option when you upload a directory in default ASCII mode, but you want to\\\\n specify certain files to be uploaded in binary mode. All files matching\\\\n specified file names will be uploaded in binary mode. If a .zosattributes file\\\\n (or equivalent file specified via --attributes) is present, --binary-files will\\\\n be ignored.\\\\n\\\\n --ascii-files | --af (string)\\\\n\\\\n Comma separated list of file names to be uploaded in ASCII mode. Use this option\\\\n when you upload a directory with --binary/-b flag, but you want to specify\\\\n certain files to be uploaded in ASCII mode. All files matching specified file\\\\n names will be uploaded in ASCII mode. If a .zosattributes file (or equivalent\\\\n file specified via --attributes) is present, --ascii-files will be ignored.\\\\n\\\\n --attributes | --attrs (string)\\\\n\\\\n Path of an attributes file to control how files are uploaded.\\\\n\\\\n --max-concurrent-requests | --mcr (number)\\\\n\\\\n Specifies the maximum number of concurrent z/OSMF REST API requests to upload\\\\n files. Increasing the value results in faster uploads. However, increasing the\\\\n value increases resource consumption on z/OS and can be prone to errors caused\\\\n by making too many concurrent requests. If the upload process encounters an\\\\n error, the following message displays:\\\\n The maximum number of TSO address spaces have been created. When you specify 0,\\\\n Zowe CLI attempts to upload all members at once without a maximum number of\\\\n concurrent requests.\\\\n\\\\n Default value: 1\\\\n\\\\n --include-hidden | --ih (boolean)\\\\n\\\\n Include hidden files and folders that have names beginning with a dot.\\\\n\\\\n --encoding | --ec (string)\\\\n\\\\n Data content in encoding mode, which means that data conversion is performed\\\\n according to the encoding specified.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\"\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory and all its\\\\n sub-directories, to the \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --recursive\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory in default ASCII mode, while specifying a list\\\\n of file names (without path) to be uploaded in binary mode:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --binary-files \\\\\\"myFile1.exe,myFile2.exe,myFile3.exe\\\\\\"\\\\n\\\\n - Upload all files from the \\\\\\"local_dir\\\\\\" directory to the\\\\n \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory in binary mode, while specifying a list of\\\\n file names (without path) to be uploaded in ASCII mode:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --binary --ascii-files \\\\\\"myFile1.txt,myFile2.txt,myFile3.txt\\\\\\"\\\\n\\\\n - Recursively upload all files from the \\\\\\"local_dir\\\\\\" directory\\\\n to the \\\\\\"/a/ibmuser/my_dir\\\\\\" USS directory, specifying files to ignore and file\\\\n encodings in the local file my_global_attributes:\\\\n\\\\n $ zowe zos-files upload dir-to-uss \\\\\\"local_dir\\\\\\" \\\\\\"/a/ibmuser/my_dir\\\\\\" --recursive --attributes my_global_attributes\\\\n\\\\n\\" }" `; diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/DirToUSS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/DirToUSS.handler.unit.test.ts index f1965a7d8d..b80b898aba 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/DirToUSS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/DirToUSS.handler.unit.test.ts @@ -19,6 +19,7 @@ describe("Upload dir-to-uss handler", () => { let fakeSession: any = null; const inputDir = "/somedir/test_dir"; const USSDir = "USS_dir"; + const encoding = "IBM-1047"; let handler: any; const UPLOAD_OPTIONS_ARG_INDEX = 3; @@ -64,6 +65,43 @@ describe("Upload dir-to-uss handler", () => { } } }; + const DEFAULT_ENCODING_PARAMETERS = { + arguments: { + $0: "fake", + _: ["fake"], + inputDir, + USSDir, + encoding, + // binary: boolean, + // recursive: boolean, + // asciiFiles: "a,b,c", + // binaryFiles: "a,b,c", + ...UNIT_TEST_ZOSMF_PROF_OPTS + }, + response: { + data: { + setMessage: jest.fn((setMsgArgs) => { + apiMessage = setMsgArgs; + }), + setObj: jest.fn((setObjArgs) => { + jsonObj = setObjArgs; + }) + }, + console: { + log: jest.fn((logArgs) => { + logMessage += "\n" + logArgs; + }) + }, + progress: { + startBar: jest.fn((parms) => { + // do nothing + }), + endBar: jest.fn(() => { + // do nothing + }) + } + } + }; beforeEach(() => { @@ -100,6 +138,23 @@ describe("Upload dir-to-uss handler", () => { } }); }); + it("should upload a directory to a USS directory if requested with encoding flag", async () => { + const params = Object.assign({}, ...[DEFAULT_ENCODING_PARAMETERS]); + await testHandlerWorksWithParameters(params); + expect(Upload.dirToUSSDir).toHaveBeenCalledTimes(1); + expect(Upload.dirToUSSDir).toHaveBeenCalledWith(fakeSession, inputDir, USSDir, { + binary: undefined, + filesMap: null, + maxConcurrentRequests: undefined, + recursive: undefined, + task: { + percentComplete: 0, + stageName: 0, + statusMessage: "Uploading all files" + }, + encoding: "IBM-1047" + }); + }); it("should pass attributes when a .zosattributes file is present", async () => { jest.spyOn(fs, "existsSync").mockReturnValueOnce(true); const attributesContents = "foo.stuff -"; diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/__snapshots__/DirToUSS.definition.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/__snapshots__/DirToUSS.definition.unit.test.ts.snap index d39c1604e9..6429faaaa4 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/__snapshots__/DirToUSS.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/__snapshots__/DirToUSS.definition.unit.test.ts.snap @@ -73,6 +73,14 @@ The maximum number of TSO address spaces have been created. When you specify 0, "name": "include-hidden", "type": "boolean", }, + Object { + "aliases": Array [ + "ec", + ], + "description": "Data content in encoding mode, which means that data conversion is performed according to the encoding specified.", + "name": "encoding", + "type": "string", + }, ] `; diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/__snapshots__/DirToUSS.handler.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/__snapshots__/DirToUSS.handler.unit.test.ts.snap index 2119caf884..e4a4c2eee7 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/__snapshots__/DirToUSS.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/__snapshots__/DirToUSS.handler.unit.test.ts.snap @@ -69,6 +69,20 @@ uploaded to:  nowhere +uploaded +-  + success: true + from:  /somedir/test_dir + to:  USS_dir +-  + success: false + from:  testfrom + to:  testto +-  + from: dummy + to:  nowhere + + uploaded" `; @@ -127,6 +141,20 @@ uploaded to:  nowhere +uploaded +-  + success: true + from:  /somedir/test_dir + to:  USS_dir +-  + success: false + from:  testfrom + to:  testto +-  + from: dummy + to:  nowhere + + uploaded" `; @@ -173,3 +201,61 @@ exports[`Upload dir-to-uss handler process method should upload a directory to a uploaded" `; + +exports[`Upload dir-to-uss handler process method should upload a directory to a USS directory if requested with encoding flag 1`] = ` +Object { + "apiResponse": Array [ + Object { + "from": "/somedir/test_dir", + "success": true, + "to": "USS_dir", + }, + Object { + "from": "testfrom", + "success": false, + "to": "testto", + }, + Object { + "from": "dummy", + "success": undefined, + "to": "nowhere", + }, + ], + "commandResponse": "uploaded", + "success": false, +} +`; + +exports[`Upload dir-to-uss handler process method should upload a directory to a USS directory if requested with encoding flag 2`] = `""`; + +exports[`Upload dir-to-uss handler process method should upload a directory to a USS directory if requested with encoding flag 3`] = ` +" +-  + success: true + from:  /somedir/test_dir + to:  USS_dir +-  + success: false + from:  testfrom + to:  testto +-  + from: dummy + to:  nowhere + + +uploaded +-  + success: true + from:  /somedir/test_dir + to:  USS_dir +-  + success: false + from:  testfrom + to:  testto +-  + from: dummy + to:  nowhere + + +uploaded" +`; diff --git a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.definition.ts b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.definition.ts index f7b1256b7b..f912891d61 100644 --- a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.definition.ts +++ b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.definition.ts @@ -52,7 +52,8 @@ export const DirToUSSDirDefinition: ICommandDefinition = { UploadOptions.asciiFiles, UploadOptions.attributes, UploadOptions.maxConcurrentRequests, - UploadOptions.includeHidden + UploadOptions.includeHidden, + UploadOptions.encoding ], examples: [ { diff --git a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts index 939efd1de5..f5c406ac37 100644 --- a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts @@ -43,7 +43,8 @@ export default class DirToUSSDirHandler extends ZosFilesBaseHandler { maxConcurrentRequests: commandParameters.arguments.maxConcurrentRequests, task: status, responseTimeout: commandParameters.arguments.responseTimeout, - includeHidden: commandParameters.arguments.includeHidden + includeHidden: commandParameters.arguments.includeHidden, + encoding: commandParameters.arguments.encoding }; const attributes = ZosFilesAttributes.loadFromFile(commandParameters.arguments.attributes, inputDir); diff --git a/packages/zosfiles/CHANGELOG.md b/packages/zosfiles/CHANGELOG.md index a7d879d22f..c22572bb4e 100644 --- a/packages/zosfiles/CHANGELOG.md +++ b/packages/zosfiles/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe z/OS files SDK package will be documented in this file. +## Recent Changes + +- BugFix: Added support for the `--encoding` flag to the `zowe upload dir-to-uss` to allow for encoding uploaded directories for command group consistency. [#2337](https://github.com/zowe/zowe-cli/issues/2337) + ## `8.6.2` - BugFix: Resolved issue where encoding argument was missing from `FileToUss.handler.ts` options object. [#2234](https://github.com/zowe/zowe-cli/pull/2334) diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts index d9a1e0597e..2c1491b946 100644 --- a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts @@ -27,6 +27,7 @@ let dsname: string; let ussname: string; const inputfile = __dirname + "/testfiles/upload.txt"; const testdata = "abcdefghijklmnopqrstuvwxyz"; +const encodedTestData = "á é í ó ú ñ Ç ß 12345 !@#$% ^ [ ] $ £"; const uploadOptions: IUploadOptions = {} as any; describe("Upload Data Set", () => { @@ -1127,7 +1128,34 @@ describe("Upload a local directory to USS directory", () => { expect(isDirectoryExist).toBeDefined(); expect(isDirectoryExist).toBeTruthy(); }); + it("should upload local directory to USS with an encoding", async () => { + let error; + let uploadResponse: IZosFilesResponse; + let isDirectoryExist: any; + let getResponse; + let getResponseBinary; + let getResponseDiffEncoding; + try { + uploadResponse = await Upload.dirToUSSDir(REAL_SESSION, localDir, ussname, {encoding: "IBM-1047"}); + await wait(waitTime); + isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, ussname); + getResponse = await Get.USSFile(REAL_SESSION, `${ussname}/file4.txt`, {encoding: "IBM-1047"}); + getResponseBinary = await Get.USSFile(REAL_SESSION, `${ussname}/file4.txt`, {binary: true}); + getResponseDiffEncoding = await Get.USSFile(REAL_SESSION, `${ussname}/file4.txt`, {encoding: "IBM-1147"}); + } catch (err) { + error = err; + Imperative.console.info("Error: " + inspect(error)); + } + expect(error).toBeFalsy(); + expect(uploadResponse).toBeDefined(); + expect(uploadResponse.success).toBeTruthy(); + expect(isDirectoryExist).toBeDefined(); + expect(isDirectoryExist).toBeTruthy(); + expect(getResponse).toEqual(Buffer.from(encodedTestData)); + expect(getResponseBinary).not.toEqual(Buffer.from(encodedTestData)); + expect(getResponseDiffEncoding).not.toEqual(Buffer.from(encodedTestData)); + }); it("should upload local directory to USS in binary mode", async () => { let error; let uploadResponse: IZosFilesResponse; diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/file4.txt b/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/file4.txt new file mode 100644 index 0000000000..7038873a47 --- /dev/null +++ b/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/file4.txt @@ -0,0 +1 @@ +á é í ó ú ñ Ç ß 12345 !@#$% ^ [ ] $ £ \ No newline at end of file diff --git a/packages/zosfiles/src/methods/upload/Upload.ts b/packages/zosfiles/src/methods/upload/Upload.ts index 13a53abef4..b4d17b937a 100644 --- a/packages/zosfiles/src/methods/upload/Upload.ts +++ b/packages/zosfiles/src/methods/upload/Upload.ts @@ -877,7 +877,7 @@ export class Upload { } else if(options.filesMap?.fileNames.indexOf(path.basename(localPath)) > -1) { tempOptions.binary = options.filesMap.binary; - // Reset encoding to undefined if binary is true to avoid file tagging issues + //Reset encoding to undefined if binary is true to avoid file tagging issues if(tempOptions.binary) tempOptions.encoding = undefined; }