From 02f2f6e8188c8d5cd92878ee3a2de41bc73354a5 Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Thu, 10 Oct 2024 14:11:33 +0000 Subject: [PATCH] enh: limit allowed pocketbase versions --- .../UpdateCommand/freshenPocketbaseVersions.ts | 7 ++++++- packages/pockethost/src/constants.ts | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/pockethost/src/cli/commands/PocketBaseCommand/UpdateCommand/freshenPocketbaseVersions.ts b/packages/pockethost/src/cli/commands/PocketBaseCommand/UpdateCommand/freshenPocketbaseVersions.ts index 2f68fd97..2b322624 100644 --- a/packages/pockethost/src/cli/commands/PocketBaseCommand/UpdateCommand/freshenPocketbaseVersions.ts +++ b/packages/pockethost/src/cli/commands/PocketBaseCommand/UpdateCommand/freshenPocketbaseVersions.ts @@ -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)}` { diff --git a/packages/pockethost/src/constants.ts b/packages/pockethost/src/constants.ts index e7f3a85c..bc281fed 100644 --- a/packages/pockethost/src/constants.ts +++ b/packages/pockethost/src/constants.ts @@ -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)