MCPcopy Create free account
hub / github.com/formkit/formkit / drawDependencyTree

Function drawDependencyTree

scripts/utils.mjs:201–231  ·  view source on GitHub ↗
(
  tree = [],
  depth = 0,
  directoryPrefix = '∟ ',
  parent
)

Source from the content-addressed store, hash-verified

199 * Given a dependency tree, do a pretty console log of the graph
200 */
201export function drawDependencyTree(
202 tree = [],
203 depth = 0,
204 directoryPrefix = '∟ ',
205 parent
206) {
207 for (const [i, branch] of tree.entries()) {
208 const title = branch[0]
209 const deps = branch[1]
210 const directoryIndent = `${' '.repeat(depth)}${
211 depth > 0 ? directoryPrefix : ''
212 }${'— '.repeat(Math.min(1, depth))}`
213 if (depth === 0) {
214 console.log(
215 `${i + 1}) ${directoryIndent}${title} ` +
216 chalk.dim(`(${getPackageVersion(title)})`)
217 )
218 } else {
219 msg.info(
220 ` ${directoryIndent}${title} ` +
221 chalk.dim(`(${getDependencyVersion(parent, title)})`)
222 )
223 }
224
225 if (deps) {
226 for (const dep of deps) {
227 drawDependencyTree([dep], depth + 1, directoryPrefix, title)
228 }
229 }
230 }
231}
232
233/**
234 * Given a package name, return relevant build files from the file system

Callers 2

publishPackagesFunction · 0.90
publishPackagesFunction · 0.90

Calls 2

getPackageVersionFunction · 0.85
getDependencyVersionFunction · 0.85

Tested by

no test coverage detected