|
| 1 | + |
| 2 | +async function installPluginsIncludingHidden() { |
| 3 | + _installPlugins(true) |
| 4 | +} |
| 5 | + |
| 6 | +async function installPlugins() { |
| 7 | + _installPlugins(false) |
| 8 | +} |
| 9 | + |
| 10 | +async function _installPlugins(showHidden) { |
| 11 | + let plugins = await DataStore.listPlugins(true, showHidden) |
| 12 | + |
| 13 | + let list = plugins.map(p => pluginToDescription(p)) |
| 14 | + list.push("❌ Cancel") |
| 15 | + |
| 16 | + let selection = await CommandBar.showOptions(list, "Select a plugin to install/update:") |
| 17 | + |
| 18 | + if(selection.index < plugins.length) { |
| 19 | + let plugin = plugins[selection.index] |
| 20 | + try { |
| 21 | + let result = await DataStore.installPlugin(plugin, true) |
| 22 | + |
| 23 | + let list = ["✅ OK", "📖 Open Readme", "", "Commands:"] |
| 24 | + plugin.commands.forEach((item, i) => { |
| 25 | + list.push("/" + item.name + " - " + item.desc) |
| 26 | + }); |
| 27 | + |
| 28 | + let selection = await CommandBar.showOptions(list, "Successfully installed '" + plugin.name + "'") |
| 29 | + if(selection.index == 1) { |
| 30 | + CommandBar.openURL(plugin.repoUrl) |
| 31 | + } |
| 32 | + } catch(err) { |
| 33 | + await CommandBar.showOptions(["✅ OK"], "Error: " + err) |
| 34 | + } |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +function pluginToDescription(p) { |
| 39 | + let installed = p.isOnline ? "" : ", installed: 🆗" |
| 40 | + |
| 41 | + if(p.availableUpdate) { |
| 42 | + installed += ", update: v" + p.availableUpdate.version + " 🆕" |
| 43 | + } |
| 44 | + |
| 45 | + return p.name + " (v" + p.version + installed + ")" |
| 46 | +} |
0 commit comments