From 62b1cfb7aa8214c8b06b26f6e15a0d474ca4db42 Mon Sep 17 00:00:00 2001 From: Joseph Replin Date: Thu, 16 Jan 2025 20:33:53 -0600 Subject: [PATCH] Create v4.js --- migrations/v4.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 migrations/v4.js diff --git a/migrations/v4.js b/migrations/v4.js new file mode 100644 index 0000000..d6dcb8a --- /dev/null +++ b/migrations/v4.js @@ -0,0 +1,30 @@ +import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin } from 'adapt-migrations'; + +describe('adapt-contrib-blank - v2.0.0 > v4.1.3', async () => { + let blanks; + + whereFromPlugin('adapt-contrib-blank - from v2.0.0', { name: 'adapt-contrib-blank', version: '<=4.1.3' }); + + whereContent('adapt-contrib-blank - where blank', async content => { + blanks = content.filter(({ _component }) => _component === 'blank'); + if (blanks) return true; + }); + + /** + * * Add JSON field to component and set attribute. + */ + mutateContent('adapt-contrib-blank - add blank._isOptional', async () => { + blanks.forEach(blank => { + blank._isOptional = true; + }); + return true; + }); + + checkContent('adapt-contrib-blank - check blank._isOptional atrribute', async () => { + const isValid = blanks.every(({ _isOptional }) => _isOptional === true); + if (!isValid) throw new Error('adapt-contrib-blank - _isOptional not added to every instance of blank'); + return true; + }); + + updatePlugin('adapt-contrib-blank - update to v4.1.3', { name: 'adapt-contrib-blank', version: '4.1.3', framework: '>=4' }); +});