Skip to content
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

removed logic of requesting user to select metadatatype for retrieve … #195

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
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
31 changes: 1 addition & 30 deletions src/devtools/commands/DevToolsCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,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 +53,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 +69,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
20 changes: 4 additions & 16 deletions src/devtools/commands/DevToolsStandardCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,8 @@ class DevToolsStandardCommands extends DevToolsCommands {
) {
log("info", `Running DevTools Standard Command: Retrieve...`);
if ("command" in config && config.command) {
// Gets that metadata types that are supported for retrieve
const supportedMdTypes: SupportedMetadataTypes[] = this.getSupportedMetadataTypeByAction("retrieve");

// Configures the command to replace all the parameters with the values
const commandConfigured: string | undefined = await this.configureCommandWithParameters(
config,
args,
supportedMdTypes
);
const commandConfigured: string | undefined = await this.configureCommandWithParameters(config, args);

// Checks if the command is still missing so required parameter
if (this.hasPlaceholders(commandConfigured)) {
Expand All @@ -89,6 +82,7 @@ class DevToolsStandardCommands extends DevToolsCommands {

log("debug", `Retrieve Command configured: ${commandConfigured}`);
loadingNotification();

const commandResult: string | number = await this.executeCommand(commandConfigured, path, true);
if (typeof commandResult === "number") {
handleCommandResult({ success: commandResult === 0, cancelled: false });
Expand All @@ -106,15 +100,8 @@ class DevToolsStandardCommands extends DevToolsCommands {
) {
log("info", `Running DevTools Standard Command: Deploy...`);
if ("command" in config && config.command) {
// Gets that metadata types that are supported for deploy
const supportedMdTypes: SupportedMetadataTypes[] = this.getSupportedMetadataTypeByAction("deploy");

// Configures the command to replace all the parameters with the values
const commandConfigured: string | undefined = await this.configureCommandWithParameters(
config,
args,
supportedMdTypes
);
const commandConfigured: string | undefined = await this.configureCommandWithParameters(config, args);

// Checks if the command is still missing so required parameter
if (this.hasPlaceholders(commandConfigured)) {
Expand All @@ -125,6 +112,7 @@ class DevToolsStandardCommands extends DevToolsCommands {

log("debug", `Deploy Command configured: ${commandConfigured}`);
loadingNotification();

const commandResult: string | number = await this.executeCommand(commandConfigured, path, true);
if (typeof commandResult === "number") {
handleCommandResult({ success: commandResult === 0, cancelled: false });
Expand Down
8 changes: 4 additions & 4 deletions src/devtools/commands/commands.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
"id":"retrieve",
"title": "Retrieve",
"command": "mcdev retrieve {{bu}} {{mdtypes}} {{key}} --skipInteraction",
"requiredParams": ["bu", "mdtypes"],
"optionalParams": ["key"],
"requiredParams": ["bu"],
"optionalParams": ["key", "mdtypes"],
"description": "Retrieves metadata of a business unit.",
"isAvailable": true
},
{
"id":"deploy",
"title": "Deploy",
"command": "mcdev deploy {{bu}} {{mdtypes}} {{key}} {{fromRetrieve}} --skipInteraction",
"requiredParams": ["bu", "mdtypes"],
"optionalParams": ["key", "fromRetrieve"],
"requiredParams": ["bu"],
"optionalParams": ["key", "mdtypes", "fromRetrieve"],
"description": "Deploys local metadata to a business unit.",
"isAvailable": true
},
Expand Down
Loading