mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 04:43:20 +03:00
feat: generate blocksuite changelog (#5724)
This commit is contained in:
parent
25e8b8306f
commit
5bd339bed7
146
tools/bump-blocksuite/index.js
Normal file
146
tools/bump-blocksuite/index.js
Normal file
@ -0,0 +1,146 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { Clipboard } from '@napi-rs/clipboard';
|
||||
import { Repository, Sort } from '@napi-rs/simple-git';
|
||||
|
||||
import corePackage from '../../packages/frontend/core/package.json' assert { type: 'json' };
|
||||
|
||||
const clipboard = new Clipboard();
|
||||
|
||||
const oldHash = corePackage.dependencies['@blocksuite/block-std']
|
||||
.split('-')
|
||||
.pop();
|
||||
|
||||
const info = await fetch(
|
||||
'https://registry.npmjs.org/@blocksuite/block-std'
|
||||
).then(res => res.json());
|
||||
|
||||
const latestVersion = info['dist-tags'].nightly;
|
||||
const latestHash = latestVersion.split('-').pop();
|
||||
|
||||
console.info(`Upgrade blocksuite from ${oldHash} -> ${latestHash}`);
|
||||
|
||||
const blockSuiteDeps = execSync(`yarn info -A --name-only --json`, {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
|
||||
const blocksuiteDepsList = blockSuiteDeps
|
||||
.split('\n')
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean)
|
||||
.map(s => s.substring(1, s.length - 1))
|
||||
.filter(
|
||||
s => s.startsWith('@blocksuite') && !s.startsWith('@blocksuite/icons')
|
||||
)
|
||||
.map(s => s.split('@npm').at(0));
|
||||
|
||||
for (const pkg of blocksuiteDepsList) {
|
||||
const command = `yarn up ${pkg}@${latestVersion}`;
|
||||
console.info(`Executing ${command}`);
|
||||
execSync(command, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
|
||||
console.info(`Upgrade complete`);
|
||||
|
||||
const repo = new Repository(
|
||||
join(fileURLToPath(import.meta.url), '..', '..', '..', '..', 'BlockSuite')
|
||||
);
|
||||
|
||||
repo.remote('origin').fetch(['master'], progress => {
|
||||
if (progress.totalDeltas && progress.totalObjects) {
|
||||
console.log(
|
||||
`${(
|
||||
(progress.receivedObjects / progress.totalObjects) * 50 +
|
||||
(progress.indexedDeltas / progress.totalDeltas) * 50
|
||||
).toFixed(2)}%`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const latest = repo.findCommit(latestHash);
|
||||
|
||||
const commits = {
|
||||
Features: [],
|
||||
Bugfix: [],
|
||||
Refactor: [],
|
||||
Misc: [],
|
||||
};
|
||||
|
||||
for (const oid of repo
|
||||
.revWalk()
|
||||
.push(latest.id())
|
||||
.setSorting(Sort.Time & Sort.Topological)) {
|
||||
const commit = repo.findCommit(oid);
|
||||
const summary = commit.summary();
|
||||
if (summary.startsWith('feat')) {
|
||||
commits.Features.push(commit);
|
||||
} else if (summary.startsWith('fix')) {
|
||||
commits.Bugfix.push(commit);
|
||||
} else if (summary.startsWith('refactor')) {
|
||||
commits.Refactor.push(commit);
|
||||
} else {
|
||||
commits.Misc.push(commit);
|
||||
}
|
||||
if (oid.startsWith(oldHash)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clipboard.setText(await formatCommits(commits));
|
||||
|
||||
console.info(`Changelog copied to clipboard`);
|
||||
|
||||
async function formatCommits(commits) {
|
||||
return `## Features
|
||||
${await Promise.all(commits.Features.map(format)).then(commits =>
|
||||
commits.join('\n')
|
||||
)}
|
||||
|
||||
## Bugfix
|
||||
${await Promise.all(commits.Bugfix.map(format)).then(commits =>
|
||||
commits.join('\n')
|
||||
)}
|
||||
|
||||
## Refactor
|
||||
${await Promise.all(commits.Refactor.map(format)).then(commits =>
|
||||
commits.join('\n')
|
||||
)}
|
||||
|
||||
## Misc
|
||||
${await Promise.all(commits.Misc.map(format)).then(commits =>
|
||||
commits.join('\n')
|
||||
)}
|
||||
`;
|
||||
/**
|
||||
* @param {import('./index').Commit} commit
|
||||
* @returns string
|
||||
*/
|
||||
async function format(commit) {
|
||||
const summary = commit.summary();
|
||||
const match = summary.match(/\(#(\d+)\)/);
|
||||
if (match) {
|
||||
const [_, pull] = match;
|
||||
const pullInfo = await fetch(
|
||||
`https://api.github.com/repos/toeverything/BlockSuite/pulls/${pull}`,
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/vnd.github+json',
|
||||
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
|
||||
'X-GitHub-Api-Version': '2022-11-28',
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(res => res.json())
|
||||
.catch(() => ({ user: {} }));
|
||||
const {
|
||||
user: { login },
|
||||
} = pullInfo;
|
||||
return `- https://github.com/toeverything/BlockSuite/pull/${pull} @${login}`;
|
||||
}
|
||||
return `- ${summary}`;
|
||||
}
|
||||
}
|
12
tools/bump-blocksuite/package.json
Normal file
12
tools/bump-blocksuite/package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "@affine/bump-blocksuite",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
"description": "Generate changelog from blocksuite version change",
|
||||
"dependencies": {
|
||||
"@napi-rs/clipboard": "^1.1.1",
|
||||
"@napi-rs/simple-git": "^0.1.11"
|
||||
}
|
||||
}
|
237
yarn.lock
237
yarn.lock
@ -149,6 +149,15 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@affine/bump-blocksuite@workspace:tools/bump-blocksuite":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@affine/bump-blocksuite@workspace:tools/bump-blocksuite"
|
||||
dependencies:
|
||||
"@napi-rs/clipboard": "npm:^1.1.1"
|
||||
"@napi-rs/simple-git": "npm:^0.1.11"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@affine/cli@workspace:*, @affine/cli@workspace:tools/cli":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@affine/cli@workspace:tools/cli"
|
||||
@ -6736,6 +6745,115 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-darwin-arm64@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-darwin-arm64@npm:1.1.1"
|
||||
conditions: os=darwin & cpu=arm64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-darwin-x64@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-darwin-x64@npm:1.1.1"
|
||||
conditions: os=darwin & cpu=x64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-linux-arm-gnueabihf@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-linux-arm-gnueabihf@npm:1.1.1"
|
||||
conditions: os=linux & cpu=arm
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-linux-arm64-gnu@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-linux-arm64-gnu@npm:1.1.1"
|
||||
conditions: os=linux & cpu=arm64 & libc=glibc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-linux-arm64-musl@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-linux-arm64-musl@npm:1.1.1"
|
||||
conditions: os=linux & cpu=arm64 & libc=musl
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-linux-x64-gnu@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-linux-x64-gnu@npm:1.1.1"
|
||||
conditions: os=linux & cpu=x64 & libc=glibc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-linux-x64-musl@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-linux-x64-musl@npm:1.1.1"
|
||||
conditions: os=linux & cpu=x64 & libc=musl
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-win32-arm64-msvc@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-win32-arm64-msvc@npm:1.1.1"
|
||||
conditions: os=win32 & cpu=arm64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-win32-ia32-msvc@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-win32-ia32-msvc@npm:1.1.1"
|
||||
conditions: os=win32 & cpu=ia32
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard-win32-x64-msvc@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard-win32-x64-msvc@npm:1.1.1"
|
||||
conditions: os=win32 & cpu=x64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/clipboard@npm:^1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@napi-rs/clipboard@npm:1.1.1"
|
||||
dependencies:
|
||||
"@napi-rs/clipboard-darwin-arm64": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-darwin-x64": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-linux-arm-gnueabihf": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-linux-arm64-gnu": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-linux-arm64-musl": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-linux-x64-gnu": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-linux-x64-musl": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-win32-arm64-msvc": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-win32-ia32-msvc": "npm:1.1.1"
|
||||
"@napi-rs/clipboard-win32-x64-msvc": "npm:1.1.1"
|
||||
dependenciesMeta:
|
||||
"@napi-rs/clipboard-darwin-arm64":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-darwin-x64":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-linux-arm-gnueabihf":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-linux-arm64-gnu":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-linux-arm64-musl":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-linux-x64-gnu":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-linux-x64-musl":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-win32-arm64-msvc":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-win32-ia32-msvc":
|
||||
optional: true
|
||||
"@napi-rs/clipboard-win32-x64-msvc":
|
||||
optional: true
|
||||
checksum: 3cdd934538417b3911589d494b79e5e5abe1e8be6bb832d13b78fcee3a5df9a514c3268df5b1d02bf8d78d29aeafac4c242854e7093a758c679cf696a975b9ec
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/cross-toolchain@npm:^0.0.14":
|
||||
version: 0.0.14
|
||||
resolution: "@napi-rs/cross-toolchain@npm:0.0.14"
|
||||
@ -7035,6 +7153,125 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-android-arm-eabi@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-android-arm-eabi@npm:0.1.11"
|
||||
conditions: os=android & cpu=arm
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-android-arm64@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-android-arm64@npm:0.1.11"
|
||||
conditions: os=android & cpu=arm64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-darwin-arm64@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-darwin-arm64@npm:0.1.11"
|
||||
conditions: os=darwin & cpu=arm64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-darwin-x64@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-darwin-x64@npm:0.1.11"
|
||||
conditions: os=darwin & cpu=x64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-linux-arm-gnueabihf@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-linux-arm-gnueabihf@npm:0.1.11"
|
||||
conditions: os=linux & cpu=arm
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-linux-arm64-gnu@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-linux-arm64-gnu@npm:0.1.11"
|
||||
conditions: os=linux & cpu=arm64 & libc=glibc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-linux-arm64-musl@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-linux-arm64-musl@npm:0.1.11"
|
||||
conditions: os=linux & cpu=arm64 & libc=musl
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-linux-x64-gnu@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-linux-x64-gnu@npm:0.1.11"
|
||||
conditions: os=linux & cpu=x64 & libc=glibc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-linux-x64-musl@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-linux-x64-musl@npm:0.1.11"
|
||||
conditions: os=linux & cpu=x64 & libc=musl
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-win32-arm64-msvc@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-win32-arm64-msvc@npm:0.1.11"
|
||||
conditions: os=win32 & cpu=arm64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git-win32-x64-msvc@npm:0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git-win32-x64-msvc@npm:0.1.11"
|
||||
conditions: os=win32 & cpu=x64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/simple-git@npm:^0.1.11":
|
||||
version: 0.1.11
|
||||
resolution: "@napi-rs/simple-git@npm:0.1.11"
|
||||
dependencies:
|
||||
"@napi-rs/simple-git-android-arm-eabi": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-android-arm64": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-darwin-arm64": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-darwin-x64": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-linux-arm-gnueabihf": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-linux-arm64-gnu": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-linux-arm64-musl": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-linux-x64-gnu": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-linux-x64-musl": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-win32-arm64-msvc": "npm:0.1.11"
|
||||
"@napi-rs/simple-git-win32-x64-msvc": "npm:0.1.11"
|
||||
dependenciesMeta:
|
||||
"@napi-rs/simple-git-android-arm-eabi":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-android-arm64":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-darwin-arm64":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-darwin-x64":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-linux-arm-gnueabihf":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-linux-arm64-gnu":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-linux-arm64-musl":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-linux-x64-gnu":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-linux-x64-musl":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-win32-arm64-msvc":
|
||||
optional: true
|
||||
"@napi-rs/simple-git-win32-x64-msvc":
|
||||
optional: true
|
||||
checksum: 5802a96fb4152d3fd6cc28ebea56fd363d7055bb7a185289dab33954980d7114ee174290b8d12f4b5630a97dc4a443d24e5873417a3f9aa6877a5d3ec2f62165
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/tar-android-arm-eabi@npm:0.1.0":
|
||||
version: 0.1.0
|
||||
resolution: "@napi-rs/tar-android-arm-eabi@npm:0.1.0"
|
||||
|
Loading…
Reference in New Issue
Block a user