Skip to content

Commit

Permalink
AMPscript extensions checker (#29)
Browse files Browse the repository at this point in the history
* ampscript extensions checker

* implemented different warning message for MCFS extension
  • Loading branch information
FiB3 committed Mar 18, 2024
1 parent 567a36b commit a2d8959
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/vscode/src/checks.ts
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 3 additions & 0 deletions src/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down

0 comments on commit a2d8959

Please sign in to comment.