npm install feature
This commit is contained in:
parent
ae7373b937
commit
ab32c95233
3
.gitignore
vendored
3
.gitignore
vendored
@ -31,6 +31,7 @@ dist
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
npm/node_modules
|
||||
jspm_packages
|
||||
|
||||
# Optional npm cache directory
|
||||
@ -48,4 +49,4 @@ config.yml
|
||||
# Data directories
|
||||
/repo
|
||||
/data
|
||||
/uploads
|
||||
/uploads
|
||||
|
@ -3,9 +3,12 @@ All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v1.0.0-beta.6] - 2017-02-14
|
||||
### Added
|
||||
- Automated Upgrade / Re-install feature
|
||||
- Automated process manager
|
||||
- Automated process management
|
||||
- npm automatic site installation
|
||||
|
||||
## [v1.0-beta.5] - 2017-02-12
|
||||
### Added
|
||||
|
@ -3,7 +3,7 @@
|
||||
# This is reserved for system use!
|
||||
# ---------------------------------
|
||||
name: Wiki.js
|
||||
version: v1.0-beta.5
|
||||
version: v1.0.0-beta.6
|
||||
capabilities:
|
||||
guest: true
|
||||
rights: true
|
||||
|
12
gulpfile.js
12
gulpfile.js
@ -71,16 +71,16 @@ const paths = {
|
||||
],
|
||||
deploy: [
|
||||
'./**/*',
|
||||
'!node_modules', '!node_modules/**',
|
||||
'!coverage', '!coverage/**',
|
||||
'!client/js', '!client/js/**',
|
||||
'!client/scss', '!client/scss/**',
|
||||
'!dist', '!dist/**',
|
||||
'!tests', '!tests/**',
|
||||
'!coverage', '!coverage/**',
|
||||
'!data', '!data/**',
|
||||
'!dist', '!dist/**',
|
||||
'!node_modules', '!node_modules/**',
|
||||
'!npm', '!npm/**',
|
||||
'!repo', '!repo/**',
|
||||
'!.babelrc', '!.gitattributes', '!.gitignore', '!.snyk', '!.travis.yml',
|
||||
'!gulpfile.js', '!inch.json', '!config.yml', '!wiki.sublime-project'
|
||||
'!test', '!test/**',
|
||||
'!gulpfile.js', '!config.yml'
|
||||
]
|
||||
}
|
||||
|
||||
|
1
npm/README.md
Normal file
1
npm/README.md
Normal file
@ -0,0 +1 @@
|
||||
Under development
|
67
npm/install.js
Normal file
67
npm/install.js
Normal file
@ -0,0 +1,67 @@
|
||||
'use strict'
|
||||
|
||||
const ora = require('ora')('Initializing...').start()
|
||||
const Promise = require('bluebird')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
const https = require('follow-redirects').https
|
||||
const path = require('path')
|
||||
const pm2 = Promise.promisifyAll(require('pm2'))
|
||||
const tar = require('tar')
|
||||
const zlib = require('zlib')
|
||||
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...'
|
||||
|
||||
/**
|
||||
* 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)
|
||||
})
|
||||
})
|
||||
})
|
||||
}).then(() => {
|
||||
fs.accessAsync(path.join(installDir, 'config.yml')).then(() => {
|
||||
/**
|
||||
* Upgrade mode
|
||||
*/
|
||||
ora.text = 'Upgrade succeeded. Reloading Wiki.js...'
|
||||
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.')
|
||||
})
|
||||
}).catch(err => {
|
||||
/**
|
||||
* Install mode
|
||||
*/
|
||||
if (err.code === 'ENOENT') {
|
||||
ora.succeed('Installation succeeded. You can now continue with the configuration steps. Check out https://docs.wiki.requarks.io/install for more info.')
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
ora.fail(err)
|
||||
})
|
41
npm/package.json
Normal file
41
npm/package.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "wiki.js",
|
||||
"version": "1.0.0-beta.6",
|
||||
"description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
|
||||
"main": "install.js",
|
||||
"scripts": {
|
||||
"test": "exit 1",
|
||||
"install": "node install.js",
|
||||
"preuninstall": "node uninstall.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Requarks/wiki.git"
|
||||
},
|
||||
"keywords": [
|
||||
"wiki",
|
||||
"wikis",
|
||||
"wikijs",
|
||||
"wiki.js",
|
||||
"wiki-js",
|
||||
"docs",
|
||||
"documentation",
|
||||
"markdown",
|
||||
"guides"
|
||||
],
|
||||
"author": "Nicolas Giard",
|
||||
"license": "AGPL-3.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Requarks/wiki/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Requarks/wiki#readme",
|
||||
"dependencies": {
|
||||
"bluebird": "^3.4.7",
|
||||
"follow-redirects": "^1.2.1",
|
||||
"fs-extra": "^2.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"ora": "^1.1.0",
|
||||
"pm2": "^2.4.0",
|
||||
"tar": "^2.2.1"
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "wiki",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.0-beta.6",
|
||||
"description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node wiki start",
|
||||
"stop": "node wiki stop",
|
||||
"dev": "gulp dev",
|
||||
"test": "snyk test && standard && pug-lint ./views",
|
||||
"snyk-protect": "snyk protect",
|
||||
|
6
wiki.js
6
wiki.js
@ -1,11 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
|
||||
const fs = require('fs-extra')
|
||||
const ora = require('ora')
|
||||
const Promise = require('bluebird')
|
||||
const pm2 = Promise.promisifyAll(require('pm2'))
|
||||
const cmdr = require('commander')
|
||||
|
||||
cmdr.version('1.0.0')
|
||||
const packageObj = fs.readJsonSync('package.json')
|
||||
|
||||
cmdr.version(packageObj.version)
|
||||
|
||||
cmdr.command('start')
|
||||
.description('Start Wiki.js process')
|
||||
|
Loading…
Reference in New Issue
Block a user