2022-08-10 21:58:22 +03:00
|
|
|
import usePantry from "hooks/usePantry.ts"
|
|
|
|
import { PackageRequirement } from "types"
|
|
|
|
|
2022-08-31 22:39:16 +03:00
|
|
|
/// this function is poorly named and does too many things
|
|
|
|
/// sorry. Refactor is desired.
|
|
|
|
|
2022-08-10 21:58:22 +03:00
|
|
|
export function get_build_deps(dry: Set<string>) {
|
|
|
|
const pantry = usePantry()
|
|
|
|
|
|
|
|
return async (pkg: PackageRequirement) => {
|
|
|
|
const deps = await pantry.getDeps(pkg)
|
|
|
|
if (dry.has(pkg.project)) {
|
|
|
|
// we hydrate the runtime deps of any build deps since if
|
|
|
|
// any of `dry` is a runtime dep of any build dep (obv. from another)
|
|
|
|
// pkg in the set we are building then it needs to be sorted first
|
2022-08-31 22:39:16 +03:00
|
|
|
const rv = [...deps.runtime, ...deps.build]
|
|
|
|
|
|
|
|
// if we are building a test-dep then we need it to be built before we
|
|
|
|
// build `pkg` or we will not be able to test it before building the whole
|
|
|
|
// graph
|
|
|
|
for (const test_dep of deps.test) {
|
|
|
|
if (dry.has(test_dep.project)) {
|
|
|
|
rv.push(test_dep)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv
|
|
|
|
|
2022-08-10 21:58:22 +03:00
|
|
|
} else {
|
|
|
|
return deps.runtime
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|