Просмотр исходного кода

Merge pull request #4205 from weseek/feat/pack-textlint

codemirror-textlintパッケージ化
Yuki Takei 4 лет назад
Родитель
Сommit
9c6ca62a20

+ 2 - 0
packages/app/docker/Dockerfile

@@ -18,6 +18,7 @@ COPY ./yarn.lock .
 COPY ./lerna.json .
 COPY ./packages/app/package.json packages/app/
 COPY ./packages/core/package.json packages/core/
+COPY ./packages/codemirror-textlint/package.json packages/codemirror-textlint/
 COPY ./packages/plugin-attachment-refs/package.json packages/plugin-attachment-refs/
 COPY ./packages/plugin-lsx/package.json packages/plugin-lsx/
 COPY ./packages/plugin-pukiwiki-like-linker/package.json packages/plugin-pukiwiki-like-linker/
@@ -96,6 +97,7 @@ COPY ./tsconfig.base.json ./
 # copy all related packages
 COPY packages/app packages/app
 COPY packages/core packages/core
+COPY packages/codemirror-textlint packages/codemirror-textlint
 COPY packages/plugin-attachment-refs packages/plugin-attachment-refs
 COPY packages/plugin-lsx packages/plugin-lsx
 COPY packages/plugin-pukiwiki-like-linker packages/plugin-pukiwiki-like-linker

+ 1 - 20
packages/app/package.json

