Skip to content

Make ServerManager extension as optional, do not prevent this extension working. #188

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

Merged
merged 3 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
"onDebugInitialConfigurations"
],
"main": "./dist/extension",
"extensionDependencies": [
"intersystems-community.servermanager"
],
"contributes": {
"menus": {
"commandPalette": [
Expand Down Expand Up @@ -711,7 +708,12 @@
"objectscript.studioActionDebugOutput": {
"type": "boolean",
"default": false,
"description": "Output the action that VSCode should perform as requested by the server in JSON format."
"description": "Output the action that VS Code should perform as requested by the server in JSON format."
},
"objectscript.ignoreInstallServerManager": {
"type": "boolean",
"default": false,
"markdownDescription": "Do not offer to install the [intersystems-community.servermanager](https://marketplace.visualstudio.com/items?itemName=intersystems-community.servermanager) helper extension."
}
}
},
Expand Down
34 changes: 34 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,37 @@ export const checkConnection = (clearCookies = false): void => {
});
};

async function serverManager(): Promise<void> {
const extId = "intersystems-community.servermanager";
const ignore =
config("ignoreInstallServerManager") ||
vscode.workspace.getConfiguration("intersystems.servers").get("/ignore", false);
if (ignore || vscode.extensions.getExtension(extId)) {
return;
}
return vscode.window
.showInformationMessage(
"The InterSystems® Server Manager extension is recommended to help you define connections.",
"Install",
"Skip",
"Ignore"
)
.then(async (action) => {
switch (action) {
case "Install":
await vscode.commands.executeCommand("workbench.extensions.search", `@tag:"intersystems"`);
await vscode.commands.executeCommand("extension.open", extId);
await vscode.commands.executeCommand("workbench.extensions.installExtension", extId);
break;
case "Ignore":
config().update("ignoreInstallServerManager", true, vscode.ConfigurationTarget.Global);
break;
case "Skip":
default:
}
});
}

export async function activate(context: vscode.ExtensionContext): Promise<void> {
if (!packageJson.version.includes("SNAPSHOT")) {
reporter = new TelemetryReporter(extensionId, extensionVersion, aiKey);
Expand Down Expand Up @@ -540,6 +571,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
...proposed
);
reporter && reporter.sendTelemetryEvent("extensionActivated");

// offer to install servermanager extension
await serverManager();
}

export function deactivate(): void {
Expand Down
1 change: 1 addition & 0 deletions test-fixtures/test.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"objectscript.conn": {
"active": false
},
"objectscript.ignoreInstallServerManager": true,
"intersystems.servers": {
}
}
Expand Down