feat: upgradeFromMongo (wip) + panel UI improvements
This commit is contained in:
		| @@ -51,8 +51,7 @@ export default { | |||||||
|         telemetry: true, |         telemetry: true, | ||||||
|         title: siteConfig.title || 'Wiki', |         title: siteConfig.title || 'Wiki', | ||||||
|         upgrade: false, |         upgrade: false, | ||||||
|         upgMongo: 'mongodb://', |         upgMongo: 'mongodb://' | ||||||
|         upgUserGroups: false |  | ||||||
|       }, |       }, | ||||||
|       considerations: { |       considerations: { | ||||||
|         https: false, |         https: false, | ||||||
|   | |||||||
| @@ -33,7 +33,9 @@ | |||||||
|       border-top-left-radius: 4px; |       border-top-left-radius: 4px; | ||||||
|       border-top-right-radius: 4px; |       border-top-right-radius: 4px; | ||||||
|       background-color: mc('blue', '700'); |       background-color: mc('blue', '700'); | ||||||
|  |       background-image: linear-gradient(to bottom, mc('blue', '700') 0%, mc('blue', '800') 100%); | ||||||
|       border-bottom-color: mc('blue', '900'); |       border-bottom-color: mc('blue', '900'); | ||||||
|  |       box-shadow: inset 0 0 0 1px mc('blue', '600'), inset 0 0 0px 2px rgba(mc('blue', '800'), .5); | ||||||
|       color: #FFF; |       color: #FFF; | ||||||
|  |  | ||||||
|       > i::before { |       > i::before { | ||||||
| @@ -42,6 +44,10 @@ | |||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     & + .panel-content { | ||||||
|  |       box-shadow: inset 0 0 0 1px #FFF, inset 0 30px 80px -25px mc('blue', '100'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     > span { |     > span { | ||||||
|       font-weight: 500; |       font-weight: 500; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -108,4 +108,6 @@ langs: | |||||||
|   - |   - | ||||||
|     id: es |     id: es | ||||||
|     name: Spanish - Español |     name: Spanish - Español | ||||||
|  | rtlLangs: | ||||||
|  |   - fa | ||||||
| # --------------------------------- | # --------------------------------- | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ module.exports = () => { | |||||||
|   const favicon = require('serve-favicon') |   const favicon = require('serve-favicon') | ||||||
|   const http = require('http') |   const http = require('http') | ||||||
|   const Promise = require('bluebird') |   const Promise = require('bluebird') | ||||||
|   const fs = require('fs-extra') |   const fs = Promise.promisifyAll(require('fs-extra')) | ||||||
|   const yaml = require('js-yaml') |   const yaml = require('js-yaml') | ||||||
|   const _ = require('lodash') |   const _ = require('lodash') | ||||||
|   const cfgHelper = require('./helpers/config') |   const cfgHelper = require('./helpers/config') | ||||||
| @@ -236,22 +236,37 @@ module.exports = () => { | |||||||
|         }) |         }) | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       // Load configuration file |       // Update config file | ||||||
|       let confRaw = await fs.readFile(path.join(wiki.ROOTPATH, 'config.yml'), 'utf8') |       let confRaw = await fs.readFileAsync(path.join(wiki.ROOTPATH, 'config.yml'), 'utf8') | ||||||
|       let conf = yaml.safeLoad(confRaw) |       let conf = yaml.safeLoad(confRaw) | ||||||
|  |  | ||||||
|       // Update config |  | ||||||
|       conf.host = req.body.host |  | ||||||
|       conf.port = req.body.port |       conf.port = req.body.port | ||||||
|       conf.paths.repo = req.body.pathRepo |       conf.paths.repo = req.body.pathRepo | ||||||
|  |  | ||||||
|       // Generate session secret |  | ||||||
|       let sessionSecret = (await crypto.randomBytesAsync(32)).toString('hex') |  | ||||||
|       console.info(sessionSecret) |  | ||||||
|  |  | ||||||
|       // Save updated config to file |  | ||||||
|       confRaw = yaml.safeDump(conf) |       confRaw = yaml.safeDump(conf) | ||||||
|       await fs.writeFile(path.join(wiki.ROOTPATH, 'config.yml'), confRaw) |       await fs.writeFileAsync(path.join(wiki.ROOTPATH, 'config.yml'), confRaw) | ||||||
|  |  | ||||||
|  |       // Populate config namespaces | ||||||
|  |       wiki.config.auth = wiki.config.auth || {} | ||||||
|  |       wiki.config.features = wiki.config.features || {} | ||||||
|  |       wiki.config.git = wiki.config.git || {} | ||||||
|  |       wiki.config.logging = wiki.config.logging || {} | ||||||
|  |       wiki.config.site = wiki.config.site || {} | ||||||
|  |       wiki.config.theme = wiki.config.theme || {} | ||||||
|  |       wiki.config.uploads = wiki.config.uploads || {} | ||||||
|  |  | ||||||
|  |       // Site namespace | ||||||
|  |       wiki.config.site.title = req.body.title | ||||||
|  |       wiki.config.site.path = req.body.path | ||||||
|  |       wiki.config.site.lang = req.body.lang | ||||||
|  |       wiki.config.site.rtl = _.includes(wiki.data.rtlLangs, req.body.lang) | ||||||
|  |       wiki.config.site.sessionSecret = (await crypto.randomBytesAsync(32)).toString('hex') | ||||||
|  |  | ||||||
|  |       // Auth namespace | ||||||
|  |       wiki.config.auth.public = (req.body.public === 'true') | ||||||
|  |  | ||||||
|  |       // Logging namespace | ||||||
|  |       wiki.config.logging.telemetry = (req.body.telemetry === 'true') | ||||||
|  |  | ||||||
|       res.json({ ok: true }) |       res.json({ ok: true }) | ||||||
|     } catch (err) { |     } catch (err) { | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|  |  | ||||||
| const Promise = require('bluebird') | const Promise = require('bluebird') | ||||||
| // const pm2 = Promise.promisifyAll(require('pm2')) | // const pm2 = Promise.promisifyAll(require('pm2')) | ||||||
| // const _ = require('lodash') | const _ = require('lodash') | ||||||
| const cfgHelper = require('../helpers/config') | const cfgHelper = require('../helpers/config') | ||||||
|  |  | ||||||
| module.exports = { | module.exports = { | ||||||
| @@ -20,7 +20,7 @@ module.exports = { | |||||||
|     return new Promise((resolve, reject) => { |     return new Promise((resolve, reject) => { | ||||||
|       // Connect to MongoDB |       // Connect to MongoDB | ||||||
|  |  | ||||||
|       return mongo.connect(parsedMongoConStr, { |       mongo.connect(parsedMongoConStr, { | ||||||
|         autoReconnect: false, |         autoReconnect: false, | ||||||
|         reconnectTries: 2, |         reconnectTries: 2, | ||||||
|         reconnectInterval: 1000, |         reconnectInterval: 1000, | ||||||
| @@ -34,19 +34,33 @@ module.exports = { | |||||||
|  |  | ||||||
|           // Check if users table is populated |           // Check if users table is populated | ||||||
|           let userCount = await users.count() |           let userCount = await users.count() | ||||||
|           if (userCount < 1) { |           if (userCount < 2) { | ||||||
|             throw new Error('Users table is empty or invalid!') |             throw new Error('MongoDB Upgrade: Users table is empty!') | ||||||
|           } |           } | ||||||
|  |  | ||||||
|           // Fetch all users |           // Import all users | ||||||
|           let userData = await users.find({}).toArray() |           let userData = await users.find({ | ||||||
|           console.info(userData) |             email: { | ||||||
|  |               $not: 'guest' | ||||||
|  |             } | ||||||
|  |           }).toArray() | ||||||
|  |           await wiki.db.User.bulkCreate(_.map(userData, usr => { | ||||||
|  |             return { | ||||||
|  |               email: usr.email, | ||||||
|  |               name: usr.name || 'Imported User', | ||||||
|  |               password: usr.password || '', | ||||||
|  |               provider: usr.provider || 'local', | ||||||
|  |               providerId: usr.providerId || '', | ||||||
|  |               role: 'user', | ||||||
|  |               createdAt: usr.createdAt | ||||||
|  |             } | ||||||
|  |           })) | ||||||
|  |  | ||||||
|           resolve(true) |           resolve(true) | ||||||
|         } catch (err) { |         } catch (err) { | ||||||
|           reject(err) |           reject(err) | ||||||
|           db.close() |  | ||||||
|         } |         } | ||||||
|  |         db.close() | ||||||
|       }) |       }) | ||||||
|     }) |     }) | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -319,11 +319,6 @@ block body | |||||||
|                         label.label Connection String to Wiki.js 1.x MongoDB database |                         label.label Connection String to Wiki.js 1.x MongoDB database | ||||||
|                         input(type='text', placeholder='mongodb://', v-model='conf.upgMongo', data-vv-scope='upgrade', name='ipt-mongo', v-validate='{ required: true, min: 2 }') |                         input(type='text', placeholder='mongodb://', v-model='conf.upgMongo', data-vv-scope='upgrade', name='ipt-mongo', v-validate='{ required: true, min: 2 }') | ||||||
|                         span.desc A MongoDB database connection string where a Wiki.js 1.x installation is located. #[strong No alterations will be made to this database. ] |                         span.desc A MongoDB database connection string where a Wiki.js 1.x installation is located. #[strong No alterations will be made to this database. ] | ||||||
|                     section |  | ||||||
|                       p.control.is-fullwidth |  | ||||||
|                         input#ipt-public(type='checkbox', v-model='conf.upgUserGroups', data-vv-scope='upgrade', name='ipt-public') |  | ||||||
|                         label.label(for='ipt-public') Create groups based on individual permissions |  | ||||||
|                         span.desc User groups will be created based on existing users permissions. If multiple users have the exact same permission rules, they will be put in the same user group. |  | ||||||
|                   .panel-footer |                   .panel-footer | ||||||
|                     .progress-bar: div(v-bind:style='{width: currentProgress}') |                     .progress-bar: div(v-bind:style='{width: currentProgress}') | ||||||
|                     button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToAdmin', v-bind:disabled='loading') Back |                     button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToAdmin', v-bind:disabled='loading') Back | ||||||
|   | |||||||
| @@ -29,9 +29,9 @@ const args = require('yargs') | |||||||
| const dev = args.dev | const dev = args.dev | ||||||
|  |  | ||||||
| if (dev) { | if (dev) { | ||||||
|   console.info(colors.bgWhite.black(' Starting Fuse in DEVELOPER mode... ')) |   console.info(colors.bgWhite.black(' Starting Wiki.js in DEVELOPER mode... ')) | ||||||
| } else { | } else { | ||||||
|   console.info(colors.bgWhite.black(' Starting Fuse in BUILD mode... ')) |   console.info(colors.bgWhite.black(' Starting Wiki.js in BUILD mode... ')) | ||||||
| } | } | ||||||
|  |  | ||||||
| // ------------------------------------------------------- | // ------------------------------------------------------- | ||||||
|   | |||||||
							
								
								
									
										92
									
								
								wercker.yml
									
									
									
									
									
								
							
							
						
						
									
										92
									
								
								wercker.yml
									
									
									
									
									
								
							| @@ -1,92 +0,0 @@ | |||||||
| build: |  | ||||||
|   box: node:8 |  | ||||||
|   steps: |  | ||||||
|     - script: |  | ||||||
|       name: install dependencies |  | ||||||
|       code: | |  | ||||||
|         apt-get update |  | ||||||
|         apt-get install build-essential -y |  | ||||||
|         npm install -g yarn |  | ||||||
|     - script: |  | ||||||
|       name: yarn install |  | ||||||
|       code: | |  | ||||||
|         yarn config set cache-folder "$WERCKER_CACHE_DIR/yarn" |  | ||||||
|         yarn install |  | ||||||
|     - script: |  | ||||||
|       name: build |  | ||||||
|       code: yarn run build |  | ||||||
|     - npm-test |  | ||||||
|     - script: |  | ||||||
|       name: purge dev files |  | ||||||
|       code: | |  | ||||||
|         yarn install --production --ignore-scripts --prefer-offline |  | ||||||
|  |  | ||||||
| deploy-docker-master: |  | ||||||
|   box: node:8-alpine |  | ||||||
|   steps: |  | ||||||
|     - script: |  | ||||||
|       name: install dependencies |  | ||||||
|       code: | |  | ||||||
|         apk update |  | ||||||
|         apk add bash curl git openssh |  | ||||||
|     - script: |  | ||||||
|       name: copy app files |  | ||||||
|       code: | |  | ||||||
|         mkdir -p /var/wiki |  | ||||||
|         cp -LR assets node_modules server config.sample.yml package.json LICENSE /var/wiki |  | ||||||
|         rm -rf /pipeline |  | ||||||
|     - internal/docker-push: |  | ||||||
|         username: $DOCKER_HUB_USERNAME |  | ||||||
|         password: $DOCKER_HUB_PASSWORD |  | ||||||
|         tag: latest, master |  | ||||||
|         ports: "3000" |  | ||||||
|         working-dir: /var/wiki |  | ||||||
|         entrypoint: node server |  | ||||||
|         env: "WIKI_JS_HEROKU=1" |  | ||||||
|         repository: requarks/wiki |  | ||||||
|         registry: https://registry.hub.docker.com |  | ||||||
|  |  | ||||||
| deploy-docker-dev: |  | ||||||
|   box: node:8-alpine |  | ||||||
|   steps: |  | ||||||
|     - script: |  | ||||||
|       name: install dependencies |  | ||||||
|       code: | |  | ||||||
|         apk update |  | ||||||
|         apk add bash curl git openssh |  | ||||||
|     - script: |  | ||||||
|       name: copy app files |  | ||||||
|       code: | |  | ||||||
|         mkdir -p /var/wiki |  | ||||||
|         cp -LR assets node_modules server config.sample.yml package.json LICENSE /var/wiki |  | ||||||
|         rm -rf /pipeline |  | ||||||
|     - internal/docker-push: |  | ||||||
|         username: $DOCKER_HUB_USERNAME |  | ||||||
|         password: $DOCKER_HUB_PASSWORD |  | ||||||
|         tag: dev |  | ||||||
|         ports: "3000" |  | ||||||
|         working-dir: /var/wiki |  | ||||||
|         entrypoint: node server |  | ||||||
|         repository: requarks/wiki |  | ||||||
|         registry: https://registry.hub.docker.com |  | ||||||
|  |  | ||||||
| deploy-github: |  | ||||||
|   box: node:8 |  | ||||||
|   steps: |  | ||||||
|     - script: |  | ||||||
|       name: package |  | ||||||
|       code: | |  | ||||||
|         tar -chzf wiki-js.tar.gz assets server config.sample.yml package.json wiki.js LICENSE |  | ||||||
|         tar -chzf node_modules.tar.gz node_modules |  | ||||||
|         SEMVER_NEXT=`curl --request POST --url https://beta.requarks.io/api/version/increment --header "authorization: $WIKIJSORG_TOKEN" --header 'cache-control: no-cache' --header 'content-type: application/json' --data '{"channel": "stable"}'` |  | ||||||
|     - github-create-release: |  | ||||||
|       token: $GITHUB_TOKEN |  | ||||||
|       tag: "v${SEMVER_NEXT}" |  | ||||||
|       prerelease: true |  | ||||||
|       title: "$SEMVER_NEXT Release" |  | ||||||
|     - github-upload-asset: |  | ||||||
|       token: $GITHUB_TOKEN |  | ||||||
|       file: wiki-js.tar.gz |  | ||||||
|     - github-upload-asset: |  | ||||||
|       token: $GITHUB_TOKEN |  | ||||||
|       file: node_modules.tar.gz |  | ||||||
		Reference in New Issue
	
	Block a user