From 325941a1ada398416be002d209b6b6d66606b602 Mon Sep 17 00:00:00 2001 From: John McLear Date: Fri, 27 Nov 2020 21:43:23 +0000 Subject: [PATCH] plugins: add peerdeps and correct engine to checkPlugins script (#4524) * pere deps example * fixed by rh * doh * doh... --- bin/plugins/checkPlugin.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/bin/plugins/checkPlugin.js b/bin/plugins/checkPlugin.js index 8ef2e9f13..a96176ca1 100755 --- a/bin/plugins/checkPlugin.js +++ b/bin/plugins/checkPlugin.js @@ -165,6 +165,26 @@ fs.readdir(pluginPath, (err, rootFiles) => { } } + // include peer deps config + if (packageJSON.toLowerCase().indexOf('peerdependencies') === -1 || !parsedPackageJSON.peerDependencies) { + console.warn('Missing peer deps reference in package.json'); + if (autoFix) { + const peerDependencies = { + "ep_etherpad-lite": ">=1.8.6", + } + hasAutoFixed = true; + parsedPackageJSON.peerDependencies = peerDependencies; + fs.writeFileSync(`${pluginPath}/package.json`, JSON.stringify(parsedPackageJSON, null, 2)); + const child_process = require('child_process'); + try { + child_process.execSync('npm install --no-save ep_etherpad-lite@file:../../src', {cwd: `${pluginPath}/`}); + hasAutoFixed = true; + } catch (e) { + console.error('Failed to create package-lock.json'); + } + } + } + if (packageJSON.toLowerCase().indexOf('eslintconfig') === -1) { console.warn('No esLintConfig in package.json'); if (autoFix) { @@ -191,11 +211,11 @@ fs.readdir(pluginPath, (err, rootFiles) => { } } - if (packageJSON.toLowerCase().indexOf('engines') === -1) { - console.warn('No engines in package.json'); + if ( (packageJSON.toLowerCase().indexOf('engines') === -1) || !parsedPackageJSON.engines.node) { + console.warn('No engines or node engine in package.json'); if (autoFix) { const engines = { - lint: 'eslint .', + node: '>=10.13.0', }; hasAutoFixed = true; parsedPackageJSON.engines = engines;