Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/npm_and_yarn/develop/ts-jest-2…
Browse files Browse the repository at this point in the history
…9.2.4
  • Loading branch information
anasilva105 authored Aug 28, 2024
2 parents 1b28aac + e910d04 commit d948703
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 129 deletions.
99 changes: 87 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
},
{
"command": "sfmc-devtools-vscext.devtoolsCMCopyToBU",
"when": "sfmc-devtools-vscode.isDevToolsProject && editorIsOpen && resourcePath =~ /retrieve/"
"when": "sfmc-devtools-vscode.isDevToolsProject && editorIsOpen && resourcePath =~ /\\\\retrieve\\\\.*\\\\.*/"
}
],
"explorer/context": [
Expand All @@ -85,7 +85,7 @@
"group": "devtools"
},
{
"when": "sfmc-devtools-vscode.isDevToolsProject && resourcePath =~ /retrieve/ && resourceFilename != 'retrieve' && resourceFilename != 'deploy'",
"when": "sfmc-devtools-vscode.isDevToolsProject && resourcePath =~ /\\\\retrieve\\\\.*\\\\.*/",
"command": "sfmc-devtools-vscext.devtoolsCMCopyToBU",
"group": "devtools"
}
Expand All @@ -102,7 +102,7 @@
"group": "devtools"
},
{
"when": "sfmc-devtools-vscode.isDevToolsProject && resourcePath =~ /retrieve/ && resourceFilename != 'retrieve' && resourceFilename != 'deploy'",
"when": "sfmc-devtools-vscode.isDevToolsProject && resourcePath =~ /\\\\retrieve\\\\.*\\\\.*/",
"command": "sfmc-devtools-vscext.devtoolsCMCopyToBU",
"group": "devtools"
}
Expand All @@ -119,7 +119,7 @@
"group": "devtools"
},
{
"when": "sfmc-devtools-vscode.isDevToolsProject && resourcePath =~ /retrieve/ && resourceFilename != 'retrieve' && resourceFilename != 'deploy'",
"when": "sfmc-devtools-vscode.isDevToolsProject && resourcePath =~ /\\\\retrieve\\\\.*\\\\.*/",
"command": "sfmc-devtools-vscext.devtoolsCMCopyToBU",
"group": "devtools"
}
Expand Down Expand Up @@ -152,7 +152,7 @@
"@types/node": "^20.12.8",
"@types/vscode": "^1.81.1",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.7.0",
"@typescript-eslint/parser": "^7.18.0",
"@vscode/test-electron": "^2.3.9",
"chai": "^5.1.0",
"eslint": "^8.56.0",
Expand All @@ -165,7 +165,7 @@
},
"dependencies": {
"@salesforce-ux/design-system": "^2.23.2",
"@vscode/codicons": "^0.0.35",
"@vscode/codicons": "^0.0.36",
"winston": "^3.13.0"
}
}
12 changes: 2 additions & 10 deletions src/devtools/commands/DevToolsAdminCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ class DevToolsAdminCommands extends DevToolsCommands {
}
log("debug", `Init payload: ${JSON.stringify(initArgs)}`);

