Skip to content

Commit

Permalink
Merge pull request zowe#2532 from zowe/port-main-to-next
Browse files Browse the repository at this point in the history
Port main changes to next
  • Loading branch information
rudyflores authored Nov 14, 2023
2 parents 538048f + e390537 commit 9ad5a7f
Show file tree
Hide file tree
Showing 140 changed files with 5,487 additions and 777 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/zowe-explorer-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ jobs:
# install pnpm
- run: npm install -g pnpm

- run: pnpm config set network-timeout 60000 && pnpm i
- run: pnpm --filter "zowe-explorer-api" build
- run: for dir in samples/*; do pushd $dir && pnpm --ignore-workspace i && pnpm run compile && popd; done

shell: bash
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"private": true,
"workspaces": [
"packages/*",
"packages/zowe-explorer/webviews/*"
"packages/zowe-explorer/src/webviews"
],
"engines": {
"vscode": "^1.79.0"
Expand Down Expand Up @@ -62,8 +62,8 @@
"madge": "pnpm -r run madge",
"pretty": "prettier --write .",
"build": "pnpm -r run build",
"test": "pnpm -r --reporter append-only run test",
"test:parallel": "pnpm -r --parallel run test",
"test": "pnpm -r --sequential --color --reporter append-only run test",
"test:parallel": "pnpm -r --parallel --color run test",
"package": "pnpm run -r package",
"pretest:integration": "ts-node ./scripts/create-env.ts",
"posttest:integration": "ts-node ./scripts/clean-env.ts",
Expand Down
32 changes: 8 additions & 24 deletions packages/eslint-plugin-zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,36 @@ All notable changes to the "eslint-plugin-zowe-explorer" package will be documen
- Added placeholder `madge` script to `package.json` for workspace script to succeed.
- Migrated to new package manager PNPM from Yarn.

## `2.9.1`
## `2.11.2`

### New features and enhancements

### Bug fixes

## `2.11.0`
## `2.11.1`

### New features and enhancements

### Bug fixes

## `2.10.0`
## `2.12.0`

### New features and enhancements
## `2.11.2`

### Bug fixes
## `2.11.1`

## `2.9.2`
## `2.11.0`

### New features and enhancements
## `2.10.0`

### Bug fixes
## `2.9.2`

## `2.9.1`

### New features and enhancements

### Bug fixes

## `2.9.0`

### New features and enhancements

### Bug fixes

## `2.8.1`

### New features and enhancements

### Bug fixes

- Added `no-floating-promises` rule that ignores floating thenables without a `.catch` method. [#2291](https://github.com/zowe/vscode-extension-for-zowe/issues/2291)
Expand All @@ -57,14 +47,8 @@ All notable changes to the "eslint-plugin-zowe-explorer" package will be documen

- Updated linter rules and addressed linter errors throughout the codebase. [#2184](https://github.com/zowe/vscode-extension-for-zowe/issues/2184)

### Bug fixes

## `2.7.0`

### New features and enhancements

### Bug fixes

## `2.6.0`

### New features and enhancements
Expand Down
23 changes: 19 additions & 4 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
- Added `madge` script in `package.json` to track circular dependencies. [#2148](https://github.com/zowe/vscode-extension-for-zowe/issues/2148)
- Migrated to new package manager PNPM from Yarn.

## `2.12.0`

### New features and enhancements

- Added optional `getTag` function to `ZoweExplorerAPI.IUss` for getting the tag of a file on USS.
- Added new API {ZE Extender MetaData} to allow extenders to have the metadata of registered extenders to aid in team configuration file creation from a view that isn't Zowe Explorer's. [#2394](https://github.com/zowe/vscode-extension-for-zowe/issues/2394)
- Add `sort` and `filter` optional variables for storing sort/filter options alongside tree nodes. [#2420](https://github.com/zowe/vscode-extension-for-zowe/issues/2420)
- Add `stats` optional variable for storing dataset stats (such as user, modified date, etc.)
- Add option enums and types for sorting, filtering and sort direction in tree nodes. [#2420](https://github.com/zowe/vscode-extension-for-zowe/issues/2420)
- Added option for retaining context when generating webviews in Webview API

## `2.11.2`

### Bug fixes

- Bundle Zowe Secrets for issues seen by extenders that use the ProfilesCache for profile management. [#2512](https://github.com/zowe/vscode-extension-for-zowe/issues/2512)

## `2.11.1`

## `2.11.0`

### New features and enhancements
Expand All @@ -32,10 +51,6 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t

## `2.9.2`

### New features and enhancements

### Bug fixes

## `2.9.1`

### New features and enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function createGlobalMocks() {
showWarningMessage: jest.fn(),
createOutputChannel: jest.fn(),
createQuickPick: jest.fn(),
createTreeView: jest.fn(),
createTreeView: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }),
createWebviewPanel: jest.fn(),
withProgress: jest.fn(),
showTextDocument: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ const baseProfileWithToken = {
tokenValue: "baseToken",
},
};
const profilemetadata: zowe.imperative.ICommandProfileTypeConfiguration[] = [
{
type: "acme",
schema: {
type: "object",
title: "acme profile1",
description: "A profile to execute commands",
properties: {},
},
},
];

function createProfInfoMock(profiles: Partial<zowe.imperative.IProfileLoaded>[]): zowe.imperative.ProfileInfo {
return {
Expand Down Expand Up @@ -154,6 +165,20 @@ describe("ProfilesCache", () => {
expect(Object.keys(keyring).length).toBe(5);
});

it("addToConfigArray should set the profileTypeConfigurations array", () => {
const profCache = new ProfilesCache(fakeLogger as unknown as zowe.imperative.Logger);
profilemetadata.push(profilemetadata[0]);
profCache.addToConfigArray(profilemetadata);
expect(profCache.profileTypeConfigurations).toEqual(profilemetadata.filter((a, index) => index == 0));
});

it("getConfigArray should return the data of profileTypeConfigurations Array", () => {
const profCache = new ProfilesCache(fakeLogger as unknown as zowe.imperative.Logger);
profCache.profileTypeConfigurations = profilemetadata;
const res = profCache.getConfigArray();
expect(res).toEqual(profilemetadata);
});

it("loadNamedProfile should find profiles by name and type", () => {
const profCache = new ProfilesCache(fakeLogger as unknown as zowe.imperative.Logger);
profCache.allProfiles = [lpar1Profile as zowe.imperative.IProfileLoaded, zftpProfile as zowe.imperative.IProfileLoaded];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,30 @@ describe("ZosmfUssApi", () => {
expect(logoutSpy).toHaveBeenCalledWith(fakeSession);
});

it("should retrieve the tag of a file", async () => {
const zosmfApi = new ZosmfUssApi();
jest.spyOn(JSON, "parse").mockReturnValue({
stdout: ["-t UTF-8 tesfile.txt"],
});

Object.defineProperty(zowe.Utilities, "putUSSPayload", {
value: () => Buffer.from(""),
configurable: true,
});
await expect(zosmfApi.getTag("testfile.txt")).resolves.toEqual("UTF-8");
});

it("should update the tag attribute when passed in", async () => {
const zosmfApi = new ZosmfUssApi();
const changeTagSpy = jest.fn();
Object.defineProperty(zowe.Utilities, "putUSSPayload", {
value: changeTagSpy,
configurable: true,
});
await expect(zosmfApi.updateAttributes("/test/path", { tag: "utf-8" })).resolves.not.toThrow();
expect(changeTagSpy).toBeCalledTimes(1);
});

const ussApis: ITestApi<ZosmfUssApi>[] = [
{
name: "isFileTagBinOrAscii",
Expand Down
8 changes: 5 additions & 3 deletions packages/zowe-explorer-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"lib"
],
"devDependencies": {
"@types/semver": "^7.5.0"
"@types/semver": "^7.5.0",
"copyfiles": "^2.4.1"
},
"dependencies": {
"@types/vscode": "^1.53.2",
Expand All @@ -23,7 +24,7 @@
"semver": "^7.5.3"
},
"scripts": {
"build": "pnpm check-cli && pnpm clean && pnpm madge && tsc -p ./ && pnpm license",
"build": "pnpm check-cli && pnpm copy-secrets && pnpm clean && pnpm madge && tsc -p ./ && pnpm license",
"test:unit": "jest \".*__tests__.*\\.unit\\.test\\.ts\" --coverage",
"test": "pnpm test:unit",
"lint": "concurrently -n \"_eslint_,prettier\" \"eslint .\" \"prettier --write . && prettier --check .\"",
Expand All @@ -34,7 +35,8 @@
"clean": "rimraf lib",
"fresh-clone": "pnpm clean && (rimraf node_modules || true)",
"license": "node ../../scripts/updateLicenses.js",
"package": "pnpm build && pnpm pack && node ../../scripts/mv-pack.js zowe-zowe-explorer-api tgz"
"package": "pnpm build && pnpm pack && node ../../scripts/mv-pack.js zowe-zowe-explorer-api tgz",
"copy-secrets": "copyfiles -f ../../node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/*.node ./prebuilds"
},
"jest": {
"moduleFileExtensions": [
Expand Down
8 changes: 8 additions & 0 deletions packages/zowe-explorer-api/src/extend/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ export interface IUss extends ICommon {
* @returns {Promise<zowe.IZosFilesResponse>}
*/
rename(currentUssPath: string, newUssPath: string): Promise<zowe.IZosFilesResponse>;

/**
* Get the tag of a USS file
*
* @param {string} ussPath
* @returns {Promise<zowe.IZosFilesResponse>}
*/
getTag?(ussPath: string): Promise<string>;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion packages/zowe-explorer-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ export * from "./profiles/ProfilesCache";
export * from "./profiles/ZoweExplorerZosmfApi";
export * from "./security/KeytarApi";
export * from "./security/KeytarCredentialManager";
export * from "./tree";
export * from "./security/KeytarApi";
export * from "./security/KeytarCredentialManager";
export * from "./tree/ZoweExplorerTreeApi";
export * from "./tree/ZoweTreeNode";
export * from "./tree/IZoweTree";
export * from "./tree/IZoweTreeNode";
export * from "./tree/sorting";
export * from "./utils";
export * from "./vscode/ZoweVsCodeExtension";
export * from "./vscode/ui";
Expand Down
16 changes: 16 additions & 0 deletions packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class ProfilesCache {
public profilesForValidation: IProfileValidation[] = [];
public profilesValidationSetting: IValidationSetting[] = [];
public allProfiles: zowe.imperative.IProfileLoaded[] = [];
public profileTypeConfigurations: zowe.imperative.ICommandProfileTypeConfiguration[] = [];
protected allTypes: string[];
protected allExternalTypes = new Set<string>();
protected profilesByType = new Map<string, zowe.imperative.IProfileLoaded[]>();
Expand All @@ -83,6 +84,21 @@ export class ProfilesCache {
return require("@zowe/secrets-for-zowe-sdk").keyring;
}

public addToConfigArray(extendermetadata: zowe.imperative.ICommandProfileTypeConfiguration[]): void {
extendermetadata?.forEach((item) => {
const index = this.profileTypeConfigurations.findIndex((ele) => ele.type == item.type);
if (index !== -1) {
this.profileTypeConfigurations[index] = item;
} else {
this.profileTypeConfigurations.push(item);
}
});
}

public getConfigArray(): zowe.imperative.ICommandProfileTypeConfiguration[] {
return this.profileTypeConfigurations;
}

public async getProfileInfo(_envTheia = false): Promise<zowe.imperative.ProfileInfo> {
const mProfileInfo = new zowe.imperative.ProfileInfo("zowe", {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
Expand Down
17 changes: 16 additions & 1 deletion packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ export class ZosmfUssApi extends ZosmfApiCommon implements IUss {

public async updateAttributes(ussPath: string, attributes: Partial<FileAttributes>): Promise<zowe.IZosFilesResponse> {
try {
if (attributes.tag) {
await zowe.Utilities.putUSSPayload(this.getSession(), ussPath, {
request: "chtag",
action: "set",
type: "text",
codeset: attributes.tag !== null ? attributes.tag.toString() : attributes.tag,
});
}
if ((attributes.group || attributes.gid) && (attributes.owner || attributes.uid)) {
await zowe.Utilities.putUSSPayload(this.getSession(), ussPath, {
request: "chown",
Expand All @@ -141,7 +149,6 @@ export class ZosmfUssApi extends ZosmfApiCommon implements IUss {
recursive: true,
});
}

if (attributes.perms) {
await zowe.Utilities.putUSSPayload(this.getSession(), ussPath, {
request: "chmod",
Expand Down Expand Up @@ -185,6 +192,14 @@ export class ZosmfUssApi extends ZosmfApiCommon implements IUss {
apiResponse: result,
};
}

public async getTag(ussPath: string): Promise<string> {
const response = await zowe.Utilities.putUSSPayload(this.getSession(), ussPath, {
request: "chtag",
action: "list",
});
return JSON.parse(response.toString()).stdout[0].split(" ")[1] as string;
}
}

/**
Expand Down
Loading

0 comments on commit 9ad5a7f

Please sign in to comment.