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

Implemented unix command #2515

Merged
merged 30 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
29467b8
UnixImplementation
likhithanimma1 Oct 18, 2023
f5dceac
Linting fixed
likhithanimma1 Oct 18, 2023
ee1b9f0
Changelog Updated
likhithanimma1 Oct 19, 2023
982399a
Updated the UnixCommandHandlerfile
likhithanimma1 Oct 20, 2023
c5e1ad7
Updated with Unit Testing
likhithanimma1 Oct 24, 2023
fa3c3ea
Included test in init file
likhithanimma1 Oct 24, 2023
0cb79d7
Updated UnixFile
likhithanimma1 Oct 30, 2023
484b47b
code coverage
likhithanimma1 Oct 30, 2023
0354c0a
Merge branch 'next' into Issue-Unix-Command
JillieBeanSim Oct 30, 2023
4d2f40e
Change in api interface and changelog
likhithanimma1 Nov 1, 2023
f88cebf
Linting Fixed
likhithanimma1 Nov 2, 2023
4ef6c1f
tests modified
likhithanimma1 Nov 3, 2023
c2a93f2
Merge remote-tracking branch 'zowe/next' into Issue-Unix-Command
likhithanimma1 Nov 14, 2023
f70560a
Resolved Conflicts
likhithanimma1 Nov 14, 2023
e1f7eb9
Added path to output view
likhithanimma1 Nov 16, 2023
6cad371
Conflicts Resolved
likhithanimma1 Nov 16, 2023
05f3f44
Fixed Broken Tests
likhithanimma1 Nov 16, 2023
00d3cc1
Registered ssh profile types
likhithanimma1 Nov 17, 2023
808a8bb
Resolved Conflicts
likhithanimma1 Nov 17, 2023
a54e148
UnixFile Modified
likhithanimma1 Nov 20, 2023
9b6b045
Conflicts Resolved
likhithanimma1 Nov 20, 2023
da72a7b
Changelog modified
likhithanimma1 Nov 20, 2023
22da2b7
Merge remote-tracking branch 'zowe/next' into Issue-Unix-Command
likhithanimma1 Nov 22, 2023
28ea8e6
Changelog and optional path updated
likhithanimma1 Nov 23, 2023
1677a4c
Linting Fixed
likhithanimma1 Nov 23, 2023
d1f4cbe
Code Coverage
likhithanimma1 Nov 23, 2023
faf156f
Coverage
likhithanimma1 Nov 23, 2023
92d040c
tests modified
likhithanimma1 Nov 23, 2023
42bf71e
Modified Actions to InputPath
likhithanimma1 Nov 26, 2023
d195934
Merge branch 'next' into Issue-Unix-Command
JillieBeanSim Nov 30, 2023
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/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t

## TBD Release

- Added new APIs for Issue UNIX Command. [#1326](https://github.com/zowe/vscode-extension-for-zowe/issues/1326)

### New features and enhancements

### Bug fixes
Expand Down Expand Up @@ -199,3 +201,5 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
## `1.10.1`

- Initial release


Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe("ProfilesCache", () => {
expect(profCache.allProfiles.length).toEqual(2);
expect(profCache.allProfiles[0]).toMatchObject(lpar1Profile);
expect(profCache.allProfiles[1]).toMatchObject(zftpProfile);
expect(profCache.getAllTypes()).toEqual([...profileTypes, "base"]);
expect(profCache.getAllTypes()).toEqual([...profileTypes, "ssh","base"]);
expect(mockLogError).not.toHaveBeenCalled();
});

Expand All @@ -281,7 +281,7 @@ describe("ProfilesCache", () => {
expect(profCache.allProfiles[0]).toMatchObject(lpar1ProfileWithToken);
expect(profCache.allProfiles[1]).toMatchObject(lpar2Profile); // without token
expect(profCache.allProfiles[2]).toMatchObject(baseProfileWithToken);
expect(profCache.getAllTypes()).toEqual([...profileTypes, "base"]);
expect(profCache.getAllTypes()).toEqual([...profileTypes, "ssh","base"]);
expect(mockLogError).not.toHaveBeenCalled();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ const fakeProfile: ITestProfile = {
};
const fakeSession = zowe.imperative.Session.createFromUrl(new URL("https://example.com"));

const mISshSession: zowe.ISshSession = {
hostname: "example.com",
port: 22,
};

async function expectUnixCommandApiWithSshSession<T>(
{ name, spy, args }: ITestApi<T>,
apiInstance: ZoweExplorerApi.ICommon,
sshobj: zowe.SshSession
): Promise<void> {
spy.mockClear().mockResolvedValue(undefined);
spy.mockImplementation((sshobject: zowe.SshSession, command: string, cwd: string, callback: (data: string) => void) => {
let r=""
callback("test");
r += "test";
});
await apiInstance[name as string](sshobj,...args,() => {});
expect(spy).toHaveBeenCalled();
}
async function expectApiWithSession<T>({ name, spy, args, transform }: ITestApi<T>, apiInstance: ZoweExplorerApi.ICommon): Promise<void> {
spy.mockClear().mockResolvedValue(undefined);
const getSessionSpy = jest.spyOn(apiInstance, "getSession").mockReturnValue(fakeSession);
Expand Down Expand Up @@ -537,6 +556,7 @@ describe("ZosmfJesApi", () => {
});

describe("ZosmfCommandApi", () => {
const SshSessionobj = new zowe.SshSession(mISshSession);
const commandApis: ITestApi<ZosmfCommandApi>[] = [
{
name: "issueTsoCommandWithParms",
Expand All @@ -555,4 +575,20 @@ describe("ZosmfCommandApi", () => {
await expectApiWithSession(commandApi, new ZosmfCommandApi());
});
});
const UnixcommandApiwithsshSession: ITestApi<ZosmfCommandApi>[] = [
{
name: "issueUnixCommand",
spy: jest.spyOn(zowe.Shell, "executeSshCwd"),
args: ["command", "cwd"],
},
];
UnixcommandApiwithsshSession.forEach((cmdApi)=>{
it(`${cmdApi?.name} should inject session into Zowe API`, async () => {
await expectUnixCommandApiWithSshSession(cmdApi, new ZosmfCommandApi(),SshSessionobj);
});
})
it("check whether sshProfileNeeded", () => {
const obj = new ZosmfCommandApi();
expect(obj.sshProfileRequired?.()).toBe(true);
});
});
11 changes: 11 additions & 0 deletions packages/zowe-explorer-api/src/extend/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,15 @@ export interface ICommand extends ICommon {
* @memberof ICommand
*/
issueMvsCommand?(command: string): Promise<zowe.IConsoleResponse>;

/**
* Issues a Unix Command and returns a Console Command API response.
*
* @param {string} command
* @param {string} cwd
* @returns {string>}
* @memberof ICommand
*/
issueUnixCommand?(sshSession: zowe.SshSession, command: string, cwd: string): Promise<string>;
sshProfileRequired?(): boolean;
}
2 changes: 1 addition & 1 deletion packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class ProfilesCache {
return;
}
const allTypes = this.getAllProfileTypes(apiRegister.registeredApiTypes());
allTypes.push("base");
allTypes.push("ssh","base");
for (const type of allTypes) {
const tmpAllProfiles: zowe.imperative.IProfileLoaded[] = [];
// Step 1: Get all profiles for each registered type
Expand Down
11 changes: 11 additions & 0 deletions packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,15 @@ export class ZosmfCommandApi extends ZosmfApiCommon implements ICommand {
public issueMvsCommand(command: string): Promise<zowe.IConsoleResponse> {
return zowe.IssueCommand.issueSimple(this.getSession(), command);
}

public async issueUnixCommand(sshSession: zowe.SshSession, command: string, cwd: string): Promise<string> {
let stdout = "";
await zowe.Shell.executeSshCwd(sshSession, command, '"'+cwd+'"', (data: string) => {
stdout += data;
});
return stdout;
}
public sshProfileRequired?(): boolean {
return true;
}
}
4 changes: 4 additions & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -984,3 +984,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
## 0.5.0

- Initial release

## TBD Release

- Added the Issue UNIX Commands feature. [#1326](https://github.com/zowe/vscode-extension-for-zowe/issues/1326)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we get this changelog moved to top of file please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes moved to the top

Loading
Loading