fix: Install fixes + localization home key
This commit is contained in:
parent
fa68da3396
commit
bbaf311372
@ -19,6 +19,8 @@ const tar = require('tar')
|
|||||||
const zlib = require('zlib')
|
const zlib = require('zlib')
|
||||||
|
|
||||||
const installDir = path.resolve(__dirname, '../..')
|
const installDir = path.resolve(__dirname, '../..')
|
||||||
|
const isContainerBased = (process.env.WIKI_JS_HEROKU || process.env.WIKI_JS_DOCKER)
|
||||||
|
let installMode = 'new'
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// INSTALLATION TASKS
|
// INSTALLATION TASKS
|
||||||
@ -28,7 +30,7 @@ const tasks = {
|
|||||||
/**
|
/**
|
||||||
* Stop and delete existing instances
|
* Stop and delete existing instances
|
||||||
*/
|
*/
|
||||||
stopAndDeleteInstances () {
|
stopAndDeleteInstances() {
|
||||||
ora.text = 'Looking for running instances...'
|
ora.text = 'Looking for running instances...'
|
||||||
return pm2.connectAsync().then(() => {
|
return pm2.connectAsync().then(() => {
|
||||||
return pm2.describeAsync('wiki').then(() => {
|
return pm2.describeAsync('wiki').then(() => {
|
||||||
@ -39,14 +41,16 @@ const tasks = {
|
|||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
pm2.disconnect()
|
pm2.disconnect()
|
||||||
})
|
})
|
||||||
|
}).catch(err => { // eslint-disable-line handle-callback-err
|
||||||
|
return true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Check for sufficient memory
|
* Check for sufficient memory
|
||||||
*/
|
*/
|
||||||
checkRequirements () {
|
checkRequirements() {
|
||||||
ora.text = 'Checking system requirements...'
|
ora.text = 'Checking system requirements...'
|
||||||
if (os.totalmem() < 1024 * 1024 * 768) {
|
if (os.totalmem() < 1000 * 1000 * 768) {
|
||||||
return Promise.reject(new Error('Not enough memory to install dependencies. Minimum is 768 MB.'))
|
return Promise.reject(new Error('Not enough memory to install dependencies. Minimum is 768 MB.'))
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve(true)
|
return Promise.resolve(true)
|
||||||
@ -55,7 +59,7 @@ const tasks = {
|
|||||||
/**
|
/**
|
||||||
* Install via local tarball if present
|
* Install via local tarball if present
|
||||||
*/
|
*/
|
||||||
installFromLocal () {
|
installFromLocal() {
|
||||||
let hasTarball = true
|
let hasTarball = true
|
||||||
let tbPath = path.join(installDir, 'wiki-js.tar.gz')
|
let tbPath = path.join(installDir, 'wiki-js.tar.gz')
|
||||||
return fs.accessAsync(tbPath)
|
return fs.accessAsync(tbPath)
|
||||||
@ -67,7 +71,7 @@ const tasks = {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fs.createReadStream(tbPath).pipe(zlib.createGunzip())
|
fs.createReadStream(tbPath).pipe(zlib.createGunzip())
|
||||||
.pipe(tar.Extract({ path: installDir }))
|
.pipe(tar.extract({ cwd: installDir }))
|
||||||
.on('error', err => reject(err))
|
.on('error', err => reject(err))
|
||||||
.on('end', () => {
|
.on('end', () => {
|
||||||
ora.text = 'Tarball extracted successfully.'
|
ora.text = 'Tarball extracted successfully.'
|
||||||
@ -82,7 +86,7 @@ const tasks = {
|
|||||||
/**
|
/**
|
||||||
* Install from GitHub release download
|
* Install from GitHub release download
|
||||||
*/
|
*/
|
||||||
installFromRemote () {
|
installFromRemote() {
|
||||||
// Fetch version from npm package
|
// Fetch version from npm package
|
||||||
return fs.readJsonAsync('package.json').then((packageObj) => {
|
return fs.readJsonAsync('package.json').then((packageObj) => {
|
||||||
let versionGet = _.chain(packageObj.version).split('.').take(4).join('.')
|
let versionGet = _.chain(packageObj.version).split('.').take(4).join('.')
|
||||||
@ -96,10 +100,11 @@ const tasks = {
|
|||||||
return reject(new Error('Remote file not found'))
|
return reject(new Error('Remote file not found'))
|
||||||
}
|
}
|
||||||
ora.text = 'Remote wiki.js tarball found. Downloading...'
|
ora.text = 'Remote wiki.js tarball found. Downloading...'
|
||||||
|
isContainerBased && console.info('>> Extracting to ' + installDir)
|
||||||
|
|
||||||
// Extract tarball
|
// Extract tarball
|
||||||
resp.pipe(zlib.createGunzip())
|
resp.pipe(zlib.createGunzip())
|
||||||
.pipe(tar.Extract({ path: installDir }))
|
.pipe(tar.extract({ cwd: installDir }))
|
||||||
.on('error', err => reject(err))
|
.on('error', err => reject(err))
|
||||||
.on('end', () => {
|
.on('end', () => {
|
||||||
ora.text = 'Tarball extracted successfully.'
|
ora.text = 'Tarball extracted successfully.'
|
||||||
@ -109,10 +114,36 @@ const tasks = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Create default config.yml file if new installation
|
||||||
|
*/
|
||||||
|
ensureConfigFile() {
|
||||||
|
return fs.accessAsync(path.join(installDir, 'config.yml')).then(() => {
|
||||||
|
// Is Upgrade
|
||||||
|
ora.text = 'Existing config.yml found. Upgrade mode.'
|
||||||
|
installMode = 'upgrade'
|
||||||
|
return true
|
||||||
|
}).catch(err => {
|
||||||
|
// Is New Install
|
||||||
|
if (err.code === 'ENOENT') {
|
||||||
|
ora.text = 'First-time install, creating a new config.yml...'
|
||||||
|
installMode = 'new'
|
||||||
|
let sourceConfigFile = path.join(installDir, 'config.sample.yml')
|
||||||
|
if (process.env.WIKI_JS_HEROKU) {
|
||||||
|
sourceConfigFile = path.join(__dirname, 'configs/config.heroku.yml')
|
||||||
|
} else if (process.env.WIKI_JS_DOCKER) {
|
||||||
|
sourceConfigFile = path.join(__dirname, 'configs/config.docker.yml')
|
||||||
|
}
|
||||||
|
return fs.copyAsync(sourceConfigFile, path.join(installDir, 'config.yml'))
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Install npm dependencies
|
* Install npm dependencies
|
||||||
*/
|
*/
|
||||||
installDependencies () {
|
installDependencies() {
|
||||||
ora.text = 'Installing Wiki.js npm dependencies...'
|
ora.text = 'Installing Wiki.js npm dependencies...'
|
||||||
return exec.stdout('npm', ['install', '--only=production', '--no-optional'], {
|
return exec.stdout('npm', ['install', '--only=production', '--no-optional'], {
|
||||||
cwd: installDir
|
cwd: installDir
|
||||||
@ -121,42 +152,20 @@ const tasks = {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
startConfigurationWizard() {
|
||||||
* Create default config.yml file if new installation
|
ora.succeed('Installation succeeded.')
|
||||||
*/
|
if (process.env.WIKI_JS_HEROKU) {
|
||||||
ensureConfigFile () {
|
console.info('> Wiki.js has been installed and is configured to use Heroku configuration.')
|
||||||
return fs.accessAsync(path.join(installDir, 'config.yml')).then(() => {
|
return true
|
||||||
// Is Upgrade
|
} else if (process.env.WIKI_JS_DOCKER) {
|
||||||
ora.succeed('Upgrade completed.')
|
console.info('Docker environment detected. Skipping setup wizard auto-start.')
|
||||||
|
return true
|
||||||
|
} else if (process.stdout.isTTY) {
|
||||||
|
if (installMode === 'upgrade') {
|
||||||
console.info(colors.yellow('\n!!! IMPORTANT !!!'))
|
console.info(colors.yellow('\n!!! IMPORTANT !!!'))
|
||||||
console.info(colors.yellow('Running the configuration wizard is optional but recommended after an upgrade to ensure your config file is using the latest available settings.'))
|
console.info(colors.yellow('Running the configuration wizard is optional but recommended after an upgrade to ensure your config file is using the latest available settings.'))
|
||||||
console.info(colors.yellow('Note that the contents of your config file will be displayed during the configuration wizard. It is therefor highly recommended to run the wizard on a non-publicly accessible port or skip this step completely.\n'))
|
console.info(colors.yellow('Note that the contents of your config file will be displayed during the configuration wizard. It is therefor highly recommended to run the wizard on a non-publicly accessible port or skip this step completely.\n'))
|
||||||
return true
|
|
||||||
}).catch(err => {
|
|
||||||
// Is New Install
|
|
||||||
if (err.code === 'ENOENT') {
|
|
||||||
ora.text = 'First-time install, creating a new config.yml...'
|
|
||||||
let sourceConfigFile = path.join(installDir, 'config.sample.yml')
|
|
||||||
if (process.env.WIKI_JS_HEROKU) {
|
|
||||||
sourceConfigFile = path.join(__dirname, 'configs/config.heroku.yml')
|
|
||||||
} else if (process.env.WIKI_JS_DOCKER) {
|
|
||||||
sourceConfigFile = path.join(__dirname, 'configs/config.docker.yml')
|
|
||||||
}
|
}
|
||||||
return fs.copyAsync(sourceConfigFile, path.join(installDir, 'config.yml')).then(() => {
|
|
||||||
ora.succeed('Installation succeeded.')
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
startConfigurationWizard () {
|
|
||||||
if (process.env.WIKI_JS_HEROKU) {
|
|
||||||
console.info('Wiki.js has been installed and is configured to use Heroku configuration.')
|
|
||||||
} else if (process.env.WIKI_JS_DOCKER) {
|
|
||||||
console.info('Docker environment detected. Skipping setup wizard auto-start.')
|
|
||||||
} else if (process.stdout.isTTY) {
|
|
||||||
inquirer.prompt([{
|
inquirer.prompt([{
|
||||||
type: 'list',
|
type: 'list',
|
||||||
name: 'action',
|
name: 'action',
|
||||||
@ -215,7 +224,7 @@ const tasks = {
|
|||||||
// INSTALL SEQUENCE
|
// INSTALL SEQUENCE
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
if (!process.env.WIKI_JS_HEROKU && !process.env.WIKI_JS_DOCKER) {
|
if (!isContainerBased) {
|
||||||
console.info(colors.yellow(
|
console.info(colors.yellow(
|
||||||
' __ __ _ _ _ _ \n' +
|
' __ __ _ _ _ _ \n' +
|
||||||
'/ / /\\ \\ (_) | _(_) (_)___ \n' +
|
'/ / /\\ \\ (_) | _(_) (_)___ \n' +
|
||||||
@ -233,15 +242,19 @@ Promise.join(
|
|||||||
tasks.stopAndDeleteInstances(),
|
tasks.stopAndDeleteInstances(),
|
||||||
tasks.checkRequirements()
|
tasks.checkRequirements()
|
||||||
).then(() => {
|
).then(() => {
|
||||||
|
isContainerBased && console.info('>> Fetching tarball...')
|
||||||
return tasks.installFromLocal().then(succeeded => {
|
return tasks.installFromLocal().then(succeeded => {
|
||||||
return (!succeeded) ? tasks.installFromRemote() : true
|
return (!succeeded) ? tasks.installFromRemote() : true
|
||||||
})
|
})
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return tasks.installDependencies()
|
isContainerBased && console.info('>> Creating config file...')
|
||||||
}).then(() => {
|
|
||||||
return tasks.ensureConfigFile()
|
return tasks.ensureConfigFile()
|
||||||
|
}).then(() => {
|
||||||
|
isContainerBased && console.info('>> Installing dependencies...')
|
||||||
|
return tasks.installDependencies()
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return tasks.startConfigurationWizard()
|
return tasks.startConfigurationWizard()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
isContainerBased && console.error(err)
|
||||||
ora.fail(err)
|
ora.fail(err)
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wiki.js",
|
"name": "wiki.js",
|
||||||
"version": "1.0.0-beta.12.4",
|
"version": "1.0.0-beta.12.12",
|
||||||
"description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
|
"description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
|
||||||
"main": "install.js",
|
"main": "install.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
"move": "Move",
|
"move": "Move",
|
||||||
"myprofile": "My Profile",
|
"myprofile": "My Profile",
|
||||||
"normalview": "Normal View",
|
"normalview": "Normal View",
|
||||||
|
"root": "Home",
|
||||||
"savechanges": "Save Changes",
|
"savechanges": "Save Changes",
|
||||||
"savedocument": "Save Document",
|
"savedocument": "Save Document",
|
||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
|
@ -8,7 +8,7 @@ block rootNavRight
|
|||||||
.nav-item
|
.nav-item
|
||||||
a.button.btn-edit-discard(href='/')
|
a.button.btn-edit-discard(href='/')
|
||||||
i.icon-home
|
i.icon-home
|
||||||
span= t('nav.home')
|
span= t('nav.root')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ block content
|
|||||||
li
|
li
|
||||||
a(href='/')
|
a(href='/')
|
||||||
i.icon-home
|
i.icon-home
|
||||||
span= t('nav.home')
|
span= t('nav.root')
|
||||||
|
|
||||||
aside
|
aside
|
||||||
.sidebar-label
|
.sidebar-label
|
||||||
|
@ -10,7 +10,7 @@ block content
|
|||||||
li
|
li
|
||||||
a(href='/')
|
a(href='/')
|
||||||
i.icon-home
|
i.icon-home
|
||||||
span= t('nav.home')
|
span= t('nav.root')
|
||||||
if !isGuest
|
if !isGuest
|
||||||
li
|
li
|
||||||
a(href='/admin')
|
a(href='/admin')
|
||||||
|
@ -44,7 +44,7 @@ block content
|
|||||||
li
|
li
|
||||||
a(href='/')
|
a(href='/')
|
||||||
i.icon-home
|
i.icon-home
|
||||||
span= t('nav.home')
|
span= t('nav.root')
|
||||||
li
|
li
|
||||||
a(href='/all')
|
a(href='/all')
|
||||||
i.icon-paper
|
i.icon-paper
|
||||||
|
Loading…
x
Reference in New Issue
Block a user