From c1a91be430e26215da1b14418c7fe546b0d4999d Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Fri, 29 Mar 2024 11:46:57 +0100 Subject: [PATCH] Added update-version script + bumped to v3.0.0-rc.21 --- package.json | 2 +- packages/extension-tei/package.json | 6 +-- packages/text-annotator-react/package.json | 8 +-- packages/text-annotator/package.json | 4 +- update-version.js | 58 ++++++++++++++++++++++ 5 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 update-version.js diff --git a/package.json b/package.json index efd4d17a..d3ed24ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@recogito/text-annotator-monorepo", - "version": "3.0.0-rc.20", + "version": "3.0.0-rc.21", "description": "Recogito Text Annotator monorepo", "author": "Rainer Simon", "repository": { diff --git a/packages/extension-tei/package.json b/packages/extension-tei/package.json index 8944b5bf..9461c358 100644 --- a/packages/extension-tei/package.json +++ b/packages/extension-tei/package.json @@ -1,6 +1,6 @@ { "name": "@recogito/text-annotator-tei", - "version": "3.0.0-rc.20", + "version": "3.0.0-rc.21", "description": "Recogito Text Annotator TEI extension", "author": "Rainer Simon", "license": "BSD-3-Clause", @@ -33,6 +33,6 @@ }, "peerDependencies": { "@annotorious/core": "^3.0.0-rc.22", - "@recogito/text-annotator": "^3.0.0-rc.20" + "@recogito/text-annotator": "3.0.0-rc.21" } -} +} \ No newline at end of file diff --git a/packages/text-annotator-react/package.json b/packages/text-annotator-react/package.json index 41cf82e1..a4c7d62a 100644 --- a/packages/text-annotator-react/package.json +++ b/packages/text-annotator-react/package.json @@ -1,6 +1,6 @@ { "name": "@recogito/react-text-annotator", - "version": "3.0.0-rc.20", + "version": "3.0.0-rc.21", "description": "Recogito Text Annotator React bindings", "author": "Rainer Simon", "license": "BSD-3-Clause", @@ -41,9 +41,9 @@ "dependencies": { "@annotorious/core": "^3.0.0-rc.22", "@annotorious/react": "^3.0.0-rc.22", - "@recogito/text-annotator": "^3.0.0-rc.20", - "@recogito/text-annotator-tei": "^3.0.0-rc.20", + "@recogito/text-annotator": "3.0.0-rc.21", + "@recogito/text-annotator-tei": "3.0.0-rc.21", "@neodrag/react": "^2.0.3", "CETEIcean": "^1.9.2" } -} +} \ No newline at end of file diff --git a/packages/text-annotator/package.json b/packages/text-annotator/package.json index f601cfbe..3953e29b 100644 --- a/packages/text-annotator/package.json +++ b/packages/text-annotator/package.json @@ -1,6 +1,6 @@ { "name": "@recogito/text-annotator", - "version": "3.0.0-rc.20", + "version": "3.0.0-rc.21", "description": "A JavaScript text annotation library", "author": "Rainer Simon", "license": "BSD-3-Clause", @@ -43,4 +43,4 @@ "rbush": "^3.0.1", "uuid": "^9.0.1" } -} +} \ No newline at end of file diff --git a/update-version.js b/update-version.js new file mode 100644 index 00000000..150de241 --- /dev/null +++ b/update-version.js @@ -0,0 +1,58 @@ +const fs = require('fs'); +const path = require('path'); + +const searchDirectories = (dir, fileList = []) => { + const files = fs.readdirSync(dir); + + files.forEach(file => { + const filePath = path.join(dir, file); + if (fs.statSync(filePath).isDirectory()) { + if (file !== 'node_modules') + fileList = searchDirectories(filePath, fileList); + } else { + if (file === 'package.json') { + fileList.push(filePath); + } + } + }); + + return fileList; +}; + +const updateVersionNumbers = (filePath, newVersion) => { + try { + let packageJson = fs.readFileSync(filePath, 'utf8'); + const packageData = JSON.parse(packageJson); + + packageData.version = newVersion; + + ['dependencies', 'peerDependencies'].forEach(depType => { + if (packageData[depType]) { + for (const dep in packageData[depType]) { + if (dep.startsWith('@recogito/text-')) { + packageData[depType][dep] = newVersion; + } + } + } + }); + + fs.writeFileSync(filePath, JSON.stringify(packageData, null, 2), 'utf8'); + console.log(`Updated ${filePath}`); + } catch (error) { + console.error(`Error updating ${filePath}: ${error}`); + } +} + +const main = () => { + const newVersion = process.argv[2]; + + const packageJsonFiles = searchDirectories('.'); + + packageJsonFiles.forEach(filePath => { + updateVersionNumbers(filePath, newVersion); + }); + + console.log(`All package.json files updated to version ${newVersion}`); +}; + +main(); \ No newline at end of file