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
No known key found for this signature in database
GPG Key ID: 30B1140CE1C07C99
5 changed files with 88 additions and 75 deletions

3
scripts/bump-blocksuite.js Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
import('@affine/bump-blocksuite');

View File

@ -1,13 +0,0 @@
#!/bin/bash
LATEST_NIGHTLY=$(npm view @blocksuite/presets@nightly version | cut -d ':' -f 2 | tr -d '[:space:]')
echo "Bump to latest BlockSuite nightly version: $LATEST_NIGHTLY"
yarn up \
"@blocksuite/store@${LATEST_NIGHTLY}" \
"@blocksuite/blocks@${LATEST_NIGHTLY}" \
"@blocksuite/presets@${LATEST_NIGHTLY}" \
"@blocksuite/global@${LATEST_NIGHTLY}" \
"@blocksuite/block-std@${LATEST_NIGHTLY}" \
"@blocksuite/lit@${LATEST_NIGHTLY}" \
"@blocksuite/inline@${LATEST_NIGHTLY}"

View File

@ -3,7 +3,14 @@ import { join } from 'node:path';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { Clipboard } from '@napi-rs/clipboard'; 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' }; 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 latestVersion = info['dist-tags'].nightly;
const latestHash = latestVersion.split('-').pop(); const latestHash = latestVersion.split('-').pop();
if (oldHash === latestHash) {
console.info(chalk.greenBright('Already updated'));
process.exit(0);
}
console.info(`Upgrade blocksuite from ${oldHash} -> ${latestHash}`); console.info(`Upgrade blocksuite from ${oldHash} -> ${latestHash}`);
const blockSuiteDeps = execSync(`yarn info -A --name-only --json`, { const blockSuiteDeps = execSync(`yarn info -A --name-only --json`, {
@ -38,7 +50,7 @@ const blocksuiteDepsList = blockSuiteDeps
for (const pkg of blocksuiteDepsList) { for (const pkg of blocksuiteDepsList) {
const command = `yarn up ${pkg}@${latestVersion}`; const command = `yarn up ${pkg}@${latestVersion}`;
console.info(`Executing ${command}`); console.info(chalk.bgCyan(`Executing ${command}`));
execSync(command, { execSync(command, {
stdio: 'inherit', stdio: 'inherit',
}); });
@ -50,16 +62,25 @@ const repo = new Repository(
join(fileURLToPath(import.meta.url), '..', '..', '..', '..', 'BlockSuite') join(fileURLToPath(import.meta.url), '..', '..', '..', '..', 'BlockSuite')
); );
repo.remote('origin').fetch(['master'], progress => { const remote = repo.remoteAnonymous(
if (progress.totalDeltas && progress.totalObjects) { 'https://github.com/toeverything/BlockSuite.git'
console.log( );
`${(
(progress.receivedObjects / progress.totalObjects) * 50 + remote.fetch(
(progress.indexedDeltas / progress.totalDeltas) * 50 ['master'],
).toFixed(2)}%` 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); const latest = repo.findCommit(latestHash);

View File

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

View File

@ -154,7 +154,8 @@ __metadata:
resolution: "@affine/bump-blocksuite@workspace:tools/bump-blocksuite" resolution: "@affine/bump-blocksuite@workspace:tools/bump-blocksuite"
dependencies: dependencies:
"@napi-rs/clipboard": "npm:^1.1.1" "@napi-rs/clipboard": "npm:^1.1.1"
"@napi-rs/simple-git": "npm:^0.1.11" "@napi-rs/simple-git": "npm:^0.1.16"
chalk: "npm:^5.3.0"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@ -7133,98 +7134,98 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-android-arm-eabi@npm:0.1.11": "@napi-rs/simple-git-android-arm-eabi@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-android-arm-eabi@npm:0.1.11" resolution: "@napi-rs/simple-git-android-arm-eabi@npm:0.1.16"
conditions: os=android & cpu=arm conditions: os=android & cpu=arm
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-android-arm64@npm:0.1.11": "@napi-rs/simple-git-android-arm64@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-android-arm64@npm:0.1.11" resolution: "@napi-rs/simple-git-android-arm64@npm:0.1.16"
conditions: os=android & cpu=arm64 conditions: os=android & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-darwin-arm64@npm:0.1.11": "@napi-rs/simple-git-darwin-arm64@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-darwin-arm64@npm:0.1.11" resolution: "@napi-rs/simple-git-darwin-arm64@npm:0.1.16"
conditions: os=darwin & cpu=arm64 conditions: os=darwin & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-darwin-x64@npm:0.1.11": "@napi-rs/simple-git-darwin-x64@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-darwin-x64@npm:0.1.11" resolution: "@napi-rs/simple-git-darwin-x64@npm:0.1.16"
conditions: os=darwin & cpu=x64 conditions: os=darwin & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-linux-arm-gnueabihf@npm:0.1.11": "@napi-rs/simple-git-linux-arm-gnueabihf@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-linux-arm-gnueabihf@npm:0.1.11" resolution: "@napi-rs/simple-git-linux-arm-gnueabihf@npm:0.1.16"
conditions: os=linux & cpu=arm conditions: os=linux & cpu=arm
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-linux-arm64-gnu@npm:0.1.11": "@napi-rs/simple-git-linux-arm64-gnu@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-linux-arm64-gnu@npm:0.1.11" resolution: "@napi-rs/simple-git-linux-arm64-gnu@npm:0.1.16"
conditions: os=linux & cpu=arm64 & libc=glibc conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-linux-arm64-musl@npm:0.1.11": "@napi-rs/simple-git-linux-arm64-musl@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-linux-arm64-musl@npm:0.1.11" resolution: "@napi-rs/simple-git-linux-arm64-musl@npm:0.1.16"
conditions: os=linux & cpu=arm64 & libc=musl conditions: os=linux & cpu=arm64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-linux-x64-gnu@npm:0.1.11": "@napi-rs/simple-git-linux-x64-gnu@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-linux-x64-gnu@npm:0.1.11" resolution: "@napi-rs/simple-git-linux-x64-gnu@npm:0.1.16"
conditions: os=linux & cpu=x64 & libc=glibc conditions: os=linux & cpu=x64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-linux-x64-musl@npm:0.1.11": "@napi-rs/simple-git-linux-x64-musl@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-linux-x64-musl@npm:0.1.11" resolution: "@napi-rs/simple-git-linux-x64-musl@npm:0.1.16"
conditions: os=linux & cpu=x64 & libc=musl conditions: os=linux & cpu=x64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-win32-arm64-msvc@npm:0.1.11": "@napi-rs/simple-git-win32-arm64-msvc@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-win32-arm64-msvc@npm:0.1.11" resolution: "@napi-rs/simple-git-win32-arm64-msvc@npm:0.1.16"
conditions: os=win32 & cpu=arm64 conditions: os=win32 & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git-win32-x64-msvc@npm:0.1.11": "@napi-rs/simple-git-win32-x64-msvc@npm:0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git-win32-x64-msvc@npm:0.1.11" resolution: "@napi-rs/simple-git-win32-x64-msvc@npm:0.1.16"
conditions: os=win32 & cpu=x64 conditions: os=win32 & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@napi-rs/simple-git@npm:^0.1.11": "@napi-rs/simple-git@npm:^0.1.16":
version: 0.1.11 version: 0.1.16
resolution: "@napi-rs/simple-git@npm:0.1.11" resolution: "@napi-rs/simple-git@npm:0.1.16"
dependencies: dependencies:
"@napi-rs/simple-git-android-arm-eabi": "npm:0.1.11" "@napi-rs/simple-git-android-arm-eabi": "npm:0.1.16"
"@napi-rs/simple-git-android-arm64": "npm:0.1.11" "@napi-rs/simple-git-android-arm64": "npm:0.1.16"
"@napi-rs/simple-git-darwin-arm64": "npm:0.1.11" "@napi-rs/simple-git-darwin-arm64": "npm:0.1.16"
"@napi-rs/simple-git-darwin-x64": "npm:0.1.11" "@napi-rs/simple-git-darwin-x64": "npm:0.1.16"
"@napi-rs/simple-git-linux-arm-gnueabihf": "npm:0.1.11" "@napi-rs/simple-git-linux-arm-gnueabihf": "npm:0.1.16"
"@napi-rs/simple-git-linux-arm64-gnu": "npm:0.1.11" "@napi-rs/simple-git-linux-arm64-gnu": "npm:0.1.16"
"@napi-rs/simple-git-linux-arm64-musl": "npm:0.1.11" "@napi-rs/simple-git-linux-arm64-musl": "npm:0.1.16"
"@napi-rs/simple-git-linux-x64-gnu": "npm:0.1.11" "@napi-rs/simple-git-linux-x64-gnu": "npm:0.1.16"
"@napi-rs/simple-git-linux-x64-musl": "npm:0.1.11" "@napi-rs/simple-git-linux-x64-musl": "npm:0.1.16"
"@napi-rs/simple-git-win32-arm64-msvc": "npm:0.1.11" "@napi-rs/simple-git-win32-arm64-msvc": "npm:0.1.16"
"@napi-rs/simple-git-win32-x64-msvc": "npm:0.1.11" "@napi-rs/simple-git-win32-x64-msvc": "npm:0.1.16"
dependenciesMeta: dependenciesMeta:
"@napi-rs/simple-git-android-arm-eabi": "@napi-rs/simple-git-android-arm-eabi":
optional: true optional: true
@ -7248,7 +7249,7 @@ __metadata:
optional: true optional: true
"@napi-rs/simple-git-win32-x64-msvc": "@napi-rs/simple-git-win32-x64-msvc":
optional: true optional: true
checksum: 5802a96fb4152d3fd6cc28ebea56fd363d7055bb7a185289dab33954980d7114ee174290b8d12f4b5630a97dc4a443d24e5873417a3f9aa6877a5d3ec2f62165 checksum: c847f5797dffad09115b2925a4e1964a9e61ae2ddca4e30f6bcc6fb8432a634625be71fcd79bb66379660b31171058969a61ad58e794197e143e7437db1fd852
languageName: node languageName: node
linkType: hard linkType: hard