From a2d8959122aea11cc0a243369423e3072ff51e31 Mon Sep 17 00:00:00 2001 From: FiB <filip.bostik@gmail.com> Date: Mon, 18 Mar 2024 18:53:32 +0100 Subject: [PATCH] AMPscript extensions checker (#29) * ampscript extensions checker * implemented different warning message for MCFS extension --- src/vscode/src/checks.ts | 31 +++++++++++++++++++++++++++++++ src/vscode/src/main.ts | 3 +++ 2 files changed, 34 insertions(+) create mode 100644 src/vscode/src/checks.ts diff --git a/src/vscode/src/checks.ts b/src/vscode/src/checks.ts new file mode 100644 index 0000000..7d3832e --- /dev/null +++ b/src/vscode/src/checks.ts @@ -0,0 +1,31 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import * as vscode from 'vscode'; + +export function extensionsChecks() { + const extensionHandlers = { + // "publisher.extensionName": + "sergey-agadzhanov.AMPscript": { + // handler returns false if the extension is incompatible, true otherwise. + // handler can also run additional actions in the case there's a need. + handler: () => { + vscode.window.showInformationMessage(`The extension MCFS [AMPScript] is incompatible with AMPscript Core and will prevent AMPscript Core from debugging AMPscript.`); + return false; + } + } + }; + + let allSupported = true; + for (let extensionId in extensionHandlers) { + const extension = vscode.extensions.getExtension(extensionId); + if (extension) { + const handler = extensionHandlers[extensionId as keyof typeof extensionHandlers].handler; + if (handler) { + const result = handler(); + if (result === false) { + allSupported = false; + } + } + } + } + return allSupported; +} \ No newline at end of file diff --git a/src/vscode/src/main.ts b/src/vscode/src/main.ts index 99e70e6..5881c63 100644 --- a/src/vscode/src/main.ts +++ b/src/vscode/src/main.ts @@ -4,6 +4,7 @@ import * as vscode from 'vscode'; import * as path from 'path'; import TelemetryReporter from '@vscode/extension-telemetry'; import registerCommands from './commands'; +import { extensionsChecks } from './checks'; // the application insights key (also known as instrumentation key) const applicationInsightsKey = 'd3cdabd2-8a47-44c7-92bd-7c786d2dd3bd'; @@ -21,6 +22,8 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('ampscript', provider)); context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('JSON', provider)); context.subscriptions.push(reporter); + console.log(`Extension starting`); + extensionsChecks(); } // This method is called when your extension is deactivated