From 8c133fd638a76ee8ebbae06b3f171d1a73c9807b Mon Sep 17 00:00:00 2001 From: Hotaru Date: Sun, 31 Dec 2023 19:20:22 +0800 Subject: [PATCH] release: v1.1.0 --- CHANGELOG.md | 2 +- package.json | 2 +- packages/core/package.json | 2 +- packages/loader/package.json | 2 +- scripts/release.ts | 79 +++++++++++++++--------------------- 5 files changed, 37 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3852868e..61ac2c78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [1.0.1](https://github.com/kotorijs/kotori/compare/v1.0.0...v1.0.1) (2023-12-31) +# v1.1.0 (2023-12-31) ### Features diff --git a/package.json b/package.json index 33d5486e..a399d50e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@kotori-bot/root", "description": "ChatBot Framework", - "version": "v1.0.1", + "version": "v1.0.0", "packageManager": "pnpm@8.7.4", "private": true, "scripts": { diff --git a/packages/core/package.json b/packages/core/package.json index 140cc48e..39d025d2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@kotori-bot/core", - "version": "v1.0.1", + "version": "v1.0.0", "description": "Kotori Core", "main": "lib/index.js", "license": "GPL-3.0", diff --git a/packages/loader/package.json b/packages/loader/package.json index 93b84058..bbb23744 100644 --- a/packages/loader/package.json +++ b/packages/loader/package.json @@ -1,6 +1,6 @@ { "name": "@kotori-bot/loader", - "version": "1.1.0", + "version": "v1.2.0", "description": "Loader For KotoriBot", "license": "GPL-3.0", "main": "lib/index.js", diff --git a/scripts/release.ts b/scripts/release.ts index 7bf99072..5979b8d6 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -25,7 +25,6 @@ const config = { const ROOT_DIR = resolve(__dirname, '../'); const WORKSPACE = getPackagesSync(ROOT_DIR); -const MAIN_PACKAGE = getTargetPackage(config.main, WORKSPACE.packages); function getTargetPackage(pkgName: string, pkgs: Package[]) { const filterPackages = pkgs.filter(pkg => pkg.packageJson.name === pkgName); @@ -84,20 +83,20 @@ type Option = { return handle.split('.').map(val => parseInt(val, 10)); } - function isUpdateVersion(pkgName: string, version: Version) { + function isUpdateVersion(version: Version) { return prompt({ type: 'confirm', name: 'value', - message: `For ${pkgName} : update ${version} version?`, + message: `Do you want to update ${version} version?`, default: false, }); } - async function getVersion(pkg: Package) { - const version = parseVersion(pkg.packageJson.version); - if ((await isUpdateVersion(pkg.packageJson.name, 'Major')).value) return `v${version[0] + 1}.0.0`; - if ((await isUpdateVersion(pkg.packageJson.name, 'Minor')).value) return `v${version[0]}.${version[1] + 1}.0`; - return `v${version[0]}.${version[1]}.${version[2] + 1}`; + async function genVersion() { + if ((await isUpdateVersion(/* pkg.packageJson.name, */ 'Major')).value) + return (version: number[]) => `v${version[0] + 1}.0.0`; + if ((await isUpdateVersion('Minor')).value) return (version: number[]) => `v${version[0]}.${version[1] + 1}.0`; + return (version: number[]) => `v${version[0]}.${version[1]}.${version[2] + 1}`; } function setVersion(pkg: Package) { @@ -106,32 +105,20 @@ type Option = { } async function setVersions(pkgs: Package[]) { + const getVersion = await genVersion(); const mainPkg = getTargetPackage(config.main, pkgs); if (mainPkg) { - pkgs.push( - ...(config.sync - .map(pkgName => getTargetPackage(pkgName, WORKSPACE.packages)) - .filter(pkg => !!pkg) as Package[]), - ); - if (WORKSPACE.rootPackage) pkgs.push(WORKSPACE.rootPackage); + const extraPkgs = config.sync.map(pkgName => getTargetPackage(pkgName, WORKSPACE.packages)); + extraPkgs.push(WORKSPACE.rootPackage as (typeof extraPkgs)[0]); } - const res = await Promise.all( - pkgs.map(async pkg => { - const handle = pkg; - /* Sync packages version by main package */ - if ( - config.sync.includes(pkg.packageJson.name) || - pkg.packageJson.name === WORKSPACE.rootPackage?.packageJson.name - ) { - handle.packageJson.version = MAIN_PACKAGE!.packageJson.version; - return handle; - } - handle.packageJson.version = await getVersion(pkg); - if (handle.packageJson.name === config.main) MAIN_PACKAGE!.packageJson.version = handle.packageJson.version; - return handle; - }), - ); - res.forEach(pkg => setVersion(pkg)); + pkgs.forEach(pkg => { + const pkgJson = pkg.packageJson; + pkgJson.version = + pkgJson.name === WORKSPACE.rootPackage?.packageJson.name || config.sync.includes(pkgJson.name) + ? mainPkg!.packageJson.version + : getVersion(parseVersion(pkg.packageJson.version)); + setVersion(pkg); + }); } async function handleGit(version: string) { @@ -165,25 +152,11 @@ type Option = { log('Run eslint and prettier...'); await hooks(config.hooks.beforeAddcommit); - const answer = await prompt([ - { - type: 'confirm', - name: 'push', - message: 'Do you need push to remote branch?', - default: true, - }, - { - type: 'confirm', - name: 'publish', - message: 'Do you need publish all updated package?', - default: true, - }, - ]); const mainPkg = getTargetPackage(config.main, packages); if (mainPkg) { /* Step: spawn tag */ log('Adding tag...'); - await handleGit(`v${mainPkg.packageJson.version}`); + await handleGit(mainPkg.packageJson.version); /* Step: zip main package */ const answer = await prompt({ type: 'confirm', @@ -195,6 +168,20 @@ type Option = { } /* Step: push to remote branch */ + const answer = await prompt([ + { + type: 'confirm', + name: 'push', + message: 'Do you need push to remote branch?', + default: true, + }, + { + type: 'confirm', + name: 'publish', + message: 'Do you need publish all updated package?', + default: true, + }, + ]); const pushCommand = `git push ${config.remote} ${config.branch} ${mainPkg ? '--tags' : ''}`; if (answer.push) await step(pushCommand);