MCPcopy Index your code
hub / github.com/npmx-dev/npmx.dev / buildCompareResponse

Function buildCompareResponse

server/utils/compare.ts:226–271  ·  view source on GitHub ↗
(
  packageName: string,
  from: string,
  to: string,
  fromTree: PackageFileTree[],
  toTree: PackageFileTree[],
  fromPkg: Record<string, unknown> | null,
  toPkg: Record<string, unknown> | null,
  computeTime: number,
)

Source from the content-addressed store, hash-verified

224
225/** Build the full compare response */
226export function buildCompareResponse(
227 packageName: string,
228 from: string,
229 to: string,
230 fromTree: PackageFileTree[],
231 toTree: PackageFileTree[],
232 fromPkg: Record<string, unknown> | null,
233 toPkg: Record<string, unknown> | null,
234 computeTime: number,
235): CompareResponse {
236 const fileChanges = compareFileTrees(fromTree, toTree)
237 const dependencyChanges = compareDependencies(fromPkg, toPkg)
238
239 const warnings: string[] = []
240 if (fileChanges.truncated) {
241 warnings.push(`File list truncated to ${MAX_FILES_COMPARE} files`)
242 }
243
244 return {
245 package: packageName,
246 from,
247 to,
248 packageJson: {
249 from: fromPkg,
250 to: toPkg,
251 },
252 files: {
253 added: fileChanges.added,
254 removed: fileChanges.removed,
255 modified: fileChanges.modified,
256 },
257 dependencyChanges,
258 stats: {
259 totalFilesFrom: countFiles(fromTree),
260 totalFilesTo: countFiles(toTree),
261 filesAdded: fileChanges.added.length,
262 filesRemoved: fileChanges.removed.length,
263 filesModified: fileChanges.modified.length,
264 },
265 meta: {
266 truncated: fileChanges.truncated,
267 warnings: warnings.length > 0 ? warnings : undefined,
268 computeTime,
269 },
270 }
271}

Callers 1

[...pkg].get.tsFile · 0.85

Calls 3

compareFileTreesFunction · 0.85
compareDependenciesFunction · 0.85
countFilesFunction · 0.85

Tested by

no test coverage detected