checkPlugin: Ensure that a peer dep for `ep_etherpad-lite` exists
Tweak the new `updateDeps()` function and use it to add the `ep_etherpad-lite` dependency if it is missing.image-example
parent
42da976705
commit
9f4bcfb79b
|
@ -53,11 +53,13 @@ const writePackageJson = (obj) => {
|
||||||
const updateDeps = (parsedPackageJson, key, wantDeps) => {
|
const updateDeps = (parsedPackageJson, key, wantDeps) => {
|
||||||
const {[key]: deps = {}} = parsedPackageJson;
|
const {[key]: deps = {}} = parsedPackageJson;
|
||||||
let changed = false;
|
let changed = false;
|
||||||
for (const [pkg, ver] of Object.entries(wantDeps)) {
|
for (const [pkg, verInfo] of Object.entries(wantDeps)) {
|
||||||
|
const {ver, overwrite = true} = typeof verInfo === 'string' ? {ver: verInfo} : verInfo;
|
||||||
if (deps[pkg] === ver) continue;
|
if (deps[pkg] === ver) continue;
|
||||||
if (deps[pkg] == null) {
|
if (deps[pkg] == null) {
|
||||||
console.warn(`Missing dependency in ${key}: '${pkg}': '${ver}'`);
|
console.warn(`Missing dependency in ${key}: '${pkg}': '${ver}'`);
|
||||||
} else {
|
} else {
|
||||||
|
if (!overwrite) continue;
|
||||||
console.warn(`Dependency mismatch in ${key}: '${pkg}': '${ver}' (current: ${deps[pkg]})`);
|
console.warn(`Dependency mismatch in ${key}: '${pkg}': '${ver}' (current: ${deps[pkg]})`);
|
||||||
}
|
}
|
||||||
if (autoFix) {
|
if (autoFix) {
|
||||||
|
@ -247,18 +249,10 @@ fs.readdir(pluginPath, (err, rootFiles) => {
|
||||||
'eslint-plugin-you-dont-need-lodash-underscore': '^6.10.0',
|
'eslint-plugin-you-dont-need-lodash-underscore': '^6.10.0',
|
||||||
});
|
});
|
||||||
|
|
||||||
// include peer deps config
|
updateDeps(parsedPackageJSON, 'peerDependencies', {
|
||||||
if (packageJSON.toLowerCase().indexOf('peerdependencies') === -1 || !parsedPackageJSON.peerDependencies) {
|
// Some plugins require a newer version of Etherpad so don't overwrite if already set.
|
||||||
console.warn('Missing peer deps reference in package.json');
|
'ep_etherpad-lite': {ver: '>=1.8.6', overwrite: false},
|
||||||
if (autoFix) {
|
});
|
||||||
const peerDependencies = {
|
|
||||||
'ep_etherpad-lite': '>=1.8.6',
|
|
||||||
};
|
|
||||||
hasAutoFixed = true;
|
|
||||||
parsedPackageJSON.peerDependencies = peerDependencies;
|
|
||||||
writePackageJson(parsedPackageJSON);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packageJSON.toLowerCase().indexOf('eslintconfig') === -1) {
|
if (packageJSON.toLowerCase().indexOf('eslintconfig') === -1) {
|
||||||
console.warn('No esLintConfig in package.json');
|
console.warn('No esLintConfig in package.json');
|
||||||
|
|
Loading…
Reference in New Issue