Skip to content

Commit

Permalink
Merge pull request #54 from anatawa12/pick-11729
Browse files Browse the repository at this point in the history
fix: aiscript version check of plugin
  • Loading branch information
anatawa12 authored Aug 16, 2023
2 parents 6ddaf01 + 5839ec7 commit 5542e37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- センシティブチャンネルのNoteがたたまれる方法がCWになりました
- About Misskeyにこのforkに付いての情報を追加しました
- Fix: 未読のお知らせの「わかった」をクリック・タップしてもその場で「わかった」が消えない問題を修正
- Fix: Misskeyプラグインをインストールする際のAiScriptバージョンのチェックが0.14.0以降に対応していない問題を修正

### Server
- ファイルアップロード時等にファイル名の拡張子を修正する関数(correctFilename)の挙動を改善
Expand Down
11 changes: 10 additions & 1 deletion packages/frontend/src/pages/settings/plugin.install.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

Expand All @@ -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 :(`,
Expand Down

0 comments on commit 5542e37

Please sign in to comment.