chore: change bump-blocksuite script to js (#5763)

`./scripts/bump-blocksuite.js`
This commit is contained in:
LongYinan
2024-02-01 07:16:18 +00:00
parent 799fa9cfa6
commit 61677b2ac4
5 changed files with 88 additions and 75 deletions

View File

@@ -3,7 +3,14 @@ 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 {
FetchOptions,
ProxyOptions,
RemoteCallbacks,
Repository,
Sort,
} from '@napi-rs/simple-git';
import chalk from 'chalk';
import corePackage from '../../packages/frontend/core/package.json' assert { type: 'json' };
@@ -20,6 +27,11 @@ const info = await fetch(
const latestVersion = info['dist-tags'].nightly;
const latestHash = latestVersion.split('-').pop();
if (oldHash === latestHash) {
console.info(chalk.greenBright('Already updated'));
process.exit(0);
}
console.info(`Upgrade blocksuite from ${oldHash} -> ${latestHash}`);
const blockSuiteDeps = execSync(`yarn info -A --name-only --json`, {
@@ -38,7 +50,7 @@ const blocksuiteDepsList = blockSuiteDeps
for (const pkg of blocksuiteDepsList) {
const command = `yarn up ${pkg}@${latestVersion}`;
console.info(`Executing ${command}`);
console.info(chalk.bgCyan(`Executing ${command}`));
execSync(command, {
stdio: 'inherit',
});
@@ -50,16 +62,25 @@ 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 remote = repo.remoteAnonymous(
'https://github.com/toeverything/BlockSuite.git'
);
remote.fetch(
['master'],
new FetchOptions().proxyOptions(new ProxyOptions().auto()).remoteCallback(
new RemoteCallbacks().transferProgress(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);

View File

@@ -7,6 +7,7 @@
"description": "Generate changelog from blocksuite version change",
"dependencies": {
"@napi-rs/clipboard": "^1.1.1",
"@napi-rs/simple-git": "^0.1.11"
"@napi-rs/simple-git": "^0.1.16",
"chalk": "^5.3.0"
}
}