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

[vNext] Update SDKs and address breaking changes #2932

Merged
merged 24 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
74f29ec
update SDKs and address breaking changes
JillieBeanSim Jun 3, 2024
e39b222
add CHANGELOGs
JillieBeanSim Jun 4, 2024
88f3eca
Replace ConfigBuilder with ConvertV1Profiles in API unit tests
t1m0thyj Jun 4, 2024
1efd4f7
Add appendFileSync mock to fix unit test
t1m0thyj Jun 4, 2024
c759100
changes after testing convertV1Profiles
JillieBeanSim Jun 6, 2024
7c810ef
Add base profile when creating team config
t1m0thyj Jun 7, 2024
b73f479
Merge remote-tracking branch 'origin/next' into update-sdks
JillieBeanSim Jun 19, 2024
b795f05
Await profile conversion before loading ZE
t1m0thyj Jun 24, 2024
9d217d8
Merge branch 'next' into update-sdks
t1m0thyj Jun 25, 2024
68bff9e
Merge branch 'next' into update-sdks
t1m0thyj Jul 3, 2024
b6ea6c8
Update dialog text and pass ProfileInfo to convert API
t1m0thyj Jul 5, 2024
634884b
Update Zowe SDKs again and fix unit test
t1m0thyj Jul 8, 2024
0d201d0
Update braces dep to fix audit check
t1m0thyj Jul 8, 2024
6eee6dd
clean up commented code
JillieBeanSim Jul 9, 2024
1a2a3cd
open config after conversion
JillieBeanSim Jul 9, 2024
8edba0c
update version in CHANGELOGs
JillieBeanSim Jul 11, 2024
3878944
Enhance response message for convert v1 profiles
t1m0thyj Jul 12, 2024
39b1e13
Document static method change in changelog
t1m0thyj Jul 17, 2024
a33b419
Merge branch 'next' into update-sdks
t1m0thyj Jul 17, 2024
72e0901
address comment about interface ZeApiConvertResponse
JillieBeanSim Jul 18, 2024
309c492
add codecov
JillieBeanSim Jul 19, 2024
bfdd4b1
more codecov added
JillieBeanSim Jul 19, 2024
aca7442
cover elses in testing
JillieBeanSim Jul 19, 2024
4f1c8aa
address comment
JillieBeanSim Jul 23, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@
"test:parallel": "pnpm -r --parallel --color test",
"package": "pnpm -r --sequential package",
"preinstall": "npx only-allow pnpm",
"update-sdks": "pnpm -r update \"@zowe/*@next\" \"!@zowe/zowe-explorer-api\""
"update-sdks": "pnpm -r update \"@zowe/*@next\" \"!@zowe/zowe-explorer-api\" \"!@zowe/zos-ftp-for-zowe-cli\""
}
}
2 changes: 2 additions & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
- Updated the `ProfilesCache.getProfiles` method to return empty list instead of undefined when there are no profiles. [#2947](https://github.com/zowe/zowe-explorer-vscode/pull/2947)
- Added PEM certificate support as an authentication method for logging into the API ML. [#2621](https://github.com/zowe/zowe-explorer-vscode/issues/2621)
- Deprecated the `getUSSDocumentFilePath` function on the `IZoweTreeNode` interface as Zowe Explorer no longer uses the local file system for storing USS files. **No replacement is planned**; please access data from tree nodes using their [resource URIs](https://github.com/zowe/zowe-explorer-vscode/wiki/FileSystemProvider#operations-for-extenders) instead. [#2968](https://github.com/zowe/zowe-explorer-vscode/pull/2968)
- **Next Breaking:** Changed `ProfilesCache.convertV1ProfToConfig` method to be a static method that requires `ProfileInfo` instance as a parameter.

### Bug fixes

- Fixed an issue where the `onProfilesUpdate` event did not fire after secure credentials were updated. [#2822](https://github.com/zowe/zowe-explorer-vscode/issues/2822)
- Fixed an issue where `ProfilesCache` may return missing or incorrect profile values when multiple extensions call it during activation. [#2831](https://github.com/zowe/zowe-explorer-vscode/issues/2831)
- Removed `handlebars` dependency in favor of `mustache` for technical currency purposes. [#2975](https://github.com/zowe/zowe-explorer-vscode/pull/2975)
- Update Zowe SDKs to `8.0.0-next.202407051717` for technical currency. [#2918](https://github.com/zowe/zowe-explorer-vscode/issues/2918)

## `3.0.0-next.202404242037`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as path from "path";
import * as fs from "fs";
import * as imperative from "@zowe/imperative";
import { ProfilesCache } from "../../../src/profiles/ProfilesCache";
import { FileManagement, ZoweExplorerApi } from "../../../src";
import { FileManagement, Types } from "../../../src";

jest.mock("fs");

Expand Down Expand Up @@ -141,6 +141,7 @@ describe("ProfilesCache", () => {

it("getProfileInfo should initialize ProfileInfo API", async () => {
const existsSync = jest.spyOn(fs, "existsSync").mockImplementation();
jest.spyOn(FileManagement, "getZoweDir").mockReturnValue(fakeZoweDir);
const profInfo = await new ProfilesCache(fakeLogger as unknown as imperative.Logger, __dirname).getProfileInfo();
expect(readProfilesFromDiskSpy).toHaveBeenCalledTimes(1);
expect(defaultCredMgrWithKeytarSpy).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -260,7 +261,7 @@ describe("ProfilesCache", () => {
it("should refresh profile data for multiple profile types", async () => {
const profCache = new ProfilesCache({ ...fakeLogger, error: mockLogError } as unknown as imperative.Logger);
const getProfInfoSpy = jest.spyOn(profCache, "getProfileInfo").mockResolvedValue(createProfInfoMock([lpar1Profile, zftpProfile]));
await profCache.refresh(fakeApiRegister as unknown as ZoweExplorerApi.IApiRegisterClient);
await profCache.refresh(fakeApiRegister as unknown as Types.IApiRegisterClient);
expect(profCache.allProfiles.length).toEqual(2);
expect(profCache.allProfiles[0]).toMatchObject(lpar1Profile);
expect(profCache.allProfiles[1]).toMatchObject(zftpProfile);
Expand All @@ -273,7 +274,7 @@ describe("ProfilesCache", () => {
jest.spyOn(profCache, "getProfileInfo").mockResolvedValue(
createProfInfoMock([lpar1ProfileWithToken, lpar2ProfileWithToken, baseProfileWithToken])
);
await profCache.refresh(fakeApiRegister as unknown as ZoweExplorerApi.IApiRegisterClient);
await profCache.refresh(fakeApiRegister as unknown as Types.IApiRegisterClient);
expect(profCache.allProfiles.length).toEqual(3);
expect(profCache.allProfiles[0]).toMatchObject(lpar1ProfileWithToken);
expect(profCache.allProfiles[1]).toMatchObject(lpar2Profile); // without token
Expand All @@ -288,7 +289,7 @@ describe("ProfilesCache", () => {
jest.spyOn(profCache, "getProfileInfo").mockImplementation(() => {
throw fakeError;
});
await profCache.refresh(fakeApiRegister as unknown as ZoweExplorerApi.IApiRegisterClient);
await profCache.refresh(fakeApiRegister as unknown as Types.IApiRegisterClient);
expect(profCache.allProfiles.length).toEqual(0);
expect(profCache.getAllTypes().length).toEqual(0);
expect(mockLogError).toHaveBeenCalledWith(fakeError);
Expand Down Expand Up @@ -438,55 +439,48 @@ describe("ProfilesCache", () => {
});

describe("convertV1ProfToConfig", () => {
Object.defineProperty(FileManagement, "getZoweDir", { value: jest.fn().mockReturnValue(fakeZoweDir), configurable: true });
Object.defineProperty(ProfilesCache, "addToConfigArray", { value: jest.fn(), configurable: true });
Object.defineProperty(fs, "renameSync", { value: jest.fn(), configurable: true });
Object.defineProperty(ProfilesCache, "getConfigArray", { value: jest.fn(), configurable: true });
it("Should convert v1 profiles to config file", async () => {
const profCache = new ProfilesCache(fakeLogger as unknown as imperative.Logger);
jest.spyOn(imperative.ConfigBuilder, "convert").mockImplementationOnce(() => {
const profInfo = createProfInfoMock([lpar1Profile]);
jest.spyOn(imperative.ConvertV1Profiles, "convert").mockImplementationOnce(() => {
return {
profilesConverted: { zosmf: ["profile1"] },
profilesFailed: {},
config: {},
} as any;
});
await expect(profCache.convertV1ProfToConfig()).resolves.not.toThrow();
await expect(ProfilesCache.convertV1ProfToConfig(profInfo)).resolves.not.toThrow();
});
it("Should convert v1 profiles to config file with profilesFailed", async () => {
const profCache = new ProfilesCache(fakeLogger as unknown as imperative.Logger);
jest.spyOn(imperative.ConfigBuilder, "convert").mockImplementationOnce(() => {
const profInfo = createProfInfoMock([lpar1Profile]);
jest.spyOn(imperative.ConvertV1Profiles, "convert").mockImplementationOnce(() => {
return {
profilesConverted: {},
profilesFailed: [{ name: ["profile2"], types: "zosmf", error: "Error converting" }],
config: {},
} as any;
});
await expect(profCache.convertV1ProfToConfig()).resolves.not.toThrow();
await expect(ProfilesCache.convertV1ProfToConfig(profInfo)).resolves.not.toThrow();
});
it("Should convert v1 profiles to config even if rename of profiles directory fails", async () => {
Object.defineProperty(fs, "renameSync", {
value: jest.fn().mockImplementation(() => {
throw new Error("Error renaming file");
}),
configurable: true,
jest.spyOn(fs, "renameSync").mockImplementationOnce(() => {
throw new Error("Error renaming file");
});
const profCache = new ProfilesCache(fakeLogger as unknown as imperative.Logger);
jest.spyOn(imperative.ConfigBuilder, "convert").mockImplementationOnce(() => {
const profInfo = createProfInfoMock([lpar1Profile]);
jest.spyOn(imperative.ConvertV1Profiles, "convert").mockImplementationOnce(() => {
return {
profilesConverted: {},
profilesFailed: [{ name: ["profile2"], types: "zosmf", error: "Error converting" }],
config: {},
} as any;
});
await expect(profCache.convertV1ProfToConfig()).resolves.not.toThrow();
await expect(ProfilesCache.convertV1ProfToConfig(profInfo)).resolves.not.toThrow();
});
it("Should reject if error thrown other than renaming profiles directory", async () => {
const profCache = new ProfilesCache(fakeLogger as unknown as imperative.Logger);
jest.spyOn(imperative.ConfigBuilder, "convert").mockImplementationOnce(() => {
const profInfo = createProfInfoMock([lpar1Profile]);
jest.spyOn(imperative.ConvertV1Profiles, "convert").mockImplementationOnce(() => {
throw new Error("Error converting config");
});
await expect(profCache.convertV1ProfToConfig()).rejects.toThrow("Error converting config");
await expect(ProfilesCache.convertV1ProfToConfig(profInfo)).rejects.toThrow("Error converting config");
});
});

Expand Down
18 changes: 9 additions & 9 deletions packages/zowe-explorer-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
},
"dependencies": {
"@types/vscode": "^1.53.2",
"@zowe/core-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/imperative": "8.0.0-next.202404032038",
"@zowe/secrets-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/zos-console-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/zos-files-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/zos-jobs-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/zos-tso-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/zos-uss-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/zosmf-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/core-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/imperative": "8.0.0-next.202407051717",
"@zowe/secrets-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/zos-console-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/zos-files-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/zos-jobs-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/zos-tso-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/zos-uss-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/zosmf-for-zowe-sdk": "8.0.0-next.202407051717",
"mustache": "^4.2.0",
"semver": "^7.6.0"
},
Expand Down
18 changes: 0 additions & 18 deletions packages/zowe-explorer-api/src/globals/Interfaces.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/zowe-explorer-api/src/globals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
export * from "./Constants";
export * from "./Gui";
export * from "./GuiOptions";
export * from "./Interfaces";
52 changes: 6 additions & 46 deletions packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
*
*/

import * as path from "path";
import * as fs from "fs";
import * as imperative from "@zowe/imperative";
import type { IRegisterClient } from "../extend/IRegisterClient";
import { FileManagement } from "../utils";
import { Validation } from "./Validation";
import { ZeApiConvertResponse } from "../globals";
import { ZosmfProfile } from "@zowe/zosmf-for-zowe-sdk";
import { ZosTsoProfile } from "@zowe/zos-tso-for-zowe-sdk";
import { ZosUssProfile } from "@zowe/zos-uss-for-zowe-sdk";
import { ProfileConstants } from "@zowe/core-for-zowe-sdk";

export class ProfilesCache {
public profilesForValidation: Validation.IValidationProfile[] = [];
Expand Down Expand Up @@ -354,48 +350,12 @@ export class ProfilesCache {
};
}

public async convertV1ProfToConfig(): Promise<ZeApiConvertResponse> {
const successMsg: string[] = [];
const warningMsg: string[] = [];
const zoweDir = FileManagement.getZoweDir();
const profilesPath = path.join(zoweDir, "profiles");
const oldProfilesPath = `${profilesPath.replace(/[\\/]$/, "")}-old`;
const convertResult = await imperative.ConfigBuilder.convert(profilesPath);
for (const [k, v] of Object.entries(convertResult.profilesConverted)) {
successMsg.push(`Converted ${k} profile: ${v.join(", ")}\n`);
}
if (convertResult.profilesFailed.length > 0) {
warningMsg.push(`Failed to convert ${convertResult.profilesFailed.length} profile(s). See details below\n`);
for (const { name, type, error } of convertResult.profilesFailed) {
if (name != null) {
warningMsg.push(`Failed to load ${type} profile "${name}":\n${String(error)}\n`);
} else {
warningMsg.push(`Failed to find default ${type} profile:\n${String(error)}\n`);
}
}
}
const teamConfig = await imperative.Config.load("zowe", {
homeDir: zoweDir,
projectDir: false,
});
teamConfig.api.layers.activate(false, true);
teamConfig.api.layers.merge(convertResult.config);
const knownCliConfig: imperative.ICommandProfileTypeConfiguration[] = this.getCoreProfileTypes();
knownCliConfig.push(ProfileConstants.BaseProfile);
this.addToConfigArray(knownCliConfig);
teamConfig.setSchema(imperative.ConfigSchema.buildSchema(this.getConfigArray()));
await teamConfig.save();
try {
fs.renameSync(profilesPath, oldProfilesPath);
} catch (error) {
warningMsg.push(`Failed to rename profiles directory to ${oldProfilesPath}:\n ${String(error)}`);
}
successMsg.push(`Your new profiles have been saved to ${teamConfig.layerActive().path}.\n`);
return {
success: String(successMsg.join("")),
warnings: String(warningMsg.join("")),
convertResult,
};
public static async convertV1ProfToConfig(
profileInfo: imperative.ProfileInfo,
deleteV1Profs: boolean = false
): Promise<imperative.IConvertV1ProfResult> {
const convertResult = await imperative.ConvertV1Profiles.convert({ deleteV1Profs, profileInfo });
return convertResult;
}

protected getCoreProfileTypes(): imperative.IProfileTypeConfiguration[] {
Expand Down
2 changes: 2 additions & 0 deletions packages/zowe-explorer-ftp-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to the "zowe-explorer-ftp-extension" extension will be docum

- Changed the hashing algorithm for e-tag generation from `sha1` to `sha256` to avoid collisions. [#2890](https://github.com/zowe/zowe-explorer-vscode/pull/2890)
- Updated the FTP plugin dependency to `3.0.0-next.202403191358` for technical currency [#2783](https://github.com/zowe/vscode-extension-for-zowe/pull/2783).
- Update Zowe SDKs to `8.0.0-next.202405241828` for technical currency. [#2918](https://github.com/zowe/zowe-explorer-vscode/issues/2918)

## `3.0.0-next.202404242037`

Expand Down Expand Up @@ -80,6 +81,7 @@ All notable changes to the "zowe-explorer-ftp-extension" extension will be docum
### Bug fixes

- Fixed ECONNRESET error when trying to upload or create an empty data set member. [#2350](https://github.com/zowe/vscode-extension-for-zowe/issues/2350)
- Update Zowe SDKs to `8.0.0-next.202407051717` for technical currency. [#2918](https://github.com/zowe/zowe-explorer-vscode/issues/2918)
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove this line (seems redundant) and update line 13 above to have latest timestamp (8.0.0-next.202407051717)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can keep the pre-release version updates in CHANGELOGs, this may help extenders know the compatible CLI/SDK dependency version per Zowe Explorer pre-release. We will create a nice clean CHANGELOG for the GA


## 2.16.0

Expand Down
4 changes: 2 additions & 2 deletions packages/zowe-explorer-ftp-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
"vscode": "^1.79.0"
},
"dependencies": {
"@zowe/zos-files-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/zos-files-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/zos-ftp-for-zowe-cli": "3.0.0-next.202403191358",
"@zowe/zos-jobs-for-zowe-sdk": "8.0.0-next.202404032038",
"@zowe/zos-jobs-for-zowe-sdk": "8.0.0-next.202407051717",
"@zowe/zowe-explorer-api": "3.0.0-next-SNAPSHOT",
"tmp": "0.2.3"
},
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Fixed issue where saving changes to favorited PDS member fails when custom temp folder is set on Windows. [#2880](https://github.com/zowe/zowe-explorer-vscode/issues/2880)
- Fixed issue where multiple extensions that contribute profiles to a tree view using the Zowe Explorer API may fail to load. [#2888](https://github.com/zowe/zowe-explorer-vscode/issues/2888)
- Fixed regression where `getProviderForNode` returned the wrong tree provider after performing an action on a Zowe tree node, causing some commands to fail silently. [#2967](https://github.com/zowe/zowe-explorer-vscode/issues/2967)
- Update Zowe SDKs to `8.0.0-next.202407051717` for technical currency. [#2918](https://github.com/zowe/zowe-explorer-vscode/issues/2918)

## `3.0.0-next.202404242037`

Expand Down
11 changes: 11 additions & 0 deletions packages/zowe-explorer/__tests__/__mocks__/@zowe/imperative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,14 @@ export namespace SessConstants {
export const apiErrorHeader = {
message: "API Error",
};

export class ConvertV1Profiles {
public static convert() {
return {
msgs: "",
profilesConverted: [],
profilesFailed: [],
v1ScsPluginName: undefined,
};
}
}
2 changes: 2 additions & 0 deletions packages/zowe-explorer/__tests__/__mocks__/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class FakeStats implements Stats {

export function access(path: string, callback: any): void {}

export function appendFileSync(path: string, data: any, encoding: string): void {}

export function closeSync(fd: number): void {}

export function existsSync(path: string | Buffer): boolean {
Expand Down
Loading
Loading