[Plugin] Überprüfung der Abhängigkeiten geändert

* werden als promise außerhalb von loadplugins geprüft.
* TODO: version muss geprüft werden.
This commit is contained in:
Tim Gröger 2020-11-14 10:58:21 +01:00
parent d5e4571b73
commit 60417f6585
9 changed files with 1752 additions and 254 deletions

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 321 KiB

8
src-cordova/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
.DS_Store
# Generated by package manager
node_modules/
# Generated by Cordova
/plugins/
/platforms/

24
src-cordova/config.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="de.wu5.flaschengeist" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Flaschengeist</name>
<description>Dynamischen Managementsystem für Studentenclubs</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<allow-navigation href="about:*" />
</widget>

9
src-cordova/cordova-flag.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
import "quasar/dist/types/feature-flag";
declare module "quasar/dist/types/feature-flag" {
interface QuasarFeatureFlags {
cordova: true;
}
}

1643
src-cordova/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

27
src-cordova/package.json Normal file
View File

@ -0,0 +1,27 @@
{
"name": "de.wu5.flaschengeist",
"displayName": "Flaschengeist",
"version": "1.0.0",
"description": "A sample Apache Cordova application that responds to the deviceready event.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"ecosystem:cordova"
],
"author": "Apache Cordova Team",
"license": "Apache-2.0",
"devDependencies": {
"cordova-ios": "^6.1.1",
"cordova-plugin-whitelist": "^1.3.4"
},
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {}
},
"platforms": [
"ios"
]
}
}

View File

