wip: Recursive resolving of (non-injected) dependencies
We started out with following dependencies that are injected (from) and now added dependencies that are merely required to be drafted first (after). This also adds further support for part-level configuration.
This commit is contained in:
parent
4cf9c3bd47
commit
2b254c721d
3 changed files with 203 additions and 13 deletions
|
@ -437,7 +437,7 @@ const addPartOptionalMeasurements = (part, config, list=false) => {
|
|||
}
|
||||
|
||||
|
||||
const addDependencies = (dep, current) => {
|
||||
export const mergeDependencies = (dep=[], current=[]) => {
|
||||
// Current dependencies
|
||||
const list = []
|
||||
if (Array.isArray(current)) list.push(...current)
|
||||
|
@ -446,13 +446,21 @@ const addDependencies = (dep, current) => {
|
|||
if (Array.isArray(dep)) list.push(...dep)
|
||||
else if (typeof dep === 'string') list.push(dep)
|
||||
|
||||
return [...new Set(list)]
|
||||
// Dependencies should be parts names (string) not the object
|
||||
const deps = []
|
||||
for (const part of [...new Set(list)]) {
|
||||
if (typeof part === 'object') deps.push(part.name)
|
||||
else deps.push(part)
|
||||
}
|
||||
|
||||
return deps
|
||||
}
|
||||
|
||||
// Add part-level dependencies
|
||||
export const addPartDependencies = (part, config) => {
|
||||
if (part.after) {
|
||||
config.dependencies[part.name] = addDependencies(config.dependencies[part.name], part.after)
|
||||
if (typeof config.dependencies === 'undefined') config.dependencies = {}
|
||||
config.dependencies[part.name] = mergeDependencies(config.dependencies[part.name], part.after)
|
||||
}
|
||||
|
||||
return config
|
||||
|
@ -467,4 +475,3 @@ export const addPartConfig = (part, config) => {
|
|||
return config
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue