Skip to content

Commit

Permalink
Merge pull request #210 from Accenture/feature/202-update-default-met…
Browse files Browse the repository at this point in the history
…adata-types-file-by-running-mcdev-explaintypes-in-background

Feature/202 update default metadata types file by running mcdev explaintypes in background
  • Loading branch information
anasilva105 authored Sep 4, 2024
2 parents 1d48a6f + 0c92163 commit 5669d32
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/config/metadatatypes.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const metadatatypes = [
import SupportedMetadataTypes from "../shared/interfaces/supportedMetadataTypes";

export const metadatatypes: SupportedMetadataTypes[] = [
{
name: "Asset-[Subtype]",
apiName: "asset",
Expand Down
3 changes: 0 additions & 3 deletions src/devtools/commands/DevToolsAdminCommands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import DevToolsCommands from "./DevToolsCommands";
import DevToolsCommandSetting from "../../shared/interfaces/devToolsCommandSetting";
import DevToolsCommandRunner from "../../shared/interfaces/devToolsCommandRunner";
import SupportedMetadataTypes from "../../shared/interfaces/supportedMetadataTypes";
import { log } from "../../editor/output";

class DevToolsAdminCommands extends DevToolsCommands {
Expand Down Expand Up @@ -34,8 +33,6 @@ class DevToolsAdminCommands extends DevToolsCommands {
}
}

getMetadataTypes(): SupportedMetadataTypes[] | void {}
setMetadataTypes(_: SupportedMetadataTypes[]): void {}
isSupportedMetadataType(_action: string, _metadataType: string): boolean | void {}

async init(
Expand Down
20 changes: 16 additions & 4 deletions src/devtools/commands/DevToolsCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,23 @@ abstract class DevToolsCommands {
}, {});
}

// Sets the metadata types sorted by name
const sortedSuppMdtByName: SupportedMetadataTypes[] = metadatatypes.sort((a, b) =>
a.name.localeCompare(b.name)
// sets default metadata type file
this.setMetadataTypes(metadatatypes);

// Updates metadatypes with the result from explainTypes command, not blocking code execution
this.runCommand(
"admin",
"etypes",
"",
{ json: true },
{
handleCommandResult: ({ success, data }: { success: boolean; data: string }) => {
if (success) {
this.setMetadataTypes(JSON.parse(data) as SupportedMetadataTypes[]);
}
}
}
);
this.setMetadataTypes(sortedSuppMdtByName);
}

static async runCommand(
Expand Down

0 comments on commit 5669d32

Please sign in to comment.