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

Function makePackument

test/unit/server/utils/dependency-resolver.spec.ts:17–44  ·  view source on GitHub ↗

* Helper to build a minimal Packument for mocking.

(
  name: string,
  versions: Array<{
    version: string
    deps?: Record<string, string>
    optionalDeps?: Record<string, string>
    os?: string[]
    cpu?: string[]
    libc?: string[]
    unpackedSize?: number
    deprecated?: string
  }>,
)

Source from the content-addressed store, hash-verified

15 * Helper to build a minimal Packument for mocking.
16 */
17function makePackument(
18 name: string,
19 versions: Array<{
20 version: string
21 deps?: Record<string, string>
22 optionalDeps?: Record<string, string>
23 os?: string[]
24 cpu?: string[]
25 libc?: string[]
26 unpackedSize?: number
27 deprecated?: string
28 }>,
29): Packument {
30 const versionsMap: Record<string, PackumentVersion> = {}
31 for (const v of versions) {
32 versionsMap[v.version] = {
33 version: v.version,
34 dependencies: v.deps,
35 optionalDependencies: v.optionalDeps,
36 os: v.os,
37 cpu: v.cpu,
38 ...(v.libc ? { libc: v.libc } : {}),
39 dist: { unpackedSize: v.unpackedSize },
40 ...(v.deprecated ? { deprecated: v.deprecated } : {}),
41 } as unknown as PackumentVersion
42 }
43 return { name, versions: versionsMap } as Packument
44}
45
46describe('dependency-resolver', () => {
47 describe('TARGET_PLATFORM', () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected