diff --git a/bin/utils.js b/bin/utils.js index a0d0f480b..25bb7d42e 100644 --- a/bin/utils.js +++ b/bin/utils.js @@ -203,7 +203,16 @@ const stripNullifiedFields = (plugin) => { * return {BuildPluginEntity[]} The updated list of plugins */ export const updatePlugins = (changes, plugins) => { - const pluginChanges = convertCmsChangesToRepoPlugin(changes) + const { compatibility, ...restOfChanges } = changes + const updatedCompatibility = compatibility?.map((compatibilityItem) => { + // eslint-disable-next-line no-unused-vars + const { _key, ...rest } = compatibilityItem + + return rest + }) + + const sanitizedChanges = { ...restOfChanges, compatibility: updatedCompatibility } + const pluginChanges = convertCmsChangesToRepoPlugin(sanitizedChanges) let pluginToUpdate = plugins.find((plugin) => plugin.package === pluginChanges.package) diff --git a/test/bin/utils.js b/test/bin/utils.js index c19c305b8..d9e6168e6 100644 --- a/test/bin/utils.js +++ b/test/bin/utils.js @@ -177,13 +177,23 @@ test('should return no plugin diffs for Sanity if there are no changes', (t) => test('should update a plugin', (t) => { const changes = { - compatibility: null, description: 'Require visual changes on production to be manually approved before going live!', packageName: 'netlify-plugin-visual-diff', repoUrl: 'https://github.com/applitools/netlify-plugin-visual-diff', status: 'active', title: 'Visual diff (Applitools)', version: '5.0.0', + compatibility: [ + { + _key: 'dfsfg3443sdfgdfgd', + version: '3.0.0', + }, + { + _key: 'dfsfg3443sdfgdfgd', + version: '1.3.0', + nodeVersion: '<12.0.0', + }, + ], } const plugins = [ @@ -231,6 +241,15 @@ test('should update a plugin', (t) => { package: 'netlify-plugin-visual-diff', repo: 'https://github.com/applitools/netlify-plugin-visual-diff', version: '5.0.0', + compatibility: [ + { + version: '3.0.0', + }, + { + version: '1.3.0', + nodeVersion: '<12.0.0', + }, + ], }, { author: 'pizzafox', diff --git a/types/plugins.d.ts b/types/plugins.d.ts index 32f797e2f..1e4b1250d 100644 --- a/types/plugins.d.ts +++ b/types/plugins.d.ts @@ -5,7 +5,7 @@ export interface SanityBuildPluginEntity { name: string | null }, ] - compatibility: null + compatibility?: Compatibility[] description: string packageName: string repoUrl: string