Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/commands/fix/npm-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ export async function npmFix(
return { ok: true, data: { fixed: false } }
}

// baseBranch and branchParser are now from env
// Lazily access constants.packumentCache.
const { packumentCache } = constants

const workspacePkgJsonPaths = await globWorkspace(
pkgEnvDetails.agent,
rootPath,
Expand All @@ -168,11 +170,14 @@ export async function npmFix(
naturalCompare(a[0], b[0]),
)

const handleInstallFail = (): CResult<{ fixed: boolean }> => {
debugFn(`fail: ${pkgEnvDetails.agent} install\n`)
const cleanupInfoEntriesLoop = () => {
logger.dedent()
spinner?.dedent()
packumentCache.clear()
}

const handleInstallFail = (): CResult<{ fixed: boolean }> => {
cleanupInfoEntriesLoop()
return {
ok: false,
message: 'Installation failure',
Expand Down Expand Up @@ -214,8 +219,7 @@ export async function npmFix(
const packument = await fetchPackagePackument(name)
if (!packument) {
logger.warn(`Unexpected condition: No packument found for ${name}.\n`)
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
continue infoEntriesLoop
}

Expand Down Expand Up @@ -249,8 +253,7 @@ export async function npmFix(
if (!oldVersions.length) {
debugFn(`skip: ${name} not found\n`)
// Skip to next package.
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
continue infoEntriesLoop
}

Expand Down Expand Up @@ -312,8 +315,7 @@ export async function npmFix(
) {
debugFn(`skip: open PR found for ${name}@${newVersion}`)
if (++count >= limit) {
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
break infoEntriesLoop
}
continue infosLoop
Expand Down Expand Up @@ -554,8 +556,7 @@ export async function npmFix(
logger.fail(`Update failed for ${oldId} in ${workspace}.`, error)
}
if (++count >= limit) {
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
break infoEntriesLoop
}
}
Expand All @@ -571,8 +572,7 @@ export async function npmFix(
if (!isLastInfoEntry) {
logger.logNewline()
}
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
}

spinner?.stop()
Expand Down
25 changes: 13 additions & 12 deletions src/commands/fix/pnpm-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ export async function pnpmFix(
return { ok: true, data: { fixed: false } }
}

// baseBranch and branchParser are now from env
// Lazily access constants.packumentCache.
const { packumentCache } = constants

const workspacePkgJsonPaths = await globWorkspace(
pkgEnvDetails.agent,
rootPath,
Expand All @@ -244,10 +246,14 @@ export async function pnpmFix(
naturalCompare(a[0], b[0]),
)

const handleInstallFail = (): CResult<{ fixed: boolean }> => {
const cleanupInfoEntriesLoop = () => {
logger.dedent()
spinner?.dedent()
packumentCache.clear()
}

const handleInstallFail = (): CResult<{ fixed: boolean }> => {
cleanupInfoEntriesLoop()
return {
ok: false,
message: 'Install failed',
Expand Down Expand Up @@ -289,8 +295,7 @@ export async function pnpmFix(
const packument = await fetchPackagePackument(name)
if (!packument) {
logger.warn(`Unexpected condition: No packument found for ${name}.\n`)
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
continue infoEntriesLoop
}

Expand Down Expand Up @@ -350,8 +355,7 @@ export async function pnpmFix(
if (!oldVersions.length) {
debugFn(`skip: ${name} not found\n`)
// Skip to next package.
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
continue infoEntriesLoop
}

Expand Down Expand Up @@ -420,8 +424,7 @@ export async function pnpmFix(
) {
debugFn(`skip: open PR found for ${name}@${newVersion}`)
if (++count >= limit) {
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
break infoEntriesLoop
}
continue infosLoop
Expand Down Expand Up @@ -753,8 +756,7 @@ export async function pnpmFix(
debugFn('name:', name)
debugFn('increment: count', count + 1)
if (++count >= limit) {
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
break infoEntriesLoop
}
}
Expand All @@ -770,8 +772,7 @@ export async function pnpmFix(
if (!isLastInfoEntry) {
logger.logNewline()
}
logger.dedent()
spinner?.dedent()
cleanupInfoEntriesLoop()
}

spinner?.stop()
Expand Down