Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(github): Better massageMarkdown implementation #11133

Merged

Conversation

zharinov
Copy link
Collaborator

@zharinov zharinov commented Aug 6, 2021

Changes:

Implement remark plugin inspired by remark-github.
Type declarations aren't ideal, but any interaction with syntax-tree packages is painful since we can't install fresh ESM-only packages.

Context:

Closes #10902

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@zharinov zharinov marked this pull request as draft August 6, 2021 10:41
@zharinov zharinov marked this pull request as ready for review August 6, 2021 11:13
@zharinov
Copy link
Collaborator Author

zharinov commented Aug 6, 2021

Example: renovate-testing/test-10902-markdown-github-links-1#1 (open release notes, search for "our progress")

@zharinov zharinov requested a review from viceice August 6, 2021 11:21
package.json Outdated
@@ -167,6 +167,8 @@
"luxon": "2.0.1",
"markdown-it": "12.1.0",
"markdown-table": "2.0.0",
"mdast-util-find-and-replace": "1.0.0",
"mdast-util-to-string": "1.0.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same versions as for remark-github

Copy link
Member

Choose a reason for hiding this comment

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

remark-github seems to use ^1.0.0 which not points to some higher version, check lockfile changes below

import findAndReplace from 'mdast-util-find-and-replace';
import remark from 'remark';
import type { Plugin, Transformer } from 'unified';
// eslint-disable-next-line import/no-unresolved
Copy link
Collaborator Author

@zharinov zharinov Aug 6, 2021

Choose a reason for hiding this comment

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

@types/unist exists in NPM while unist doesn't 🤷‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

It's a type only package 🤔

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

LGTM, should be bump the versions to make less lockfile changes?

import findAndReplace from 'mdast-util-find-and-replace';
import remark from 'remark';
import type { Plugin, Transformer } from 'unified';
// eslint-disable-next-line import/no-unresolved
Copy link
Member

Choose a reason for hiding this comment

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

It's a type only package 🤔

});
}

const githubExtra: Plugin<any> = (): Transformer => transformer;
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just didn't want to write this lambda in .use(...) expression

package.json Outdated
@@ -167,6 +167,8 @@
"luxon": "2.0.1",
"markdown-it": "12.1.0",
"markdown-table": "2.0.0",
"mdast-util-find-and-replace": "1.0.0",
"mdast-util-to-string": "1.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

remark-github seems to use ^1.0.0 which not points to some higher version, check lockfile changes below

@zharinov
Copy link
Collaborator Author

zharinov commented Aug 6, 2021

Updated new dependencies to the latest version before ESM transition

@rarkins
Copy link
Collaborator

rarkins commented Aug 6, 2021

But are we adding dependencies now which we can't upgrade later due to ESM?

@zharinov
Copy link
Collaborator Author

zharinov commented Aug 6, 2021

Yes, it's a sad part. If I understand it right, we're making them explicit. I mean, it's just what remark-github used before, isn't it.

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

We've effectively the same deps as before. Just some explicit package.json references added.

@rarkins rarkins merged commit 0da13d1 into renovatebot:main Aug 7, 2021
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 25.69.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@viceice
Copy link
Member

viceice commented Aug 10, 2021

@zharinov This broke some release notes

https://github.com/visualon/docker-docuum/releases/v0.20.3

image

### Release Notes

<details>
<summary>visualon/docker-docuum</summary>

### [`v0.20.3`](https://github.com/visualon/docker-docuum/releases/v0.20.3)

[Compare Source](https://github.com/visualon/docker-docuum/compare/v0.20.2...v0.20.3)

See [https://github.com/stepchowfun/docuum/releases/tag/v0](https://github.com/stepchowfun/docuum/releases/tag/v0).20.3 for more changes

</details>

@zharinov
Copy link
Collaborator Author

Seems like the remark plugin itself worked fine, though we needed better URL-in-text recognition.
I think we should try another approach: linkify only those URLs that match /(issue|pull|discussions)/ paths.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Renovate spam GitHub issues
4 participants