diff --git a/package.json b/package.json index 0c168077a3..93361b23b4 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "rimraf": "^3.0.2", "terser-webpack-plugin": "^5.3.10", "ts-jest": "^29.0.3", - "tsconfig-paths-webpack-plugin": "^4.1.0", "tsx": "^4.9.3", "typescript": "^5.3.3", "webpack": "^5.89.0", diff --git a/packages/zowe-explorer-api/CHANGELOG.md b/packages/zowe-explorer-api/CHANGELOG.md index 4914f39653..42074fa2ec 100644 --- a/packages/zowe-explorer-api/CHANGELOG.md +++ b/packages/zowe-explorer-api/CHANGELOG.md @@ -45,7 +45,7 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t - 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) +- Fixed an issue where the `ZoweVsCodeExtension.updateCredentials` method could remove credentials from session when input prompt was cancelled. [#3009](https://github.com/zowe/zowe-explorer-vscode/pull/3009) - Fixed an issue where the loaded configuration could be overridden when extenders retrieved the Zowe home directory. [#2994](https://github.com/zowe/zowe-explorer-vscode/pull/2994) - Update Zowe SDKs to `8.0.0-next.202407232256` for technical currency. [#2994](https://github.com/zowe/zowe-explorer-vscode/pull/2994) diff --git a/packages/zowe-explorer-api/__tests__/__unit__/vscode/ZoweVsCodeExtension.unit.test.ts b/packages/zowe-explorer-api/__tests__/__unit__/vscode/ZoweVsCodeExtension.unit.test.ts index c481f97f25..13568ff055 100644 --- a/packages/zowe-explorer-api/__tests__/__unit__/vscode/ZoweVsCodeExtension.unit.test.ts +++ b/packages/zowe-explorer-api/__tests__/__unit__/vscode/ZoweVsCodeExtension.unit.test.ts @@ -467,10 +467,11 @@ describe("ZoweVsCodeExtension", () => { }); it("should do nothing if user input is cancelled", async () => { + const fakeProfile = { user: "fakeUser", password: "fakePass" }; const mockUpdateProperty = jest.fn(); jest.spyOn(ZoweVsCodeExtension as any, "profilesCache", "get").mockReturnValue({ getLoadedProfConfig: jest.fn().mockReturnValue({ - profile: {}, + profile: fakeProfile, }), getProfileInfo: jest.fn().mockReturnValue({ isSecured: jest.fn().mockReturnValue(true), @@ -479,17 +480,23 @@ describe("ZoweVsCodeExtension", () => { refresh: jest.fn(), }); const showInputBoxSpy = jest.spyOn(Gui, "showInputBox").mockResolvedValueOnce(undefined); - const profileLoaded = await ZoweVsCodeExtension.updateCredentials(promptCredsOptions, undefined as unknown as Types.IApiRegisterClient); + const profileLoaded = await ZoweVsCodeExtension.updateCredentials( + { ...promptCredsOptions, rePrompt: true }, + undefined as unknown as Types.IApiRegisterClient + ); expect(profileLoaded).toBeUndefined(); expect(showInputBoxSpy).toHaveBeenCalledTimes(1); expect(mockUpdateProperty).toHaveBeenCalledTimes(0); + expect(fakeProfile.user).toBeDefined(); + expect(fakeProfile.password).toBeDefined(); }); it("should do nothing if password input is cancelled", async () => { + const fakeProfile = { user: "fakeUser", password: "fakePass" }; const mockUpdateProperty = jest.fn(); jest.spyOn(ZoweVsCodeExtension as any, "profilesCache", "get").mockReturnValue({ getLoadedProfConfig: jest.fn().mockReturnValue({ - profile: {}, + profile: fakeProfile, }), getProfileInfo: jest.fn().mockReturnValue({ isSecured: jest.fn().mockReturnValue(true), @@ -498,10 +505,15 @@ describe("ZoweVsCodeExtension", () => { refresh: jest.fn(), }); const showInputBoxSpy = jest.spyOn(Gui, "showInputBox").mockResolvedValueOnce("fakeUser").mockResolvedValueOnce(undefined); - const profileLoaded = await ZoweVsCodeExtension.updateCredentials(promptCredsOptions, undefined as unknown as Types.IApiRegisterClient); + const profileLoaded = await ZoweVsCodeExtension.updateCredentials( + { ...promptCredsOptions, rePrompt: true }, + undefined as unknown as Types.IApiRegisterClient + ); expect(profileLoaded).toBeUndefined(); expect(showInputBoxSpy).toHaveBeenCalledTimes(2); expect(mockUpdateProperty).toHaveBeenCalledTimes(0); + expect(fakeProfile.user).toBeDefined(); + expect(fakeProfile.password).toBeDefined(); }); it("should do nothing if profile and sessionName args are not provided", async () => { diff --git a/packages/zowe-explorer-api/package.json b/packages/zowe-explorer-api/package.json index 3a67b262a4..9fc5242d19 100644 --- a/packages/zowe-explorer-api/package.json +++ b/packages/zowe-explorer-api/package.json @@ -12,6 +12,12 @@ "provenance": true }, "main": "lib/index.js", + "exports": { + ".": { + "@zowe:bundler": "./src/index.ts", + "default": "./lib/index.js" + } + }, "files": [ "lib" ], diff --git a/packages/zowe-explorer-api/src/vscode/ZoweVsCodeExtension.ts b/packages/zowe-explorer-api/src/vscode/ZoweVsCodeExtension.ts index 405de13d7b..fec0f7a2ff 100644 --- a/packages/zowe-explorer-api/src/vscode/ZoweVsCodeExtension.ts +++ b/packages/zowe-explorer-api/src/vscode/ZoweVsCodeExtension.ts @@ -291,7 +291,6 @@ export class ZoweVsCodeExtension { value: newUser, ...(options.userInputBoxOptions ?? {}), }); - options.session.user = newUser; } if (!newUser || (options.rePrompt && newUser === "")) { return undefined; @@ -307,13 +306,14 @@ export class ZoweVsCodeExtension { value: newPass, ...(options.passwordInputBoxOptions ?? {}), }); - options.session.password = newPass; } if (!newPass || (options.rePrompt && newPass === "")) { return undefined; } - return [newUser.trim(), newPass.trim()]; + options.session.user = newUser.trim(); + options.session.password = newPass.trim(); + return [options.session.user, options.session.password]; } private static async promptCertificate(options: PromptCredentialsOptions.CertificateOptions): Promise { diff --git a/packages/zowe-explorer-ftp-extension/webpack.config.js b/packages/zowe-explorer-ftp-extension/webpack.config.js index 1c933bb49a..eda7e505b5 100644 --- a/packages/zowe-explorer-ftp-extension/webpack.config.js +++ b/packages/zowe-explorer-ftp-extension/webpack.config.js @@ -17,8 +17,6 @@ const path = require("path"); const webpack = require("webpack"); const fs = require("fs"); const TerserPlugin = require("terser-webpack-plugin"); - -const { TsconfigPathsPlugin } = require("tsconfig-paths-webpack-plugin"); const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); /**@type {webpack.Configuration}*/ @@ -39,11 +37,7 @@ const config = { alias: { "@zowe/zowe-explorer-api$": path.resolve(__dirname, "..", "zowe-explorer-api/src"), }, - plugins: [ - new TsconfigPathsPlugin({ - references: ["../zowe-explorer-api"], - }), - ], + conditionNames: ["@zowe:bundler", "..."], }, watchOptions: { ignored: /node_modules/, diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index 473f1a8020..10d46414b1 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -63,7 +63,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) +- Fixed issue where creating a new team configuration file could cause Zowe Explorer to crash, resulting in all sessions disappearing from trees. [#2906](https://github.com/zowe/zowe-explorer-vscode/issues/2906) - Update Zowe SDKs to `8.0.0-next.202407232256` for technical currency. [#2994](https://github.com/zowe/zowe-explorer-vscode/pull/2994) ## `3.0.0-next.202404242037` diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/shared/SharedActions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/shared/SharedActions.unit.test.ts index 05792b554b..4088375a99 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/shared/SharedActions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/shared/SharedActions.unit.test.ts @@ -16,6 +16,7 @@ import { createISessionWithoutCredentials, createQuickPickContent, createQuickPickItem, + createTreeProviders, createTreeView, } from "../../../__mocks__/mockCreators/shared"; import { createDatasetSessionNode, createDatasetTree } from "../../../__mocks__/mockCreators/datasets"; @@ -34,6 +35,8 @@ import { FilterDescriptor, FilterItem } from "../../../../src/management/FilterM import { SharedActions } from "../../../../src/trees/shared/SharedActions"; import { IconUtils } from "../../../../src/icons/IconUtils"; import { IconGenerator } from "../../../../src/icons/IconGenerator"; +import { SharedTreeProviders } from "../../../../src/trees/shared/SharedTreeProviders"; +import { TreeViewUtils } from "../../../../src/utils/TreeViewUtils"; function createGlobalMocks() { const globalMocks = { @@ -542,3 +545,27 @@ describe("Shared Actions Unit Tests - Function resetValidationSettings", () => { expect(response.contextValue).toContain(`${Constants.VALIDATE_SUFFIX}true`); }); }); + +describe("Shared Actions Unit Tests - Function refreshAll", () => { + afterAll(() => { + jest.restoreAllMocks(); + }); + + it("should refresh all tree providers and update session nodes", async () => { + createGlobalMocks(); + jest.spyOn(SharedTreeProviders, "providers", "get").mockReturnValue(createTreeProviders()); + const removedProfNames = new Set(); + const addedProfTypes = new Set(); + const removeSessionSpy = jest + .spyOn(TreeViewUtils, "removeSession") + .mockImplementation(async (treeProvider, profileName) => removedProfNames.add(profileName)); + const addDefaultSessionSpy = jest + .spyOn(TreeViewUtils, "addDefaultSession") + .mockImplementation(async (treeProvider, profileType) => addedProfTypes.add(profileType)); + await SharedActions.refreshAll(); + expect(removeSessionSpy).toHaveBeenCalledTimes(6); + expect([...removedProfNames]).toEqual(["zosmf", "zosmf2"]); + expect(addDefaultSessionSpy).toHaveBeenCalledTimes(3); + expect([...addedProfTypes]).toEqual(["zosmf"]); + }); +}); diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/shared/SharedInit.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/shared/SharedInit.unit.test.ts index 814385af43..bc8205811f 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/shared/SharedInit.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/shared/SharedInit.unit.test.ts @@ -122,9 +122,7 @@ describe("Test src/shared/extension", () => { { spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [Constants.SETTINGS_LOGS_FOLDER_PATH], ret: false }, { spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [Constants.SETTINGS_AUTOMATIC_PROFILE_VALIDATION], ret: true }, { spy: jest.spyOn(Profiles, "getInstance"), arg: [], ret: profileMocks }, - { spy: jest.spyOn(SharedActions, "refreshAll"), arg: ["ds"] }, - { spy: jest.spyOn(SharedActions, "refreshAll"), arg: ["uss"] }, - { spy: jest.spyOn(SharedActions, "refreshAll"), arg: ["job"] }, + { spy: jest.spyOn(SharedActions, "refreshAll"), arg: [] }, { spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [Constants.SETTINGS_SECURE_CREDENTIALS_ENABLED], ret: false }, ], }, @@ -359,39 +357,69 @@ describe("Test src/shared/extension", () => { describe("watchConfigProfile", () => { let context: any; + let watcherPromise: any; const spyReadFile = jest.fn().mockReturnValue("test"); - const spyExecuteCommand = jest.fn(); + const mockEmitter = jest.fn(); const watcher: any = { - onDidCreate: jest.fn().mockImplementation((fun) => fun()), - onDidDelete: jest.fn().mockImplementation((fun) => fun()), - onDidChange: jest.fn().mockImplementation((fun) => fun("uri")), + onDidCreate: jest.fn(), + onDidDelete: jest.fn(), + onDidChange: jest.fn(), }; beforeEach(() => { context = { subscriptions: [] }; jest.clearAllMocks(); - Object.defineProperty(vscode.workspace, "createFileSystemWatcher", { value: () => watcher, configurable: true }); Object.defineProperty(vscode.workspace, "workspaceFolders", { value: [{ uri: { fsPath: "fsPath" } }], configurable: true }); - Object.defineProperty(vscode.commands, "executeCommand", { value: spyExecuteCommand, configurable: true }); Object.defineProperty(vscode.workspace, "fs", { value: { readFile: spyReadFile }, configurable: true }); Object.defineProperty(Constants, "SAVED_PROFILE_CONTENTS", { value: "test", configurable: true }); + jest.spyOn(vscode.workspace, "createFileSystemWatcher").mockReturnValue(watcher); + jest.spyOn(ZoweExplorerApiRegister.getInstance().onProfilesUpdateEmitter, "fire").mockImplementation(mockEmitter); }); afterAll(() => { jest.restoreAllMocks(); }); - it("should be able to trigger all listeners", async () => { - const spyRefreshAll = jest.spyOn(SharedActions, "refreshAll").mockImplementation(jest.fn()); - jest.spyOn(ZoweExplorerApiRegister.getInstance().onProfilesUpdateEmitter, "fire").mockImplementation(); - await SharedInit.watchConfigProfile(context, { ds: "ds", uss: "uss", job: "job" } as any); - expect(spyExecuteCommand).toHaveBeenCalledWith("zowe.extRefresh"); + it("should be able to trigger onDidCreate listener", async () => { + const spyRefreshAll = jest.spyOn(SharedActions, "refreshAll").mockImplementation(); + watcher.onDidCreate.mockImplementationOnce((fun) => (watcherPromise = fun())); + SharedInit.watchConfigProfile(context); + await watcherPromise; + expect(context.subscriptions).toContain(watcher); + expect(spyRefreshAll).toHaveBeenCalledTimes(1); + expect(mockEmitter).toHaveBeenCalledTimes(1); + }); + + it("should be able to trigger onDidDelete listener", async () => { + const spyRefreshAll = jest.spyOn(SharedActions, "refreshAll").mockImplementation(); + watcher.onDidDelete.mockImplementationOnce((fun) => (watcherPromise = fun())); + SharedInit.watchConfigProfile(context); + await watcherPromise; + expect(context.subscriptions).toContain(watcher); + expect(spyRefreshAll).toHaveBeenCalledTimes(1); + expect(mockEmitter).toHaveBeenCalledTimes(1); + }); + + it("should be able to trigger onDidChange listener", async () => { + const spyRefreshAll = jest.spyOn(SharedActions, "refreshAll").mockImplementation(); + watcher.onDidChange.mockImplementationOnce((fun) => (watcherPromise = fun("uri"))); + SharedInit.watchConfigProfile(context); + await watcherPromise; expect(context.subscriptions).toContain(watcher); expect(spyReadFile).toHaveBeenCalledWith("uri"); expect(spyRefreshAll).not.toHaveBeenCalled(); + expect(mockEmitter).not.toHaveBeenCalled(); + }); - spyReadFile.mockReturnValue("other"); - await SharedInit.watchConfigProfile(context, { ds: "ds", uss: "uss", job: "job" } as any); - expect(spyRefreshAll).toHaveBeenCalled(); + it("should be able to trigger onDidChange listener with changes", async () => { + const spyRefreshAll = jest.spyOn(SharedActions, "refreshAll").mockImplementation(); + spyReadFile.mockReturnValueOnce("other"); + watcher.onDidChange.mockImplementationOnce((fun) => (watcherPromise = fun("uri"))); + SharedInit.watchConfigProfile(context); + await watcherPromise; + expect(context.subscriptions).toContain(watcher); + expect(spyReadFile).toHaveBeenCalledWith("uri"); + expect(spyRefreshAll).toHaveBeenCalledTimes(1); + expect(mockEmitter).toHaveBeenCalledTimes(1); }); it("should trigger callbacks when credentials or credManager are updated by another application", async () => { diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 6b6c6f4963..d904444c6a 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -1746,7 +1746,7 @@ ] }, "scripts": { - "build": "pnpm clean:bundle && pnpm license && webpack --mode development && pnpm madge", + "build": "pnpm copy-secrets && pnpm clean:bundle && pnpm license && webpack --mode development && pnpm madge", "test": "pnpm test:unit", "test:e2e": "cd __tests__/__e2e__/ && wdio run ./wdio.conf.ts", "test:integration": "cd __tests__/__integration__/bdd && wdio run ./wdio.conf.ts", @@ -1773,7 +1773,8 @@ "pretty": "prettier --write .", "createTestProfileData": "tsx ./scripts/createTestProfileData.ts", "createDemoNodes": "tsx ./scripts/createDemoNodes.ts", - "generateLocalization": "pnpm dlx @vscode/l10n-dev export --o ./l10n ./src && node ./scripts/generatePoeditorJson.js" + "generateLocalization": "pnpm dlx @vscode/l10n-dev export --o ./l10n ./src && node ./scripts/generatePoeditorJson.js", + "copy-secrets": "tsx ./scripts/getSecretsPrebuilds.ts" }, "engines": { "vscode": "^1.79.0" @@ -1797,7 +1798,6 @@ "chai": "^4.1.2", "chai-as-promised": "^7.1.1", "chalk": "^2.4.1", - "copy-webpack-plugin": "^12.0.2", "eslint-plugin-zowe-explorer": "3.0.0-next-SNAPSHOT", "expect": "^24.8.0", "expect-webdriverio": "^4.13.0", diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index ce0d6d60c6..c4e92f08ae 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -47,7 +47,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { // Event Emitters used to notify subscribers that the refresh event has fired @@ -356,12 +357,6 @@ export class ZoweTreeProvider { } } } - if (treeProvider.mSessionNodes.length === 1) { - try { - await treeProvider.addSingleSession(Profiles.getInstance().getDefaultProfile(profileType)); - } catch (error) { - ZoweLogger.warn(error); - } - } + await TreeViewUtils.addDefaultSession(treeProvider, profileType); } } diff --git a/packages/zowe-explorer/src/trees/shared/SharedActions.ts b/packages/zowe-explorer/src/trees/shared/SharedActions.ts index 850afcbfa5..eb0b7f87b9 100644 --- a/packages/zowe-explorer/src/trees/shared/SharedActions.ts +++ b/packages/zowe-explorer/src/trees/shared/SharedActions.ts @@ -22,6 +22,7 @@ import { TreeViewUtils } from "../../utils/TreeViewUtils"; import { FilterItem, FilterDescriptor } from "../../management/FilterManagement"; import { IconUtils } from "../../icons/IconUtils"; import { AuthUtils } from "../../utils/AuthUtils"; +import { SharedTreeProviders } from "./SharedTreeProviders"; export class SharedActions { /** @@ -231,8 +232,14 @@ export class SharedActions { * * @param {IZoweTree} treeProvider */ - public static async refreshAll(treeProvider: IZoweTree): Promise { + public static async refreshAll(treeProvider?: IZoweTree): Promise { ZoweLogger.trace("refresh.refreshAll called."); + if (treeProvider == null) { + for (const provider of Object.values(SharedTreeProviders.providers)) { + await this.refreshAll(provider); + } + return; + } await Profiles.getInstance().refresh(ZoweExplorerApiRegister.getInstance()); for (const sessNode of treeProvider.mSessionNodes) { const profiles = await Profiles.getInstance().fetchAllProfiles(); @@ -247,6 +254,9 @@ export class SharedActions { await TreeViewUtils.removeSession(treeProvider, sessNode.label.toString().trim()); } } + for (const profType of ZoweExplorerApiRegister.getInstance().registeredApiTypes()) { + await TreeViewUtils.addDefaultSession(treeProvider, profType); + } treeProvider.refresh(); } } diff --git a/packages/zowe-explorer/src/trees/shared/SharedInit.ts b/packages/zowe-explorer/src/trees/shared/SharedInit.ts index 092b622406..21baa9846c 100644 --- a/packages/zowe-explorer/src/trees/shared/SharedInit.ts +++ b/packages/zowe-explorer/src/trees/shared/SharedInit.ts @@ -132,22 +132,16 @@ export class SharedInit { context.subscriptions.push( vscode.workspace.onDidChangeConfiguration(async (e) => { // If the log folder location has been changed, update current log folder preference - if (e.affectsConfiguration(Constants.SETTINGS_LOGS_FOLDER_PATH)) { + if (e.affectsConfiguration(Constants.SETTINGS_LOGS_FOLDER_PATH) || e.affectsConfiguration(Constants.LOGGER_SETTINGS)) { await SharedInit.initZoweLogger(context); } if (e.affectsConfiguration(Constants.SETTINGS_AUTOMATIC_PROFILE_VALIDATION)) { await Profiles.getInstance().refresh(ZoweExplorerApiRegister.getInstance()); - await SharedActions.refreshAll(providers.ds); - await SharedActions.refreshAll(providers.uss); - await SharedActions.refreshAll(providers.job); + await SharedActions.refreshAll(); } - if (e.affectsConfiguration(Constants.SETTINGS_SECURE_CREDENTIALS_ENABLED)) { await vscode.commands.executeCommand("zowe.updateSecureCredentials"); } - if (e.affectsConfiguration(Constants.LOGGER_SETTINGS)) { - await vscode.commands.executeCommand("zowe.extRefresh"); - } }) ); @@ -297,7 +291,7 @@ export class SharedInit { } } - public static watchConfigProfile(context: vscode.ExtensionContext, providers: Definitions.IZoweProviders): void { + public static watchConfigProfile(context: vscode.ExtensionContext): void { ZoweLogger.trace("shared.init.watchConfigProfile called."); const watchers: vscode.FileSystemWatcher[] = []; watchers.push( @@ -317,12 +311,12 @@ export class SharedInit { watchers.forEach((watcher) => { watcher.onDidCreate(async () => { ZoweLogger.info(vscode.l10n.t("Team config file created, refreshing Zowe Explorer.")); - await vscode.commands.executeCommand("zowe.extRefresh"); + await SharedActions.refreshAll(); ZoweExplorerApiRegister.getInstance().onProfilesUpdateEmitter.fire(Validation.EventType.CREATE); }); watcher.onDidDelete(async () => { ZoweLogger.info(vscode.l10n.t("Team config file deleted, refreshing Zowe Explorer.")); - await vscode.commands.executeCommand("zowe.extRefresh"); + await SharedActions.refreshAll(); ZoweExplorerApiRegister.getInstance().onProfilesUpdateEmitter.fire(Validation.EventType.DELETE); }); watcher.onDidChange(async (uri: vscode.Uri) => { @@ -332,9 +326,7 @@ export class SharedInit { return; } Constants.SAVED_PROFILE_CONTENTS = newProfileContents; - await SharedActions.refreshAll(providers.ds); - await SharedActions.refreshAll(providers.uss); - await SharedActions.refreshAll(providers.job); + await SharedActions.refreshAll(); ZoweExplorerApiRegister.getInstance().onProfilesUpdateEmitter.fire(Validation.EventType.UPDATE); }); }); diff --git a/packages/zowe-explorer/src/utils/LoggerUtils.ts b/packages/zowe-explorer/src/utils/LoggerUtils.ts index 5629df30e1..7f677e12fc 100644 --- a/packages/zowe-explorer/src/utils/LoggerUtils.ts +++ b/packages/zowe-explorer/src/utils/LoggerUtils.ts @@ -18,12 +18,14 @@ import { SettingsConfig } from "../configuration/SettingsConfig"; import { ZoweLogger } from "../tools/ZoweLogger"; export class LoggerUtils { + private static outputChannel: vscode.OutputChannel; + public static async initVscLogger(context: vscode.ExtensionContext, logFileLocation: string): Promise { - const outputChannel = Gui.createOutputChannel(vscode.l10n.t("Zowe Explorer")); - this.writeVscLoggerInfo(outputChannel, logFileLocation, context); + LoggerUtils.outputChannel ??= Gui.createOutputChannel(vscode.l10n.t("Zowe Explorer")); + this.writeVscLoggerInfo(LoggerUtils.outputChannel, logFileLocation, context); ZoweLogger.info(vscode.l10n.t("Initialized logger for Zowe Explorer")); await this.compareCliLogSetting(); - return outputChannel; + return LoggerUtils.outputChannel; } private static writeVscLoggerInfo(outputChannel: vscode.OutputChannel, logFileLocation: string, context: vscode.ExtensionContext): void { diff --git a/packages/zowe-explorer/src/utils/TreeViewUtils.ts b/packages/zowe-explorer/src/utils/TreeViewUtils.ts index 1b903ed110..c6814ae79b 100644 --- a/packages/zowe-explorer/src/utils/TreeViewUtils.ts +++ b/packages/zowe-explorer/src/utils/TreeViewUtils.ts @@ -15,6 +15,7 @@ import { IconGenerator } from "../icons/IconGenerator"; import type { ZoweTreeProvider } from "../trees/ZoweTreeProvider"; import { ZoweLocalStorage } from "../tools/ZoweLocalStorage"; import { ZoweLogger } from "../tools/ZoweLogger"; +import { Profiles } from "../configuration/Profiles"; export class TreeViewUtils { /** @@ -96,4 +97,14 @@ export class TreeViewUtils { setting.favorites = fave; ZoweLocalStorage.setValue(treeType, setting); } + + public static async addDefaultSession(treeProvider: IZoweTree, profileType: string): Promise { + if (treeProvider.mSessionNodes.length === 1) { + try { + await treeProvider.addSingleSession(Profiles.getInstance().getDefaultProfile(profileType)); + } catch (error) { + ZoweLogger.warn(error); + } + } + } } diff --git a/packages/zowe-explorer/webpack.config.js b/packages/zowe-explorer/webpack.config.js index 3d3de050b3..e83d03e00a 100644 --- a/packages/zowe-explorer/webpack.config.js +++ b/packages/zowe-explorer/webpack.config.js @@ -16,10 +16,7 @@ const path = require("path"); const webpack = require("webpack"); const fs = require("fs"); -const CopyPlugin = require("copy-webpack-plugin"); const TerserPlugin = require("terser-webpack-plugin"); - -const { TsconfigPathsPlugin } = require("tsconfig-paths-webpack-plugin"); const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); /**@type {webpack.Configuration}*/ @@ -39,11 +36,7 @@ const config = { alias: { "@zowe/zowe-explorer-api$": path.resolve(__dirname, "..", "zowe-explorer-api/src"), }, - plugins: [ - new TsconfigPathsPlugin({ - references: ["../zowe-explorer-api"], - }), - ], + conditionNames: ["@zowe:bundler", "..."], }, watchOptions: { ignored: /node_modules/, @@ -94,9 +87,6 @@ const config = { }, plugins: [ new webpack.BannerPlugin(fs.readFileSync("../../scripts/LICENSE_HEADER", "utf-8")), - new CopyPlugin({ - patterns: [{ from: "../../node_modules/@zowe/secrets-for-zowe-sdk/prebuilds", to: "../../prebuilds/" }], - }), new ForkTsCheckerWebpackPlugin({ typescript: { build: true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dda5e86b26..9e876a8091 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -108,9 +108,6 @@ importers: ts-jest: specifier: ^29.0.3 version: 29.1.2(@babel/core@7.24.9)(jest@29.7.0)(typescript@5.4.5) - tsconfig-paths-webpack-plugin: - specifier: ^4.1.0 - version: 4.1.0 tsx: specifier: ^4.9.3 version: 4.10.4 @@ -220,9 +217,6 @@ importers: chalk: specifier: ^2.4.1 version: 2.4.2 - copy-webpack-plugin: - specifier: ^12.0.2 - version: 12.0.2(webpack@5.93.0) eslint-plugin-zowe-explorer: specifier: 3.0.0-next-SNAPSHOT version: link:../eslint-plugin-zowe-explorer @@ -249,7 +243,7 @@ importers: version: 16.1.3 ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@20.14.12)(typescript@5.5.4) + version: 10.9.2(@types/node@18.19.33)(typescript@5.5.4) wdio-vscode-service: specifier: ^6.0.3 version: 6.0.3(webdriverio@8.38.2) @@ -2520,11 +2514,6 @@ packages: engines: {node: '>=14.16'} dev: true - /@sindresorhus/merge-streams@2.3.0: - resolution: {integrity: sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==} - engines: {node: '>=18'} - dev: true - /@sinonjs/commons@2.0.0: resolution: {integrity: sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==} dependencies: @@ -2746,19 +2735,13 @@ packages: undici-types: 5.26.5 dev: true - /@types/node@20.14.10: - resolution: {integrity: sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==} - requiresBuild: true - dependencies: - undici-types: 5.26.5 - dev: true - optional: true - /@types/node@20.14.12: resolution: {integrity: sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==} + requiresBuild: true dependencies: undici-types: 5.26.5 dev: true + optional: true /@types/node@20.14.2: resolution: {integrity: sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==} @@ -3408,7 +3391,7 @@ packages: engines: {node: ^16.13 || >=18} requiresBuild: true dependencies: - '@types/node': 20.14.10 + '@types/node': 20.14.12 dev: true optional: true @@ -3779,14 +3762,6 @@ packages: acorn: 8.11.3 dev: true - /acorn-import-attributes@1.9.5(acorn@8.12.1): - resolution: {integrity: sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==} - peerDependencies: - acorn: ^8 - dependencies: - acorn: 8.12.1 - dev: true - /acorn-jsx@5.3.2(acorn@7.4.1): resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -3820,12 +3795,6 @@ packages: hasBin: true dev: true - /acorn@8.12.1: - resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} - engines: {node: '>=0.4.0'} - hasBin: true - dev: true - /agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} @@ -3881,15 +3850,6 @@ packages: ajv: 6.12.6 dev: true - /ajv-keywords@5.1.0(ajv@8.13.0): - resolution: {integrity: sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==} - peerDependencies: - ajv: ^8.8.2 - dependencies: - ajv: 8.13.0 - fast-deep-equal: 3.1.3 - dev: true - /ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} dependencies: @@ -4776,11 +4736,6 @@ packages: engines: {node: '>=6.0'} dev: true - /chrome-trace-event@1.0.4: - resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==} - engines: {node: '>=6.0'} - dev: true - /chromium-bidi@0.4.16(devtools-protocol@0.0.1147663): resolution: {integrity: sha512-7ZbXdWERxRxSwo3txsBjjmc/NLxqb1Bk30mRb0BMS4YIaiV6zvKZqL/UAH+DdqcDYayDWk2n/y8klkBDODrPvA==} peerDependencies: @@ -5071,21 +5026,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /copy-webpack-plugin@12.0.2(webpack@5.93.0): - resolution: {integrity: sha512-SNwdBeHyII+rWvee/bTnAYyO8vfVdcSTud4EIb6jcZ8inLeWucJE0DnxXQBjlQ5zlteuuvooGQy3LIyGxhvlOA==} - engines: {node: '>= 18.12.0'} - peerDependencies: - webpack: ^5.1.0 - dependencies: - fast-glob: 3.3.2 - glob-parent: 6.0.2 - globby: 14.0.1 - normalize-path: 3.0.0 - schema-utils: 4.2.0 - serialize-javascript: 6.0.2 - webpack: 5.93.0(webpack-cli@5.1.4) - dev: true - /copyfiles@2.4.1: resolution: {integrity: sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==} hasBin: true @@ -5848,14 +5788,6 @@ packages: tapable: 2.2.1 dev: true - /enhanced-resolve@5.17.1: - resolution: {integrity: sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==} - engines: {node: '>=10.13.0'} - dependencies: - graceful-fs: 4.2.11 - tapable: 2.2.1 - dev: true - /enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} @@ -5970,10 +5902,6 @@ packages: resolution: {integrity: sha512-l60ETUTmLqbVbVHv1J4/qj+M8nq7AwMzEcg3kmJDt9dCNrTk+yHcYFf/Kw75pMDwd9mPcIGCG5LcS20SxYRzFA==} dev: true - /es-module-lexer@1.5.4: - resolution: {integrity: sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==} - dev: true - /es-object-atoms@1.0.0: resolution: {integrity: sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==} engines: {node: '>= 0.4'} @@ -6425,7 +6353,7 @@ packages: optionalDependencies: '@wdio/globals': 8.39.1(typescript@5.5.4) '@wdio/logger': 8.38.0 - webdriverio: 8.38.2(typescript@5.5.4) + webdriverio: 8.39.1(typescript@5.5.4) transitivePeerDependencies: - bufferutil - devtools @@ -7301,18 +7229,6 @@ packages: slash: 3.0.0 dev: true - /globby@14.0.1: - resolution: {integrity: sha512-jOMLD2Z7MAhyG8aJpNOpmziMOP4rPLcc95oQPKXBazW82z+CEgPFBQvEpRUa1KeIMUJo4Wsm+q6uzO/Q/4BksQ==} - engines: {node: '>=18'} - dependencies: - '@sindresorhus/merge-streams': 2.3.0 - fast-glob: 3.3.2 - ignore: 5.3.1 - path-type: 5.0.0 - slash: 5.1.0 - unicorn-magic: 0.1.0 - dev: true - /globule@1.3.4: resolution: {integrity: sha512-OPTIfhMBh7JbBYDpa5b+Q5ptmMWKwcNcFSR/0c6t8V4f3ZAVBEsKNY37QdVqmLRYSMhOUGYrY0QhSoEpzGr/Eg==} engines: {node: '>= 0.10'} @@ -10593,11 +10509,6 @@ packages: engines: {node: '>=8'} dev: true - /path-type@5.0.0: - resolution: {integrity: sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==} - engines: {node: '>=12'} - dev: true - /pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} dev: true @@ -11520,16 +11431,6 @@ packages: ajv-keywords: 3.5.2(ajv@6.12.6) dev: true - /schema-utils@4.2.0: - resolution: {integrity: sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw==} - engines: {node: '>= 12.13.0'} - dependencies: - '@types/json-schema': 7.0.15 - ajv: 8.13.0 - ajv-formats: 2.1.1(ajv@8.13.0) - ajv-keywords: 5.1.0(ajv@8.13.0) - dev: true - /secure-json-parse@2.7.0: resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==} dev: true @@ -12346,30 +12247,6 @@ packages: webpack: 5.91.0(webpack-cli@5.1.4) dev: true - /terser-webpack-plugin@5.3.10(webpack@5.93.0): - resolution: {integrity: sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==} - engines: {node: '>= 10.13.0'} - peerDependencies: - '@swc/core': '*' - esbuild: '*' - uglify-js: '*' - webpack: ^5.1.0 - peerDependenciesMeta: - '@swc/core': - optional: true - esbuild: - optional: true - uglify-js: - optional: true - dependencies: - '@jridgewell/trace-mapping': 0.3.25 - jest-worker: 27.5.1 - schema-utils: 3.3.0 - serialize-javascript: 6.0.2 - terser: 5.31.0 - webpack: 5.93.0(webpack-cli@5.1.4) - dev: true - /terser@5.31.0: resolution: {integrity: sha512-Q1JFAoUKE5IMfI4Z/lkE/E6+SwgzO+x4tq4v1AyBLRj8VSYvRO6A/rQrPg1yud4g0En9EKI1TvFRF2tQFcoUkg==} engines: {node: '>=10'} @@ -12586,7 +12463,7 @@ packages: yargs-parser: 21.1.1 dev: true - /ts-node@10.9.2(@types/node@20.14.12)(typescript@5.5.4): + /ts-node@10.9.2(@types/node@18.19.33)(typescript@5.5.4): resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true peerDependencies: @@ -12605,7 +12482,7 @@ packages: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.14.12 + '@types/node': 18.19.33 acorn: 8.11.3 acorn-walk: 8.3.2 arg: 4.1.3 @@ -12617,15 +12494,6 @@ packages: yn: 3.1.1 dev: true - /tsconfig-paths-webpack-plugin@4.1.0: - resolution: {integrity: sha512-xWFISjviPydmtmgeUAuXp4N1fky+VCtfhOkDUFIv5ea7p4wuTomI4QTrXvFBX2S4jZsmyTSrStQl+E+4w+RzxA==} - engines: {node: '>=10.13.0'} - dependencies: - chalk: 4.1.2 - enhanced-resolve: 5.16.1 - tsconfig-paths: 4.2.0 - dev: true - /tsconfig-paths@4.2.0: resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} engines: {node: '>=6'} @@ -12839,11 +12707,6 @@ packages: '@fastify/busboy': 2.1.1 dev: true - /unicorn-magic@0.1.0: - resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} - engines: {node: '>=18'} - dev: true - /union-value@1.0.1: resolution: {integrity: sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==} engines: {node: '>=0.10.0'} @@ -13266,7 +13129,7 @@ packages: engines: {node: ^16.13 || >=18} requiresBuild: true dependencies: - '@types/node': 20.14.10 + '@types/node': 20.14.12 '@types/ws': 8.5.10 '@wdio/config': 8.39.0 '@wdio/logger': 8.38.0 @@ -13354,7 +13217,7 @@ packages: jszip: 3.10.1 lodash.clonedeep: 4.5.0 lodash.zip: 4.2.0 - minimatch: 9.0.5 + minimatch: 9.0.4 puppeteer-core: 20.9.0(typescript@5.5.4) query-selector-shadow-dom: 1.0.1 resq: 1.11.0 @@ -13469,47 +13332,6 @@ packages: - uglify-js dev: true - /webpack@5.93.0(webpack-cli@5.1.4): - resolution: {integrity: sha512-Y0m5oEY1LRuwly578VqluorkXbvXKh7U3rLoQCEO04M97ScRr44afGVkI0FQFsXzysk5OgFAxjZAb9rsGQVihA==} - engines: {node: '>=10.13.0'} - hasBin: true - peerDependencies: - webpack-cli: '*' - peerDependenciesMeta: - webpack-cli: - optional: true - dependencies: - '@types/eslint-scope': 3.7.7 - '@types/estree': 1.0.5 - '@webassemblyjs/ast': 1.12.1 - '@webassemblyjs/wasm-edit': 1.12.1 - '@webassemblyjs/wasm-parser': 1.12.1 - acorn: 8.12.1 - acorn-import-attributes: 1.9.5(acorn@8.12.1) - browserslist: 4.23.2 - chrome-trace-event: 1.0.4 - enhanced-resolve: 5.17.1 - es-module-lexer: 1.5.4 - eslint-scope: 5.1.1 - events: 3.3.0 - glob-to-regexp: 0.4.1 - graceful-fs: 4.2.11 - json-parse-even-better-errors: 2.3.1 - loader-runner: 4.3.0 - mime-types: 2.1.35 - neo-async: 2.6.2 - schema-utils: 3.3.0 - tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(webpack@5.93.0) - watchpack: 2.4.1 - webpack-cli: 5.1.4(webpack@5.91.0) - webpack-sources: 3.2.3 - transitivePeerDependencies: - - '@swc/core' - - esbuild - - uglify-js - dev: true - /whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} dependencies: