Skip to content

Commit 35e3751

Browse files
authored
fix: disable minimumReleaseAge setting in pnpm-workspace.yaml (#431)
fix: disable minimumReleaseAge setting in pnpm-workspace.yaml to avoid error on install when our own overrides have dependencies that violate this setting
1 parent 8417143 commit 35e3751

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

utils.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -572,18 +572,16 @@ export async function applyPackageOverrides(
572572
// check `overrides` in pnpm-workspace.yaml
573573
const pnpmWorkspaceFile = path.join(dir, 'pnpm-workspace.yaml')
574574
if (fs.existsSync(pnpmWorkspaceFile)) {
575-
const pnpmWorkspaceContent = await fs.promises.readFile(
576-
pnpmWorkspaceFile,
577-
'utf-8',
578-
)
579-
if (/^overrides:/m.test(pnpmWorkspaceContent)) {
575+
let content = await fs.promises.readFile(pnpmWorkspaceFile, 'utf-8')
576+
let modified = false
577+
if (/^overrides:/m.test(content)) {
580578
delete pkg.pnpm.overrides // remove pnpm.overrides from package.json so that pnpm-workspace.yaml's one is used
581579
// merge with existing overrides
582580
const output = await $`pnpm config list --json --location project`
583581
const currentOverrides = JSON.parse(output).overrides
584582
const mergedOverrides = { ...currentOverrides, ...overrides }
585583
// replace all indented lines in `overrides` section
586-
const newContent = pnpmWorkspaceContent.replace(
584+
content = content.replace(
587585
/^overrides:\n((?:[ \t]+.+\n)*)/m,
588586
() =>
589587
`overrides:\n${Object.entries(mergedOverrides)
@@ -593,7 +591,18 @@ export async function applyPackageOverrides(
593591
)
594592
.join('')}`,
595593
)
596-
await fs.promises.writeFile(pnpmWorkspaceFile, newContent, 'utf-8')
594+
modified = true
595+
}
596+
if (content.includes('minimumReleaseAge:')) {
597+
// disable with comment to avoid error on installation if ecosystem-ci overrides pull in violating updates
598+
content = content.replace(
599+
/^([ \t]*minimumReleaseAge[ \t]*:[ \t]*\d+[^\r\n]*)$/m,
600+
'# $1 -- disabled by ecosystem-ci',
601+
)
602+
modified = true
603+
}
604+
if (modified) {
605+
await fs.promises.writeFile(pnpmWorkspaceFile, content, 'utf-8')
597606
}
598607
}
599608
} else if (pm === 'yarn') {

0 commit comments

Comments
 (0)