Skip to content

Commit

Permalink
fix: app tree types
Browse files Browse the repository at this point in the history
  • Loading branch information
seankwarren committed Feb 9, 2024
1 parent aca13e9 commit 22714d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/js/build_templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ export type ExecutableTreeData = {
postProcessors?: AllowedPostProcessors[];
isDefault?: boolean;
hasAdvancedComputeOptions?: boolean;
flavors: Record<string, FlavorTreeData>;
flavors: {
[key: string]: FlavorTreeData;
};
};

export type ApplicationTreeData = {
[key in AllowedApplications]: Record<string, ExecutableTreeData>;
[key: string]: ExecutableTreeData;
};

export type ApplicationTree = {
[key in AllowedApplications]: ApplicationTreeData
};

/*
Expand Down Expand Up @@ -96,7 +102,7 @@ buildAsset<ApplicationData>({
dataKey: "applicationData",
});

buildAsset<ApplicationTreeData>({
buildAsset<ApplicationTree>({
assetPath: "./executables/tree.yml",
targetPath: "./src/js/data/tree.js",
dataKey: "applicationTree",
Expand Down
9 changes: 5 additions & 4 deletions src/js/tree.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { AllowedApplications, ExecutableTreeData } from ".";
import { ApplicationTreeData } from "./build_templates";
import { AllowedApplications } from ".";
import { ApplicationTree } from "./build_templates";
import { applicationTree } from "./data/tree";

/**
* @summary Given an application name, return the applications's tree.
* Expands and caches the tree to contain parent level attributes for flavors.
*/
export function getAppTree(appName: AllowedApplications) {
if (!(appName in applicationTree)) {
const appTree = applicationTree as ApplicationTree;
if (!(appName in appTree)) {
throw new Error(`${appName} is not a known application with a tree.`);
}

return applicationTree[appName];
return appTree[appName];
}

0 comments on commit 22714d1

Please sign in to comment.