Skip to content

Commit 888c24b

Browse files
authored
fix: corrected sync issue from CMS that included _key in compatibility array items (#885)
1 parent 1d5250b commit 888c24b

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

bin/utils.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,16 @@ const stripNullifiedFields = (plugin) => {
203203
* return {BuildPluginEntity[]} The updated list of plugins
204204
*/
205205
export const updatePlugins = (changes, plugins) => {
206-
const pluginChanges = convertCmsChangesToRepoPlugin(changes)
206+
const { compatibility, ...restOfChanges } = changes
207+
const updatedCompatibility = compatibility?.map((compatibilityItem) => {
208+
// eslint-disable-next-line no-unused-vars
209+
const { _key, ...rest } = compatibilityItem
210+
211+
return rest
212+
})
213+
214+
const sanitizedChanges = { ...restOfChanges, compatibility: updatedCompatibility }
215+
const pluginChanges = convertCmsChangesToRepoPlugin(sanitizedChanges)
207216

208217
let pluginToUpdate = plugins.find((plugin) => plugin.package === pluginChanges.package)
209218

test/bin/utils.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,23 @@ test('should return no plugin diffs for Sanity if there are no changes', (t) =>
177177

178178
test('should update a plugin', (t) => {
179179
const changes = {
180-
compatibility: null,
181180
description: 'Require visual changes on production to be manually approved before going live!',
182181
packageName: 'netlify-plugin-visual-diff',
183182
repoUrl: 'https://github.com/applitools/netlify-plugin-visual-diff',
184183
status: 'active',
185184
title: 'Visual diff (Applitools)',
186185
version: '5.0.0',
186+
compatibility: [
187+
{
188+
_key: 'dfsfg3443sdfgdfgd',
189+
version: '3.0.0',
190+
},
191+
{
192+
_key: 'dfsfg3443sdfgdfgd',
193+
version: '1.3.0',
194+
nodeVersion: '<12.0.0',
195+
},
196+
],
187197
}
188198

189199
const plugins = [
@@ -231,6 +241,15 @@ test('should update a plugin', (t) => {
231241
package: 'netlify-plugin-visual-diff',
232242
repo: 'https://github.com/applitools/netlify-plugin-visual-diff',
233243
version: '5.0.0',
244+
compatibility: [
245+
{
246+
version: '3.0.0',
247+
},
248+
{
249+
version: '1.3.0',
250+
nodeVersion: '<12.0.0',
251+
},
252+
],
234253
},
235254
{
236255
author: 'pizzafox',

types/plugins.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface SanityBuildPluginEntity {
55
name: string | null
66
},
77
]
8-
compatibility: null
8+
compatibility?: Compatibility[]
99
description: string
1010
packageName: string
1111
repoUrl: string

0 commit comments

Comments
 (0)