From d6ba79e1707a56b06c1d7254c62844c0b67ab572 Mon Sep 17 00:00:00 2001 From: chanheeis Date: Thu, 2 Sep 2021 16:12:41 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20gulp=20task=EC=97=90=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EB=AA=A8=EB=93=88=20=EC=84=A4=EC=B9=98=20?= =?UTF-8?q?=20=20-=20fancy-log=20:=20gulp=20task=20error=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D=20=EC=8B=9C=20=EB=A1=9C=EA=B1=B0=20=EC=97=AD=ED=95=A0?= =?UTF-8?q?=20=20=20-=20gulp-modify-file=20:=20gulp=20task=EB=A1=9C=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EB=B3=80=EA=B2=BD=EC=97=90=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EB=AA=A8=EB=93=88=20=20=20-=20gulp-pretti?= =?UTF-8?q?er=20:=20modify-file=20=EC=8B=9C=20prettier=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=AA=A8=EB=93=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 221842f8..282e8881 100644 --- a/package.json +++ b/package.json @@ -53,20 +53,24 @@ "@types/react": "^17.0.16", "@types/react-helmet": "^6.1.2", "@types/react-router-dom": "^5.1.8", - "dotenv-webpack": "^7.0.3", - "babel-plugin-module-resolver": "^4.1.0", - "typescript": "^4.3.5", "@typescript-eslint/eslint-plugin": "^4.29.1", "@typescript-eslint/parser": "^4.29.1", + "babel-plugin-module-resolver": "^4.1.0", + "dotenv-webpack": "^7.0.3", "eslint": "^7.32.0", + "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.24.0", "eslint-plugin-jest": "^24.4.0", "eslint-plugin-jsx-a11y": "^6.4.1", + "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-react": "^7.24.0", "eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-testing-library": "^4.10.1", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-prettier": "^3.4.0", - "prettier": "^2.3.2" + "fancy-log": "^1.3.3", + "gulp": "^4.0.2", + "gulp-modify-file": "^1.0.1", + "gulp-prettier": "^4.0.0", + "prettier": "^2.3.2", + "typescript": "^4.3.5" } } From e0fb0025fe83b805073ef0f89d4740540deac63e Mon Sep 17 00:00:00 2001 From: chanheeis Date: Thu, 2 Sep 2021 16:16:56 +0900 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20Sorting=20&=20Testing=20gulp=20tas?= =?UTF-8?q?k=20=EC=B6=94=EA=B0=80=20=20=20-=20root=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=EC=9D=98=20wiki.json=20=ED=8C=8C=EC=9D=BC=20=EC=9D=BD=EC=96=B4?= =?UTF-8?q?=EC=84=9C=20Assending=20Sort=20=20=20-=20isValidName=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=EB=A5=BC=20=ED=86=B5=ED=95=B4=20Naming=20Con?= =?UTF-8?q?vention=20=EC=B2=B4=ED=81=AC=20=20=20-=20Regular=20Experssion?= =?UTF-8?q?=20(const=20regex)=EB=A5=BC=20=ED=86=B5=ED=95=B4=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Regex 설명] - 첫 파트의 첫 문자와 마지막 문자는 알파벳, 숫자, 한글만 허용 - 두 번째 파트는 반드시 괄호로 싸여있어야 함 - 두번째 파트의 첫 문자와 마지막 문자는 알파벳, 숫자만 허용 --- gulpfile.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 gulpfile.js diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..50e3c138 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,53 @@ +const log = require('fancy-log'); +const modifyFile = require('gulp-modify-file'); +const prettier = require('gulp-prettier'); + +task('check-wiki.json', done => { + src('./wiki.json') + .pipe( + modifyFile(content => { + let hasWrongFormatName = false; + const wikiData = JSON.parse(content); + + for (let idx = 0; idx < wikiData.length; idx++) { + if (isValidName(wikiData[idx].name) === false) { + hasWrongFormatName = true; + break; + } + } + + const sorted = !!hasWrongFormatName + ? wikiData + : wikiData.sort((a, b) => { + return a.name < b.name ? -1 : a.name > b.name ? 1 : 0; + }); + + return JSON.stringify(sorted); + }), + ) + .pipe(prettier()) + .pipe(dest('./')); + done(); +}); + +function isValidName(str) { + const regex = + /^[a-zA-Z0-9가-힣][a-zA-Z0-9가-힣\s]*[a-zA-Z0-9가-힣]\s\([a-zA-Z0-9][a-zA-Z0-9\s]*[a-zA-Z0-9]\)/; + + if (regex.test(str) === false) { + log.error(` + Error occured in wiki.json data : ${str} + Please check below wiki.json naming convetion + ● Each part of name must start with non-whitespace + ● First part of name must be combination of (korean | english | number | whitespace) + ● Second part of name must be wrapped round brackets + ● Second part of name must be combination of (english | number | whitespace) + ● Second part of name must not be empty + ● More than two words must be separated by ', ' + `); + return false; + } + return true; +} + +exports.default = series('check-wiki.json'); From a7819c7c9d66c5b4a4fab577e8eef3fb20a5807a Mon Sep 17 00:00:00 2001 From: chanheeis Date: Thu, 2 Sep 2021 16:17:37 +0900 Subject: [PATCH 3/4] chore: prebuild setting --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 282e8881..a5503ae1 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "docusaurus": "docusaurus", "start": "docusaurus start", + "prebuild": "gulp", "build": "docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", From faf9045f06c6da603179514a1c7772a811ac7b48 Mon Sep 17 00:00:00 2001 From: chanheeis Date: Thu, 2 Sep 2021 16:19:51 +0900 Subject: [PATCH 4/4] fix: requier gulp on gulpfile.js --- gulpfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/gulpfile.js b/gulpfile.js index 50e3c138..d0519e20 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,3 +1,4 @@ +const { task, src, series, dest } = require('gulp'); const log = require('fancy-log'); const modifyFile = require('gulp-modify-file'); const prettier = require('gulp-prettier');