소스 검색

feat: apollo upgrade to 2.0 + dev improvements + localization

NGPixel 7 년 전
부모
커밋
49834461a6

+ 14 - 5
client/app.js

@@ -1,12 +1,16 @@
 'use strict'
 
+/* global siteConfig */
+
 import Vue from 'vue'
 import VueRouter from 'vue-router'
 import VueClipboards from 'vue-clipboards'
 import VueSimpleBreakpoints from 'vue-simple-breakpoints'
 import VeeValidate from 'vee-validate'
 import { ApolloClient } from 'apollo-client'
-import { BatchHttpLink } from 'apollo-link-batch-http'
+import { createPersistedQueryLink } from 'apollo-link-persisted-queries'
+// import { BatchHttpLink } from 'apollo-link-batch-http'
+import { createHttpLink } from 'apollo-link-http'
 import { InMemoryCache } from 'apollo-cache-inmemory'
 import VueApollo from 'vue-apollo'
 import Vuetify from 'vuetify'
@@ -37,17 +41,22 @@ window.WIKI = null
 window.boot = boot
 window.Hammer = Hammer
 
+moment.locale(siteConfig.lang)
+
 // ====================================
 // Initialize Apollo Client (GraphQL)
 // ====================================
 
 const graphQLEndpoint = window.location.protocol + '//' + window.location.host + '/graphql'
 
+const graphQLLink = createPersistedQueryLink().concat(createHttpLink({
+  includeExtensions: true,
+  uri: graphQLEndpoint,
+  credentials: 'include'
+}))
+
 window.graphQL = new ApolloClient({
-  link: new BatchHttpLink({
-    uri: graphQLEndpoint,
-    credentials: 'include'
-  }),
+  link: graphQLLink,
   cache: new InMemoryCache(),
   connectToDevTools: (process.env.node_env === 'development')
 })

+ 2 - 0
client/components/admin/admin-locale.vue