@ -1,6 +1,6 @@
import {boot} from 'quasar/wrappers'; import {boot} from 'quasar/wrappers';
import {RouteConfig} from 'vue-router'; import {RouteConfig} from 'vue-router';
import {VueRouter} from "vue-router/types/router"; import {VueRouter} from 'vue-router/types/router';
import {Store} from 'vuex'; import {Store} from 'vuex';
import {StateInterface} from 'src/store'; import {StateInterface} from 'src/store';
import {FG_Plugin} from 'src/plugins'; import {FG_Plugin} from 'src/plugins';
@ -147,36 +147,15 @@ function loadPlugin(
loadedPlugins: FG_Plugin.LoadedPlugins, loadedPlugins: FG_Plugin.LoadedPlugins,
modules: string[], modules: string[],
backendpromise: Promise<Backend | null>, backendpromise: Promise<Backend | null>,
plugins: Plugin[], plugins: FG_Plugin.Plugin[],
store: Store<any>, store: Store<any>,
router: VueRouter router: VueRouter
): FG_Plugin.LoadedPlugins { ): FG_Plugin.LoadedPlugins {
modules.forEach(requiredModule => { modules.forEach(requiredModule => {
const plugin = <FG_Plugin.Plugin | undefined>plugins.find(plugin => { const plugin = plugins.find(plugin => {
return plugin.name == requiredModule; return plugin.name == requiredModule;
}); });
if (plugin) { if (plugin) {
backendpromise.then((backend) => {
console.log(backend)
if (backend) {
const missedPlugins: string[] = []
plugin.requiredBackendModules.every((requiredBackendModule: string) => {
if (!(requiredBackendModule in backend.plugins)) {
missedPlugins.push(requiredBackendModule)
console.error(`Plugin ${requiredBackendModule} not activated in backend.`)
router.push({name: 'error'}).
catch(err => {
console.warn(err)
})
}
return requiredBackendModule in backend.plugins
})
}
})
.catch(e => {
console.error(e)
})
if (plugin.mainRoutes) { if (plugin.mainRoutes) {
loadedPlugins.routes = combineRoutes( loadedPlugins.routes = combineRoutes(
loadedPlugins.routes, loadedPlugins.routes,
@ -221,6 +200,9 @@ function loadPlugin(
}); });
} else { } else {
console.exception(`Could not find required Plugin ${requiredModule}`); console.exception(`Could not find required Plugin ${requiredModule}`);
router.push({name: 'error'}).catch((e) => {
console.warn(e)
})
} }
}); });
return loadedPlugins; return loadedPlugins;
@ -242,7 +224,7 @@ async function getBackend(): Promise<Backend | null> {
// "async" is optional; // "async" is optional;
// more info on params: https://quasar.dev/quasar-cli/cli-documentation/boot-files#Anatomy-of-a-boot-file // more info on params: https://quasar.dev/quasar-cli/cli-documentation/boot-files#Anatomy-of-a-boot-file
export default boot<Store<StateInterface>>(({Vue, router, store}) => { export default boot<Store<StateInterface>>(({Vue, router, store}) => {
const plugins: Plugin[] = []; const plugins: FG_Plugin.Plugin[] = [];
const backendPromise = getBackend(); const backendPromise = getBackend();
@ -262,6 +244,35 @@ export default boot<Store<StateInterface>>(({Vue, router, store}) => {
plugins.push(pluginsContext(fileName).default); plugins.push(pluginsContext(fileName).default);
}); });
// check dependencies
backendPromise.then((backend) => {
console.log(backend)
if (backend) {
plugins.forEach((plugin: FG_Plugin.Plugin) => {
plugin.requiredModules.forEach((requiredModule: string) => {
if (!(config.requiredModules.includes(requiredModule) || config.loadModules.includes(requiredModule))) {
console.error(`Plugin ${plugin.name} need Plugin ${requiredModule}`)
router.push({name: 'error'}).catch((e) => {
console.warn(e)
})
}
})
plugin.requiredBackendModules.forEach((requiredBackendModule: string) => {
if (!(requiredBackendModule in backend.plugins)) {
console.error(`Plugin ${plugin.name} need Plugin ${requiredBackendModule} in backend.`)
router.push({name: 'error'}).catch(err => {
console.warn(err)
})
}
})
})
}
})
.catch(e => {
console.error(e)
})
// load plugins // load plugins
loadedPlugins = loadPlugin( loadedPlugins = loadPlugin(
loadedPlugins, loadedPlugins,

View File

@ -2,7 +2,7 @@
<div class="fullscreen bg-blue text-white text-center q-pa-md flex flex-center"> <div class="fullscreen bg-blue text-white text-center q-pa-md flex flex-center">
<div> <div>
<div> <div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 292.761 292.761" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 292.761 292.761" fill="white"> <svg style="max-width: 400px;" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 292.761 292.761" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 292.761 292.761" fill="white">
<g> <g>
<circle cx="87.493" cy="25.907" r="25.907"/> <circle cx="87.493" cy="25.907" r="25.907"/>
<path d="m194.386,209.531l-42.802-36.895c-1.825-1.573-4.001-2.683-6.345-3.237l-72.533-17.136 47.755,.703v-34.439l-46.525-26.18 50.36,14.829c4.016,1.182 8.356,0.276 11.564-2.414l38.264-32.093c1.1-0.923 2.001-1.994 2.698-3.161 2.656-4.442 2.36-10.26-1.154-14.449-4.437-5.29-12.32-5.981-17.61-1.544l-33.127,27.785-45.605-13.428 41.402,1.292 16.027-13.442-6.021-2.955-3.631,3.945-18.134,2.86h-37.216c-9.665,0-17.501,7.835-17.501,17.501v90.395l.029-.024c0.252,6.569 4.819,12.433 11.527,14.019l68.966,16.292 40.024,34.501c2.834,2.442 6.318,3.639 9.787,3.639 4.213,0 8.402-1.765 11.368-5.206 5.41-6.278 4.708-15.75-1.567-21.158z"/> <path d="m194.386,209.531l-42.802-36.895c-1.825-1.573-4.001-2.683-6.345-3.237l-72.533-17.136 47.755,.703v-34.439l-46.525-26.18 50.36,14.829c4.016,1.182 8.356,0.276 11.564-2.414l38.264-32.093c1.1-0.923 2.001-1.994 2.698-3.161 2.656-4.442 2.36-10.26-1.154-14.449-4.437-5.29-12.32-5.981-17.61-1.544l-33.127,27.785-45.605-13.428 41.402,1.292 16.027-13.442-6.021-2.955-3.631,3.945-18.134,2.86h-37.216c-9.665,0-17.501,7.835-17.501,17.501v90.395l.029-.024c0.252,6.569 4.819,12.433 11.527,14.019l68.966,16.292 40.024,34.501c2.834,2.442 6.318,3.639 9.787,3.639 4.213,0 8.402-1.765 11.368-5.206 5.41-6.278 4.708-15.75-1.567-21.158z"/>
@ -22,10 +22,10 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import {defineComponent} from "@vue/composition-api"; import {defineComponent} from '@vue/composition-api';
export default defineComponent({ export default defineComponent({
name: "PluginError.vue" name: 'PluginError.vue'
}) })
</script> </script>

View File

@ -43,7 +43,6 @@ const routes: RouteConfig[] = [
name: 'error', name: 'error',
component: () => import('pages/PluginError.vue') component: () => import('pages/PluginError.vue')
}, },
// Always leave this as last one, // Always leave this as last one,
// but you can also remove it // but you can also remove it
{ {