mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-25 15:07:06 -04:00
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import fs from 'fs'
|
|
import path from 'path'
|
|
import { audit } from '@pnpm/audit'
|
|
import { readWantedLockfile } from '@pnpm/lockfile.fs'
|
|
import { fixtures } from '@pnpm/test-fixtures'
|
|
|
|
const f = fixtures(import.meta.dirname)
|
|
|
|
async function writeResponse (lockfileDir: string, filename: string, opts: {
|
|
production?: boolean
|
|
dev?: boolean
|
|
optional?: boolean
|
|
}) {
|
|
const lockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: true })
|
|
const include = {
|
|
dependencies: opts.production !== false,
|
|
devDependencies: opts.dev !== false,
|
|
optionalDependencies: opts.optional !== false,
|
|
}
|
|
// @ts-expect-error
|
|
const auditReport = await audit(lockfile!, {
|
|
agentOptions: {},
|
|
include,
|
|
registry: 'https://registry.npmjs.org/',
|
|
})
|
|
fs.writeFileSync(path.join(import.meta.dirname, filename), JSON.stringify(auditReport, null, 2))
|
|
}
|
|
|
|
; (async () => {
|
|
await writeResponse(f.find('has-vulnerabilities'), 'dev-vulnerabilities-only-response.json', {
|
|
dev: true,
|
|
production: false,
|
|
})
|
|
await writeResponse(f.find('has-vulnerabilities'), 'all-vulnerabilities-response.json', {})
|
|
await writeResponse(f.find('has-outdated-deps'), 'no-vulnerabilities-response.json', {})
|
|
})()
|