@@ -189,6 +189,7 @@ export default {
       const resp = _.get(respRaw, 'data.localization.updateLocale.responseResult', {})
       if (resp.succeeded) {
         WIKI.$i18n.i18next.changeLanguage(this.selectedLocale)
+        WIKI.$moment.locale(this.selectedLocale)
         this.$store.commit('showNotification', {
           message: 'Locale settings updated successfully.',
           style: 'success',
@@ -207,6 +208,7 @@ export default {
   apollo: {
     locales: {
       query: localesQuery,
+      fetchPolicy: 'network-only',
       update: (data) => data.localization.locales.map(lc => ({ ...lc, isDownloading: false })),
       watchLoading (isLoading) {
         this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-locale-refresh')

+ 13 - 13
client/components/admin/admin-system.vue

@@ -2,8 +2,8 @@
   v-container(fluid, fill-height, grid-list-lg)
     v-layout(row, wrap)
       v-flex(xs12)
-        .headline.primary--text System Info
-        .subheading.grey--text Information about your system
+        .headline.primary--text {{ $t('admin:system.title') }}
+        .subheading.grey--text {{ $t('admin:system.subtitle') }}
         v-layout.mt-3(row wrap)
           v-flex(lg6 xs12)
             v-card
@@ -14,55 +14,55 @@
                   v-list-tile-avatar
                     v-icon.blue.white--text system_update_alt
                   v-list-tile-content
-                    v-list-tile-title Current Version
+                    v-list-tile-title {{ $t('admin:system.currentVersion') }}
                     v-list-tile-sub-title {{ info.currentVersion }}
                 v-list-tile(avatar)
                   v-list-tile-avatar
                     v-icon.blue.white--text open_in_browser
                   v-list-tile-content
-                    v-list-tile-title Latest Version
+                    v-list-tile-title {{ $t('admin:system.latestVersion') }}
                     v-list-tile-sub-title {{ info.latestVersion }}
                   v-list-tile-action
-                    v-list-tile-action-text Published X days ago
+                    v-list-tile-action-text {{ $t('admin:system.published') }} {{ info.latestVersionReleaseDate | moment('from') }}
 
                 v-divider
 
-                v-subheader Host Information
+                v-subheader {{ $t('admin:system.hostInfo') }}
                 v-list-tile(avatar)
                   v-list-tile-avatar
                     v-icon.blue-grey.white--text bubble_chart
                   v-list-tile-content
-                    v-list-tile-title Operating System
+                    v-list-tile-title {{ $t('admin:system.os') }}
                     v-list-tile-sub-title {{ info.operatingSystem }}
                 v-list-tile(avatar)
                   v-list-tile-avatar
                     v-icon.blue-grey.white--text computer
                   v-list-tile-content
-                    v-list-tile-title Hostname
+                    v-list-tile-title {{ $t('admin:system.hostname') }}
                     v-list-tile-sub-title {{ info.hostname }}
                 v-list-tile(avatar)
                   v-list-tile-avatar
                     v-icon.blue-grey.white--text nfc
                   v-list-tile-content
-                    v-list-tile-title CPU Cores
+                    v-list-tile-title {{ $t('admin:system.cpuCores') }}
                     v-list-tile-sub-title {{ info.cpuCores }}
                 v-list-tile(avatar)
                   v-list-tile-avatar
                     v-icon.blue-grey.white--text memory
                   v-list-tile-content
-                    v-list-tile-title Total RAM
+                    v-list-tile-title {{ $t('admin:system.totalRAM') }}
                     v-list-tile-sub-title {{ info.ramTotal }}
                 v-list-tile(avatar)
                   v-list-tile-avatar
                     v-icon.blue-grey.white--text last_page
                   v-list-tile-content
-                    v-list-tile-title Working Directory
+                    v-list-tile-title {{ $t('admin:system.workingDirectory') }}
                     v-list-tile-sub-title {{ info.workingDirectory }}
                 v-list-tile(avatar)
                   v-list-tile-avatar
                     v-icon.blue-grey.white--text settings
                   v-list-tile-content
-                    v-list-tile-title Configuration File
+                    v-list-tile-title {{ $t('admin:system.configFile') }}
                     v-list-tile-sub-title {{ info.configFile }}
 
           v-flex(lg6 xs12)
@@ -87,7 +87,7 @@
                     v-list-tile-title {{ info.redisVersion }}
                     v-list-tile-sub-title {{ info.redisHost }}
                   v-list-tile-action
-                    v-list-tile-action-text RAM Usage: {{ info.redisUsedRAM }} / {{ info.redisTotalRAM }}
+                    v-list-tile-action-text {{ $t('admin:system.ramUsage', { used: info.redisUsedRAM, total: info.redisTotalRAM }) }}
 
                 v-divider
 

+ 1 - 1
client/components/login.vue

@@ -35,7 +35,7 @@
           button.button.is-blue.is-fullwidth(@click='verifySecurityCode')
             span {{ $t('auth:tfa.verifyToken') }}
       .login-copyright
-        span {{ $t('footer.poweredBy') }}
+        span {{ $t('common:footer.poweredBy') }}
         a(href='https://wiki.js.org', rel='external', title='Wiki.js') Wiki.js
 
     v-snackbar(

+ 13 - 0
client/graph/admin-users-query-list.gql

@@ -0,0 +1,13 @@
+query {
+  users {
+    list {
+      id
+      name
+      email
+      provider
+      role
+      createdAt
+      updatedAt
+    }
+  }
+}

+ 6 - 1
dev/webpack/webpack.dev.js

@@ -15,6 +15,8 @@ const babelDir = path.join(process.cwd(), '.webpack-cache/babel')
 
 process.noDeprecation = true
 
+fs.emptyDirSync(path.join(process.cwd(), 'assets'))
+
 module.exports = {
   mode: 'development',
   entry: {
@@ -143,7 +145,10 @@ module.exports = {
       {
         test: /\.(graphql|gql)$/,
         exclude: /node_modules/,
-        loader: 'graphql-tag/loader'
+        use: [
+          { loader: 'graphql-persisted-document-loader' },
+          { loader: 'graphql-tag/loader' }
+        ]
       },
       {
         test: /.jsx$/,

+ 6 - 1
dev/webpack/webpack.prod.js

@@ -19,6 +19,8 @@ const babelDir = path.join(process.cwd(), '.webpack-cache/babel')
 
 process.noDeprecation = true
 
+fs.emptyDirSync(path.join(process.cwd(), 'assets'))
+
 module.exports = {
   mode: 'production',
   entry: {
@@ -149,7 +151,10 @@ module.exports = {
       {
         test: /\.(graphql|gql)$/,
         exclude: /node_modules/,
-        loader: 'graphql-tag/loader'
+        use: [
+          { loader: 'graphql-persisted-document-loader' },
+          { loader: 'graphql-tag/loader' }
+        ]
       },
       {
         test: /.jsx$/,

+ 40 - 37
package.json

@@ -37,23 +37,25 @@
     "node": ">=8.11"
   },
   "dependencies": {
-    "apollo-server-express": "1.3.6",
+    "apollo-server": "2.0.0-rc.2",
+    "apollo-server-express": "2.0.0-rc.2",
     "auto-load": "3.0.0",
     "axios": "0.18.0",
     "bcryptjs-then": "1.0.1",
     "bluebird": "3.5.1",
     "body-parser": "1.18.3",
-    "bugsnag": "2.4.0",
+    "bugsnag": "2.4.3",
     "bull": "3.4.2",
+    "chalk": "2.4.1",
     "cheerio": "1.0.0-rc.2",
     "child-process-promise": "2.2.1",
-    "chokidar": "2.0.3",
+    "chokidar": "2.0.4",
     "compression": "1.7.2",
     "connect-redis": "3.3.3",
     "cookie-parser": "1.4.3",
     "cors": "2.8.4",
-    "dependency-graph": "0.7.0",
-    "diff2html": "2.3.3",
+    "dependency-graph": "0.7.1",
+    "diff2html": "2.4.0",
     "dotize": "^0.2.0",
     "execa": "0.10.0",
     "express": "4.16.3",
@@ -68,21 +70,21 @@
     "graphql": "0.13.2",
     "graphql-list-fields": "2.0.2",
     "graphql-tools": "3.0.2",
-    "i18next": "11.3.2",
+    "i18next": "11.3.3",
     "i18next-express-middleware": "1.1.1",
     "i18next-localstorage-cache": "1.1.1",
     "i18next-node-fs-backend": "1.0.0",
-    "image-size": "0.6.2",
+    "image-size": "0.6.3",
     "ioredis": "3.2.2",
     "js-yaml": "3.12.0",
-    "jsonwebtoken": "8.2.2",
+    "jsonwebtoken": "8.3.0",
     "klaw": "2.1.1",
     "knex": "0.14.6",
     "lodash": "4.17.10",
     "markdown-it": "8.4.1",
     "markdown-it-abbr": "1.0.4",
-    "markdown-it-anchor": "4.0.0",
-    "markdown-it-attrs": "2.1.0",
+    "markdown-it-anchor": "5.0.2",
+    "markdown-it-attrs": "2.2.0",
     "markdown-it-emoji": "1.4.0",
     "markdown-it-expand-tabs": "1.0.13",
     "markdown-it-external-links": "0.0.6",
@@ -93,10 +95,10 @@
     "markdown-it-sub": "1.0.0",
     "markdown-it-sup": "1.0.0",
     "markdown-it-task-lists": "2.1.1",
-    "mathjax-node": "2.1.0",
+    "mathjax-node": "2.1.1",
     "mime-types": "2.1.18",
     "moment": "2.22.2",
-    "moment-timezone": "0.5.17",
+    "moment-timezone": "0.5.21",
     "mongodb": "3.1.0-beta4",
     "mssql": "4.1.0",
     "multer": "1.3.0",
@@ -124,7 +126,7 @@
     "pm2": "2.10.4",
     "pug": "2.0.3",
     "qr-image": "3.2.0",
-    "raven": "2.6.2",
+    "raven": "2.6.3",
     "read-chunk": "2.1.0",
     "remove-markdown": "0.3.0",
     "request": "2.87.0",
@@ -134,29 +136,30 @@
     "serve-favicon": "2.5.0",
     "sqlite3": "4.0.0",
     "uuid": "3.2.1",
-    "validator": "10.2.0",
+    "validator": "10.4.0",
     "validator-as-promised": "1.0.2",
-    "winston": "3.0.0-rc2",
+    "winston": "3.0.0",
     "yargs": "11.0.0"
   },
   "devDependencies": {
     "@panter/vue-i18next": "0.11.0",
-    "@vue/cli": "3.0.0-beta.15",
-    "apollo-cache-inmemory": "1.2.2",
-    "apollo-client": "2.3.2",
+    "@vue/cli": "3.0.0-rc.3",
+    "apollo-cache-inmemory": "1.2.5",
+    "apollo-client": "2.3.5",
     "apollo-fetch": "0.7.0",
     "apollo-link": "1.2.2",
     "apollo-link-batch-http": "1.2.2",
-    "apollo-link-error": "1.0.9",
+    "apollo-link-error": "1.1.0",
     "apollo-link-http": "1.5.4",
-    "autoprefixer": "8.6.0",
+    "apollo-link-persisted-queries": "0.2.1",
+    "autoprefixer": "8.6.3",
     "babel-cli": "6.26.0",
     "babel-core": "6.26.3",
-    "babel-eslint": "8.2.3",
+    "babel-eslint": "8.2.5",
     "babel-jest": "23.0.1",
     "babel-loader": "7.1.4",
     "babel-plugin-graphql-tag": "1.6.0",
-    "babel-plugin-lodash": "3.3.2",
+    "babel-plugin-lodash": "3.3.4",
     "babel-plugin-transform-imports": "1.5.0",
     "babel-polyfill": "6.26.0",
     "babel-preset-env": "1.7.0",
@@ -165,12 +168,11 @@
     "cache-loader": "1.2.2",
     "chart.js": "2.7.2",
     "clean-webpack-plugin": "0.1.19",
-    "colors": "1.3.0",
     "copy-webpack-plugin": "4.5.1",
     "css-loader": "0.28.11",
     "cssnano": "4.0.0-rc.2",
     "duplicate-package-checker-webpack-plugin": "3.0.0",
-    "eslint": "4.19.1",
+    "eslint": "5.0.0",
     "eslint-config-requarks": "1.0.7",
     "eslint-config-standard": "11.0.0",
     "eslint-plugin-import": "2.12.0",
@@ -180,15 +182,16 @@
     "eslint-plugin-vue": "4.5.0",
     "file-loader": "1.1.11",
     "graphiql": "0.11.11",
+    "graphql-persisted-document-loader": "1.0.1",
     "graphql-tag": "^2.9.2",
-    "graphql-voyager": "1.0.0-rc.15",
+    "graphql-voyager": "1.0.0-rc.19",
     "hammerjs": "2.0.8",
     "html-webpack-plugin": "3.2.0",
     "html-webpack-pug-plugin": "0.3.0",
     "i18next-xhr-backend": "1.5.1",
     "ignore-loader": "0.1.2",
     "jest": "23.1.0",
-    "jest-junit": "5.0.0",
+    "jest-junit": "5.1.0",
     "js-cookie": "2.2.0",
     "lodash-webpack-plugin": "0.11.5",
     "mini-css-extract-plugin": "0.4.0",
@@ -206,9 +209,9 @@
     "pug-loader": "2.4.0",
     "pug-plain-loader": "1.0.0",
     "raw-loader": "0.5.1",
-    "react": "16.4.0",
-    "react-dom": "16.4.0",
-    "sass-loader": "7.0.2",
+    "react": "16.4.1",
+    "react-dom": "16.4.1",
+    "sass-loader": "7.0.3",
     "sass-resources-loader": "1.3.3",
     "script-ext-html-webpack-plugin": "2.0.1",
     "simple-progress-webpack-plugin": "1.1.2",
@@ -217,29 +220,29 @@
     "stylus-loader": "3.0.2",
     "twemoji-awesome": "1.0.6",
     "url-loader": "1.0.1",
-    "vee-validate": "2.1.0-beta.1",
+    "vee-validate": "2.1.0-beta.2",
     "velocity-animate": "1.5.1",
     "vue": "2.5.16",
-    "vue-apollo": "3.0.0-beta.16",
-    "vue-chartjs": "3.3.1",
+    "vue-apollo": "3.0.0-beta.19",
+    "vue-chartjs": "3.3.2",
     "vue-clipboards": "1.2.4",
     "vue-codemirror": "4.0.5",
     "vue-hot-reload-api": "2.3.0",
     "vue-loader": "15.2.4",
     "vue-material-design-icons": "1.5.1",
-    "vue-moment": "4.0.0-0",
+    "vue-moment": "4.0.0",
     "vue-router": "3.0.1",
     "vue-simple-breakpoints": "1.0.3",
     "vue-template-compiler": "2.5.16",
-    "vuetify": "1.0.18",
+    "vuetify": "1.0.19",
     "vuex": "3.0.1",
     "vuex-persistedstate": "2.5.4",
-    "webpack": "4.10.2",
+    "webpack": "4.12.0",
     "webpack-bundle-analyzer": "2.13.1",
-    "webpack-cli": "3.0.1",
+    "webpack-cli": "3.0.8",
     "webpack-dev-middleware": "3.1.3",
     "webpack-hot-middleware": "2.22.2",
-    "webpack-merge": "4.1.2",
+    "webpack-merge": "4.1.3",
     "whatwg-fetch": "2.0.4",
     "write-file-webpack-plugin": "4.3.2"
   },

+ 1 - 0
server/db/models/users.js

@@ -171,6 +171,7 @@ module.exports = class User extends Model {
   }
 
   static async login (opts, context) {
+    console.info(context)
     if (_.has(WIKI.auth.strategies, opts.strategy)) {
       _.set(context.req, 'body.email', opts.username)
       _.set(context.req, 'body.password', opts.password)

+ 9 - 6
server/graph/index.js

@@ -1,6 +1,6 @@
 const _ = require('lodash')
 const fs = require('fs')
-const gqlTools = require('graphql-tools')
+// const gqlTools = require('graphql-tools')
 const path = require('path')
 const autoload = require('auto-load')
 
@@ -24,11 +24,14 @@ resolversObj.forEach(resolver => {
   _.merge(resolvers, resolver)
 })
 
-const Schema = gqlTools.makeExecutableSchema({
-  typeDefs,
-  resolvers
-})
+// const Schema = gqlTools.makeExecutableSchema({
+//   typeDefs,
+//   resolvers
+// })
 
 WIKI.logger.info(`GraphQL Schema: [ OK ]`)
 
-module.exports = Schema
+module.exports = {
+  typeDefs,
+  resolvers
+}

+ 0 - 2
server/graph/resolvers/system.js

@@ -29,8 +29,6 @@ module.exports = {
         osLabel = `${os.type()} - ${osInfo.dist} (${osInfo.codename || os.platform()}) ${osInfo.release || os.release()} ${os.arch()}`
       }
 
-      console.info(WIKI.db.knex.client)
-
       return {
         configFile: path.join(process.cwd(), 'config.yml'),
         currentVersion: WIKI.version,

+ 4 - 1
server/graph/resolvers/user.js

@@ -21,7 +21,10 @@ module.exports = {
         .select('id', 'email', 'name', 'provider', 'role', 'createdAt', 'updatedAt')
     },
     async single(obj, args, context, info) {
-      return WIKI.db.users.query().findById(args.id)
+      let usr = await WIKI.db.users.query().findById(args.id)
+      usr.password = ''
+      usr.tfaSecret = ''
+      return usr
     }
   },
   UserMutation: {

+ 7 - 15
server/graph/schemas/common.graphql

@@ -13,14 +13,6 @@ enum RightRole {
   manage
 }
 
-# INTERFACES
-
-interface Base {
-  id: Int!
-  createdAt: Date
-  updatedAt: Date
-}
-
 # TYPES
 
 type KeyValuePair {
@@ -43,7 +35,7 @@ type ResponseStatus {
   message: String
 }
 
-type Comment implements Base {
+type Comment {
   id: Int!
   createdAt: Date
   updatedAt: Date
@@ -52,7 +44,7 @@ type Comment implements Base {
   author: User!
 }
 
-type Document implements Base {
+type Document {
   id: Int!
   createdAt: Date
   updatedAt: Date
@@ -68,7 +60,7 @@ type Document implements Base {
   tags: [Tag]
 }
 
-type File implements Base {
+type File {
   id: Int!
   createdAt: Date
   updatedAt: Date
@@ -81,7 +73,7 @@ type File implements Base {
   folder: Folder
 }
 
-type Folder implements Base {
+type Folder {
   id: Int!
   createdAt: Date
   updatedAt: Date
@@ -89,7 +81,7 @@ type Folder implements Base {
   files: [File]
 }
 
-type Right implements Base {
+type Right {
   id: Int!
   createdAt: Date
   updatedAt: Date
@@ -106,7 +98,7 @@ type SearchResult {
   tags: [String]
 }
 
-type Setting implements Base {
+type Setting {
   id: Int!
   createdAt: Date
   updatedAt: Date
@@ -115,7 +107,7 @@ type Setting implements Base {
 }
 
 # Tags are attached to one or more documents
-type Tag implements Base {
+type Tag {
   id: Int!
   createdAt: Date
   updatedAt: Date

+ 25 - 15
server/master.js

@@ -9,8 +9,7 @@ const http = require('http')
 const path = require('path')
 const session = require('express-session')
 const SessionRedisStore = require('connect-redis')(session)
-const graphqlApollo = require('apollo-server-express')
-const graphqlSchema = require('./graph')
+const { ApolloServer } = require('apollo-server-express')
 // const oauth2orize = require('oauth2orize')
 
 /* global WIKI */
@@ -124,23 +123,34 @@ module.exports = async () => {
   }
 
   // ----------------------------------------
-  // Controllers
+  // Apollo Server (GraphQL)
+  // ----------------------------------------
+
+  const graphqlSchema = require('./graph')
+  const apolloServer = new ApolloServer({
+    ...graphqlSchema,
+    context: ({ req, res }) => ({ req, res })
+  })
+  apolloServer.applyMiddleware({ app })
+
+  // ----------------------------------------
+  // Routing
   // ----------------------------------------
 
   app.use('/', ctrl.auth)
 
-  app.use('/graphql', (req, res, next) => {
-    graphqlApollo.graphqlExpress({
-      schema: graphqlSchema,
-      context: { req, res },
-      formatError: (err) => {
-        return {
-          message: err.message
-        }
-      }
-    })(req, res, next)
-  })
-  app.use('/graphiql', graphqlApollo.graphiqlExpress({ endpointURL: '/graphql' }))
+  // app.use('/graphql', (req, res, next) => {
+  //   graphqlApollo.graphqlExpress({
+  //     schema: graphqlSchema,
+  //     context: { req, res },
+  //     formatError: (err) => {
+  //       return {
+  //         message: err.message
+  //       }
+  //     }
+  //   })(req, res, next)
+  // })
+  // app.use('/graphiql', graphqlApollo.graphiqlExpress({ endpointURL: '/graphql' }))
 
   app.use('/', mw.auth, ctrl.common)
 

+ 39 - 19
wiki.js

@@ -12,6 +12,8 @@ const pm2 = Promise.promisifyAll(require('pm2'))
 const ora = require('ora')
 const path = require('path')
 const cluster = require('cluster')
+const _ = require('lodash')
+const chalk = require('chalk')
 
 const ROOTPATH = process.cwd()
 
@@ -81,9 +83,19 @@ const init = {
         hotMiddleware: require('webpack-hot-middleware')(global.WP)
       }
       global.WP_DEV.devMiddleware.waitUntilValid(() => {
-        console.info('>>> Starting Wiki.js in DEVELOPER mode...')
+        console.info(chalk.yellow.bold('>>> Starting Wiki.js in DEVELOPER mode...'))
         require('./server')
 
+        process.stdin.setEncoding('utf8')
+        process.stdin.on('data', data => {
+          if (_.trim(data) === 'rs') {
+            console.warn(chalk.yellow.bold('--- >>>>>>>>>>>>>>>>>>>>>>>> ---'))
+            console.warn(chalk.yellow.bold('--- Manual restart requested ---'))
+            console.warn(chalk.yellow.bold('--- <<<<<<<<<<<<<<<<<<<<<<<< ---'))
+            this.reload()
+          }
+        })
+
         const devWatcher = chokidar.watch([
           './server',
           '!./server/views/master.pug'
@@ -92,30 +104,38 @@ const init = {
           atomic: 400
         })
         devWatcher.on('ready', () => {
-          devWatcher.on('all', async () => {
-            console.warn('--- >>>>>>>>>>>>>>>>>>>>>>>>>>>> ---')
-            console.warn('--- Changes detected: Restarting ---')
-            console.warn('--- <<<<<<<<<<<<<<<<<<<<<<<<<<<< ---')
-            console.warn('--- Closing DB connections...')
-            await global.WIKI.db.knex.destroy()
-            console.warn('--- Closing Redis connections...')
-            await global.WIKI.redis.quit()
-            console.warn('--- Closing Server connections...')
-            global.WIKI.server.destroy(() => {
-              global.WIKI = {}
-              Object.keys(require.cache).forEach(function(id) {
-                if (/[/\\]server[/\\]/.test(id)) {
-                  delete require.cache[id]
-                }
-              })
-              require('./server')
-            })
+          devWatcher.on('all', () => {
+            console.warn(chalk.yellow.bold('--- >>>>>>>>>>>>>>>>>>>>>>>>>>>> ---'))
+            console.warn(chalk.yellow.bold('--- Changes detected: Restarting ---'))
+            console.warn(chalk.yellow.bold('--- <<<<<<<<<<<<<<<<<<<<<<<<<<<< ---'))
+            this.reload()
           })
         })
       })
     } else {
       require('./server')
     }
+  },
+  async reload() {
+    console.warn(chalk.yellow('--- Closing DB connections...'))
+    await global.WIKI.db.knex.destroy()
+    console.warn(chalk.yellow('--- Closing Redis connections...'))
+    await global.WIKI.redis.quit()
+    console.warn(chalk.yellow('--- Closing Server connections...'))
+    global.WIKI.server.destroy(() => {
+      global.WIKI = {}
+      Object.keys(require.cache).forEach(id => {
+        if (/[/\\]server[/\\]/.test(id)) {
+          delete require.cache[id]
+        }
+      })
+      Object.keys(module.constructor._pathCache).forEach(cacheKey => {
+        if (/[/\\]server[/\\]/.test(cacheKey)) {
+          delete module.constructor._pathCache[cacheKey]
+        }
+      })
+      require('./server')
+    })
   }
 }
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 441 - 199
yarn.lock


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.