Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 20 additions & 1 deletion test/bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion types/plugins.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface SanityBuildPluginEntity {
name: string | null
},
]
compatibility: null
compatibility?: Compatibility[]
description: string
packageName: string
repoUrl: string
Expand Down