mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Add runner version info
This commit is contained in:
parent
309068ae1d
commit
3e1cdb9fa2
23 changed files with 233 additions and 192 deletions
|
@ -1,12 +1,13 @@
|
|||
import { isStableOrUnstableVersionValid } from '@server/helpers/custom-validators/misc.js'
|
||||
import { outputJSON, pathExists } from 'fs-extra/esm'
|
||||
import { join } from 'path'
|
||||
import { execShell } from '../../helpers/core-utils.js'
|
||||
import { isNpmPluginNameValid, isPluginStableOrUnstableVersionValid } from '../../helpers/custom-validators/plugins.js'
|
||||
import { isNpmPluginNameValid } from '../../helpers/custom-validators/plugins.js'
|
||||
import { logger } from '../../helpers/logger.js'
|
||||
import { CONFIG } from '../../initializers/config.js'
|
||||
import { getLatestPluginVersion } from './plugin-index.js'
|
||||
|
||||
async function installNpmPlugin (npmName: string, versionArg?: string) {
|
||||
export async function installNpmPlugin (npmName: string, versionArg?: string) {
|
||||
// Security check
|
||||
checkNpmPluginNameOrThrow(npmName)
|
||||
if (versionArg) checkPluginVersionOrThrow(versionArg)
|
||||
|
@ -21,31 +22,22 @@ async function installNpmPlugin (npmName: string, versionArg?: string) {
|
|||
logger.debug('Added a yarn package.', { yarnStdout: stdout })
|
||||
}
|
||||
|
||||
async function installNpmPluginFromDisk (path: string) {
|
||||
export async function installNpmPluginFromDisk (path: string) {
|
||||
await execYarn('add file:' + path)
|
||||
}
|
||||
|
||||
async function removeNpmPlugin (name: string) {
|
||||
export async function removeNpmPlugin (name: string) {
|
||||
checkNpmPluginNameOrThrow(name)
|
||||
|
||||
await execYarn('remove ' + name)
|
||||
}
|
||||
|
||||
async function rebuildNativePlugins () {
|
||||
export async function rebuildNativePlugins () {
|
||||
await execYarn('install --pure-lockfile')
|
||||
}
|
||||
|
||||
// ############################################################################
|
||||
|
||||
export {
|
||||
installNpmPlugin,
|
||||
installNpmPluginFromDisk,
|
||||
rebuildNativePlugins,
|
||||
removeNpmPlugin
|
||||
}
|
||||
|
||||
// ############################################################################
|
||||
|
||||
async function execYarn (command: string) {
|
||||
try {
|
||||
const pluginDirectory = CONFIG.STORAGE.PLUGINS_DIR
|
||||
|
@ -69,5 +61,5 @@ function checkNpmPluginNameOrThrow (name: string) {
|
|||
}
|
||||
|
||||
function checkPluginVersionOrThrow (name: string) {
|
||||
if (!isPluginStableOrUnstableVersionValid(name)) throw new Error('Invalid NPM plugin version to install')
|
||||
if (!isStableOrUnstableVersionValid(name)) throw new Error('Invalid NPM plugin version to install')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue