forked from zowe/zowe-explorer-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.ts
53 lines (48 loc) · 2.69 KB
/
extension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* This program and the accompanying materials are made available under the terms of the *
* Eclipse Public License v2.0 which accompanies this distribution, and is available at *
* https://www.eclipse.org/legal/epl-v20.html *
* *
* SPDX-License-Identifier: EPL-2.0 *
* *
* Copyright Contributors to the Zowe Project. *
* *
*/
import * as vscode from "vscode";
import { ZoweExplorerApi } from "@zowe/zowe-explorer-api";
import { FtpUssApi } from "./ZoweExplorerFtpUssApi";
import { FtpMvsApi } from "./ZoweExplorerFtpMvsApi";
import { FtpJesApi } from "./ZoweExplorerFtpJesApi";
import { CoreUtils } from "@zowe/zos-ftp-for-zowe-cli";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function activate(context: vscode.ExtensionContext): void {
void registerFtpApis();
}
/**
* Function that searches for the Zowe VS Code Extension and if found
* registers the additional USS API implementation provided by this extension.
*/
async function registerFtpApis(): Promise<boolean> {
const zoweExplorerApi = vscode.extensions.getExtension("Zowe.vscode-extension-for-zowe");
if (zoweExplorerApi && zoweExplorerApi.exports) {
const importedApi = zoweExplorerApi.exports as ZoweExplorerApi.IApiRegisterClient;
importedApi.registerUssApi(new FtpUssApi());
importedApi.registerMvsApi(new FtpMvsApi());
importedApi.registerJesApi(new FtpJesApi());
// check for getExplorerExtenderApi().initForZowe() to initialize home dir folder if cli not installed
if (importedApi.getExplorerExtenderApi && importedApi.getExplorerExtenderApi().initForZowe) {
const meta = await CoreUtils.getProfileMeta();
await importedApi.getExplorerExtenderApi().initForZowe("zftp", meta);
}
// check as getExplorerExtenderApi().reloadProfiles() was add in Zowe Explorer 1.5 only
if (importedApi.getExplorerExtenderApi && importedApi.getExplorerExtenderApi().reloadProfiles) {
await importedApi.getExplorerExtenderApi().reloadProfiles();
}
void vscode.window.showInformationMessage("Zowe Explorer was modified for FTP support.");
return true;
}
void vscode.window.showInformationMessage(
"Zowe Explorer was not found: either it is not installed or you are using an older version without extensibility API."
);
return false;
}