Commit 8023dc86 authored by qinhaitao's avatar qinhaitao

feat: 🎸 格式化编译代码格式

parent bc63fb49
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
const gulp = require('gulp') const gulp = require('gulp')
const rename = require('gulp-rename') const rename = require('gulp-rename')
const nunjucksRender = require('gulp-nunjucks-render') const nunjucksRender = require('gulp-nunjucks-render')
const prettier = require('gulp-prettier')
const codeGenerate = require('./generate') const codeGenerate = require('./generate')
var jsScript = 'node' var jsScript = 'node'
...@@ -12,6 +13,18 @@ if (process.env.npm_config_argv !== undefined && process.env.npm_config_argv.ind ...@@ -12,6 +13,18 @@ if (process.env.npm_config_argv !== undefined && process.env.npm_config_argv.ind
const ServerFullPath = '../src' const ServerFullPath = '../src'
const prettierConfig = {
printWidth: 120,
semi: false,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: true,
arrowParens: 'avoid',
insertPragma: true,
tabWidth: 2,
useTabs: false
}
const nunjucksRenderConfig = { const nunjucksRenderConfig = {
path: 'templates', path: 'templates',
ext: '.ts', ext: '.ts',
...@@ -33,7 +46,16 @@ const nunjucksRenderConfig = { ...@@ -33,7 +46,16 @@ const nunjucksRenderConfig = {
ServerFullPath ServerFullPath
} }
gulp.task('code', function () { gulp.task('build', function () {
require('events').EventEmitter.defaultMaxListeners = 0 require('events').EventEmitter.defaultMaxListeners = 0
return codeGenerate.run(gulp, nunjucksRender, rename, nunjucksRenderConfig) return codeGenerate.run(gulp, nunjucksRender, rename, nunjucksRenderConfig)
}) })
gulp.task('format', () => {
return gulp
.src(nunjucksRenderConfig.ServerFullPath + '/controller/**/*.ts')
.pipe(prettier(prettierConfig))
.pipe(gulp.dest(nunjucksRenderConfig.ServerFullPath + '/controller'))
})
gulp.task('code', gulp.series('build', 'format'))
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
"devDependencies": { "devDependencies": {
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-nunjucks-render": "^2.2.3", "gulp-nunjucks-render": "^2.2.3",
"gulp-rename": "^2.0.0" "gulp-rename": "^2.0.0",
"gulp-prettier": "^3.0.0"
}, },
"dependencies": { "dependencies": {
"fs-extra": "^9.0.1" "fs-extra": "^9.0.1"
......
...@@ -933,11 +933,27 @@ gulp-nunjucks-render@^2.2.3: ...@@ -933,11 +933,27 @@ gulp-nunjucks-render@^2.2.3:
replace-ext "^1.0.0" replace-ext "^1.0.0"
through2 "^2.0.3" through2 "^2.0.3"
gulp-prettier@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/gulp-prettier/download/gulp-prettier-3.0.0.tgz#21c7de272fc7528168af6086e8edae6a645168a8"
integrity sha1-IcfeJy/HUoFor2CG6O2uamRRaKg=
dependencies:
plugin-error "^1.0.1"
prettier "^2.0.0"
through2 "^3.0.0"
gulp-rename@^2.0.0: gulp-rename@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.npm.taobao.org/gulp-rename/download/gulp-rename-2.0.0.tgz#9bbc3962b0c0f52fc67cd5eaff6c223ec5b9cf6c" resolved "https://registry.npm.taobao.org/gulp-rename/download/gulp-rename-2.0.0.tgz#9bbc3962b0c0f52fc67cd5eaff6c223ec5b9cf6c"
integrity sha1-m7w5YrDA9S/GfNXq/2wiPsW5z2w= integrity sha1-m7w5YrDA9S/GfNXq/2wiPsW5z2w=
gulp-sequence@^1.0.0:
version "1.0.0"
resolved "https://registry.npm.taobao.org/gulp-sequence/download/gulp-sequence-1.0.0.tgz#862f93e6503e67c350a42948fa666953cf88ba67"
integrity sha1-hi+T5lA+Z8NQpClI+mZpU8+Iumc=
dependencies:
thunks "^4.9.0"
gulp@^4.0.2: gulp@^4.0.2:
version "4.0.2" version "4.0.2"
resolved "https://registry.npm.taobao.org/gulp/download/gulp-4.0.2.tgz#543651070fd0f6ab0a0650c6a3e6ff5a7cb09caa" resolved "https://registry.npm.taobao.org/gulp/download/gulp-4.0.2.tgz#543651070fd0f6ab0a0650c6a3e6ff5a7cb09caa"
...@@ -1018,7 +1034,7 @@ inflight@^1.0.4: ...@@ -1018,7 +1034,7 @@ inflight@^1.0.4:
once "^1.3.0" once "^1.3.0"
wrappy "1" wrappy "1"
inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3:
version "2.0.4" version "2.0.4"
resolved "https://registry.npm.taobao.org/inherits/download/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" resolved "https://registry.npm.taobao.org/inherits/download/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w= integrity sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=
...@@ -1684,6 +1700,11 @@ posix-character-classes@^0.1.0: ...@@ -1684,6 +1700,11 @@ posix-character-classes@^0.1.0:
resolved "https://registry.npm.taobao.org/posix-character-classes/download/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" resolved "https://registry.npm.taobao.org/posix-character-classes/download/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
prettier@^2.0.0:
version "2.1.2"
resolved "https://registry.npm.taobao.org/prettier/download/prettier-2.1.2.tgz?cache=0&sync_timestamp=1600215482255&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fprettier%2Fdownload%2Fprettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
integrity sha1-MFBwDa4uTItnxMP2Zs24r0BeHOU=
pretty-hrtime@^1.0.0: pretty-hrtime@^1.0.0:
version "1.0.3" version "1.0.3"
resolved "https://registry.npm.taobao.org/pretty-hrtime/download/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" resolved "https://registry.npm.taobao.org/pretty-hrtime/download/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1"
...@@ -1728,6 +1749,15 @@ read-pkg@^1.0.0: ...@@ -1728,6 +1749,15 @@ read-pkg@^1.0.0:
normalize-package-data "^2.3.2" normalize-package-data "^2.3.2"
path-type "^1.0.0" path-type "^1.0.0"
"readable-stream@2 || 3":
version "3.6.0"
resolved "https://registry.npm.taobao.org/readable-stream/download/readable-stream-3.6.0.tgz?cache=0&sync_timestamp=1589682741447&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freadable-stream%2Fdownload%2Freadable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198"
integrity sha1-M3u9o63AcGvT4CRCaihtS0sskZg=
dependencies:
inherits "^2.0.3"
string_decoder "^1.1.1"
util-deprecate "^1.0.1"
readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6: readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6:
version "2.3.7" version "2.3.7"
resolved "https://registry.npm.taobao.org/readable-stream/download/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" resolved "https://registry.npm.taobao.org/readable-stream/download/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57"
...@@ -1861,7 +1891,7 @@ ret@~0.1.10: ...@@ -1861,7 +1891,7 @@ ret@~0.1.10:
resolved "https://registry.npm.taobao.org/ret/download/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" resolved "https://registry.npm.taobao.org/ret/download/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
integrity sha1-uKSCXVvbH8P29Twrwz+BOIaBx7w= integrity sha1-uKSCXVvbH8P29Twrwz+BOIaBx7w=
safe-buffer@^5.1.0: safe-buffer@^5.1.0, safe-buffer@~5.2.0:
version "5.2.1" version "5.2.1"
resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY= integrity sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY=
...@@ -2026,6 +2056,13 @@ string-width@^1.0.1, string-width@^1.0.2: ...@@ -2026,6 +2056,13 @@ string-width@^1.0.1, string-width@^1.0.2:
is-fullwidth-code-point "^1.0.0" is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0" strip-ansi "^3.0.0"
string_decoder@^1.1.1:
version "1.3.0"
resolved "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.3.0.tgz?cache=0&sync_timestamp=1589682743884&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstring_decoder%2Fdownload%2Fstring_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e"
integrity sha1-QvEUWUpGzxqOMLCoT1bHjD7awh4=
dependencies:
safe-buffer "~5.2.0"
string_decoder@~1.1.1: string_decoder@~1.1.1:
version "1.1.1" version "1.1.1"
resolved "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" resolved "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
...@@ -2071,6 +2108,19 @@ through2@^2.0.0, through2@^2.0.3, through2@~2.0.0: ...@@ -2071,6 +2108,19 @@ through2@^2.0.0, through2@^2.0.3, through2@~2.0.0:
readable-stream "~2.3.6" readable-stream "~2.3.6"
xtend "~4.0.1" xtend "~4.0.1"
through2@^3.0.0:
version "3.0.2"
resolved "https://registry.npm.taobao.org/through2/download/through2-3.0.2.tgz#99f88931cfc761ec7678b41d5d7336b5b6a07bf4"
integrity sha1-mfiJMc/HYex2eLQdXXM2tbage/Q=
dependencies:
inherits "^2.0.4"
readable-stream "2 || 3"
thunks@^4.9.0:
version "4.9.6"
resolved "https://registry.npm.taobao.org/thunks/download/thunks-4.9.6.tgz#08f268ab32ad12b8e1838d2b819dbd7d9b3262a0"
integrity sha1-CPJoqzKtErjhg40rgZ29fZsyYqA=
time-stamp@^1.0.0: time-stamp@^1.0.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.npm.taobao.org/time-stamp/download/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" resolved "https://registry.npm.taobao.org/time-stamp/download/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3"
...@@ -2215,7 +2265,7 @@ use@^3.1.0: ...@@ -2215,7 +2265,7 @@ use@^3.1.0:
resolved "https://registry.npm.taobao.org/use/download/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" resolved "https://registry.npm.taobao.org/use/download/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
integrity sha1-1QyMrHmhn7wg8pEfVuuXP04QBw8= integrity sha1-1QyMrHmhn7wg8pEfVuuXP04QBw8=
util-deprecate@~1.0.1: util-deprecate@^1.0.1, util-deprecate@~1.0.1:
version "1.0.2" version "1.0.2"
resolved "https://registry.npm.taobao.org/util-deprecate/download/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" resolved "https://registry.npm.taobao.org/util-deprecate/download/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment