PluginProbe
Extendify / 1.9.3
Extendify v1.9.3
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / Library / middleware / helpers.js

helpers.js in Extendify 1.9.3, at src/Library/middleware/helpers.js

62 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Plugins } from '@library/api/Plugins'
2
3 let installedPlugins = []
4 let activatedPlugins = []
5
6 export async function checkIfUserNeedsToInstallPlugins(template) {
7 let required = template?.fields?.required_plugins ?? []
8 // Hardcoded temporarily to not force EP install
9 required = required.filter((p) => p !== 'editorplus')
10 if (!required?.length) {
11 return false
12 }
13
14 if (!installedPlugins?.length) {
15 installedPlugins = Object.keys(await Plugins.getInstalled())
16 }
17 // if no dependencies are required, then this will be false automatically
18 const weNeedInstalls = required?.length
19 ? required.filter((plugin) => {
20 // TODO: if we have better data to work with this can be more literal
21 return !installedPlugins.some((k) => {
22 return k.includes(plugin)
23 })
24 })
25 : false
26
27 return weNeedInstalls.length
28 }
29
30 export async function checkIfUserNeedsToActivatePlugins(template) {
31 let required = template?.fields?.required_plugins ?? []
32
33 // Hardcoded temporarily to not force EP install
34 required = required.filter((p) => p !== 'editorplus')
35 if (!required?.length) {
36 return false
37 }
38
39 if (!activatedPlugins?.length) {
40 activatedPlugins = Object.values(await Plugins.getActivated())
41 }
42
43 // if no dependencies are required, then this will be false automatically
44 const weNeedActivations = required?.length
45 ? required.filter((plugin) => {
46 // TODO: if we have better data to work with this can be more literal
47 return !activatedPlugins.some((k) => {
48 return k.includes(plugin)
49 })
50 })
51 : false
52
53 // if the plugins we need to have activated are not even installed, handle them elsewhere
54 if (weNeedActivations) {
55 // This call is a bit more expensive so only run it if needed
56 if (await checkIfUserNeedsToInstallPlugins(template)) {
57 return false
58 }
59 }
60 return weNeedActivations?.length
61 }
62