MCPcopy
hub / github.com/toeverything/AFFiNE / buildDeps

Method buildDeps

tools/utils/src/workspace.ts:108–145  ·  view source on GitHub ↗
(
    pkg: Package,
    packages: Map<string, Package>,
    building: Set<string>
  )

Source from the content-addressed store, hash-verified

106 }
107
108 buildDeps(
109 pkg: Package,
110 packages: Map<string, Package>,
111 building: Set<string>
112 ) {
113 if (pkg.deps.length) {
114 return;
115 }
116
117 building.add(pkg.name);
118
119 // @ts-expect-error workspace is the builder for package deps
120 pkg.deps = pkg.workspaceDependencies
121 .map(relativeDepPath => {
122 const dep = packages.get(relativeDepPath);
123
124 if (!dep) {
125 this.logger.error(
126 `Cannot find package at ${relativeDepPath}. While build dependencies of ${pkg.name}`
127 );
128 return null;
129 }
130
131 if (building.has(dep.name)) {
132 throw new CircularDependenciesError(dep.name);
133 }
134
135 if (!pkg.packageJson.private && dep.packageJson.private) {
136 throw new ForbiddenPackageRefError(pkg.name, dep.name);
137 }
138
139 this.buildDeps(dep, packages, building);
140 return dep;
141 })
142 .filter(Boolean) as Package[];
143
144 building.delete(pkg.name);
145 }
146
147 forEach(callback: (pkg: Package) => void) {
148 this.packages.forEach(callback);

Callers 1

constructorMethod · 0.95

Calls 7

mapMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
addMethod · 0.45
filterMethod · 0.45
errorMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected