(base: ApiSnapshot, head: ApiSnapshot)
| 344 | } |
| 345 | |
| 346 | const moduleChanges = (base: ApiSnapshot, head: ApiSnapshot): ReadonlyArray<ApiChange> => { |
| 347 | const changes: Array<ApiChange> = [] |
| 348 | const basePackages = new Set(base.packages) |
| 349 | const headPackages = new Set(head.packages) |
| 350 | for (const packageName of basePackages) { |
| 351 | if (!headPackages.has(packageName)) { |
| 352 | changes.push({ |
| 353 | id: `change-${fingerprint(["package-removed", packageName]).slice(0, 16)}`, |
| 354 | classification: "package-removed", |
| 355 | confidence: 1, |
| 356 | delta: { packageName }, |
| 357 | authoritative: true |
| 358 | }) |
| 359 | } |
| 360 | } |
| 361 | for (const packageName of headPackages) { |
| 362 | if (!basePackages.has(packageName)) { |
| 363 | changes.push({ |
| 364 | id: `change-${fingerprint(["package-added", packageName]).slice(0, 16)}`, |
| 365 | classification: "package-added", |
| 366 | confidence: 1, |
| 367 | delta: { packageName }, |
| 368 | authoritative: true |
| 369 | }) |
| 370 | } |
| 371 | } |
| 372 | const baseModules = new Set(base.entrypoints.map((entrypoint) => entrypoint.module)) |
| 373 | const headModules = new Set(head.entrypoints.map((entrypoint) => entrypoint.module)) |
| 374 | for (const module of baseModules) { |
| 375 | if (!headModules.has(module)) { |
| 376 | changes.push({ |
| 377 | id: `change-${fingerprint(["module-removed", module]).slice(0, 16)}`, |
| 378 | classification: "module-removed", |
| 379 | confidence: 1, |
| 380 | delta: { from: module, to: [] }, |
| 381 | authoritative: true |
| 382 | }) |
| 383 | } |
| 384 | } |
| 385 | for (const module of headModules) { |
| 386 | if (!baseModules.has(module)) { |
| 387 | changes.push({ |
| 388 | id: `change-${fingerprint(["module-added", module]).slice(0, 16)}`, |
| 389 | classification: "module-added", |
| 390 | confidence: 1, |
| 391 | delta: { to: [module] }, |
| 392 | authoritative: true |
| 393 | }) |
| 394 | } |
| 395 | } |
| 396 | return changes |
| 397 | } |
| 398 | |
| 399 | export const diffSnapshots = (base: ApiSnapshot, head: ApiSnapshot): ApiDiff => { |
| 400 | const unmatchedBase = new Map(base.entities.map((entity) => [entity.id, entity])) |
no test coverage detected