diff options
Diffstat (limited to 'packages/frontend/src')
| -rw-r--r-- | packages/frontend/src/pages/settings/plugin.install.vue | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/frontend/src/pages/settings/plugin.install.vue b/packages/frontend/src/pages/settings/plugin.install.vue index dd070dcb1d..d848f8e21c 100644 --- a/packages/frontend/src/pages/settings/plugin.install.vue +++ b/packages/frontend/src/pages/settings/plugin.install.vue @@ -19,6 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only <script lang="ts" setup> import { defineAsyncComponent, nextTick, ref } from 'vue'; +import { compareVersions } from 'compare-versions'; import { Interpreter, Parser, utils } from '@syuilo/aiscript'; import { v4 as uuid } from 'uuid'; import MkTextarea from '@/components/MkTextarea.vue'; @@ -44,6 +45,14 @@ function installPlugin({ id, meta, src, token }) { })); } +function isSupportedAiScriptVersion(version: string): boolean { + try { + return (compareVersions(version, '0.12.0') >= 0); + } catch (err) { + return false; + } +} + async function install() { if (code.value == null) return; @@ -54,7 +63,7 @@ async function install() { text: 'No language version annotation found :(', }); return; - } else if (!(lv.startsWith('0.12.') || lv.startsWith('0.13.'))) { + } else if (!isSupportedAiScriptVersion(lv)) { os.alert({ type: 'error', text: `aiscript version '${lv}' is not supported :(`, |