Skip to content

Conversation

@MKruschke
Copy link
Contributor

@MKruschke MKruschke commented Jan 16, 2026

  • add more tests

Refs: #1540

@MKruschke MKruschke marked this pull request as ready for review January 17, 2026 23:21
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to upgradeJsonCatalogDependencies.ts

{
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
Copy link
Contributor

Choose a reason for hiding this comment

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

good change imo

Copy link
Owner

@raineorshine raineorshine left a comment

Choose a reason for hiding this comment

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

Thank you!

document: Document,
path: string[],
{ newName, newValue }: { newName?: string; newValue?: string },
): Document | null {
Copy link
Owner

Choose a reason for hiding this comment

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

Returning the Document and mutating it is a bit confusing. A pure function would be ideal. If that's not possible, then a mutation + returning a boolean success state would be a bit more clear.

We should also add a comment in the JSDOC that the document may be mutated even if the return state is false which appears to be possible if newName is valid and newValue is not a scalar.

}

/**
*
Copy link
Owner

Choose a reason for hiding this comment

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

JSDOC needed

Comment on lines +5 to +8
type UpdateDependencyConfig = {
path: string[] // e.g., ['catalogs', 'my-catalog', 'my-dep'] or ['catalog', 'my-dep']
newValue: string // e.g., '^2.0.0'
}
Copy link
Owner

Choose a reason for hiding this comment

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

Let's inline this type as it is only used in one place, then we get the benefit of co-location.

document = parseDocument(fileContent, { keepSourceTokens: true })
parsedContents = CatalogsConfig.parse(document.toJSON())
} catch (err) {
return null
Copy link
Owner

Choose a reason for hiding this comment

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

We probably want to be a bit more specific here and avoid silently swallowing all errors. If there is a syntax error that prevents the file from being read, we should bubble that up to the user using programError. Otherwise they may assume that it was a successful run and there were no catalog upgrades.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants