SIGN IN SIGN UP
oramasearch / orama UNCLAIMED

🌌 A complete search engine and RAG pipeline in your browser, server or edge network with support for full-text, vector, and hybrid search in less than 2kb.

0 0 0 TypeScript
2023-03-31 17:22:37 +02:00
import { readFile, writeFile } from 'fs/promises'
import { inc, valid } from 'semver'
import { simpleGit } from 'simple-git'
import { fileURLToPath } from 'url'
import oramaPackage from '../packages/orama/package.json' assert { type: 'json' }
2023-06-15 11:48:59 +02:00
const dryRun = process.env.DRY_RUN === 'true'
const skipGit = process.env.SKIP_GIT === 'true'
2023-03-31 17:22:37 +02:00
const skip = (process.env.SKIP ?? '').split(/\s*,\s*/).map(s => s.trim())
const packages = [
'orama',
'plugin-astro',
'plugin-data-persistence',
'plugin-docusaurus',
2024-01-23 16:44:17 +01:00
'plugin-docusaurus-v3',
2023-03-31 17:22:37 +02:00
'plugin-match-highlight',
2023-06-15 11:48:59 +02:00
'plugin-nextra',
2023-03-31 17:22:37 +02:00
'plugin-parsedoc',
2023-06-15 11:48:59 +02:00
'stemmers',
'stopwords',
2023-03-31 17:22:37 +02:00
].filter(p => !skip.includes(p))
2023-06-15 11:48:59 +02:00
async function updatePackage(path, version) {
const packageJson = JSON.parse(await readFile(path))
console.log(
`\x1b[32mUpdating package \x1b[1m${packageJson.name}\x1b[22m from \x1b[1m${packageJson.version}\x1b[22m to version \x1b[1m${version}\x1b[22m ...\x1b[0m`,
)
packageJson.version = version
if (!dryRun) {
await writeFile(path, JSON.stringify(packageJson, null, 2), 'utf-8')
}
}
2023-03-31 17:22:37 +02:00
async function main() {
if (!process.argv[2]) {
console.error('\x1b[33mUsage: node version.mjs [VERSION | CHANGE [PRERELEASE]]\x1b[0m')
process.exit(1)
}
// Check if the new version is absolute, otherwise we take it from @orama/orama and increase
let version = process.argv[2]
if (!valid(version)) {
version = inc(oramaPackage.version, version, process.argv[3])
}
if (!valid(version)) {
console.error(
`\x1b[31mCannot increase version \x1b[1m${oramaPackage.version}\x1b[22m using operator \x1b[1m${process.argv[2]}\x1b[22m.\x1b[0m`,
)
process.exit(1)
}
2023-06-15 11:48:59 +02:00
// Update the main package.json
await updatePackage(fileURLToPath(new URL(`../package.json`, import.meta.url)), version)
2023-03-31 17:22:37 +02:00
// Perform the update
for (const pkg of packages) {
2023-06-15 11:48:59 +02:00
await updatePackage(fileURLToPath(new URL(`../packages/${pkg}/package.json`, import.meta.url)), version)
2023-03-31 17:22:37 +02:00
}
// Make the commit, including the tag
2023-06-15 11:48:59 +02:00
if (!dryRun && !skipGit) {
2023-03-31 17:22:37 +02:00
const git = simpleGit({ baseDir: fileURLToPath(new URL('..', import.meta.url)) })
console.log(`\x1b[32mCommitting changes and creating a tag (pushing is left to you) ...\x1b[0m`)
await git.commit(
'chore: Version bump',
packages.map(p => `packages/${p}/package.json`),
{ '--no-verify': true },
)
await git.addTag(`v${version}`)
}
}
await main()