Use process.env.npm_package_version
This commit is contained in:
parent
109d893ff5
commit
66170ca8c6
5 changed files with 43 additions and 41 deletions
|
@ -4,7 +4,7 @@ import { ServerConfig, UserRight } from '../../../shared'
|
||||||
import { About } from '../../../shared/models/server/about.model'
|
import { About } from '../../../shared/models/server/about.model'
|
||||||
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
|
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
|
||||||
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
|
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
|
||||||
import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME } from '../../initializers/constants'
|
import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '../../initializers/constants'
|
||||||
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
|
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
|
||||||
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
|
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
|
||||||
import { ClientHtml } from '../../lib/client-html'
|
import { ClientHtml } from '../../lib/client-html'
|
||||||
|
@ -18,7 +18,6 @@ import { CONFIG, reloadConfig } from '../../initializers/config'
|
||||||
import { PluginManager } from '../../lib/plugins/plugin-manager'
|
import { PluginManager } from '../../lib/plugins/plugin-manager'
|
||||||
import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
|
import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
|
||||||
|
|
||||||
const packageJSON = require('../../../../package.json')
|
|
||||||
const configRouter = express.Router()
|
const configRouter = express.Router()
|
||||||
|
|
||||||
const auditLogger = auditLoggerFactory('config')
|
const auditLogger = auditLoggerFactory('config')
|
||||||
|
@ -46,35 +45,14 @@ configRouter.delete('/custom',
|
||||||
)
|
)
|
||||||
|
|
||||||
let serverCommit: string
|
let serverCommit: string
|
||||||
|
|
||||||
async function getConfig (req: express.Request, res: express.Response) {
|
async function getConfig (req: express.Request, res: express.Response) {
|
||||||
const allowed = await isSignupAllowed()
|
const allowed = await isSignupAllowed()
|
||||||
const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip)
|
const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip)
|
||||||
|
const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
|
||||||
|
|
||||||
if (serverCommit === undefined) serverCommit = await getServerCommit()
|
if (serverCommit === undefined) serverCommit = await getServerCommit()
|
||||||
|
|
||||||
const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
|
|
||||||
.filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
|
|
||||||
.map(r => parseInt(r, 10))
|
|
||||||
|
|
||||||
const registeredPlugins = PluginManager.Instance.getRegisteredPlugins()
|
|
||||||
.map(p => ({
|
|
||||||
name: p.name,
|
|
||||||
version: p.version,
|
|
||||||
description: p.description,
|
|
||||||
clientScripts: p.clientScripts
|
|
||||||
}))
|
|
||||||
|
|
||||||
const registeredThemes = PluginManager.Instance.getRegisteredThemes()
|
|
||||||
.map(t => ({
|
|
||||||
name: t.name,
|
|
||||||
version: t.version,
|
|
||||||
description: t.description,
|
|
||||||
css: t.css,
|
|
||||||
clientScripts: t.clientScripts
|
|
||||||
}))
|
|
||||||
|
|
||||||
const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
|
|
||||||
|
|
||||||
const json: ServerConfig = {
|
const json: ServerConfig = {
|
||||||
instance: {
|
instance: {
|
||||||
name: CONFIG.INSTANCE.NAME,
|
name: CONFIG.INSTANCE.NAME,
|
||||||
|
@ -88,10 +66,10 @@ async function getConfig (req: express.Request, res: express.Response) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugin: {
|
plugin: {
|
||||||
registered: registeredPlugins
|
registered: getRegisteredPlugins()
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
registered: registeredThemes,
|
registered: getRegisteredThemes(),
|
||||||
default: defaultTheme
|
default: defaultTheme
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
|
@ -100,7 +78,7 @@ async function getConfig (req: express.Request, res: express.Response) {
|
||||||
contactForm: {
|
contactForm: {
|
||||||
enabled: CONFIG.CONTACT_FORM.ENABLED
|
enabled: CONFIG.CONTACT_FORM.ENABLED
|
||||||
},
|
},
|
||||||
serverVersion: packageJSON.version,
|
serverVersion: PEERTUBE_VERSION,
|
||||||
serverCommit,
|
serverCommit,
|
||||||
signup: {
|
signup: {
|
||||||
allowed,
|
allowed,
|
||||||
|
@ -111,7 +89,7 @@ async function getConfig (req: express.Request, res: express.Response) {
|
||||||
hls: {
|
hls: {
|
||||||
enabled: CONFIG.TRANSCODING.HLS.ENABLED
|
enabled: CONFIG.TRANSCODING.HLS.ENABLED
|
||||||
},
|
},
|
||||||
enabledResolutions
|
enabledResolutions: getEnabledResolutions()
|
||||||
},
|
},
|
||||||
import: {
|
import: {
|
||||||
videos: {
|
videos: {
|
||||||
|
@ -342,3 +320,30 @@ function convertCustomConfigBody (body: CustomConfig) {
|
||||||
|
|
||||||
return objectConverter(body, keyConverter, valueConverter)
|
return objectConverter(body, keyConverter, valueConverter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRegisteredThemes () {
|
||||||
|
return PluginManager.Instance.getRegisteredThemes()
|
||||||
|
.map(t => ({
|
||||||
|
name: t.name,
|
||||||
|
version: t.version,
|
||||||
|
description: t.description,
|
||||||
|
css: t.css,
|
||||||
|
clientScripts: t.clientScripts
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEnabledResolutions () {
|
||||||
|
return Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
|
||||||
|
.filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[ key ] === true)
|
||||||
|
.map(r => parseInt(r, 10))
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRegisteredPlugins () {
|
||||||
|
return PluginManager.Instance.getRegisteredPlugins()
|
||||||
|
.map(p => ({
|
||||||
|
name: p.name,
|
||||||
|
version: p.version,
|
||||||
|
description: p.description,
|
||||||
|
clientScripts: p.clientScripts
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as cors from 'cors'
|
import * as cors from 'cors'
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
import {
|
import {
|
||||||
HLS_STREAMING_PLAYLIST_DIRECTORY,
|
HLS_STREAMING_PLAYLIST_DIRECTORY, PEERTUBE_VERSION,
|
||||||
ROUTE_CACHE_LIFETIME,
|
ROUTE_CACHE_LIFETIME,
|
||||||
STATIC_DOWNLOAD_PATHS,
|
STATIC_DOWNLOAD_PATHS,
|
||||||
STATIC_MAX_AGE,
|
STATIC_MAX_AGE,
|
||||||
|
@ -19,7 +19,6 @@ import { join } from 'path'
|
||||||
import { root } from '../helpers/core-utils'
|
import { root } from '../helpers/core-utils'
|
||||||
import { CONFIG } from '../initializers/config'
|
import { CONFIG } from '../initializers/config'
|
||||||
|
|
||||||
const packageJSON = require('../../../package.json')
|
|
||||||
const staticRouter = express.Router()
|
const staticRouter = express.Router()
|
||||||
|
|
||||||
staticRouter.use(cors())
|
staticRouter.use(cors())
|
||||||
|
@ -205,7 +204,7 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
|
||||||
version: '2.0',
|
version: '2.0',
|
||||||
software: {
|
software: {
|
||||||
name: 'peertube',
|
name: 'peertube',
|
||||||
version: packageJSON.version
|
version: PEERTUBE_VERSION
|
||||||
},
|
},
|
||||||
protocols: [
|
protocols: [
|
||||||
'activitypub'
|
'activitypub'
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
import * as Bluebird from 'bluebird'
|
import * as Bluebird from 'bluebird'
|
||||||
import { createWriteStream, remove } from 'fs-extra'
|
import { createWriteStream, remove } from 'fs-extra'
|
||||||
import * as request from 'request'
|
import * as request from 'request'
|
||||||
import { ACTIVITY_PUB, WEBSERVER } from '../initializers/constants'
|
import { ACTIVITY_PUB, PEERTUBE_VERSION, WEBSERVER } from '../initializers/constants'
|
||||||
import { processImage } from './image-utils'
|
import { processImage } from './image-utils'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
import { CONFIG } from '../initializers/config'
|
import { CONFIG } from '../initializers/config'
|
||||||
|
|
||||||
const packageJSON = require('../../../package.json')
|
|
||||||
|
|
||||||
function doRequest <T> (
|
function doRequest <T> (
|
||||||
requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean },
|
requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean },
|
||||||
bodyKBLimit = 1000 // 1MB
|
bodyKBLimit = 1000 // 1MB
|
||||||
|
@ -68,7 +66,7 @@ async function downloadImage (url: string, destDir: string, destName: string, si
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserAgent () {
|
function getUserAgent () {
|
||||||
return `PeerTube/${packageJSON.version} (+${WEBSERVER.URL})`
|
return `PeerTube/${PEERTUBE_VERSION} (+${WEBSERVER.URL})`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -18,8 +18,8 @@ const LAST_MIGRATION_VERSION = 400
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// API version
|
|
||||||
const API_VERSION = 'v1'
|
const API_VERSION = 'v1'
|
||||||
|
const PEERTUBE_VERSION = process.env.npm_package_version || 'unknown'
|
||||||
|
|
||||||
const PAGINATION = {
|
const PAGINATION = {
|
||||||
COUNT: {
|
COUNT: {
|
||||||
|
@ -645,6 +645,7 @@ registerConfigChangedHandler(() => {
|
||||||
export {
|
export {
|
||||||
WEBSERVER,
|
WEBSERVER,
|
||||||
API_VERSION,
|
API_VERSION,
|
||||||
|
PEERTUBE_VERSION,
|
||||||
HLS_REDUNDANCY_DIRECTORY,
|
HLS_REDUNDANCY_DIRECTORY,
|
||||||
P2P_MEDIA_LOADER_PEER_VERSION,
|
P2P_MEDIA_LOADER_PEER_VERSION,
|
||||||
AVATARS_SIZE,
|
AVATARS_SIZE,
|
||||||
|
|
|
@ -10,8 +10,7 @@ import { PeerTubePluginIndex } from '../../../shared/models/plugins/peertube-plu
|
||||||
import { PluginModel } from '../../models/server/plugin'
|
import { PluginModel } from '../../models/server/plugin'
|
||||||
import { PluginManager } from './plugin-manager'
|
import { PluginManager } from './plugin-manager'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
|
import { PEERTUBE_VERSION } from '../../initializers/constants'
|
||||||
const packageJSON = require('../../../../package.json')
|
|
||||||
|
|
||||||
async function listAvailablePluginsFromIndex (options: PeertubePluginIndexList) {
|
async function listAvailablePluginsFromIndex (options: PeertubePluginIndexList) {
|
||||||
const { start = 0, count = 20, search, sort = 'npmName', pluginType } = options
|
const { start = 0, count = 20, search, sort = 'npmName', pluginType } = options
|
||||||
|
@ -22,7 +21,7 @@ async function listAvailablePluginsFromIndex (options: PeertubePluginIndexList)
|
||||||
sort,
|
sort,
|
||||||
pluginType,
|
pluginType,
|
||||||
search,
|
search,
|
||||||
currentPeerTubeEngine: packageJSON.version
|
currentPeerTubeEngine: PEERTUBE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
const uri = CONFIG.PLUGINS.INDEX.URL + '/api/v1/plugins'
|
const uri = CONFIG.PLUGINS.INDEX.URL + '/api/v1/plugins'
|
||||||
|
@ -53,7 +52,7 @@ async function addInstanceInformation (result: ResultList<PeerTubePluginIndex>)
|
||||||
async function getLatestPluginsVersion (npmNames: string[]): Promise<PeertubePluginLatestVersionResponse> {
|
async function getLatestPluginsVersion (npmNames: string[]): Promise<PeertubePluginLatestVersionResponse> {
|
||||||
const bodyRequest: PeertubePluginLatestVersionRequest = {
|
const bodyRequest: PeertubePluginLatestVersionRequest = {
|
||||||
npmNames,
|
npmNames,
|
||||||
currentPeerTubeEngine: packageJSON.version
|
currentPeerTubeEngine: PEERTUBE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
const uri = CONFIG.PLUGINS.INDEX.URL + '/api/v1/plugins/latest-version'
|
const uri = CONFIG.PLUGINS.INDEX.URL + '/api/v1/plugins/latest-version'
|
||||||
|
|
Loading…
Reference in a new issue