@@ -55,6 +55,7 @@
   "dependencies": {
     "@browser-bunyan/console-formatted-stream": "^1.6.2",
     "@google-cloud/storage": "^5.8.5",
+    "@growi/codemirror-textlint": "^4.3.3-RC",
     "@growi/plugin-attachment-refs": "^4.3.3-RC",
     "@growi/plugin-lsx": "^4.3.3-RC",
     "@growi/plugin-pukiwiki-like-linker": "^4.3.3-RC",
@@ -156,8 +157,6 @@
     "@atlaskit/navigation-next": "^8.0.5",
     "@growi/ui": "^4.3.3-RC",
     "@handsontable/react": "=2.1.0",
-    "@textlint/kernel": "^12.0.2",
-    "@types/codemirror": "^5.60.2",
     "@types/compression": "^1.7.0",
     "@types/express": "^4.17.11",
     "@types/multer": "^1.4.5",
@@ -232,24 +231,6 @@
     "stylelint-config-recess-order": "^2.0.1",
     "swagger2openapi": "^5.3.1",
     "terser-webpack-plugin": "^4.1.0",
-    "textlint-message-to-codemirror": "^1.0.0",
-    "textlint-plugin-markdown": "^4.0.6",
-    "textlint-rule-common-misspellings": "^1.0.1",
-    "textlint-rule-ja-hiragana-keishikimeishi": "^1.1.0",
-    "textlint-rule-ja-no-abusage": "^3.0.0",
-    "textlint-rule-ja-no-inappropriate-words": "^2.0.0",
-    "textlint-rule-ja-no-mixed-period": "^2.1.1",
-    "textlint-rule-ja-no-redundant-expression": "^4.0.0",
-    "textlint-rule-max-comma": "^2.0.2",
-    "textlint-rule-max-kanji-continuous-len": "^1.1.1",
-    "textlint-rule-max-ten": "^4.0.2",
-    "textlint-rule-no-double-negative-ja": "^2.0.0",
-    "textlint-rule-no-doubled-conjunction": "^2.0.2",
-    "textlint-rule-no-doubled-joshi": "^4.0.0",
-    "textlint-rule-no-dropping-the-ra": "^3.0.0",
-    "textlint-rule-no-hankaku-kana": "^1.0.2",
-    "textlint-rule-prefer-tari-tari": "^1.0.3",
-    "textlint-rule-sentence-length": "^3.0.0",
     "throttle-debounce": "^2.0.0",
     "toastr": "^2.1.2",
     "ts-loader": "^8.3.0",

+ 1 - 1
packages/app/src/components/PageEditor/CodeMirrorEditor.jsx

@@ -12,6 +12,7 @@ import { JSHINT } from 'jshint';
 import * as loadScript from 'simple-load-script';
 import * as loadCssSync from 'load-css-file';
 
+import { createValidator } from '@growi/codemirror-textlint';
 import InterceptorManager from '~/services/interceptor-manager';
 import loggerFactory from '~/utils/logger';
 
@@ -32,7 +33,6 @@ import HandsontableModal from './HandsontableModal';
 import EditorIcon from './EditorIcon';
 import DrawioModal from './DrawioModal';
 
-import { createValidator } from '../../client/util/codemirror/codemirror-textlint';
 
 window.JSHINT = JSHINT;
 

+ 1 - 0
packages/codemirror-textlint/.gitignore

@@ -0,0 +1 @@
+/dist

+ 44 - 0
packages/codemirror-textlint/package.json

@@ -0,0 +1,44 @@
+{
+  "name": "@growi/codemirror-textlint",
+  "version": "4.3.3-RC",
+  "license": "MIT",
+  "main": "dist/index.js",
+  "scripts": {
+    "build": "yarn tsc && tsc-alias -p tsconfig.build.json",
+    "tsc": "tsc -p tsconfig.build.json",
+    "tsc:w": "yarn tsc -w",
+    "lint": "eslint src --ext .ts",
+    "lint:fix": "eslint src --ext .ts --fix"
+  },
+  "dependencies": {
+    "@browser-bunyan/console-formatted-stream": "^1.6.2",
+    "browser-bunyan": "^1.6.3",
+    "bunyan": "^1.8.15",
+    "universal-bunyan": "^0.9.2"
+  },
+  "devDependencies": {
+    "@textlint/kernel": "^12.0.2",
+    "@types/codemirror": "^5.60.2",
+    "textlint-message-to-codemirror": "^1.0.0",
+    "textlint-plugin-markdown": "^4.0.6",
+    "textlint-rule-common-misspellings": "^1.0.1",
+    "textlint-rule-ja-hiragana-keishikimeishi": "^1.1.0",
+    "textlint-rule-ja-no-abusage": "^3.0.0",
+    "textlint-rule-ja-no-inappropriate-words": "^2.0.0",
+    "textlint-rule-ja-no-mixed-period": "^2.1.1",
+    "textlint-rule-ja-no-redundant-expression": "^4.0.0",
+    "textlint-rule-max-comma": "^2.0.2",
+    "textlint-rule-max-kanji-continuous-len": "^1.1.1",
+    "textlint-rule-max-ten": "^4.0.2",
+    "textlint-rule-no-double-negative-ja": "^2.0.0",
+    "textlint-rule-no-doubled-conjunction": "^2.0.2",
+    "textlint-rule-no-doubled-joshi": "^4.0.0",
+    "textlint-rule-no-dropping-the-ra": "^3.0.0",
+    "textlint-rule-no-hankaku-kana": "^1.0.2",
+    "textlint-rule-prefer-tari-tari": "^1.0.3",
+    "textlint-rule-sentence-length": "^3.0.0"
+  },
+  "peerDependencies": {
+    "codemirror": "^5.62.3"
+  }
+}

+ 1 - 1
packages/app/src/client/util/codemirror/codemirror-textlint.ts → packages/codemirror-textlint/src/index.ts

@@ -18,7 +18,7 @@ import textlintRulePreferTariTari from 'textlint-rule-prefer-tari-tari';
 import textlintRuleSentenceLength from 'textlint-rule-sentence-length';
 
 import { AsyncLinter, Annotation } from 'codemirror/addon/lint/lint';
-import loggerFactory from '../../../utils/logger';
+import { loggerFactory } from './utils/logger';
 
 type RulesConfigObj = {
   name: string,

+ 9 - 0
packages/codemirror-textlint/src/utils/logger/index.ts

@@ -0,0 +1,9 @@
+import Logger from 'bunyan';
+import { createLogger } from 'universal-bunyan';
+
+export const loggerFactory = function(name: string): Logger {
+  return createLogger({
+    name,
+    config: { default: 'info' },
+  });
+};

+ 8 - 0
packages/codemirror-textlint/tsconfig.base.json

@@ -0,0 +1,8 @@
+{
+  "extends": "../../tsconfig.base.json",
+  "compilerOptions": {
+  },
+  "include": [
+    "src"
+  ]
+}

+ 17 - 0
packages/codemirror-textlint/tsconfig.build.json

@@ -0,0 +1,17 @@
+{
+  "extends": "./tsconfig.base.json",
+  "compilerOptions": {
+    "rootDir": "./src",
+    "outDir": "dist",
+    "declaration": true,
+    "noResolve": false,
+    "preserveConstEnums": true,
+    "sourceMap": true,
+    "noEmit": false,
+    "inlineSources": true,
+
+    "baseUrl": ".",
+    "paths": {
+    }
+  }
+}

+ 6 - 0
packages/codemirror-textlint/tsconfig.json

@@ -0,0 +1,6 @@
+{
+  "extends": "./tsconfig.base.json",
+  "compilerOptions": {
+    "baseUrl": "."
+  }
+}

+ 9 - 0
packages/codemirror-textlint/utils/logger/index.ts

@@ -0,0 +1,9 @@
+import Logger from 'bunyan';
+import { createLogger } from 'universal-bunyan';
+
+export const loggerFactory = function(name: string): Logger {
+  return createLogger({
+    name,
+    config: { default: 'info' },
+  });
+};