fix: migrate setup to vuetify + remove git related steps

This commit is contained in:
NGPixel
2018-03-11 00:11:32 -05:00
parent 16d3336cd0
commit 6baa277f51
10 changed files with 405 additions and 661 deletions

View File

@@ -42,7 +42,6 @@ defaults:
enabled: true
site:
lang: en
path: ''
rtl: false
title: Wiki.js
# System defaults
@@ -103,36 +102,47 @@ langs:
-
id: en
name: English
original: English
-
id: zh
name: Chinese - 中文
name: Chinese
original: 中文
-
id: nl
name: Dutch - Nederlands
name: Dutch
original: Nederlands
-
id: fr
name: French - Français
name: French
original: Français
-
id: de
name: German - Deutsch
name: German
original: Deutsch
-
id: ja
name: Japanese - 日本語
name: Japanese
original: 日本語
-
id: ko
name: Korean - 한국어
name: Korean
original: 한국어
-
id: fa
name: Persian (Fārsi) - فارسی
name: Persian (Fārsi)
original: فارسی
-
id: pt
name: Portuguese - Português
name: Portuguese
original: Português
-
id: ru
name: Russian - Русский
name: Russian
original: Русский
-
id: es
name: Spanish - Español
name: Spanish
original: Español
rtlLangs:
- fa
# ---------------------------------

View File

