-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: filtering patches from docs deployment script (#3779)
# Description This change makes the script that runs before `yarn build` filter down the patches to the latest patch of every major. ## Problem\* This script used to remove: - Prereleases - Nightlies (which are prereleases) - "Aztec" versions However, this would mean that every patch, as long as it was stable, would have its own docs deployed. This would lead to docs having three patch versions, which shouldn't even differ (they're patches, no breaking changes), like 0.19.1, 0.19.2, etc ## Summary\* This change simplifies the script by removing some computation that was there just for debugging reasons. It also stops assuming all "aztec" versions are prereleases. And finally, it filters down only for the latest patch version. ## Additional Context Another way of doing it (which is how we're doing it now) is to just make all non-latest patch as prereleases, which is kinda annoying. With this change, it shouldn't matter.
- Loading branch information
1 parent
ea4d89d
commit d617ea4
Showing
6 changed files
with
43 additions
and
32 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ yarn-debug.log* | |
yarn-error.log* | ||
|
||
package-lock.json | ||
versions.json |
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 |
---|---|---|
@@ -1,38 +1,55 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const axios = require('axios'); | ||
|
||
const GITHUB_PAGES = 3; | ||
const IGNORE_VERSIONS = ['0.16.0']; | ||
const NUMBER_OF_VERSIONS_TO_SHOW = 4; | ||
const NUMBER_OF_VERSIONS_TO_SHOW = 2; | ||
|
||
async function main() { | ||
const versionsFile = path.resolve('../versions.json'); | ||
|
||
const axiosOpts = { | ||
params: { per_page: 100 }, | ||
headers: {}, | ||
}; | ||
|
||
if (process.env.GITHUB_TOKEN) axiosOpts.headers = { Authorization: `token ${process.env.GITHUB_TOKEN}` }; | ||
|
||
const { data } = await axios.get('https://api.github.com/repos/noir-lang/noir/releases', axiosOpts); | ||
|
||
const all = data.map((release) => release.tag_name); | ||
console.log('All versions: ', all); | ||
const aztecs = data.filter((release) => release.tag_name.includes('aztec')).map((release) => release.tag_name); | ||
console.log('Removing aztecs: ', aztecs); | ||
const prereleases = data.filter((release) => !release.prerelease).map((release) => release.tag_name); | ||
console.log('Removing prereleases: ', prereleases); | ||
|
||
const stables = data | ||
.filter((release) => !release.prerelease && !release.tag_name.includes('aztec')) | ||
.filter((release) => !IGNORE_VERSIONS.includes(release.tag_name.replace('v', ''))) | ||
.map((release) => release.tag_name) | ||
.slice(0, NUMBER_OF_VERSIONS_TO_SHOW); | ||
|
||
console.log('Stables: ', stables); | ||
|
||
fs.writeFileSync(versionsFile, JSON.stringify(stables, null, 2)); | ||
let stables = []; | ||
console.log('Retrieved versions:'); | ||
|
||
for (let i = 0; i < GITHUB_PAGES; i++) { | ||
const { data } = await axios.get(`https://api.github.com/repos/noir-lang/noir/releases?page=${i + 1}`, axiosOpts); | ||
|
||
console.log(data.map((release) => release.tag_name)); | ||
stables.push( | ||
...data | ||
.filter( | ||
(release) => | ||
!release.prerelease && !release.tag_name.includes('aztec') && !release.tag_name.includes('aztec'), | ||
) | ||
.filter((release) => !IGNORE_VERSIONS.includes(release.tag_name.replace('v', ''))) | ||
.map((release) => release.tag_name), | ||
); | ||
} | ||
|
||
stables = stables.slice(0, NUMBER_OF_VERSIONS_TO_SHOW); | ||
|
||
console.log('Filtered down to stables: ', stables); | ||
|
||
const onlyLatestPatches = []; | ||
const minorsSet = new Set(stables.map((el) => el.split('.')[1])); | ||
for (const minor of minorsSet) { | ||
const minorVersions = stables.filter((el) => el.split('.')[1] === minor); | ||
const max = minorVersions.reduce((prev, current) => { | ||
return prev > current ? prev : current; | ||
}); | ||
onlyLatestPatches.push(max); | ||
} | ||
|
||
console.log('Only latest patches: ', onlyLatestPatches); | ||
|
||
fs.writeFileSync(path.resolve(__dirname, '../versions.json'), JSON.stringify(onlyLatestPatches, null, 2)); | ||
} | ||
|
||
main(); |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"extends": "@docusaurus/tsconfig", | ||
"compilerOptions": { | ||
"baseUrl": "." | ||
"baseUrl": ".", | ||
"downlevelIteration": true | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.