mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-02 20:18:15 -05:00
* feat: replace a config This is a test commit to see if CI fails * feat: `strictPatches` * docs: future instruction * feat: `strictPatches` → `allowPatchFailure` * docs(changeset): correction * test: getOptionsFromRootManifest * fix: allowFailure * feat: groupPatchedDependencies * fix: update code after merge * fix: star spec * feat: error on invalid ranges * fix: eslint * docs: change task * feat(patching): version ranges * fix: `verifyPatches` * refactor: move types to `@pnpm/patching.types` * docs(changeset): add missing package * refactor: move `verifyPatches` to `@pnpm/patching.config` * test: fix * feat: change error message of unused patches * refactor: exact options into an interface * test(patching): version range * test(patching): allowPatchFailure * docs: change wording * docs: change wording * test(patching): version range error * test(patching): legacy behavior * test: don't use star * test(patching): strict versionless * test: strictPatches * chore(deps): `@pnpm/logger` must be peer * docs: fix grammar * refactor: rename `blank` to `all` * refactor: use string * refactor: use array for `PatchGroup.range` * refactor: stop re-exporting `allPatchKeys` * feat: re-export `PatchGroupRangeItem` * refactor: move error creation into a class * docs: replace "versionless" with "name-only" * docs: coherent wordings * test: exact version overrides range conflict * test: tweak * docs: consistent wordings * docs: correct wordings * refactor: rename `allowPatchFailure` to `ignorePatchFailures` * feat: replace `strictPatches` with `ignorePatchFailures` * docs: legacy behavior * feat: introduce `allowUnusedPatches` * docs(changeset): update * docs: remove outdated comment * docs: backward-compatibility
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
import { type PatchFile } from '@pnpm/patching.types'
|
|
import { getPatchInfo, groupPatchedDependencies } from '../src/index'
|
|
|
|
const _getPatchInfo = (patchedDependencies: Record<string, PatchFile>, name: string, version: string) =>
|
|
getPatchInfo(groupPatchedDependencies(patchedDependencies), name, version)
|
|
|
|
test('getPatchInfo(undefined, ...) returns undefined', () => {
|
|
expect(getPatchInfo(undefined, 'foo', '1.0.0')).toBeUndefined()
|
|
})
|
|
|
|
test('getPatchInfo(_, name, version) returns strict=true if name@version exists', () => {
|
|
expect(_getPatchInfo({
|
|
'foo@1.0.0': {
|
|
path: 'patches/foo@1.0.0.patch',
|
|
hash: '00000000000000000000000000000000',
|
|
},
|
|
}, 'foo', '1.0.0')).toStrictEqual({
|
|
file: {
|
|
path: 'patches/foo@1.0.0.patch',
|
|
hash: expect.any(String),
|
|
},
|
|
key: 'foo@1.0.0',
|
|
strict: true,
|
|
})
|
|
})
|
|
|
|
test('getPatchInfo(_, name, version) returns strict=false if name exists and name@version does not exist', () => {
|
|
expect(_getPatchInfo({
|
|
foo: {
|
|
path: 'patches/foo.patch',
|
|
hash: '00000000000000000000000000000000',
|
|
},
|
|
}, 'foo', '1.0.0')).toStrictEqual({
|
|
file: {
|
|
path: 'patches/foo.patch',
|
|
hash: expect.any(String),
|
|
},
|
|
key: 'foo',
|
|
strict: false,
|
|
})
|
|
})
|
|
|
|
test('getPatchInfo(_, name, version) prioritizes name@version over name if both exist', () => {
|
|
expect(_getPatchInfo({
|
|
foo: {
|
|
path: 'patches/foo.patch',
|
|
hash: '00000000000000000000000000000000',
|
|
},
|
|
'foo@1.0.0': {
|
|
path: 'patches/foo@1.0.0.patch',
|
|
hash: '00000000000000000000000000000000',
|
|
},
|
|
}, 'foo', '1.0.0')).toStrictEqual({
|
|
file: {
|
|
path: 'patches/foo@1.0.0.patch',
|
|
hash: expect.any(String),
|
|
},
|
|
key: 'foo@1.0.0',
|
|
strict: true,
|
|
})
|
|
})
|
|
|
|
test('getPatchInfo(_, name, version) does not access wrong name', () => {
|
|
expect(_getPatchInfo({
|
|
'bar@1.0.0': {
|
|
path: 'patches/bar@1.0.0.patch',
|
|
hash: '00000000000000000000000000000000',
|
|
},
|
|
}, 'foo', '1.0.0')).toBeUndefined()
|
|
})
|
|
|
|
test('getPatchInfo(_, name, version) does not access wrong version', () => {
|
|
expect(_getPatchInfo({
|
|
'foo@2.0.0': {
|
|
path: 'patches/foo@2.0.0.patch',
|
|
hash: '00000000000000000000000000000000',
|
|
},
|
|
}, 'foo', '1.0.0')).toBeUndefined()
|
|
})
|