Skip to content

Commit

Permalink
On (no branch): stash
Browse files Browse the repository at this point in the history
  • Loading branch information
jace-roell committed Aug 14, 2024
2 parents 8d51fac + 9e78a2d commit 64ebe3c
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 99 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
uses: dtolnay/rust-toolchain@stable

- name: Check Node Vulnerabilities
run: npm audit --production --audit-level=moderate
run: |
npm install --package-lock-only --ignore-scripts --no-audit --save-prod --workspace=packages/imperative ./packages/imperative/web-help
npm audit --production --audit-level=moderate
# TODO Consider using actions-rs/audit-check after https://github.com/actions-rs/audit-check/issues/116 is fixed
- name: Check Daemon Vulnerabilities
Expand All @@ -35,4 +37,4 @@ jobs:

- name: Check Secrets SDK Vulnerabilities
working-directory: packages/secrets/src/keyring
run: cargo audit --deny warnings
run: cargo audit --deny warnings
1 change: 1 addition & 0 deletions __tests__/__packages__/cli-test-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"target": "es5",
"module": "commonjs",
"declaration": true,
"declarationMap": true,
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
Expand Down
40 changes: 24 additions & 16 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/imperative/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,16 @@ All notable changes to the Imperative package will be documented in this file.

- Major: First major version bump for V3

## `5.27.0`

