Răsfoiți Sursa

WIP: impl PluginService

Yuki Takei 3 ani în urmă
părinte
comite
85ca761af6

+ 2 - 1
packages/app/src/interfaces/plugin.ts

@@ -20,6 +20,7 @@ export type GrowiPlugin = {
 
 export type GrowiPluginMeta = {
   name: string,
-  type: GrowiPluginResourceType[],
+  types: GrowiPluginResourceType[],
+  desc?: string,
   author?: string,
 }

+ 9 - 26
packages/app/src/server/service/plugin.ts

@@ -8,41 +8,24 @@ import { resolveFromRoot } from '~/utils/project-dir-utils';
 const logger = loggerFactory('growi:plugins:plugin-utils');
 
 
-const pluginStoringPath = path.resolve(__dirname, '../../../tmp/plugins');
+const pluginStoringPath = resolveFromRoot('tmp/plugins');
 
 export class PluginService {
 
   static async install(origin: GrowiPluginOrigin): Promise<void> {
+    // TODO: download
+    // TODO: detect plugins
+    // TODO: save documents
     return;
   }
 
   static detectPlugins(origin: GrowiPluginOrigin, installedPath: string): GrowiPlugin[] {
-    return [];
-  }
+    // const plugins: GrowiPlugin[] = [];
 
-  // listPlugins() {
-  //   const scopedPackages: string[] = [];
-
-  //   fs.readdirSync(nodeModulesPath)
-  //     .filter(name => scopes.includes(name))
-  //     .forEach((scope) => {
-  //       fs.readdirSync(path.resolve(nodeModulesPath, scope))
-  //         .filter(name => !name.startsWith('.'))
-  //         .forEach((folderName) => {
-  //           const { name } = require(path.resolve(
-  //             nodeModulesPath,
-  //             scope,
-  //             folderName,
-  //             'package.json',
-  //           ));
-  //           if (!opts.ignorePackageNames.includes(name)) {
-  //             scopedPackages.push(name);
-  //           }
-  //         });
-  //     });
-
-  //   return scopedPackages;
-  // }
+    // const package = require(path.resolve(installedPath, 'package.json'));
+
+    // return scopedPackages;
+  }
 
   // /**
   //  * list plugin module objects