npm install fixes + logs folder

This commit is contained in:
NGPixel
2017-02-16 12:49:56 -05:00
parent e0bb77efbb
commit f311d74a08
5 changed files with 71 additions and 50 deletions

View File

@@ -8,9 +8,7 @@
[![Release](https://img.shields.io/github/release/Requarks/wiki.svg?style=flat-square&maxAge=3600)](https://github.com/Requarks/wiki/releases)
[![License](https://img.shields.io/badge/license-AGPLv3-blue.svg?style=flat-square)](https://github.com/requarks/wiki/blob/master/LICENSE)
##### A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown
This npm package is an installer for Wiki.js. For information about Wiki.js, use the following links:
This npm package is an installer for Wiki.js. For information about Wiki.js, including detailed installation steps, read the following links:
- [Official Website](https://wiki.requarks.io/)
- [Installation Guide](https://wiki.requarks.io/get-started.html)

View File

@@ -13,32 +13,43 @@ const _ = require('lodash')
let installDir = path.resolve(__dirname, '../..')
/**
* Fetch version from npm package
*/
fs.readJsonAsync('package.json').then((packageObj) => {
let remoteURL = _.replace('https://github.com/Requarks/wiki/releases/download/v{0}/wiki-js.tar.gz', '{0}', packageObj.version)
return new Promise((resolve, reject) => {
/**
* Fetch tarball
*/
ora.text = 'Looking for latest release...'
https.get(remoteURL, resp => {
if (resp.statusCode !== 200) {
return reject(new Error('Remote file not found'))
}
ora.text = 'Install tarball found. Downloading...'
ora.text = 'Looking for running instances...'
pm2.connectAsync().then(() => {
return pm2.describeAsync('wiki').then(() => {
ora.text = 'Stopping and deleting from pm2...'
return pm2.deleteAsync('wiki')
}).catch(err => { // eslint-disable-line handle-callback-err
return true
})
}).then(() => {
/**
* Fetch version from npm package
*/
return fs.readJsonAsync('package.json').then((packageObj) => {
let versionGet = _.chain(packageObj.version).split('.').take(4).join('.')
let remoteURL = _.replace('https://github.com/Requarks/wiki/releases/download/v{0}/wiki-js.tar.gz', '{0}', versionGet)
return new Promise((resolve, reject) => {
/**
* Extract tarball
* Fetch tarball
*/
resp.pipe(zlib.createGunzip())
.pipe(tar.Extract({ path: installDir }))
.on('error', err => reject(err))
.on('end', () => {
ora.text = 'Tarball extracted successfully.'
resolve(true)
ora.text = 'Looking for latest release...'
https.get(remoteURL, resp => {
if (resp.statusCode !== 200) {
return reject(new Error('Remote file not found'))
}
ora.text = 'Install tarball found. Downloading...'
/**
* Extract tarball
*/
resp.pipe(zlib.createGunzip())
.pipe(tar.Extract({ path: installDir }))
.on('error', err => reject(err))
.on('end', () => {
ora.text = 'Tarball extracted successfully.'
resolve(true)
})
})
})
})
@@ -62,17 +73,19 @@ fs.readJsonAsync('package.json').then((packageObj) => {
/**
* Upgrade mode
*/
ora.text = 'Upgrade succeeded. Reloading Wiki.js...'
return pm2.connectAsync().then(() => {
return pm2.restartAsync('wiki').catch(err => { // eslint-disable-line handle-callback-err
return new Error('Unable to restart Wiki.js via pm2... Do a manual restart!')
}).then(() => {
ora.succeed('Wiki.js has restarted. Upgrade completed.')
return new Promise((resolve, reject) => {
ora.text = 'Upgrade succeeded. Starting Wiki.js...'
let npmInstallProc = exec('wiki start', {
cwd: installDir
})
npmInstallProc.stdout.pipe(process.stdout)
npmInstallProc.on('error', err => {
reject(err)
})
.on('exit', () => {
ora.succeed('Wiki.js has started. Upgrade completed.')
resolve(true)
})
}).catch(err => {
ora.fail(err)
}).finally(() => {
pm2.disconnect()
})
}).catch(err => {
/**
@@ -89,4 +102,6 @@ fs.readJsonAsync('package.json').then((packageObj) => {
})
}).catch(err => {
ora.fail(err)
}).finally(() => {
pm2.disconnect()
})