Skip to content

Conversation

@1000TurquoisePogs
Copy link
Member

This PR rewrites the zwe version command as a configmgr command, removing the shell code.
The shell code was also looking for manifest.json.template, but that seems like unused code, so i removed it and only check for manifest.json.

Signed-off-by: 1000TurquoisePogs <[email protected]>
@github-actions
Copy link

github-actions bot commented May 9, 2025

build 7624 SUCCEEDED.
Link to workflow run: https://github.com/zowe/zowe-install-packaging/actions/runs/14930285279

@github-actions
Copy link

github-actions bot commented May 9, 2025

Test workflow 6595 is started.
Running install test: Convenience Pax
The zowe artifact being used by this test workflow: libs-snapshot-local/org/zowe/3.2.0-PR-4322/zowe-3.2.0-pr-4322-7624-20250509134806.pax
Running on machine: zzow11
Result: SUCCESS
Link to workflow run: https://github.com/zowe/zowe-install-packaging/actions/runs/14930423900

import * as config from '../../libs/config';

export function execute() {
common.requireZoweYaml();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current zwe version is working without --config and prints the version of Zowe where the zwe is located.

This new version requires --config (which is a breaking change, but acceptable for this type of command), because it can print any Zowe version - it will use zowe.runtimeDirectory to locate manifest/version.

If possible, I would like to have this behavior:

  • If no config, return ZWE_zowe_runtimeDirectory/manifest.json -> version
    • This is very handy, if you (as a developer) have multiple versions and you can easily get the version without config
  • If config, return whatever is defined at the end of zowe.runtimeDirectory/manifest.json -> version

.examples - new example with config
.help - if we implement config yes/no behavior, couple words here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh - so there was a reason we didnt do this :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly, but works with/without config:

import * as std from 'cm_std';
import * as common from '../../libs/common';
import * as fs from '../../libs/fs';
import * as shell from '../../libs/shell';
import * as xplatform from 'xplatform';

export function execute() {

    const cliConfig = std.getenv('ZWE_CLI_PARAMETER_CONFIG');
    const currentRuntimeDirectory = std.getenv('ZWE_zowe_runtimeDirectory');
    let runtimeDirectory = currentRuntimeDirectory;

    if (cliConfig) {
      const configmgr = `${currentRuntimeDirectory}/bin/utils/configmgr`;
      const schema = `${currentRuntimeDirectory}/schemas/server-common.json:${currentRuntimeDirectory}/schemas/zowe-yaml-schema.json`;
      let file = cliConfig;
      if (fs.fileExists(file)) {
        // FILE is required for configmgr extract for a single file
        file = `FILE(${cliConfig})`;
      }
      const result = shell.execOutSync('sh', '-c', `_CEE_RUNOPTS="XPLINK(ON)" "${configmgr}" -s "$schema" -p "${file}" extract "/zowe/runtimeDirectory" 2>&1`);
      if (result.rc == 0 && result.out) {
        runtimeDirectory = result.out;
      } else {
        common.printErrorAndExit("Error ZWEL0150E: Failed to find Zowe manifest.json. Zowe runtimeDirectory is invalid.", undefined, 150);
      }
    }

    const manifestPath = `${runtimeDirectory}/manifest.json`;
    if (!fs.fileExists(manifestPath)) {
      common.printErrorAndExit("Error ZWEL0150E: Failed to find Zowe manifest.json. Zowe runtimeDirectory is invalid.", undefined, 150);
    }

    const contents = xplatform.loadFileUTF8(manifestPath, xplatform.AUTO_DETECT);
    const manifest = JSON.parse(contents);
    common.printMessage("Zowe v" + manifest.version);
    common.printDebug(`build and hash: ${manifest.build.branch}#${manifest.build.number} (${manifest.build.commitHash})`);
    common.printTrace(`Zowe directory: ${runtimeDirectory}`);

}

@1000TurquoisePogs 1000TurquoisePogs marked this pull request as draft May 10, 2025 08:09
Signed-off-by: Martin Zeithaml <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants