enh: limit allowed pocketbase versions

This commit is contained in:
Ben Allfree 2024-10-10 14:11:33 +00:00
parent 91ed5a59b9
commit 02f2f6e818
2 changed files with 10 additions and 1 deletions

View File

@ -1,7 +1,9 @@
import { writeFileSync } from 'fs'
import { lte, prerelease } from 'semver'
import {
LoggerService,
MOTHERSHIP_DATA_ROOT,
PH_ALLOWED_POCKETBASE_SEMVER,
stringify,
} from '../../../../../core'
import { GobotService } from '../../../../services/GobotService'
@ -63,7 +65,10 @@ export async function freshenPocketbaseVersions() {
await bot.update()
await bot.download()
const rawVersions = await bot.versions()
const versions = expandAndSortSemVers(rawVersions)
const allowedVersions = rawVersions.filter(
(v) => lte(v, PH_ALLOWED_POCKETBASE_SEMVER()) && prerelease(v) === null,
)
const versions = expandAndSortSemVers(allowedVersions)
const cjs = `module.exports = ${stringify(versions, null, 2)}`
{

View File

@ -78,6 +78,7 @@ if (_IS_DEV) {
}
export const SETTINGS = {
PH_ALLOWED_POCKETBASE_SEMVER: mkString(`0.22.21`),
PH_PLUGINS: mkCsvString([]),
PH_HOME: mkPath(_PH_HOME, { create: true }),
@ -162,7 +163,10 @@ export const RegisterEnvSettingsService = () => {
}
/** Accessors */
export const PH_PLUGINS = () => settings().PH_PLUGINS
export const PH_ALLOWED_POCKETBASE_SEMVER = () =>
settings().PH_ALLOWED_POCKETBASE_SEMVER
export const PH_HOME = (...paths: string[]) =>
join(settings().PH_HOME, ...paths)