Dataview - Check installed plugins vs list

What I’m trying to do

I’d like to use dataview or a similar plugin to check if all the plugins in a list is installed.

Things I have tried

I tried looking into the dataview docs, and do some google searches, but I’ve found nothing so far. This seems somewhat related, but it doesnt output what I’m looking for, and Id rather not need to install run-code if possible (though I am open to it).

Here is a little query to hopefully get you going:

```dataviewjs
// console.log(app.plugins)
// console.log(app.plugins.enabledPlugins)

const plugins = dv.array(Object.values(app.plugins.manifests))
  .sort(p => p.name)
  .map(p => [p.name, p.id, p.description, app.plugins.enabledPlugins.has(p.id) ])
  
dv.table(["Name", "ID", "Description", "Enabled"], plugins)
```

The plugin list is not available in a pure dataview query, so you’ll need to switch to dataviewjs. And then app.plugins.manifests seems to list all plugins enabled or not, and the app.plugins.plugins are only the enabled plugins.

The next order of business would then be to compare the plugin against your list. Are you using names or id’s in your list? And in which property do you store the list to check against?

1 Like

Great questions. I have not even made the list yet. Ideally it’s kept in a note or in the query itself in a way that is user friendly, but whatever would be easy to implement would be great.

Having a way to quickly generate a list would also be good.

What’s your use case if you haven’t made the lists already? What’s your end goal?

Here is the next iteration of test queries. Put the following in a note of its own, and see if you can make any sense out of it:

---
Tags: f96475
areTheseInstalled:
- Dataview
- Templater
- QuickAdd
- CSS Editor
- Tasks
- The Ultimate Plugin
---
questionUrl:: http://forum.obsidian.md/t//96475

## List according to manifest

```dataviewjs
// console.log("\n\nAPP.PLUGINS", app.plugins)
// console.log(app.plugins.enabledPlugins)
const areTheseInstalled = dv.current().areTheseInstalled

const plugins = dv.array(Object.values(app.plugins.manifests))
  .sort(p => p.name)
  // .where(p => app.plugins.enabledPlugins.has(p.id))
  .map(p => [p.name, p.id, p.description, app.plugins.enabledPlugins.has(p.id), areTheseInstalled.includes(p.name) ])
  
dv.table(["Name", "ID", "Description", "Enabled", "Is installed"], plugins)
/* */
```


## Only check those in our list

```dataviewjs
// console.log(app.plugins)
// console.log(app.plugins.enabledPlugins)
const areTheseInstalled = dv.current().areTheseInstalled

const pluginByName = {}
Object.entries(app.plugins.manifests)
  .forEach(([key, val]) => {
    pluginByName[val.name] = key
  })

const plugins = dv.array(dv.current().areTheseInstalled)
  .sort(p => p[0])
  .map(p => {
    console.log("PP", p)
    const tmp = {}
    tmp.name = p
    tmp.id = pluginByName[tmp.name]
    tmp.desc = app.plugins.manifests[tmp.id]?.description
    console.log(tmp)
    return [tmp.name, tmp.id, tmp.desc, tmp.id !== undefined, app.plugins.enabledPlugins.has(tmp.id)]
  })
  
dv.table(["Name", "ID", "Description", "Found?", "Enabled?"], plugins)
```
2 Likes