From 3a1157a68a70e90df21f743ea15154805649b8e5 Mon Sep 17 00:00:00 2001 From: John Livingston <38844060+JohnXLivingston@users.noreply.github.com> Date: Fri, 3 Dec 2021 10:14:01 +0100 Subject: CLI: plugins install command accept a --plugin-version parameter. (#4599) * CLI: plugins install command accept a --plugin-version parameter. * Unit tests for plugins install --plugin-version. * Fix linting. * Styling Co-authored-by: Chocobozzz --- server/middlewares/validators/plugins.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts index 21171af23..c1e9ebefb 100644 --- a/server/middlewares/validators/plugins.ts +++ b/server/middlewares/validators/plugins.ts @@ -116,6 +116,9 @@ const installOrUpdatePluginValidator = [ body('npmName') .optional() .custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'), + body('pluginVersion') + .optional() + .custom(isPluginVersionValid).withMessage('Should have a valid plugin version'), body('path') .optional() .custom(isSafePath).withMessage('Should have a valid safe path'), @@ -129,6 +132,9 @@ const installOrUpdatePluginValidator = [ if (!body.path && !body.npmName) { return res.fail({ message: 'Should have either a npmName or a path' }) } + if (body.pluginVersion && !body.npmName) { + return res.fail({ message: 'Should have a npmName when specifying a pluginVersion' }) + } return next() } -- cgit v1.2.3