- BugFix: Modified `showMsgWhenDeprecated` function to allow an empty string as a parameter when no replacement is available for the deprecated command. When no replacement is available an alternative message will be printed. [#2041](https://github.com/zowe/zowe-cli/issues/2041)
- BugFix: Resolved bug that resulted in user not being prompted for a key passphrase if it is located in the secure credential array of the ssh profile. [#1770](https://github.com/zowe/zowe-cli/issues/1770)

## `5.26.3`

- BugFix: Fixed issue in local web help with highlighted sidebar item getting out of sync. [#2215](https://github.com/zowe/zowe-cli/pull/2215)
- BugFix: Updated web help dependencies for technical currency. [#2215](https://github.com/zowe/zowe-cli/pull/2215)

## `5.26.2`

- BugFix: Refactored code to reduce the use of deprecated functions to prepare for upcoming Node.js 22 support. [#2191](https://github.com/zowe/zowe-cli/issues/2191)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ describe("cmd-cli profile mapping", () => {
const moldType = "none";
const response = runCliScript(__dirname + "/__scripts__/profiles/name_type_undefined.sh",
TEST_ENVIRONMENT.workingDir, [color, description, moldType]);

// name and type should be undefined since we did not specify them via command line
expect(response.stderr.toString()).toBe("");
expect(response.stdout.toString()).toContain("Name: undefined");
Expand All @@ -317,7 +316,6 @@ describe("cmd-cli profile mapping", () => {
const cliType = "Big";
const response = runCliScript(__dirname + "/__scripts__/profiles/name_type_specify.sh",
TEST_ENVIRONMENT.workingDir, [color, description, moldType, cliName, cliType]);

// name and type should be undefined since we did not specify them via command line
expect(response.stderr.toString()).toBe("");
expect(response.stdout.toString()).toContain("Name: " + cliName);
Expand Down
4 changes: 3 additions & 1 deletion packages/imperative/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"files": [
"lib",
"web-help/dist",
"web-help/package*.json",
"web-diff"
],
"publishConfig": {
Expand All @@ -40,7 +41,8 @@
"typedoc": "typedoc --options ./typedoc.json ./src/",
"typedocSpecifySrc": "typedoc --options ./typedoc.json",
"prepack": "node ../../scripts/prepareLicenses.js",
"clean": "rimraf lib tsconfig.tsbuildinfo"
"clean": "rimraf lib tsconfig.tsbuildinfo",
"prepublishOnly": "cd web-help && npm run deps:lockfile"
},
"dependencies": {
"@types/yargs": "^17.0.32",
Expand Down
14 changes: 11 additions & 3 deletions packages/imperative/src/cmd/src/help/DefaultHelpGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class DefaultHelpGenerator extends AbstractHelpGenerator {
let summaryText: string = "";
summaryText += command.summary || command.description;

if (command.deprecatedReplacement) {
if (command.deprecatedReplacement != null) {
// Mark with the deprecated tag
summaryText += this.grey(" (deprecated)");
} else if (command.experimental) {
Expand Down Expand Up @@ -359,10 +359,18 @@ export class DefaultHelpGenerator extends AbstractHelpGenerator {
|| this.mCommandDefinition.summary;

// we place the deprecated message in the DESCRIPTION help section
if (this.mCommandDefinition.deprecatedReplacement) {
if (this.mCommandDefinition.deprecatedReplacement != null) {
const noNewlineInText = this.mCommandDefinition.deprecatedReplacement.replace(/\n/g, " ");
description += this.grey("\n\nWarning: This " + this.mCommandDefinition.type +
" has been deprecated.\nRecommended replacement: " + noNewlineInText);
" has been deprecated.\n");
if(this.mCommandDefinition.deprecatedReplacement === "")
{
description += this.grey("Obsolete component. No replacement exists");
}
else
{
description += this.grey("Recommended replacement: " + noNewlineInText);
}
}
if (this.mProduceMarkdown) {
description = this.escapeMarkdown(description); // escape Markdown special characters
Expand Down
3 changes: 1 addition & 2 deletions packages/imperative/src/cmd/src/utils/CommandUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ export class CommandUtils {
if (CommandUtils.optionWasSpecified(option, commandDefinition, commandArguments)) {
// don't print "true" for boolean options
command += " " + CliUtils.getDashFormOfOption(option) + " ";
command += CommandUtils.getOptionDefinitionFromName(option, commandDefinition).type
=== "boolean" ? "" : commandArguments[option];
command += CommandUtils.getOptionDefinitionFromName(option, commandDefinition)?.type === "boolean" ? "" : commandArguments[option];
}
}
return command.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { IOptionsForAddConnProps } from "../../src/session/doc/IOptionsForAddCon
import { ImperativeConfig } from "../../../utilities";
import { ConfigUtils } from "../../../config/src/ConfigUtils";
import { ISshSession } from "../../../../../zosuss/lib/doc/ISshSession";

const certFilePath = join(
__dirname,
"..",
Expand Down Expand Up @@ -57,7 +58,6 @@ const certKeyFilePath = join(
"__resources__",
"fakeKey.key"
);

interface extendedSession extends ISession {
someKey?: string;
}
Expand Down Expand Up @@ -1753,41 +1753,6 @@ describe("ConnectionPropsForSessCfg tests", () => {
);
});

it("should state that V1 profiles are not supported", async () => {
// Pretend that we do not have a zowe config.
Object.defineProperty(ImperativeConfig.instance, "config", {
configurable: true,
get: jest.fn(() => {
return {
exists: false,
};
}),
});

/* Pretend that we only have V1 profiles.
* onlyV1ProfilesExist is a getter property, so mock the property.
*/
Object.defineProperty(ConfigUtils, "onlyV1ProfilesExist", {
configurable: true,
get: jest.fn(() => {
return true;
}),
});

// call the function that we want to test
await getValuesCallBack(["hostname"]);

expect(consoleMsgs).toContain(
"Only V1 profiles exist. V1 profiles are no longer supported. You should convert"
);
expect(consoleMsgs).toContain(
"your V1 profiles to a newer Zowe client configuration. Therefore, you will be"
);
expect(consoleMsgs).toContain(
"asked for the connection properties that are required to complete your command."
);
});

it("should state that connection properties are missing from config", async () => {
// Pretend that we have a zowe config.
Object.defineProperty(ImperativeConfig.instance, "config", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export class ConnectionPropsForSessCfg {
this.promptTextForValues[obj.name.toString()] = obj.description;
});
}

// check what properties are needed to be prompted
if (ConnectionPropsForSessCfg.propHasValue(sessCfgToUse.hostname) === false && !doNotPromptForValues.includes("hostname")) {
promptForValues.push("hostname");
Expand Down Expand Up @@ -188,7 +187,6 @@ export class ConnectionPropsForSessCfg {
}
});
}

// validate what values are given back and move it to sessCfgToUse
for (const value of promptForValues) {
if (ConnectionPropsForSessCfg.propHasValue(answers[value])) {
Expand Down Expand Up @@ -415,7 +413,8 @@ export class ConnectionPropsForSessCfg {
let answer;
while (answer === undefined) {
const hideText = profileSchema[value]?.secure || this.secureSessCfgProps.has(value);
let promptText = `${this.promptTextForValues[value] ?? `Enter your ${value} for`} ${serviceDescription}`;
const valuePrompt = this.promptTextForValues[value] ?? `Enter your ${value} for`;
let promptText = `${valuePrompt} ${serviceDescription}`;
if (hideText) {
promptText += " (will be hidden)";
}
Expand Down Expand Up @@ -473,7 +472,7 @@ export class ConnectionPropsForSessCfg {
sessCfg: SessCfgType,
options: IOptionsForAddConnProps<SessCfgType>,
tokenType: SessConstants.TOKEN_TYPE_CHOICES
) {
) {
const impLogger = Logger.getImperativeLogger();
if (options.requestToken) {
impLogger.debug("Requesting a token");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,22 @@ describe("CliUtils", () => {
CliUtils.showMsgWhenDeprecated(handlerParms);
expect(responseErrText).toEqual("Recommended replacement: " +
handlerParms.definition.deprecatedReplacement);
expect(responseErrText).not.toContain("Obsolete component. No replacement exists");
});

it("should not produce a deprecated message when not deprecated", () => {
responseErrText = notSetYet;
delete handlerParms.definition.deprecatedReplacement;
CliUtils.showMsgWhenDeprecated(handlerParms);
expect(responseErrText).toEqual(notSetYet);
expect(responseErrText).not.toContain("Obsolete component. No replacement exists");
});

it("should produce alternative text when deprecatedReplacement is an empty string", () => {
responseErrText = notSetYet;
handlerParms.definition.deprecatedReplacement = "";
CliUtils.showMsgWhenDeprecated(handlerParms);
expect(responseErrText).toContain("Obsolete component. No replacement exists");
});
});

Expand Down
22 changes: 11 additions & 11 deletions packages/imperative/src/utilities/src/CliUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,20 @@ export class CliUtils {
* @memberof CliUtils
*/
public static showMsgWhenDeprecated(handlerParms: IHandlerParameters) {
if (handlerParms.definition.deprecatedReplacement) {
if (handlerParms.definition.deprecatedReplacement || handlerParms.definition.deprecatedReplacement === "") {
// form the command that is deprecated
let oldCmd: string | number;
if (handlerParms.positionals.length >= 1) {
oldCmd = handlerParms.positionals[0];
}
if (handlerParms.positionals.length >= 2) {
oldCmd = oldCmd + " " + handlerParms.positionals[1];
}

const oldCmd = handlerParms.positionals.join(" ");
// display the message
handlerParms.response.console.error("\nWarning: The command '" + oldCmd + "' is deprecated.");
handlerParms.response.console.error("Recommended replacement: " +
handlerParms.definition.deprecatedReplacement);
if(handlerParms.definition.deprecatedReplacement === "")
{
handlerParms.response.console.error("Obsolete component. No replacement exists");
}
else
{
handlerParms.response.console.error("Recommended replacement: " +
handlerParms.definition.deprecatedReplacement);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/imperative/web-help/dist/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ body {
width: calc(100% - 10px);
}

#tree-search::placeholder {
color: var(--bs-secondary);
}

#tree-tabs {
margin: 0 5px 5px 5px;
width: calc(100% - 10px);
Expand Down
10 changes: 7 additions & 3 deletions packages/imperative/web-help/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function arrayFrom(items: any): any[] {

const isInIframe: boolean = window.location !== window.parent.location;
const links: any = arrayFrom(document.getElementsByTagName("a"));
const sameOrigin: string = window.location.protocol !== "file:" ? window.location.origin : "*";

// Process all <a> tags on page
links.forEach((link: any) => {
Expand All @@ -36,7 +37,10 @@ links.forEach((link: any) => {
link.setAttribute("target", "_blank");
} else if (isInIframe) {
// If link is relative and page is inside an iframe, then send signal to command tree when link is clicked to make it update selected node
link.setAttribute("onclick", "window.parent.postMessage(this.href, '*'); return true;");
link.onclick = (e: any) => {
window.parent.postMessage(e.target.href, sameOrigin);
return true;
};
}
});

Expand Down Expand Up @@ -89,9 +93,9 @@ function findCurrentCmdAnchor() {
if (isInIframe && window.location.href.indexOf("/all.html") !== -1) {
let currentCmdName: string;
window.onscroll = (_: any) => {
const cmdName = findCurrentCmdAnchor().getAttribute("name");
const cmdName = findCurrentCmdAnchor()?.getAttribute("name");
if (cmdName != null && cmdName !== currentCmdName) {
window.parent.postMessage(cmdName + ".html", window.location.origin);
window.parent.postMessage(cmdName + ".html", sameOrigin);
currentCmdName = cmdName;
}
};
Expand Down
Loading

0 comments on commit 64ebe3c

Please sign in to comment.