const commandConfigured: string | undefined = await this.configureCommandWithParameters(
config,
initArgs,
[]
);
const commandConfigured: string | undefined = await this.configureCommandWithParameters(config, initArgs);
// Checks if the command is still missing so required parameter
if (this.hasPlaceholders(commandConfigured)) {
log("debug", `Required Parameters missing from Init command: ${commandConfigured}`);
Expand All @@ -89,11 +85,7 @@ class DevToolsAdminCommands extends DevToolsCommands {
try {
log("info", `Running DevTools Admin Command: Explain Types...`);
if ("command" in config && config.command) {
const commandConfigured: string | undefined = await this.configureCommandWithParameters(
config,
args,
[]
);
const commandConfigured: string | undefined = await this.configureCommandWithParameters(config, args);
log("debug", `Explain types final command: ${commandConfigured}`);
const commandResult: string | number = await this.executeCommand(
commandConfigured,
Expand Down
56 changes: 15 additions & 41 deletions src/devtools/commands/DevToolsCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as commandsConfig from "./commands.config.json";
import DevToolsCommandSetting from "../../shared/interfaces/devToolsCommandSetting";
import DevToolsCommandRunner from "../../shared/interfaces/devToolsCommandRunner";
import SupportedMetadataTypes from "../../shared/interfaces/supportedMetadataTypes";
import InputOptionsSettings from "../../shared/interfaces/inputOptionsSettings";
import { editorInput } from "../../editor/input";
import { log } from "../../editor/output";
import { lib } from "../../shared/utils/lib";
Expand All @@ -13,10 +12,9 @@ import { metadatatypes } from "../../config/metadatatypes.config";
abstract class DevToolsCommands {
static readonly commandPrefix: string = "mcdev";
static commandMap: { [key: string]: DevToolsCommands };
static metadataTypes: SupportedMetadataTypes[];

abstract run(commandRunner: DevToolsCommandRunner): void;
abstract setMetadataTypes(mdTypes: SupportedMetadataTypes[]): void;
abstract getMetadataTypes(): SupportedMetadataTypes[] | void;
abstract isSupportedMetadataType(action: string, metadataType: string): boolean | void;

executeCommand(command: string, path: string, showOnTerminal: boolean): Promise<string | number> {
Expand Down Expand Up @@ -44,8 +42,7 @@ abstract class DevToolsCommands {

async configureCommandWithParameters(
config: DevToolsCommandSetting,
args: { [key: string]: string | string[] | boolean },
mdTypes: SupportedMetadataTypes[]
args: { [key: string]: string | string[] | boolean }
): Promise<string> {
log("debug", `ConfigureCommandWithParameters: ${JSON.stringify(config)}`);
let { command } = config;
Expand All @@ -54,14 +51,6 @@ abstract class DevToolsCommands {
for (const param of config.requiredParams) {
if (param in args && args[param]) {
command = command.replace(`{{${param}}}`, args[param] as string);
} else {
// Requests user
if (param.toLowerCase() === "mdtypes" && mdTypes.length) {
const userSelecteMDTypes: string | undefined = await this.handleMetadataTypeRequest(mdTypes);
if (userSelecteMDTypes) {
command = command.replace(`{{${param}}}`, `"${userSelecteMDTypes}"`);
}
}
}
}
}
Expand All @@ -78,26 +67,6 @@ abstract class DevToolsCommands {
return command;
}

async handleMetadataTypeRequest(mdTypes: SupportedMetadataTypes[]): Promise<string | undefined> {
const mdTypeInputOptions: InputOptionsSettings[] = mdTypes.map((mdType: SupportedMetadataTypes) => ({
id: mdType.apiName,
label: mdType.name,
detail: ""
}));
const userResponse: InputOptionsSettings | InputOptionsSettings[] | undefined =
await editorInput.handleQuickPickSelection(
mdTypeInputOptions,
"Please select one or multiple metadata types...",
true
);
if (userResponse && Array.isArray(userResponse)) {
const mdTypes: string = `${userResponse.map((response: InputOptionsSettings) => response.id)}`;
log("debug", `User selected metadata types: "${mdTypes}"`);
return mdTypes;
}
return;
}

hasPlaceholders(command: string): boolean {
const pattern: RegExp = /{{.*?}}/g;
return pattern.test(command);
Expand Down Expand Up @@ -130,14 +99,11 @@ abstract class DevToolsCommands {
}, {});
}

// Sends the supported mtdata types to each DevTools Command
Object.keys(this.commandMap).forEach((key: string) => {
const devToolCommand: DevToolsCommands = this.commandMap[key];
const sortedSuppMdtByName: SupportedMetadataTypes[] = metadatatypes.sort((a, b) =>
a.name.localeCompare(b.name)
);
devToolCommand.setMetadataTypes(sortedSuppMdtByName);
});
// Sets the metadata types sorted by name
const sortedSuppMdtByName: SupportedMetadataTypes[] = metadatatypes.sort((a, b) =>
a.name.localeCompare(b.name)
);
this.setMetadataTypes(sortedSuppMdtByName);
}

static async runCommand(
Expand Down Expand Up @@ -219,6 +185,14 @@ abstract class DevToolsCommands {
return false;
}

static setMetadataTypes(mdTypes: SupportedMetadataTypes[]): void {
this.metadataTypes = mdTypes;
}

static getMetadataTypes(): SupportedMetadataTypes[] {
return this.metadataTypes;
}

static isSupportedMetadataType(action: string, metadataType: string) {
if ("standard" in this.commandMap) {
const devToolsCommand: DevToolsCommands = this.commandMap["standard"];
Expand Down
Loading

0 comments on commit d948703

Please sign in to comment.