diff --git a/src/config/paths.ts b/src/config/paths.ts index e940671..0fa7f01 100644 --- a/src/config/paths.ts +++ b/src/config/paths.ts @@ -13,3 +13,7 @@ export const ADEVTOOL_DIR = path.join(OS_CHECKOUT_DIR, 'vendor/adevtool') export const CONFIG_DIR = process.env['ADEVTOOL_CONFIG_DIR'] ?? path.join(ADEVTOOL_DIR, 'config') export const DEVICE_CONFIG_DIR = path.join(CONFIG_DIR, 'device') + +export const BUILD_INDEX_DIR = path.join(CONFIG_DIR, 'build-index') +export const BUILD_INDEX_FILE = path.join(BUILD_INDEX_DIR, 'build-index.yml') +export const MAIN_BUILD_INDEX_PART = path.join(BUILD_INDEX_DIR, 'build-index-main.yml') diff --git a/src/images/build-index.ts b/src/images/build-index.ts index d6ed002..eb0045c 100644 --- a/src/images/build-index.ts +++ b/src/images/build-index.ts @@ -5,7 +5,9 @@ import path from 'path' import YAML from 'yaml' import { YAMLMap } from 'yaml/types' +import { loadAndMergeConfig } from '../config/config-loader' import { DeviceBuildId, DeviceConfig, makeDeviceBuildId } from '../config/device' +import { BUILD_INDEX_FILE } from '../config/paths' export type BuildIndex = Map export type BuildProps = Map @@ -55,6 +57,15 @@ const PAGE_TYPES: Record = { }, } +export async function loadBuildIndex(filePath: string = BUILD_INDEX_FILE): Promise { + let obj: any = await loadAndMergeConfig(filePath, {}) + let outerMap = new Map(Object.entries(obj)) + for (let k of outerMap.keys()) { + outerMap.set(k, new Map(Object.entries(outerMap.get(k)))) + } + return outerMap as BuildIndex +} + export async function fetchBuildIndex(deviceConfigs: DeviceConfig[]): Promise { return fetchBuildIndexInner(deviceConfigs) }