4Source / vare-obsidian-plugin

This is a plugin for Obsidian (https://obsidian.md). Allows you to easily manage your plugins and themes inside Obsidian.
MIT License
5 stars 1 forks source link

[Bug+FR]: Source repo for unlisted plugin does not change if removed and reinstalled from community plugins #11

Open anonhostpi opened 3 months ago

anonhostpi commented 3 months ago

Describe the bug

I recently forked the teleprompter plugin, and published my own release files for it. To add it into Obsidian I removed the original and added mine as an "unlisted" plugin. After getting my changes implemented on the upstream repo, I removed the unlisted plugin and reinstalled the official one.

However, VARE is still pulling releases from my repo despite reinstalling the plugin.

I recommend setting an option to change/update (and reset if applicable) the source repo in VARE's options

I also recommend showing a hint text that shows the currently selected source repository in addition to these:

image

How to Reproduce

Fork a plugin. Add the fork as an unlisted repo. Uninstall the plugin. Reinstall the official plugin.

Expected behavior

Update the source repo on reinstallation

OS of your device

Win10

Obsidian Version

v1.6.3

Plugin Version

0.1.1

Additional context

This is a dual bug report + feature request.

I'd like to be able to change the source repo as well.

anonhostpi commented 3 months ago

This is also a feature request to get a button or text field to update/change the source repo

anonhostpi commented 3 months ago

Current work around to reset the repo.

Change the repo value in .obsidian\plugins\vare\data.json, save, then reload obsidian

4Source commented 3 months ago

BUG: I will check the Bug but you need to wait about a month then I finished my exams and I have time to work on this.

FEAT: I think about add an edit button to the plugins BUT I mean I had this thoughts while dev and decided not to include it because any repo could be added and this could result in difficult to resolve problems. Example: Other Plugin URL is entered and a version for this is selected the plugin get installed to the old folder but from the manifest it gets a new name. Than the folder name and plugin name doesn't match.

I recently forked the teleprompter plugin, and published my own release files for it. To add it into Obsidian I removed the original and added mine as an "unlisted" plugin.

I had roughly the same idea that you can also install releases from forks. See #9. Maybe this is anything you need?

anonhostpi commented 3 months ago

You use app.plugins.installPlugin() under the hood to install the plugin. That method installs the plugin to .obsidian/plugins/{manifest.id}, so at installation time, it is impossible for the folder and the plugin id to be 2 different values.

The problematic behavior that this does cause is that if the manifest.id does not match the plugin listed in VARE, it will install the plugin as an additional plugin (or overwrite a secondary one).

To implement the edit button safely, I would enforce that the upstream manifest.id must be equal to the manifest.id of the associated plugin. If the ids mismatch, throw an error message and tell the user to use the add (+) button instead.

With that said, I would also specifically enforce that the edit and add buttons be separate:

anonhostpi commented 3 months ago

The manifest.dir that you use in your plugin is populated and overwritten at runtime by app.plugins.loadManifests() and app.plugins.loadManifest()

anonhostpi commented 3 months ago

Also how are themes intended to be installed? I don't see any calls to app.customCss.installLegacyTheme( manifest ) or app.customCss.installTheme( manifest, true /*set to true so that manifest.repo can be used for install*/)?

4Source commented 3 months ago

The manifest.dir that you use in your plugin is populated and overwritten at runtime by app.plugins.loadManifests() and app.plugins.loadManifest()

What do you mean? This?

Also how are themes intended to be installed? I don't see any calls to app.customCss.installLegacyTheme( manifest ) or app.customCss.installTheme( manifest, true /*set to true so that manifest.repo can be used for install*/)?

Templates is currently not implemented

anonhostpi commented 3 months ago

Yup. When Obsidian loads the manifests for either apps.customCss or apps.plugins, it overwrites that JSON property using the manifest.id (plugins) or manifest.name (customCss)

I think I see how you are using it though.

At first, I thought you were trying to override it by saving it to manifest.json, but it seems you are doing it to emulate Obsidian's functionality.

4Source commented 3 months ago

It's been a while but with the brief look it seems like I exactly did this