mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
const _ = require('lodash')
|
|
const { createApolloFetch } = require('apollo-fetch')
|
|
|
|
/* global WIKI */
|
|
|
|
module.exports = async () => {
|
|
WIKI.logger.info(`Fetching latest updates from Graph endpoint...`)
|
|
|
|
try {
|
|
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', false)
|
|
if (info) {
|
|
WIKI.system.updates = 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)
|
|
}
|
|
}
|