Futa Arai 6 месяцев назад
Родитель
Сommit
5e6d0e0eb1

+ 1 - 1
apps/app/src/features/growi-plugin/server/services/growi-plugin/growi-plugin.integ.ts

@@ -103,7 +103,7 @@ describe('Installing a GROWI theme plugin', () => {
     expect(results.themeMetadata).not.toBeNull();
     expect(results.themeHref).not.toBeNull();
     expect(
-      results.themeHref.startsWith(
+      results.themeHref?.startsWith(
         '/static/plugins/growilabs/growi-plugin-theme-vivid-internet/dist/assets/style-',
       ),
     ).toBeTruthy();

+ 12 - 8
apps/app/src/features/growi-plugin/server/services/growi-plugin/growi-plugin.ts

@@ -66,7 +66,7 @@ function retrievePluginManifest(
 type FindThemePluginResult = {
   growiPlugin: IGrowiPlugin;
   themeMetadata: GrowiThemeMetadata;
-  themeHref: string;
+  themeHref: string | undefined;
 };
 
 export interface IGrowiPluginService {
@@ -155,7 +155,10 @@ export class GrowiPluginService implements IGrowiPluginService {
 
     const installedPath = `${organizationName}/${reposName}`;
 
-    const organizationPath = this.joinAndValidatePath(PLUGIN_STORING_PATH, organizationName);
+    const organizationPath = this.joinAndValidatePath(
+      PLUGIN_STORING_PATH,
+      organizationName,
+    );
     const zipFilePath = this.joinAndValidatePath(
       PLUGIN_STORING_PATH,
       organizationName,
@@ -166,7 +169,11 @@ export class GrowiPluginService implements IGrowiPluginService {
       organizationName,
       `${reposName}-${extractedArchiveDirName}`,
     );
-    const reposPath = this.joinAndValidatePath(PLUGIN_STORING_PATH, organizationName, reposName);
+    const reposPath = this.joinAndValidatePath(
+      PLUGIN_STORING_PATH,
+      organizationName,
+      reposName,
+    );
 
     if (!fs.existsSync(organizationPath)) fs.mkdirSync(organizationPath);
 
@@ -427,7 +434,7 @@ export class GrowiPluginService implements IGrowiPluginService {
       return null;
     }
 
-    let themeHref: string;
+    let themeHref: string | undefined;
     try {
       const manifest = retrievePluginManifest(matchedPlugin);
       if (manifest == null) {
@@ -484,10 +491,7 @@ export class GrowiPluginService implements IGrowiPluginService {
     return entries;
   }
 
-  private joinAndValidatePath(
-    baseDir: string,
-    ...paths: string[]
-  ): string {
+  private joinAndValidatePath(baseDir: string, ...paths: string[]): string {
     const joinedPath = path.join(baseDir, ...paths);
     if (!joinedPath.startsWith(baseDir)) {
       throw new Error(

+ 1 - 1
apps/app/src/server/service/customize.ts

@@ -36,7 +36,7 @@ class CustomizeService implements S2sMessageHandlable {
 
   theme: string;
 
-  themeHref: string;
+  themeHref: string | undefined;
 
   forcedColorScheme?: ColorScheme;