MCPcopy
hub / github.com/antfu-collective/taze / CheckPackages

Function CheckPackages

src/api/check.ts:17–59  ·  view source on GitHub ↗
(options: CheckOptions, callbacks: CheckEventCallbacks = {})

Source from the content-addressed store, hash-verified

15}
16
17export async function CheckPackages(options: CheckOptions, callbacks: CheckEventCallbacks = {}) {
18 if (!options.force)
19 await loadCache()
20
21 // packages loading
22 const packages = await loadPackages(options)
23 callbacks.afterPackagesLoaded?.(packages)
24
25 const privatePackageNames = packages
26 .filter(i => i.private)
27 .map(i => i.name)
28 .filter(i => i)
29
30 // to filter out private dependency in monorepo
31 const filter = (dep: RawDep) => !privatePackageNames.includes(dep.name)
32
33 let resolvedCount = 0
34 const onDependencyResolved: DependencyResolvedCallback = (pkgName, name, progress, total) => {
35 resolvedCount++
36 callbacks.onDependencyResolved?.(pkgName, name, resolvedCount, total)
37 }
38
39 const queue = newQueue(options.concurrency || 10)
40
41 await queueContext.run(queue, () => {
42 // run all CheckSingleProject in parallel
43 // the actual resolveDependencies within CheckSingleProject -> resolvePackage -> resolveDependencies is
44 // actually limited by the queueContext/queue, so it won't overwhelm the npm meta server.
45 return Promise.all(packages.map(async (pkg) => {
46 callbacks.beforePackageStart?.(pkg)
47 await CheckSingleProject(pkg, options, filter, { ...callbacks, onDependencyResolved })
48 callbacks.afterPackageEnd?.(pkg)
49 }))
50 })
51
52 callbacks.afterPackagesEnd?.(packages)
53
54 await dumpCache()
55
56 return {
57 packages,
58 }
59}
60
61async function CheckSingleProject(pkg: PackageMeta, options: CheckOptions, filter: DependencyFilter = () => true, callbacks: CheckEventCallbacks = {}) {
62 await resolvePackage(pkg, options, filter, callbacks.onDependencyResolved)

Callers 7

bunCatalog.test.tsFile · 0.90
checkFunction · 0.90

Calls 4

loadCacheFunction · 0.90
loadPackagesFunction · 0.90
dumpCacheFunction · 0.90
CheckSingleProjectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…