plugin.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import loggerFactory from '~/utils/logger';
  2. const logger = loggerFactory('growi:plugin');
  3. export default class GrowiPlugin {
  4. /**
  5. * process plugin entry
  6. *
  7. * @param {AppContainer} appContainer
  8. *
  9. * @memberof CrowiPlugin
  10. */
  11. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  12. installAll(appContainer) {
  13. // import plugin definitions
  14. let definitions = [];
  15. try {
  16. definitions = require('^/tmp/plugins/plugin-definitions');
  17. }
  18. catch (e) {
  19. logger.error('failed to load definitions');
  20. logger.error(e);
  21. return;
  22. }
  23. definitions.forEach((definition) => {
  24. const meta = definition.meta;
  25. switch (meta.pluginSchemaVersion) {
  26. // v1, v2 and v3 is deprecated
  27. case 1:
  28. logger.warn('pluginSchemaVersion 1 is deprecated', definition);
  29. break;
  30. case 2:
  31. logger.warn('pluginSchemaVersion 2 is deprecated', definition);
  32. break;
  33. case 3:
  34. logger.warn('pluginSchemaVersion 2 is deprecated', definition);
  35. break;
  36. case 4:
  37. definition.entries.forEach((entry) => {
  38. entry(appContainer);
  39. });
  40. break;
  41. default:
  42. logger.warn('Unsupported schema version', meta.pluginSchemaVersion);
  43. }
  44. });
  45. }
  46. }
  47. window.growiPlugin = new GrowiPlugin();