X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fplugins%2Fyarn.ts;h=d105b95e07d3ce0ecd0bbd888f97127556b1409f;hb=508c1b1e9f3b26752a961e945b7fa59b72b30827;hp=e40351b6e3751cb20c40d086cd798ee1c098111a;hpb=09071200c73f5358e1d0bfb61a274e4f2c4ec52b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/plugins/yarn.ts b/server/lib/plugins/yarn.ts index e40351b6e..d105b95e0 100644 --- a/server/lib/plugins/yarn.ts +++ b/server/lib/plugins/yarn.ts @@ -1,14 +1,17 @@ +import { outputJSON, pathExists } from 'fs-extra' +import { join } from 'path' import { execShell } from '../../helpers/core-utils' -import { logger } from '../../helpers/logger' import { isNpmPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' +import { logger } from '../../helpers/logger' import { CONFIG } from '../../initializers/config' -import { outputJSON, pathExists } from 'fs-extra' -import { join } from 'path' +import { getLatestPluginVersion } from './plugin-index' -async function installNpmPlugin (npmName: string, version?: string) { +async function installNpmPlugin (npmName: string, versionArg?: string) { // Security check checkNpmPluginNameOrThrow(npmName) - if (version) checkPluginVersionOrThrow(version) + if (versionArg) checkPluginVersionOrThrow(versionArg) + + const version = versionArg || await getLatestPluginVersion(npmName) let toInstall = npmName if (version) toInstall += `@${version}` @@ -28,11 +31,16 @@ async function removeNpmPlugin (name: string) { await execYarn('remove ' + name) } +async function rebuildNativePlugins () { + await execYarn('install --pure-lockfile') +} + // ############################################################################ export { installNpmPlugin, installNpmPluginFromDisk, + rebuildNativePlugins, removeNpmPlugin }