@@ -34,8 +34,6 @@ module.exports = () => {
let app = express()
app.use(compression())
let server
// ----------------------------------------
// Public Assets
// ----------------------------------------
@@ -91,14 +89,20 @@ module.exports = () => {
if (!semver.satisfies(semver.clean(process.version), '>=8.9.0')) {
throw new Error('Node.js version is too old. Minimum is 8.9.0.')
}
return 'Node.js ' + process.version + ' detected. Minimum is 8.9.0.'
return {
title: 'Node.js ' + process.version + ' detected.',
subtitle: ' Minimum is 8.9.0.'
}
},
() => {
return Promise.try(() => {
require('crypto')
}).catch(err => {
throw new Error('Crypto Node.js module is not available.')
}).return('Node.js Crypto module is available.')
}).return({
title: 'Node.js Crypto module is available.',
subtitle: 'Crypto module is required.'
})
},
() => {
const exec = require('child_process').exec
@@ -112,16 +116,22 @@ module.exports = () => {
if (!gitver || !semver.satisfies(semver.clean(gitver), '>=2.7.4')) {
reject(new Error('Git version is too old. Minimum is 2.7.4.'))
}
resolve('Git ' + gitver + ' detected. Minimum is 2.7.4.')
resolve({
title: 'Git ' + gitver + ' detected.',
subtitle: 'Minimum is 2.7.4.'
})
})
})
},
() => {
const os = require('os')
if (os.totalmem() < 1000 * 1000 * 512) {
throw new Error('Not enough memory. Minimum is 512 MB.')
if (os.totalmem() < 1000 * 1000 * 768) {
throw new Error('Not enough memory. Minimum is 768 MB.')
}
return {
title: filesize(os.totalmem()) + ' of system memory available.',
subtitle: 'Minimum is 768 MB.'
}
return filesize(os.totalmem()) + ' of system memory available. Minimum is 512 MB.'
},
() => {
let fs = require('fs')
@@ -129,7 +139,10 @@ module.exports = () => {
fs.accessSync(path.join(WIKI.ROOTPATH, 'config.yml'), (fs.constants || fs).W_OK)
}).catch(err => {
throw new Error('config.yml file is not writable by Node.js process or was not created properly.')
}).return('config.yml is writable by the setup process.')
}).return({
title: 'config.yml is writable by the setup process.',
subtitle: 'Setup will write to this file.'
})
}
], test => test()).then(results => {
res.json({ ok: true, results })
@@ -251,13 +264,14 @@ module.exports = () => {
let conf = yaml.safeLoad(confRaw)
conf.port = req.body.port
conf.paths.repo = req.body.pathRepo
conf.paths.data = req.body.pathData
conf.paths.content = req.body.pathContent
confRaw = yaml.safeDump(conf)
await fs.writeFileAsync(path.join(WIKI.ROOTPATH, 'config.yml'), confRaw)
_.set(WIKI.config, 'port', req.body.port)
_.set(WIKI.config, 'paths.repo', req.body.pathRepo)
_.set(WIKI.config, 'paths.content', req.body.pathContent)
// Populate config namespaces
WIKI.config.auth = WIKI.config.auth || {}
@@ -270,7 +284,6 @@ module.exports = () => {
// Site namespace
_.set(WIKI.config.site, 'title', req.body.title)
_.set(WIKI.config.site, 'path', req.body.path)
_.set(WIKI.config.site, 'lang', req.body.lang)
_.set(WIKI.config.site, 'rtl', _.includes(WIKI.data.rtlLangs, req.body.lang))
_.set(WIKI.config.site, 'sessionSecret', (await crypto.randomBytesAsync(32)).toString('hex'))
@@ -280,32 +293,6 @@ module.exports = () => {
_.set(WIKI.config.auth, 'strategies.local.enabled', true)
_.set(WIKI.config.auth, 'strategies.local.allowSelfRegister', req.body.selfRegister === 'true')
// Git namespace
_.set(WIKI.config.git, 'enabled', req.body.gitUseRemote === 'true')
if (WIKI.config.git.enabled) {
_.set(WIKI.config.git, 'url', req.body.gitUrl)
_.set(WIKI.config.git, 'branch', req.body.gitBranch)
_.set(WIKI.config.git, 'author.defaultEmail', req.body.gitServerEmail)
_.set(WIKI.config.git, 'author.useUserEmail', req.body.gitShowUserEmail)
_.set(WIKI.config.git, 'sslVerify', req.body.gitAuthSSL === 'true')
_.set(WIKI.config.git, 'auth.type', req.body.gitAuthType)
switch (WIKI.config.git.auth.type) {
case 'basic':
_.set(WIKI.config.git, 'auth.user', req.body.gitAuthUser)
_.set(WIKI.config.git, 'auth.pass', req.body.gitAuthPass)
break
case 'ssh':
_.set(WIKI.config.git, 'auth.keyPath', req.body.gitAuthSSHKey)
break
case 'sshenv':
_.set(WIKI.config.git, 'auth.keyEnv', req.body.gitAuthSSHKeyEnv)
break
case 'sshdb':
_.set(WIKI.config.git, 'auth.keyContents', req.body.gitAuthSSHKeyDB)
break
}
}
// Logging namespace
WIKI.config.logging.telemetry = (req.body.telemetry === 'true')
@@ -332,7 +319,7 @@ module.exports = () => {
}).end()
WIKI.logger.info('Stopping Setup...')
server.destroy(() => {
WIKI.server.destroy(() => {
WIKI.logger.info('Setup stopped. Starting WIKI.js...')
_.delay(() => {
WIKI.kernel.bootMaster()

View File

@@ -2,5 +2,5 @@ extends ../master.pug
block body
body
#app.setup.is-fullscreen
#app
setup(telemetry-id=telemetryClientID, wiki-version=packageObj.version, :langs!=JSON.stringify(data.langs).replace(/"/g, "'"))

View File

@@ -3,34 +3,34 @@ html
head
meta(http-equiv='X-UA-Compatible', content='IE=edge')
meta(charset='UTF-8')
meta(name='viewport', content='width=device-width, initial-scale=1')
meta(name='theme-color', content='#0288d1')
meta(name='msapplication-TileColor', content='#0288d1')
meta(name='msapplication-TileImage', content=config.site.path + 'favicons/ms-icon-144x144.png')
meta(name='viewport', content='user-scalable=yes, width=device-width, initial-scale=1, maximum-scale=5')
meta(name='theme-color', content='#333333')
meta(name='msapplication-TileColor', content='#333333')
meta(name='msapplication-TileImage', content='/favicons/ms-icon-144x144.png')
title= config.site.title
//- Favicon
each favsize in [57, 60, 72, 76, 114, 120, 144, 152, 180]
link(rel='apple-touch-icon', sizes=favsize + 'x' + favsize, href=config.site.path + 'favicons/apple-icon-' + favsize + 'x' + favsize + '.png')
link(rel='icon', type='image/png', sizes='192x192', href=config.site.path + 'favicons/android-icon-192x192.png')
link(rel='apple-touch-icon', sizes=favsize + 'x' + favsize, href='/favicons/apple-icon-' + favsize + 'x' + favsize + '.png')
link(rel='icon', type='image/png', sizes='192x192', href='/favicons/android-icon-192x192.png')
each favsize in [32, 96, 16]
link(rel='icon', type='image/png', sizes=favsize + 'x' + favsize, href=config.site.path + 'favicons/favicon-' + favsize + 'x' + favsize + '.png')
link(rel='manifest', href=config.site.path + 'manifest.json')
link(rel='icon', type='image/png', sizes=favsize + 'x' + favsize, href='/favicons/favicon-' + favsize + 'x' + favsize + '.png')
link(rel='manifest', href='/manifest.json')
//- Site Lang
script.
var siteConfig = !{JSON.stringify(config.site)}
//- CSS
link(type='text/css', rel='stylesheet', href=config.site.path + 'css/bundle.css')
link(type='text/css', rel='stylesheet', href='/css/bundle.css')
link(type='text/css', rel='stylesheet', href='https://fonts.googleapis.com/icon?family=Roboto:400,500,700|Source+Code+Pro:400,700|Material+Icons')
link(type='text/css', rel='stylesheet', href='https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css')
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css" />
//- JS
script(type='text/javascript', src=config.site.path + 'js/runtime.js')
script(type='text/javascript', src=config.site.path + 'js/vendor.js')
script(type='text/javascript', src=config.site.path + 'js/client.js')
script(type='text/javascript', src='/js/runtime.js')
script(type='text/javascript', src='/js/vendor.js')
script(type='text/javascript', src='/js/client.js')
block head