MCPcopy Create free account
hub / github.com/npm/cli / getPrBody

Function getPrBody

scripts/create-node-pr.js:61–107  ·  view source on GitHub ↗
({ releases, closePrs })

Source from the content-addressed store, hash-verified

59}
60
61const getPrBody = async ({ releases, closePrs }) => {
62 const useSummary = releases.length > 1
63 const releasePath = (v) => `/npm/cli/releases/tag/v${v}`
64
65 // XXX: add links to relevant CI and CITGM runs once we no longer include our tests
66 let prBody = ''
67
68 if (useSummary) {
69 const summary = releases.map(r => {
70 return `[\`npm@${r.version}\`](https://github.com${releasePath(r.version)})`
71 })
72 prBody += `This PR contains changes from: ${summary.join(' ')}\n\n`
73 }
74
75 if (closePrs.length) {
76 prBody += `This PR replaces: ${closePrs.map(pr => pr.url).join(' ')}\n\n`
77 }
78
79 if (prBody) {
80 prBody += '---\n\n'
81 }
82
83 for (const { version, body } of releases) {
84 prBody += useSummary
85 ? `<details><summary>${version}</summary>\n<p>\n\n${body}\n\n</p>\n</details>`
86 : body
87 prBody += '\n'
88 }
89
90 // These comes from the releases so those link to the raw comparison between tags.
91 // Since we are putting this in a PR we can change those links back to the releases.
92 prBody = prBody.replace(/\/npm\/cli\/compare\/v[\w.-]+\.\.\.v([\w.-]+)/g, releasePath('$1'))
93
94 const { remark } = await import('remark')
95 const { default: remarkGfm } = await import('remark-gfm')
96 const { default: remarkGithub, defaultBuildUrl } = await import('remark-github')
97
98 return remark()
99 .use(remarkGfm)
100 .use(remarkGithub, {
101 repository: 'npm/cli',
102 // don't link mentions, but anything else make the link an explicit reference to npm/cli
103 buildUrl: (values) => values.type === 'mention' ? false : defaultBuildUrl(values),
104 })
105 .process(prBody)
106 .then(v => String(v))
107}
108
109const tokenRemoteUrl = ({ host, token }) => {
110 // this is a remote url that uses a github token as the username

Callers 1

mainFunction · 0.85

Calls 3

releasePathFunction · 0.85
replaceMethod · 0.80
useMethod · 0.80

Tested by

no test coverage detected