Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: aiscript version check of plugin #54

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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