فهرست منبع

mv devided-page-path and template-checker to @growi/core

Yuki Takei 4 سال پیش
والد
کامیت
e3a330ce2a

+ 1 - 1
packages/app/src/components/Navbar/GrowiSubNavigation.jsx

@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 
 import PagePathHierarchicalLink from '~/components/PagePathHierarchicalLink';
-import DevidedPagePath from '~/models/devided-page-path';
+import { DevidedPagePath } from '@growi/core';
 import LinkedPagePath from '~/models/linked-page-path';
 
 import { withUnstatedContainers } from '../UnstatedUtils';

+ 1 - 1
packages/app/src/components/Sidebar/RecentChanges.jsx

@@ -4,10 +4,10 @@ import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 
 import { UserPicture } from '@growi/ui';
+import { DevidedPagePath } from '@growi/core';
 import PagePathHierarchicalLink from '~/components/PagePathHierarchicalLink';
 import loggerFactory from '~/utils/logger';
 
-import DevidedPagePath from '~/models/devided-page-path';
 import LinkedPagePath from '~/models/linked-page-path';
 
 import { withUnstatedContainers } from '../UnstatedUtils';

+ 1 - 5
packages/app/src/models/linked-page-path.js

@@ -1,11 +1,7 @@
-import { pagePathUtils } from '@growi/core';
-
-const { pathUtils } = require('growi-commons');
+import { pagePathUtils, DevidedPagePath, pathUtils } from '@growi/core';
 
 const { isTrashPage } = pagePathUtils;
 
-const DevidedPagePath = require('./devided-page-path');
-
 /**
  * Linked Array Structured PagePath Model
  */

+ 1 - 2
packages/app/src/server/models/page.js

@@ -1,4 +1,4 @@
-import { pagePathUtils } from '@growi/core';
+import { templateChecker, pagePathUtils } from '@growi/core';
 import loggerFactory from '~/utils/logger';
 
 // disable no-return-await for model functions
@@ -16,7 +16,6 @@ const differenceInYears = require('date-fns/differenceInYears');
 
 const { pathUtils } = require('growi-commons');
 const escapeStringRegexp = require('escape-string-regexp');
-const templateChecker = require('~/utils/template-checker');
 
 const { isTopPage, isTrashPage } = pagePathUtils;
 

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

@@ -1,8 +1,8 @@
 // eslint-disable-next-line no-unused-vars
 import uglifycss from 'uglifycss';
 
+import { DevidedPagePath } from '@growi/core';
 import loggerFactory from '~/utils/logger';
-import DevidedPagePath from '~/models/devided-page-path';
 
 import S2sMessage from '../models/vo/s2s-message';
 import { S2sMessageHandlable } from './s2s-messaging/handlable';

+ 4 - 0
packages/core/src/index.js

@@ -1,5 +1,6 @@
 import * as _pathUtils from './utils/path-utils';
 import * as _pagePathUtils from './utils/page-path-utils';
+import * as _templateChecker from './utils/template-checker';
 
 // module.exports = {
 //   BasicInterceptor: require('./utils/basic-interceptor'),
@@ -11,6 +12,9 @@ import * as _pagePathUtils from './utils/page-path-utils';
 //   LocalStorageManager: require('./service/localstorage-manager'),
 // };
 
+export * from './models/devided-page-path';
+
 // export utils
 export const pathUtils = _pathUtils;
 export const pagePathUtils = _pagePathUtils;
+export const templateChecker = _templateChecker;

+ 2 - 4
packages/app/src/models/devided-page-path.js → packages/core/src/models/devided-page-path.js

@@ -1,11 +1,11 @@
-const { pathUtils } = require('growi-commons');
+import * as pathUtils from '../utils/path-utils';
 
 // https://regex101.com/r/BahpKX/2
 const PATTERN_INCLUDE_DATE = /^(.+\/[^/]+)\/(\d{4}|\d{4}\/\d{2}|\d{4}\/\d{2}\/\d{2})$/;
 // https://regex101.com/r/WVpPpY/1
 const PATTERN_DEFAULT = /^((.*)\/)?([^/]+)$/;
 
-class DevidedPagePath {
+export class DevidedPagePath {
 
   constructor(path, skipNormalize = false, evalDatePath = false) {
 
@@ -43,5 +43,3 @@ class DevidedPagePath {
   }
 
 }
-
-module.exports = DevidedPagePath;

+ 1 - 1
packages/app/src/utils/template-checker.ts → packages/core/src/utils/template-checker.ts

@@ -2,7 +2,7 @@
  * templateChecker
  */
 
-export default function checkTemplatePath(path: string): boolean {
+export function checkTemplatePath(path: string): boolean {
   if (path.match(/.*\/_{1,2}template$/)) {
     return true;
   }