feat: check for updates
This commit is contained in:
@@ -66,6 +66,10 @@ jobs:
|
||||
onInit: true
|
||||
cron: '0 0 * * *'
|
||||
concurrency: 0
|
||||
syncGraphUpdates:
|
||||
onInit: true
|
||||
cron: '0 0 * * *'
|
||||
concurrency: 0
|
||||
syncStorage:
|
||||
onInit: false
|
||||
cron: false
|
||||
|
@@ -52,9 +52,12 @@ module.exports = {
|
||||
appconfig.port = process.env.PORT || 80
|
||||
}
|
||||
|
||||
const packageInfo = require(path.join(WIKI.ROOTPATH, 'package.json'))
|
||||
|
||||
WIKI.config = appconfig
|
||||
WIKI.data = appdata
|
||||
WIKI.version = require(path.join(WIKI.ROOTPATH, 'package.json')).version
|
||||
WIKI.version = packageInfo.version
|
||||
WIKI.releaseDate = packageInfo.releaseDate
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -25,12 +25,11 @@ module.exports = {
|
||||
red.on('message', (channel, msg) => {
|
||||
WIKI.events.emit(channel, msg)
|
||||
})
|
||||
red.subscribe('localization', (err, count) => {
|
||||
red.subscribe('localization', 'updates', (err, count) => {
|
||||
if (err) {
|
||||
WIKI.logger.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
WIKI.logger.info('Redis Subscriber connection: [ OK ]')
|
||||
})
|
||||
return red
|
||||
}
|
||||
|
@@ -5,6 +5,25 @@ const Promise = require('bluebird')
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
updates: {
|
||||
channel: 'BETA',
|
||||
version: WIKI.version,
|
||||
releaseDate: WIKI.releaseDate,
|
||||
minimumVersionRequired: '2.0.0-beta.0',
|
||||
minimumNodeRequired: '10.12.0'
|
||||
},
|
||||
init() {
|
||||
// Listen for updates events
|
||||
WIKI.events.on('updates', (infoRaw) => {
|
||||
try {
|
||||
this.updates = JSON.parse(infoRaw)
|
||||
} catch (err) {
|
||||
WIKI.logger.warn('Failed to parse updates info.')
|
||||
}
|
||||
})
|
||||
|
||||
return this
|
||||
},
|
||||
/**
|
||||
* Upgrade from WIKI.js 1.x - MongoDB database
|
||||
*
|
||||
|
@@ -75,7 +75,7 @@ module.exports = {
|
||||
},
|
||||
async update(obj, args) {
|
||||
if(_.some(args.pageRules, pr => {
|
||||
return pr.match !== 'REGEX' || safeRegex(pr.path)
|
||||
return pr.match === 'REGEX' && !safeRegex(pr.path)
|
||||
})) {
|
||||
throw new gql.GraphQLError('Some Page Rules contains unsafe or exponential time regex.')
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ const os = require('os')
|
||||
const filesize = require('filesize')
|
||||
const path = require('path')
|
||||
const fs = require('fs-extra')
|
||||
const moment = require('moment')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
@@ -62,10 +63,10 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
latestVersion() {
|
||||
return '2.0.0' // TODO
|
||||
return WIKI.system.updates.version
|
||||
},
|
||||
latestVersionReleaseDate() {
|
||||
return new Date() // TODO
|
||||
return moment.utc(WIKI.system.updates.releaseDate)
|
||||
},
|
||||
async operatingSystem() {
|
||||
let osLabel = `${os.type()} (${os.platform()}) ${os.release()} ${os.arch()}`
|
||||
|
45
server/jobs/sync-graph-updates.js
Normal file
45
server/jobs/sync-graph-updates.js
Normal file
@@ -0,0 +1,45 @@
|
||||
require('../core/worker')
|
||||
const _ = require('lodash')
|
||||
const { createApolloFetch } = require('apollo-fetch')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
WIKI.redis = require('../core/redis').init()
|
||||
WIKI.models = require('../core/db').init()
|
||||
|
||||
module.exports = async (job) => {
|
||||
WIKI.logger.info(`Fetching latest updates from Graph endpoint...`)
|
||||
|
||||
try {
|
||||
await WIKI.configSvc.loadFromDb()
|
||||
const apollo = createApolloFetch({
|
||||
uri: WIKI.config.graphEndpoint
|
||||
})
|
||||
|
||||
const resp = await apollo({
|
||||
query: `query ($channel: ReleaseChannel!, $version: String!) {
|
||||
releases {
|
||||
checkForUpdates(channel: $channel, version: $version) {
|
||||
channel
|
||||
version
|
||||
releaseDate
|
||||
minimumVersionRequired
|
||||
minimumNodeRequired
|
||||
}
|
||||
}
|
||||
}`,
|
||||
variables: {
|
||||
channel: 'BETA', // TODO
|
||||
version: WIKI.version
|
||||
}
|
||||
})
|
||||
const info = _.get(resp, 'data.releases.checkForUpdates', {})
|
||||
|
||||
await WIKI.redis.publish('updates', JSON.stringify(info))
|
||||
|
||||
WIKI.logger.info(`Fetching latest updates from Graph endpoint: [ COMPLETED ]`)
|
||||
} catch (err) {
|
||||
WIKI.logger.error(`Fetching latest updates from Graph endpoint: [ FAILED ]`)
|
||||
WIKI.logger.error(err.message)
|
||||
}
|
||||
}
|
@@ -20,6 +20,7 @@ module.exports = async () => {
|
||||
WIKI.auth = require('./core/auth').init()
|
||||
WIKI.lang = require('./core/localization').init()
|
||||
WIKI.mail = require('./core/mail').init()
|
||||
WIKI.system = require('./core/system').init()
|
||||
|
||||
// ----------------------------------------
|
||||
// Load middlewares
|
||||
|
@@ -8,6 +8,10 @@ block body
|
||||
img.animated.fadeIn(src='/svg/icon-delete-shield.svg', alt='Unauthorized')
|
||||
.headline= t('unauthorized.title')
|
||||
.subheading.mt-3= t('unauthorized.action.' + action)
|
||||
v-btn.mt-5(color='red lighten-4', href='javascript:window.history.go(-1);', large, outline)
|
||||
v-icon(left) arrow_back
|
||||
span= t('unauthorized.goback')
|
||||
.mt-5
|
||||
v-btn(color='red lighten-4', href='javascript:window.history.go(-1);', large, outline)
|
||||
v-icon(left) arrow_back
|
||||
span= t('unauthorized.goback')
|
||||
v-btn(color='red lighten-4', href='/login', large, outline)
|
||||
v-icon(left) person_outline
|
||||
span= t('unauthorized.login')
|
||||
|
Reference in New Issue
Block a user