Yuki Takei 2 лет назад
Родитель
Сommit
3cf1f7076e

+ 2 - 1
apps/app/src/server/models/page.ts

@@ -8,7 +8,7 @@ import {
   GroupType, type HasObjectId,
 } from '@growi/core';
 import { isPopulated } from '@growi/core/dist/interfaces';
-import { isTopPage, hasSlash, collectAncestorPaths } from '@growi/core/dist/utils/page-path-utils';
+import { isTopPage, hasSlash } from '@growi/core/dist/utils/page-path-utils';
 import { addTrailingSlash, normalizePath } from '@growi/core/dist/utils/path-utils';
 import escapeStringRegexp from 'escape-string-regexp';
 import type { Model, Document, AnyObject } from 'mongoose';
@@ -23,6 +23,7 @@ import type { IOptionsForCreate } from '~/interfaces/page';
 import type { ObjectIdLike } from '~/server/interfaces/mongoose-utils';
 
 import loggerFactory from '../../utils/logger';
+import { collectAncestorPaths } from '../util/collect-ancestor-paths';
 import { getOrCreateModel } from '../util/mongoose-utils';
 
 import { getPageSchema, extractToAncestorsPaths, populateDataToShowRevision } from './obsolete-page';

+ 6 - 6
apps/app/src/server/service/page-operation.ts

@@ -1,13 +1,13 @@
 import { pagePathUtils } from '@growi/core/dist/utils';
-import { collectAncestorPaths } from '@growi/core/dist/utils/page-path-utils';
 
-import {
-  IPageOperationProcessInfo, IPageOperationProcessData, PageActionType, PageActionStage,
-} from '~/interfaces/page-operation';
-import PageOperation, { PageOperationDocument } from '~/server/models/page-operation';
+import type { IPageOperationProcessInfo, IPageOperationProcessData } from '~/interfaces/page-operation';
+import { PageActionType, PageActionStage } from '~/interfaces/page-operation';
+import type { PageOperationDocument } from '~/server/models/page-operation';
+import PageOperation from '~/server/models/page-operation';
 import loggerFactory from '~/utils/logger';
 
-import { ObjectIdLike } from '../interfaces/mongoose-utils';
+import type { ObjectIdLike } from '../interfaces/mongoose-utils';
+import { collectAncestorPaths } from '../util/collect-ancestor-paths';
 
 const logger = loggerFactory('growi:services:page-operation');
 

+ 2 - 1
apps/app/src/server/service/page/index.ts

@@ -38,6 +38,7 @@ import {
 import type { PageTagRelationDocument } from '~/server/models/page-tag-relation';
 import PageTagRelation from '~/server/models/page-tag-relation';
 import { createBatchStream } from '~/server/util/batch-stream';
+import { collectAncestorPaths } from '~/server/util/collect-ancestor-paths';
 import loggerFactory from '~/utils/logger';
 import { prepareDeleteConfigValuesForCalc } from '~/utils/page-delete-config';
 
@@ -68,7 +69,7 @@ const debug = require('debug')('growi:services:page');
 
 const logger = loggerFactory('growi:services:page');
 const {
-  isTrashPage, isTopPage, omitDuplicateAreaPageFromPages, getUsernameByPath, collectAncestorPaths,
+  isTrashPage, isTopPage, omitDuplicateAreaPageFromPages, getUsernameByPath,
   canMoveByPath, isUsersTopPage, isMovablePage, isUsersHomepage, hasSlash, generateChildrenRegExp,
 } = pagePathUtils;
 

+ 3 - 3
packages/core/src/utils/page-path-utils/collect-ancestor-paths.ts → apps/app/src/server/util/collect-ancestor-paths.ts

@@ -1,6 +1,6 @@
-import platformPath from 'path';
+import { dirname } from 'node:path';
 
-import { isTopPage } from './is-top-page';
+import { isTopPage } from '@growi/core/dist/utils/page-path-utils';
 
 /**
  * returns ancestors paths
@@ -11,7 +11,7 @@ import { isTopPage } from './is-top-page';
 export const collectAncestorPaths = (path: string, ancestorPaths: string[] = []): string[] => {
   if (isTopPage(path)) return ancestorPaths;
 
-  const parentPath = platformPath.dirname(path);
+  const parentPath = dirname(path);
   ancestorPaths.push(parentPath);
   return collectAncestorPaths(parentPath, ancestorPaths);
 };

+ 0 - 1
packages/core/src/utils/page-path-utils/index.ts

@@ -306,4 +306,3 @@ export const getUsernameByPath = (path: string): string | null => {
 
 
 export * from './is-top-page';
-export * from './collect-ancestor-paths';

+ 1 - 1
packages/core/tsconfig.json

@@ -12,5 +12,5 @@
   },
   "include": [
     "src", "test"
-  ]
+, "../../apps/app/src/server/util/collect-ancestor-paths.ts"  ]
 }