Commit e5607db9 authored by nanahira's avatar nanahira

support full package name

parent 63780ba0
......@@ -45,6 +45,7 @@ async function checkPluginExists(name: string) {
const deps = await getPackageJsonPackages();
const entry = Object.entries(deps).find(
([packageName, version]) =>
packageName === name ||
packageName === `@koishijs/plugin-${name}` ||
packageName.endsWith(`koishi-plugin-${name}`),
);
......@@ -99,14 +100,25 @@ async function installPlugin(name: string, version?: string) {
return;
}
const installList: string[] = [];
if (version) {
installList.push(`@koishijs/plugin-${name}@${version}`);
installList.push(`koishi-plugin-${name}@${version}`);
const communityPrefix = 'koishi-plugin-';
const officialPrefix = '@koishijs/plugin-';
if (name.includes(communityPrefix) || name.startsWith(officialPrefix)) {
if (version) {
installList.push(`${name}@${version}`);
} else {
installList.push(`${name}@latest`);
installList.push(`${name}@next`);
}
} else {
installList.push(`@koishijs/plugin-${name}@next`);
installList.push(`@koishijs/plugin-${name}@latest`);
installList.push(`koishi-plugin-${name}@next`);
installList.push(`koishi-plugin-${name}@latest`);
if (version) {
installList.push(`${officialPrefix}${name}@${version}`);
installList.push(`${communityPrefix}${name}@${version}`);
} else {
installList.push(`${officialPrefix}${name}@next`);
installList.push(`${officialPrefix}${name}@latest`);
installList.push(`${communityPrefix}${name}@next`);
installList.push(`${communityPrefix}${name}@latest`);
}
}
const result = await tryInstallPackages(installList);
if (!result) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment