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
10 changes: 9 additions & 1 deletion src/commands/fix/npm-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ async function install(
} as InstallOptions
const newArb = new Arborist({ path: cwd })
newArb.idealTree = await arb.buildIdealTree()
return await newArb.reify()
const actualTree = await newArb.reify()
arb.actualTree = actualTree
return actualTree
Comment on lines +73 to +75
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the project's coding style that requires explicit semicolons, each statement in this refactored code should end with a semicolon. Consider updating the code to:

const actualTree = await newArb.reify();
arb.actualTree = actualTree;
return actualTree;

This maintains consistency with the project's semicolon usage conventions.

Suggested change
const actualTree = await newArb.reify()
arb.actualTree = actualTree
return actualTree
const actualTree = await newArb.reify()
arb.actualTree = actualTree
return actualTree

Spotted by Diamond (based on custom rules)

Is this helpful? React 👍 or 👎 to let us know.

}

export async function npmFix(
Expand Down Expand Up @@ -253,6 +255,8 @@ export async function npmFix(
if (isCi) {
// eslint-disable-next-line no-await-in-loop
await gitResetAndClean(baseBranch, cwd)
// eslint-disable-next-line no-await-in-loop
actualTree = await install(arb, { cwd })
}
continue
}
Expand Down Expand Up @@ -361,6 +365,8 @@ export async function npmFix(
if (isCi) {
// eslint-disable-next-line no-await-in-loop
await gitResetAndClean(baseBranch, cwd)
// eslint-disable-next-line no-await-in-loop
actualTree = await install(arb, { cwd })
}
if (errored) {
if (!isCi) {
Expand All @@ -370,6 +376,8 @@ export async function npmFix(
removeNodeModules(cwd),
editablePkgJson.save({ ignoreWhitespace: true })
])
// eslint-disable-next-line no-await-in-loop
actualTree = await install(arb, { cwd })
}
spinner?.failAndStop(
`Update failed for ${oldId} in ${workspaceName}`,
Expand Down
7 changes: 7 additions & 0 deletions src/commands/fix/pnpm-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export async function pnpmFix(
logger.error('Required pnpm-lock.yaml not found.')
return
}

const alertsMap = purls.length
? await getAlertsMapFromPurls(purls, getAlertMapOptions({ limit }))
: await getAlertsMapFromPnpmLockfile(
Expand Down Expand Up @@ -353,6 +354,8 @@ export async function pnpmFix(
if (isCi) {
// eslint-disable-next-line no-await-in-loop
await gitResetAndClean(baseBranch, cwd)
// eslint-disable-next-line no-await-in-loop
actualTree = await install(pkgEnvDetails, { cwd, spinner })
}
continue
}
Expand Down Expand Up @@ -461,6 +464,8 @@ export async function pnpmFix(
if (isCi) {
// eslint-disable-next-line no-await-in-loop
await gitResetAndClean(baseBranch, cwd)
// eslint-disable-next-line no-await-in-loop
actualTree = await install(pkgEnvDetails, { cwd, spinner })
}
if (errored) {
if (!isCi) {
Expand All @@ -470,6 +475,8 @@ export async function pnpmFix(
removeNodeModules(cwd),
editablePkgJson.save({ ignoreWhitespace: true })
])
// eslint-disable-next-line no-await-in-loop
actualTree = await install(pkgEnvDetails, { cwd, spinner })
}
spinner?.failAndStop(
`Update failed for ${oldId} in ${workspaceName}`,
Expand Down
8 changes: 6 additions & 2 deletions src/shadow/npm/arborist-helpers.mts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function findPackageNode(
let sentinel = 0
while (queue.length) {
if (sentinel++ === LOOP_SENTINEL) {
throw new Error('Detected infinite loop in findPackageNodes')
throw new Error('Detected infinite loop in findPackageNode')
}
const nodeOrLink = queue.pop()!
const node = nodeOrLink.isLink ? nodeOrLink.target : nodeOrLink
Expand Down Expand Up @@ -300,7 +300,11 @@ export function getDetailsFromDiff(
}

export function isTopLevel(tree: SafeNode, node: SafeNode): boolean {
return tree.children.get(node.name) === node
const childNodeOrLink = tree.children.get(node.name)
const childNode = childNodeOrLink?.isLink
? childNodeOrLink.target
: childNodeOrLink
return childNode === node
}

export type Packument = Exclude<
Expand Down