jam411 3 лет назад
Родитель
Сommit
9a5198a6ed

+ 3 - 3
packages/app/src/components/Admin/AdminHome/InstalledPluginTable.jsx

@@ -1,7 +1,7 @@
 import React from 'react';
 
-import PropTypes from 'prop-types';
 import { useTranslation } from 'next-i18next';
+import PropTypes from 'prop-types';
 
 import AdminHomeContainer from '~/client/services/AdminHomeContainer';
 
@@ -27,7 +27,7 @@ const InstalledPluginTable = (props) => {
         </tr>
       </thead>
       <tbody>
-        {adminHomeContainer.state.installedPlugins.map((plugin) => {
+        {/* {adminHomeContainer.state.installedPlugins.map((plugin) => {
           return (
             <tr key={plugin.name}>
               <td>{plugin.name}</td>
@@ -35,7 +35,7 @@ const InstalledPluginTable = (props) => {
               <td data-hide-in-vrt className="text-center">{plugin.installedVersion}</td>
             </tr>
           );
-        })}
+        })} */}
       </tbody>
     </table>
   );

+ 2 - 2
packages/app/src/pages/admin/[[...path]].page.tsx

@@ -109,7 +109,7 @@ const AdminMarkdownSettingsPage: NextPage<Props> = (props: Props) => {
         nodeVersion={props.nodeVersion}
         npmVersion={props.npmVersion}
         yarnVersion={props.yarnVersion}
-        installedPlugins={props.installedPlugins}
+        // installedPlugins={props.installedPlugins}
       />,
     },
     app: {
@@ -290,7 +290,7 @@ async function injectServerConfigurations(context: GetServerSidePropsContext, pr
   props.nodeVersion = crowi.runtimeVersions.versions.node ? crowi.runtimeVersions.versions.node.version.version : null;
   props.npmVersion = crowi.runtimeVersions.versions.npm ? crowi.runtimeVersions.versions.npm.version.version : null;
   props.yarnVersion = crowi.runtimeVersions.versions.yarn ? crowi.runtimeVersions.versions.yarn.version.version : null;
-  props.installedPlugins = crowi.pluginService.listPlugins();
+  // props.installedPlugins= crowi.pluginService.listPlugins(crowi.rootDir);
   props.envVars = await ConfigLoader.getEnvVarsForDisplay(true);
   props.isAclEnabled = aclService.isAclEnabled();
 

+ 2 - 0
packages/app/src/server/routes/apiv3/import.js

@@ -214,6 +214,8 @@ module.exports = (crowi) => {
     // TODO: add express validator
     const { fileName, collections, optionsMap } = req.body;
 
+    console.log('fileName', fileName);
+
     // pages collection can only be imported by upsert if isV5Compatible is true
     const isV5Compatible = crowi.configManager.getConfig('crowi', 'app:isV5Compatible');
     const isImportPagesCollection = collections.includes('pages');

+ 4 - 5
packages/app/src/server/routes/apiv3/plugins-extention.ts

@@ -1,7 +1,6 @@
 import express, { Request } from 'express';
 
 import Crowi from '../../crowi';
-import { PluginService } from '../../service/plugin';
 
 import { ApiV3Response } from './interfaces/apiv3-response';
 
@@ -10,16 +9,16 @@ type PluginInstallerFormRequest = Request & { form: any };
 
 module.exports = (crowi: Crowi) => {
   const router = express.Router();
-  // const { pluginService } = crowi;
+  const { pluginService } = crowi;
 
   router.post('/', async(req: PluginInstallerFormRequest, res: ApiV3Response) => {
-    if (PluginService == null) {
+    if (pluginService == null) {
       return res.apiv3Err(400);
     }
 
     try {
-      PluginService.install(crowi, req.body.pluginInstallerForm);
-      return res.apiv3(200);
+      await pluginService.install(crowi, req.body.pluginInstallerForm);
+      return res.apiv3({});
     }
     catch (err) {
       // TODO: error handling

+ 15 - 22
packages/app/src/server/service/plugin.ts

@@ -14,42 +14,35 @@ const logger = loggerFactory('growi:plugins:plugin-utils');
 
 const pluginStoringPath = resolveFromRoot('tmp/plugins');
 
-function downloadZipFile(ghUrl: string, filename:string): void {
+async function downloadZipFile(ghUrl: string, filename:string, crowi): Promise<void> {
+  const { importService } = crowi;
   wget({ url: ghUrl, dest: filename });
+  try {
+    console.log('j;oif', `${filename}master.zip`);
+    const zipFile = await importService.getFile('master.zip');
+    console.log('zip');
+    const file = await importService.unzip(zipFile);
+    console.log('fixl', file);
+  }
+  catch (err) {
+    console.log('fail');
+  }
   return;
 }
-
 export class PluginService {
 
-  static async install(crowi: Crowi, origin: GrowiPluginOrigin): Promise<void> {
-    // const { importServic } = crowi;
+  async install(crowi: Crowi, origin: GrowiPluginOrigin): Promise<void> {
     // download
     const ghUrl = origin.url;
-    // const ghBranch = origin.ghBranch;
-    // const ghTag = origin.ghTag;
     const downloadDir = path.join(process.cwd(), 'tmp/plugins/');
-    downloadZipFile(`${ghUrl}/archive/refs/heads/master.zip`, downloadDir);
-    // const test = '/workspace/growi/packages/app/tmp/plugins/master.zip';
-    // const file = unzip();
-    // // unzip
-    // const files = await unzip(`${downloadDir}master.zip`);
-    // console.log('fle', files);
-    // const file = await importService.unzip(`${downloadDir}master.zip`);
-    // console.log(file);
-    // try {
-    //   // unzip
-    //   const file = await importService.unzip(zipFile);
-    //   console.log('fle', file)
-    // }
-    // catch (err) {
-    //   // TODO:
-    // }
+    await downloadZipFile(`${ghUrl}/archive/refs/heads/master.zip`, downloadDir, crowi);
 
     // TODO: detect plugins
     // TODO: save documents
     return;
   }
 
+
   // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
   static async detectPlugins(origin: GrowiPluginOrigin, installedPath: string, parentPackageJson?: any): Promise<GrowiPlugin[]> {
     const packageJsonPath = path.resolve(pluginStoringPath, installedPath, 'package.json');