-
Notifications
You must be signed in to change notification settings - Fork 30
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
Track peer dependencies mismatches #6946
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fd165be
feat(deno): add peer dependencies script
mxdvl 0d08978
fix(deps): correctly report AR deps
mxdvl 18769e5
Merge remote-tracking branch 'origin/main' into mxdvl/peer-dependencies
mxdvl b54d497
feat(peer): ensure yarn is installed
mxdvl 0badf78
refactor: workspaces initial value
mxdvl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { octokit } from './github.ts'; | ||
|
||
const peers = async () => { | ||
// yarn install --check-files | ||
const process = Deno.run({ | ||
cwd: './dotcom-rendering/', | ||
cmd: ['make', 'reinstall'], | ||
stdout: 'null', | ||
stderr: 'piped', | ||
}); | ||
|
||
const [{ code }, rawOutput] = await Promise.all([ | ||
process.status(), | ||
process.stderrOutput(), | ||
]); | ||
if (code !== 0) Deno.exit(code); | ||
|
||
return new TextDecoder() | ||
.decode(rawOutput) | ||
.split('\n') | ||
.filter((line) => line.includes('has incorrect peer dependency')) | ||
.map((line) => line.replace(/workspace-aggregator-[a-z0-9-]+ > /, '')); | ||
}; | ||
|
||
const { dcr, ar, cr } = (await peers()) | ||
.map((line) => { | ||
const matches = line.match( | ||
/warning "(.+?) > (.+?)" has incorrect peer dependency "(.+)"./, | ||
); | ||
if (!matches) throw new Error('Invalid string'); | ||
|
||
const [, workspace, dependency, peer] = matches; | ||
|
||
return { workspace, dependency, peer }; | ||
}) | ||
.reduce<{ dcr: string[]; cr: string[]; ar: string[] }>( | ||
(acc, { workspace, dependency, peer }) => { | ||
const line = `- [ ] \`${dependency}\` requires peer \`${peer}\``; | ||
switch (workspace) { | ||
case '@guardian/dotcom-rendering': | ||
return { | ||
...acc, | ||
dcr: acc.dcr.concat(line), | ||
}; | ||
|
||
case '@guardian/common-rendering ': | ||
return { | ||
...acc, | ||
cr: acc.cr.concat(line), | ||
}; | ||
|
||
case '@guardian/apps-rendering ': | ||
return { | ||
...acc, | ||
ar: acc.ar.concat(line), | ||
}; | ||
default: | ||
return acc; | ||
} | ||
}, | ||
{ dcr: [], cr: [], ar: [] }, | ||
); | ||
// .sort(({ workspace: a }, { workspace: b }) => a.localeCompare(b)); | ||
|
||
const body = `## Current peer dependencies mismatch | ||
|
||
### dotcom-rendering | ||
${dcr.length ? dcr.join('\n') : '- [X] all peer deps matched!'} | ||
|
||
### apps-rendering | ||
${ar.length ? ar.join('\n') : '- [X] all peer deps matched!'} | ||
|
||
### common-rendering | ||
${cr.length ? cr.join('\n') : '- [X] all peer deps matched!'} | ||
`; | ||
|
||
if (!octokit) { | ||
console.log(body); | ||
Deno.exit(); | ||
} | ||
|
||
/** https://github.com/guardian/dotcom-rendering/issues/6945 */ | ||
const issue_number = 6945; | ||
|
||
try { | ||
const { | ||
data: { html_url }, | ||
} = await octokit.rest.issues.update({ | ||
owner: 'guardian', | ||
repo: 'dotcom-rendering', | ||
issue_number, | ||
body, | ||
}); | ||
|
||
console.info(`Updated list of issues for dotcom-rendering#${issue_number}`); | ||
console.info(html_url); | ||
} catch (error) { | ||
// do_something | ||
console.warn(`Failed to update issue #${issue_number}`); | ||
console.error(error); | ||
|
||
console.log(body); | ||
} | ||
|
||
Deno.exit(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will break if yarn output changes (or this project gets a new package manager) – what about using something like https://www.npmjs.com/package/validate-peer-dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that might be a good future improvement! I’m not massively interested in fixing straight away, as PNPM should make this unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve actually tried this package, but could not get it to work at all!