mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
Previously, the changelog script was looking for the last "Publish Stable" commit, but it should really be looking for the last Stable release of Now CLI. This PR updates the changelog script so that it fetches the latest GH Release (which should be Now CLI) and then compares that to the HEAD.
57 lines
1.6 KiB
JavaScript
Vendored
57 lines
1.6 KiB
JavaScript
Vendored
const { join } = require('path');
|
|
const { execSync } = require('child_process');
|
|
const fetch = require('node-fetch');
|
|
|
|
process.chdir(join(__dirname, '..'));
|
|
|
|
async function main() {
|
|
const res = await fetch(
|
|
'https://api.github.com/repos/zeit/now/releases/latest'
|
|
);
|
|
const { tag_name } = await res.json();
|
|
|
|
// git log --pretty=format:"- %s [%an]" `git show-ref -s 'now@16.7.3'`...HEAD | grep -v '\- Publish '
|
|
|
|
if (!tag_name) {
|
|
throw new Error('Unable to find last GitHub Release tag.');
|
|
}
|
|
|
|
const log =
|
|
execSync(`git log --pretty=format:"- %s [%an]" ${tag_name}...HEAD`)
|
|
.toString()
|
|
.trim()
|
|
.split('\n')
|
|
.filter(line => !line.startsWith('- Publish '))
|
|
.join('\n') || 'NO CHANGES DETECTED';
|
|
|
|
console.log(`Changes since the last stable release (${tag_name}):`);
|
|
console.log(`\n${log}\n`);
|
|
|
|
const pkgs =
|
|
Array.from(
|
|
new Set(
|
|
execSync(`git diff --name-only ${tag_name}...HEAD`)
|
|
.toString()
|
|
.trim()
|
|
.split('\n')
|
|
.filter(line => line.startsWith('packages/'))
|
|
.map(line => line.split('/')[1])
|
|
.map(pkgName => {
|
|
try {
|
|
return require(`../packages/${pkgName}/package.json`).name;
|
|
} catch {
|
|
// Failed to read package.json (perhaps the pkg was deleted)
|
|
}
|
|
})
|
|
.filter(s => Boolean(s))
|
|
)
|
|
).join(',') || 'now';
|
|
|
|
console.log('To publish a stable release, execute the following:');
|
|
console.log(
|
|
`\nnpx lerna version --message 'Publish Stable' --exact --force-publish=${pkgs}\n`
|
|
);
|
|
}
|
|
|
|
main().catch(console.error);
|