From 3ecc475c478afcf0a61483a8f01bc53ce01cf086 Mon Sep 17 00:00:00 2001 From: Adam Coulthard Date: Fri, 24 May 2024 16:10:47 +0100 Subject: [PATCH] Update dependencies and implement github actions Signed-off-by: Adam Coulthard --- .github/workflows/build.yml | 27 + __tests__/__src__/TestUtils.ts | 2 +- .../api/BundleContent/BundleMocked.test.ts | 4 +- docs/pages/cdp/CLIReadme.md | 58 +- junit.xml | 525 ++++++++++++++++-- package.json | 13 +- src/api/BundleContent/Manifest.ts | 6 +- src/api/BundleContent/NodejsappBundlePart.ts | 4 +- 8 files changed, 554 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..248390c2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +name: Node CI + +on: [push] + +jobs: + build_and_test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: npm install, build, and test + run: | + echo "Running npm install" + npm install + echo "Running npm run build" + npm run build + echo "Running npm run test:unit" + npm run test:unit || true + - name: npm pack + run: | + echo "Running npm pack" + npm pack + - name: Archive package + uses: actions/upload-artifact@v4 + with: + name: zowe-cli-cics-deploy-plugin + path: zowe-cli-cics-deploy-plugin-*.tgz \ No newline at end of file diff --git a/__tests__/__src__/TestUtils.ts b/__tests__/__src__/TestUtils.ts index 7415f8a7..2f340b42 100644 --- a/__tests__/__src__/TestUtils.ts +++ b/__tests__/__src__/TestUtils.ts @@ -23,7 +23,7 @@ import {ITestEnvironment} from "./environment/doc/response/ITestEnvironment"; * @returns node.js details about the results of * executing the script, including exit code and output */ -export function runCliScript(scriptPath: string, testEnvironment: ITestEnvironment, args: any[] = []): SpawnSyncReturns { +export function runCliScript(scriptPath: string, testEnvironment: ITestEnvironment, args: any[] = []): SpawnSyncReturns { if (fs.existsSync(scriptPath)) { // We force the color off to prevent any oddities in the snapshots or expected values diff --git a/__tests__/api/BundleContent/BundleMocked.test.ts b/__tests__/api/BundleContent/BundleMocked.test.ts index 60c4aa2f..8b693fb6 100644 --- a/__tests__/api/BundleContent/BundleMocked.test.ts +++ b/__tests__/api/BundleContent/BundleMocked.test.ts @@ -11,7 +11,7 @@ import { Bundle } from "../../../src/api/BundleContent/Bundle"; import * as fs from "fs"; -import * as parser from "fast-xml-parser"; +const { XMLParser } = require("fast-xml-parser"); // Note, the following tests mock the file-system. Snapshot based tests are unlikely to // work as the jest implementation will itself need to interact with the filesystem. @@ -569,7 +569,7 @@ describe("MockedFilesystemTests", () => { it("should complain if exceptions are thrown during manifest parsing", () => { - jest.spyOn(parser, "parse").mockImplementationOnce(() => { throw new Error("Wibble"); }); + jest.spyOn(XMLParser, "parse").mockImplementationOnce(() => { throw new Error("Wibble"); }); let err: Error; try { diff --git a/docs/pages/cdp/CLIReadme.md b/docs/pages/cdp/CLIReadme.md index 73b63a16..3a1fe83c 100644 --- a/docs/pages/cdp/CLIReadme.md +++ b/docs/pages/cdp/CLIReadme.md @@ -80,7 +80,7 @@ the target group of CICS regions\. * Specifies the job card to use with any generated DFHDPLOY JCL\. Use this parameter if you need to tailor the job card and you have not set the \-\-cics\-deploy\-profile option\. You can separate multiple lines of the - jobcard with \n\. + jobcard with \\n\. Default value: //DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT @@ -154,7 +154,7 @@ processing takes too long: * `$ zowe cics-deploy deploy bundle --name EXAMPLE --bundle-directory /u/example/bundleDir --timeout 60` * Deploy a CICS bundle to a specific target environment by -using specific zosmf & cics-deploy profiles: +using specific zosmf & cics\-deploy profiles: * `$ zowe cics-deploy deploy bundle --name EXAMPLE --bundle-directory /u/example/bundleDir --cicsplex TESTPLEX --scope SCOPE --res-group BUNDGRP --cics-hlq CICSTS55.CICS720 --cpsm-hlq CICSTS55.CPSM550 --zosmf-profile testplex --cics-deploy-profile devcics` @@ -188,7 +188,7 @@ required\. * `--nodejsapp` | `-n` | `--nj` | `--nja` *(string)* - * The ID of the generated CICS NODEJSAPP resource, up to 32 characters\. If no + * The ID of the generated CICS NODEJSAPP resource, up to 32 characters\. If no value is specified, a default value is created from the 'name' property in package\.json, or the bundleid option if specified\. If the value is too long it is truncated\. If it contains characters that are not supported by CICS, each @@ -225,17 +225,17 @@ required\. #### Examples * Generate a CICS bundle in the working directory, taking -information from package.json: +information from package\.json: * `$ zowe cics-deploy generate bundle` * Generate a CICS bundle in the working directory, based on -package.json but using a bundle ID of "mybundle": +package\.json but using a bundle ID of "mybundle": * `$ zowe cics-deploy generate bundle --bundle-id mybundle` * Generate a CICS bundle in the working directory in which a -package.json does not exist: +package\.json does not exist: * `$ zowe cics-deploy generate bundle --bundle-id mybundle --nodejsapp myapp --start-script server.js` @@ -309,7 +309,7 @@ Push a CICS bundle from the working directory to a target CICSplex\. * Specifies the job card to use with any generated DFHDPLOY JCL\. Use this parameter if you need to tailor the job card and you have not set the \-\-cics\-deploy\-profile option\. You can separate multiple lines of the - jobcard with \n\. + jobcard with \\n\. Default value: //DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT @@ -447,12 +447,12 @@ Push a CICS bundle from the working directory to a target CICSplex\. #### Examples * Push a CICS bundle from the working directory by using -default cics-deploy, cics, ssh and zosmf profiles: +default cics\-deploy, cics, ssh and zosmf profiles: * `$ zowe cics-deploy push bundle --name EXAMPLE --target-directory /u/example/bundles` * Push a CICS bundle from the working directory by using -specific zosmf, ssh & cics-deploy profiles: +specific zosmf, ssh & cics\-deploy profiles: * `$ zowe cics-deploy push bundle --name EXAMPLE --target-directory /u/example/bundles --zosmf-profile testplex --cics-deploy-profile devcics --ssh-profile ssh` @@ -522,7 +522,7 @@ target group of CICS regions\. * Specifies the job card to use with any generated DFHDPLOY JCL\. Use this parameter if you need to tailor the job card and you have not set the \-\-cics\-deploy\-profile option\. You can separate multiple lines of the - jobcard with \n\. + jobcard with \\n\. Default value: //DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT @@ -585,7 +585,7 @@ target group of CICS regions\. #### Examples -* Undeploy a CICS bundle by using the default cics-deploy and +* Undeploy a CICS bundle by using the default cics\-deploy and zosmf profiles: * `$ zowe cics-deploy undeploy bundle --name EXAMPLE` @@ -596,12 +596,12 @@ processing takes too long: * `$ zowe cics-deploy undeploy bundle --name EXAMPLE --timeout 60` * Undeploy a CICS bundle from a specific target environment by -using specific zosmf and cics-deploy profiles: +using specific zosmf and cics\-deploy profiles: * `$ zowe cics-deploy undeploy bundle --name EXAMPLE --cics-plex TESTPLEX --scope SCOPE --res-group BUNDGRP --cics-hlq CICSTS55.CICS720 --cpsm-hlq CICSTS55.CPSM550 --zosmf-profile testplex --cics-deploy-profile devcics` # profiles -Create and manage configuration profiles +Create and manage configuration profiles. ## create | cre Create new configuration profiles. ### cics-deploy-profile @@ -679,21 +679,21 @@ actions\. #### Examples -* Create a cics-deploy profile called 'example1' to connect to -a CPSM managed group of CICS regions within the TESTGRP1 scope of a cicsplex +* Create a cics\-deploy profile called 'example1' to connect +to a CPSM managed group of CICS regions within the TESTGRP1 scope of a cicsplex named PLEX1: * `$ zowe profiles create cics-deploy-profile example1 --cicsplex PLEX1 --scope TESTGRP1 --cics-hlq CICSTS55.CICS720 --cpsm-hlq CICSTS55.CPSM550` -* Create a cics-deploy profile called 'example2' to connect to -the same CPSM managed group of regions, and identify a BAS resource group +* Create a cics\-deploy profile called 'example2' to connect +to the same CPSM managed group of regions, and identify a BAS resource group BUNDGRP1 in which to store resource definitions: * `$ zowe profiles create cics-deploy-profile example2 --cicsplex PLEX1 --scope TESTGRP1 --cics-hlq CICSTS55.CICS720 --cpsm-hlq CICSTS55.CPSM550 --res-group BUNDGRP1` -* Create a cics-deploy profile called 'example3' to connect to -the same CPSM managed group of regions, and identify the default USS directory -to which bundles should be uploaded: +* Create a cics\-deploy profile called 'example3' to connect +to the same CPSM managed group of regions, and identify the default USS +directory to which bundles should be uploaded: * `$ zowe profiles create cics-deploy-profile example3 --cicsplex PLEX1 --scope TESTGRP1 --cics-hlq CICSTS55.CICS720 --cpsm-hlq CICSTS55.CPSM550 --target-directory /var/cicsts/bundles` @@ -775,8 +775,8 @@ command\. By default, you will be prompted to confirm the profile removal\. * `profileName` *(string)* - * Specifies the name of the cics\-deploy profile to be deleted\. You can also load - this profile by using the name on commands that support the + * Specifies the name of the cics\-deploy profile to be deleted\. You can also + load this profile by using the name on commands that support the "\-\-cics\-deploy\-profile" option\. #### Options @@ -784,16 +784,16 @@ command\. By default, you will be prompted to confirm the profile removal\. * `--force` *(boolean)* * Force deletion of profile, and dependent profiles if specified\. No prompt will - be displayed before deletion occurs\. + be displayed before deletion occurs\. #### Examples -* Delete a cics-deploy profile named profilename: +* Delete a cics\-deploy profile named profilename: * `$ zowe profiles delete cics-deploy-profile profilename` ## list | ls -List profiles of the type +List profiles of the type . ### cics-deploy-profiles Specifies the target environment for the cics\-deploy deploy and undeploy actions\. @@ -806,16 +806,16 @@ actions\. * `--show-contents` | `--sc` *(boolean)* - * List cics\-deploy profiles and their contents\. All profile details will be + * List cics\-deploy profiles and their contents\. All profile details will be printed as part of command output\. #### Examples -* List profiles of type cics-deploy: +* List profiles of type cics\-deploy: * `$ zowe profiles list cics-deploy-profiles` -* List profiles of type cics-deploy and display their +* List profiles of type cics\-deploy and display their contents: * `$ zowe profiles list cics-deploy-profiles --sc` @@ -844,7 +844,7 @@ requirements\. #### Examples -* Set the default profile for type cics-deploy to the profile +* Set the default profile for type cics\-deploy to the profile named 'profilename': * `$ zowe profiles set-default cics-deploy-profile profilename` diff --git a/junit.xml b/junit.xml index f2fe3f23..9feab154 100644 --- a/junit.xml +++ b/junit.xml @@ -1,65 +1,502 @@ - - - + + + - + - + - + - + - + - + - + - + - - Error: expect(received).not.toBe(expected) // Object.is equality - -Expected: not "" - at C:\temp\zowe\cics\zowe-cli-cics-deploy-plugin\__tests__\__system__\cli\generate\cli.generate.bundle.system.test.ts:131:44 - at Generator.next (<anonymous>) - at fulfilled (C:\temp\zowe\cics\zowe-cli-cics-deploy-plugin\__tests__\__system__\cli\generate\cli.generate.bundle.system.test.ts:16:58) - at process._tickCallback (internal/process/next_tick.js:68:7) + - + - + - + - - Error: expect(received).not.toBe(expected) // Object.is equality - -Expected: not "" - at C:\temp\zowe\cics\zowe-cli-cics-deploy-plugin\__tests__\__system__\cli\generate\cli.generate.bundle.system.test.ts:131:44 - at Generator.next (<anonymous>) - at fulfilled (C:\temp\zowe\cics\zowe-cli-cics-deploy-plugin\__tests__\__system__\cli\generate\cli.generate.bundle.system.test.ts:16:58) - at process._tickCallback (internal/process/next_tick.js:68:7) + - - Error: expect(received).not.toBe(expected) // Object.is equality - -Expected: not "" - at C:\temp\zowe\cics\zowe-cli-cics-deploy-plugin\__tests__\__system__\cli\generate\cli.generate.bundle.system.test.ts:131:44 - at Generator.next (<anonymous>) - at fulfilled (C:\temp\zowe\cics\zowe-cli-cics-deploy-plugin\__tests__\__system__\cli\generate\cli.generate.bundle.system.test.ts:16:58) - at process._tickCallback (internal/process/next_tick.js:68:7) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Error: expect(received).not.toBe(expected) // Object.is equality + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: expect(received).toMatchSnapshot() + +Snapshot name: `AutoBundler01 should detect a bad package.json 1` -Expected: not "" - at C:\temp\zowe\cics\zowe-cli-cics-deploy-plugin\__tests__\__system__\cli\generate\cli.generate.bundle.system.test.ts:131:44 +- Snapshot - 1 ++ Received + 3 + +- Parsing error occurred reading package.json: Unexpected token g in JSON at position 0 ++ Parsing error occurred reading package.json: Unexpected token 'g', "garbage ++ ++ " is not valid JSON + at /Users/adamcoulthard/Documents/git/zowe-cli-cics-deploy-plugin/__tests__/api/BundleContent/AutoBundler.test.ts:203:23 + at Generator.next (<anonymous>) + at /Users/adamcoulthard/Documents/git/zowe-cli-cics-deploy-plugin/__tests__/api/BundleContent/AutoBundler.test.ts:18:71 + at new Promise (<anonymous>) + at Object.<anonymous>.__awaiter (/Users/adamcoulthard/Documents/git/zowe-cli-cics-deploy-plugin/__tests__/api/BundleContent/AutoBundler.test.ts:14:12) + at runAutoBundleWithError (/Users/adamcoulthard/Documents/git/zowe-cli-cics-deploy-plugin/__tests__/api/BundleContent/AutoBundler.test.ts:174:12) + at /Users/adamcoulthard/Documents/git/zowe-cli-cics-deploy-plugin/__tests__/api/BundleContent/AutoBundler.test.ts:163:15 at Generator.next (<anonymous>) - at fulfilled (C:\temp\zowe\cics\zowe-cli-cics-deploy-plugin\__tests__\__system__\cli\generate\cli.generate.bundle.system.test.ts:16:58) - at process._tickCallback (internal/process/next_tick.js:68:7) + at /Users/adamcoulthard/Documents/git/zowe-cli-cics-deploy-plugin/__tests__/api/BundleContent/AutoBundler.test.ts:18:71 + at new Promise (<anonymous>) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json index 0753ac28..e54d2db5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zowe-cli-cics-deploy-plugin", - "version": "1.1.0", + "version": "1.1.1", "description": "IBM CICS Bundle generation and deployment for Zowe CLI", "repository": { "type": "git", @@ -18,7 +18,11 @@ "main": "lib/index.js", "files": [ "lib", - "NOTICES.md" + "NOTICES.md", + "README.md", + "package.json", + "LICENSE", + "CHANGELOG.md" ], "bin": { "zowe-cli-cics-deploy": "./lib/main.js" @@ -30,7 +34,7 @@ "clean": "rimraf lib", "watch": "tsc --pretty --watch", "prepublishOnly": "npm run build", - "lint": "tslint \"src/**/*.ts\" && tslint \"**/__tests__/**/*.ts\"", + "lint": "tslint \"src/**/*.ts\" && tslint \"__tests__/**/*.ts\"", "test": "npm run test:unit && npm run test:system", "test:system": "env-cmd __tests__/__resources__/env/system.env jest .*/__system__/.* --coverage false", "test:unit": "env-cmd __tests__/__resources__/env/unit.env jest --runInBand --detectOpenHandles --coverage --testPathIgnorePatterns \".*/__system__/.*\"", @@ -41,7 +45,7 @@ "configurationModule": "lib/imperative.js" }, "dependencies": { - "@zowe/cics-for-zowe-cli": "^3.6.1", + "@zowe/cics-for-zowe-cli": "^4.0.8", "fast-xml-parser": "^3.16.0" }, "devDependencies": { @@ -53,6 +57,7 @@ "@types/yargs": "^13.0.4", "clear-require": "^2.0.0", "env-cmd": "^8.0.2", + "fast-xml-parser": "^4.2.4", "fs-extra": "^8.1.0", "gulp": "^4.0.2", "gulp-cli": "^2.2.1", diff --git a/src/api/BundleContent/Manifest.ts b/src/api/BundleContent/Manifest.ts index 3a193722..679be5e9 100644 --- a/src/api/BundleContent/Manifest.ts +++ b/src/api/BundleContent/Manifest.ts @@ -14,9 +14,9 @@ import { BundlePart, IBundlePartDataType } from "./BundlePart"; import { IHandlerParameters } from "@zowe/imperative"; -import * as parser from "fast-xml-parser"; +const { XMLParser, XMLBuilder } = require("fast-xml-parser"); -const serialiser = new parser.j2xParser({ignoreAttributes: false, attributeNamePrefix: ""}); +const serialiser = new XMLBuilder({ignoreAttributes: false, attributeNamePrefix: ""}); /** * Interface to represent the manifest data for a CICS Bundle. @@ -388,7 +388,7 @@ export class Manifest { try { // Reading the file worked, so convert the contents into a JSON Object - this.manifestAsJson = parser.parse(xmltext, {ignoreAttributes: false, attributeNamePrefix: "", trimValues: true}); + this.manifestAsJson = XMLParser.parse(xmltext, {ignoreAttributes: false, attributeNamePrefix: "", trimValues: true}); } catch (exception) { diff --git a/src/api/BundleContent/NodejsappBundlePart.ts b/src/api/BundleContent/NodejsappBundlePart.ts index f260b866..c674faf7 100644 --- a/src/api/BundleContent/NodejsappBundlePart.ts +++ b/src/api/BundleContent/NodejsappBundlePart.ts @@ -14,9 +14,9 @@ import { BundlePart } from "./BundlePart"; import { TemplateNodejsappProfile } from "./TemplateNodejsappProfile"; import { IHandlerParameters } from "@zowe/imperative"; -import * as parser from "fast-xml-parser"; +const { XMLBuilder } = require("fast-xml-parser"); -const serialiser = new parser.j2xParser({ignoreAttributes: false, attributeNamePrefix: ""}); +const serialiser = new XMLBuilder({ignoreAttributes: false, attributeNamePrefix: ""}); /** * Interface to represent the manifest data for a NODEJSAPP BundlePart.