Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize additional properties for the ConvertV1Profiles.convert function #2182

Merged
merged 17 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/imperative/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the Imperative package will be documented in this file.

## Recent Changes

- BugFix: V3 Breaking: Modified the ConvertV1Profiles.convert API to accept a new ProfileInfo option and initialize components sufficiently to enable VSCode apps to convert V1 profiles. [#2170](https://github.com/zowe/zowe-cli/issues/2170)

## `8.0.0-next.202407021516`

- BugFix: Updated dependencies for technical currency [#2188](https://github.com/zowe/zowe-cli/pull/2188)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"@zowe/secure-credential-store-for-zowe-cli": {
"package": "@zowe/secure-credential-store-for-zowe-cli@zowe-v1-lts",
"registry": "https://registry.npmjs.org/",
"version": "4.1.12"
},
"@zowe/cics-for-zowe-cli": {
"package": "@zowe/cics-for-zowe-cli@zowe-v1-lts",
"registry": "https://registry.npmjs.org/",
"version": "4.0.11"
},
"@broadcom/jclcheck-for-zowe-cli": {
"package": "@broadcom/jclcheck-for-zowe-cli@zowe-v1-lts",
"registry": "https://registry.npmjs.org/",
"version": "1.1.2"
},
"@broadcom/endevor-for-zowe-cli": {
"package": "@broadcom/endevor-for-zowe-cli@zowe-v1-lts",
"registry": "https://registry.npmjs.org/",
"version": "5.7.6"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe("imperative-test-cli config convert-profiles", () => {

beforeEach(() => {
fsExtra.copySync(__dirname + "/../../config/__resources__/profiles_secured_and_base", TEST_ENVIRONMENT.workingDir + "/profiles");
fsExtra.copySync(__dirname + "/../../config/__resources__/plugins", TEST_ENVIRONMENT.workingDir + "/plugins");
});

afterEach(() => {
Expand Down
1,028 changes: 724 additions & 304 deletions packages/imperative/src/config/__tests__/ConvertV1Profiles.unit.test.ts

Large diffs are not rendered by default.

492 changes: 283 additions & 209 deletions packages/imperative/src/config/src/ConvertV1Profiles.ts

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions packages/imperative/src/config/src/doc/IConvertV1Profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
*
*/

import { ProfileInfo } from "../ProfileInfo";

/**
* This is the structure of the input options to be supplied to ConvertV1Profiles.convert.
*/
export interface IConvertV1ProfOpts {
// Should V1 profiles be deleted after conversion?
deleteV1Profs: boolean;

// The ProfileInfo object that the API will use to initialize the Secure Credential Manager.
// This property should be supplied by a VSCode application.
profileInfo?: ProfileInfo
}

/**
Expand Down Expand Up @@ -64,12 +70,14 @@ export interface IConvertV1ProfResult {
v1ScsPluginName: string | null;

/**
* This property indicates whether secure credentials were migrated during conversion.
*
* If the old V1 Secure Credential Store plugin was supplying the credential manager
* override, that CredMgr has been replaced with the Zowe CLI built-in credential manager.
* This property indicates whether the caller must re-initialize the credential Manager
* by restarting its app.
* override and the CredentialManager was initialized before calling this function,
* profile conversion will not be able to migrate credentials from the old SCS plugin
* to the current embedded Secure Credential Store.
*/
reInitCredMgr: boolean;
credsWereMigrated: boolean;

/**
* The following properties contain information about the success or failure of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("Configuration Convert Profiles command handler", () => {
{ msgFormat: 2, msgText: "Error Msg 2" }
],
v1ScsPluginName: null as any,
reInitCredMgr: false,
credsWereMigrated: true,
cfgFilePathNm: ConvertV1Profiles["noCfgFilePathNm"],
numProfilesFound: 0,
profilesConverted: {
Expand Down Expand Up @@ -160,7 +160,7 @@ describe("Configuration Convert Profiles command handler", () => {
expect(uninstallSpy).toHaveBeenCalled();
expect(stdout).toContain("Report Msg 1");
expect(stdout).toContain("Report Msg 2");
expect(stdout).toContain('Uninstalled plug-in "fakeScsPluginName"');
expect(stdout).toContain('Successfully uninstalled plug-in fakeScsPluginName');
expect(stderr).toContain("Error Msg 1");
expect(stderr).toContain("Error Msg 2");
});
Expand All @@ -186,7 +186,7 @@ describe("Configuration Convert Profiles command handler", () => {
expect(stdout).toContain("Report Msg 2");
expect(stderr).toContain("Error Msg 1");
expect(stderr).toContain("Error Msg 2");
expect(stderr).toContain('Failed to uninstall plug-in "fakeScsPluginName"');
expect(stderr).toContain('Failed to uninstall plug-in fakeScsPluginName');
expect(stderr).toContain(fakeUninstallErr);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ export default class ConvertProfilesHandler implements ICommandHandler {
try {
uninstallPlugin(convertResult.v1ScsPluginName);
const newMsg = new ConvertMsg(
ConvertMsgFmt.REPORT_LINE, `Uninstalled plug-in "${convertResult.v1ScsPluginName}"`
ConvertMsgFmt.REPORT_LINE | ConvertMsgFmt.PARAGRAPH,
`Successfully uninstalled plug-in ${convertResult.v1ScsPluginName}.`
);
convertResult.msgs.push(newMsg);
} catch (error) {
let newMsg = new ConvertMsg(
ConvertMsgFmt.ERROR_LINE, `Failed to uninstall plug-in "${convertResult.v1ScsPluginName}"`
ConvertMsgFmt.ERROR_LINE | ConvertMsgFmt.PARAGRAPH,
`Failed to uninstall plug-in ${convertResult.v1ScsPluginName}.`
);
convertResult.msgs.push(newMsg);

Expand Down
6 changes: 3 additions & 3 deletions packages/imperative/src/utilities/src/ImperativeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export class ImperativeConfig {
private mConfig: Config;

/**
* Gets a single instance of the PluginIssues. On the first call of
* ImperativeConfig.instance, a new Plugin Issues object is initialized and returned.
* Gets a single instance of the ImperativeConfig. On the first call of
* ImperativeConfig.instance, a new ImperativeConfig object is initialized and returned.
* Every subsequent call will use the one that was first created.
*
* @returns {ImperativeConfig} The newly initialized PMF object.
* @returns {ImperativeConfig} The newly initialized ImperativeConfig object.
*/
public static get instance(): ImperativeConfig {
if (this.mInstance == null) {
Expand Down
Loading