add support for loading build index from YAML
Default path is config/build-index/build-index.yml, 'includes' directive is supported.
This commit is contained in:
parent
e1d69888dd
commit
1d3c8c59c8
2 changed files with 15 additions and 0 deletions
|
@ -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 CONFIG_DIR = process.env['ADEVTOOL_CONFIG_DIR'] ?? path.join(ADEVTOOL_DIR, 'config')
|
||||||
export const DEVICE_CONFIG_DIR = path.join(CONFIG_DIR, 'device')
|
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')
|
||||||
|
|
|
@ -5,7 +5,9 @@ import path from 'path'
|
||||||
import YAML from 'yaml'
|
import YAML from 'yaml'
|
||||||
import { YAMLMap } from 'yaml/types'
|
import { YAMLMap } from 'yaml/types'
|
||||||
|
|
||||||
|
import { loadAndMergeConfig } from '../config/config-loader'
|
||||||
import { DeviceBuildId, DeviceConfig, makeDeviceBuildId } from '../config/device'
|
import { DeviceBuildId, DeviceConfig, makeDeviceBuildId } from '../config/device'
|
||||||
|
import { BUILD_INDEX_FILE } from '../config/paths'
|
||||||
|
|
||||||
export type BuildIndex = Map<DeviceBuildId, BuildProps>
|
export type BuildIndex = Map<DeviceBuildId, BuildProps>
|
||||||
export type BuildProps = Map<string, string>
|
export type BuildProps = Map<string, string>
|
||||||
|
@ -55,6 +57,15 @@ const PAGE_TYPES: Record<string, PageTypeInfo> = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function loadBuildIndex(filePath: string = BUILD_INDEX_FILE): Promise<BuildIndex> {
|
||||||
|
let obj: any = await loadAndMergeConfig(filePath, {})
|
||||||
|
let outerMap = new Map<string, any>(Object.entries(obj))
|
||||||
|
for (let k of outerMap.keys()) {
|
||||||
|
outerMap.set(k, new Map<string, string>(Object.entries(outerMap.get(k))))
|
||||||
|
}
|
||||||
|
return outerMap as BuildIndex
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchBuildIndex(deviceConfigs: DeviceConfig[]): Promise<YAMLMap> {
|
export async function fetchBuildIndex(deviceConfigs: DeviceConfig[]): Promise<YAMLMap> {
|
||||||
return fetchBuildIndexInner(deviceConfigs)
|
return fetchBuildIndexInner(deviceConfigs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue