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

Feature/202 update default metadata types file by running mcdev explaintypes in background #210

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
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
Loading