@jungvonmatt/contentful-migrations 6.2.6 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,153 +1,90 @@
1
1
  {
2
2
  "name": "@jungvonmatt/contentful-migrations",
3
- "version": "6.2.6",
3
+ "version": "7.0.0",
4
4
  "description": "Helper to handle migrations in contentful",
5
- "main": "index.js",
6
- "files": [
7
- "index.d.ts",
8
- "index.js",
9
- "cli.js",
10
- "lib"
5
+ "keywords": [
6
+ "content-type",
7
+ "contentful",
8
+ "migration"
11
9
  ],
12
- "typings": "index.d.ts",
13
- "bin": {
14
- "contentful-migrations": "cli.js",
15
- "migrations": "cli.js"
16
- },
10
+ "license": "MIT",
11
+ "author": "Ben Zörb <benjamin.zoerb@jvm.de>",
17
12
  "repository": {
18
13
  "type": "git",
19
14
  "url": "git+https://github.com/jungvonmatt/contentful-migrations.git"
20
15
  },
21
- "author": "Ben Zörb <benjamin.zoerb@jvm.de>",
22
- "license": "MIT",
23
- "engines": {
24
- "node": ">=18"
16
+ "bin": {
17
+ "contentful-migrations": "cli.js",
18
+ "migrations": "cli.js"
25
19
  },
26
- "keywords": [
27
- "contentful",
28
- "migration",
29
- "content-type"
20
+ "files": [
21
+ "index.d.ts",
22
+ "index.js",
23
+ "cli.js",
24
+ "lib",
25
+ "!lib/**/*.test.js"
30
26
  ],
27
+ "main": "index.js",
28
+ "typings": "index.d.ts",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
31
32
  "dependencies": {
32
- "@contentful/rich-text-plain-text-renderer": "^17.1.6",
33
- "@jungvonmatt/contentful-config": "^4.0.3",
34
- "array.prototype.flatmap": "^1.3.3",
33
+ "@contentful/rich-text-plain-text-renderer": "^17.2.1",
34
+ "@jungvonmatt/contentful-config": "^5.0.1",
35
35
  "ascii-tree": "^0.3.0",
36
36
  "cli-progress": "^3.12.0",
37
- "commander": "^8.3.0",
37
+ "commander": "^14.0.3",
38
38
  "common-tags": "^1.8.2",
39
- "contentful-cli": "^3.10.2",
40
- "contentful-import": "^9.4.129",
41
- "contentful-management": "^11.67.0",
42
- "contentful-migration": "^4.31.5",
43
- "deep-diff": "^1.0.2",
44
- "diff": "^5.1.0",
39
+ "contentful-cli": "^4.0.1",
40
+ "contentful-import": "^10.0.5",
41
+ "contentful-management": "^12.5.0",
42
+ "contentful-migration": "^5.0.0",
43
+ "diff": "^9.0.0",
45
44
  "enquirer": "^2.4.1",
46
- "fs-extra": "^10.1.0",
47
- "globby": "^12.0.2",
45
+ "fs-extra": "^11.3.5",
48
46
  "markdown-table": "^3.0.4",
49
47
  "merge-options": "^3.0.4",
48
+ "microdiff": "^1.5.0",
50
49
  "mustache": "^4.2.0",
51
- "node-fetch": "^3.3.2",
52
- "node-object-hash": "^2.3.10",
53
- "picocolors": "^1.0.0",
54
- "pkg-up": "^4.0.0",
55
- "prettier": "^2.7.1",
56
- "read-pkg-up": "^9.1.0"
50
+ "node-object-hash": "^3.1.1",
51
+ "oxfmt": "^0.50.0",
52
+ "package-up": "^5.0.0",
53
+ "picocolors": "^1.1.1",
54
+ "read-package-up": "^12.0.0",
55
+ "tinyglobby": "^0.2.16"
57
56
  },
58
57
  "devDependencies": {
59
- "@babel/eslint-parser": "^7.28.5",
60
- "eslint": "^8.20.0",
61
- "eslint-config-prettier": "^8.5.0",
62
- "eslint-plugin-prettier": "^4.2.1",
63
- "husky": "^7.0.4",
64
- "jest": "^27.5.1",
65
- "jest-sonar-reporter": "^2.0.0",
66
- "lint-staged": "^12.1.2"
67
- },
68
- "publishConfig": {
69
- "access": "public"
70
- },
71
- "prettier": {
72
- "singleQuote": true,
73
- "printWidth": 120
58
+ "@vitest/coverage-v8": "^4.1.6",
59
+ "husky": "^9.1.7",
60
+ "lint-staged": "^17.0.5",
61
+ "oxlint": "^1.65.0",
62
+ "vitest": "^4.1.6"
74
63
  },
75
- "eslintConfig": {
76
- "ignorePatterns": [
77
- "**/*.d.ts"
78
- ],
79
- "plugins": [
80
- "prettier"
81
- ],
82
- "rules": {
83
- "prettier/prettier": "error"
84
- },
85
- "extends": [
86
- "prettier"
87
- ],
88
- "parser": "@babel/eslint-parser",
89
- "parserOptions": {
90
- "requireConfigFile": false,
91
- "allowImportExportEverywhere": true,
92
- "ecmaFeatures": {
93
- "ecmaVersion": 2017,
94
- "impliedStrict": true
95
- }
96
- },
97
- "env": {
98
- "node": true
64
+ "husky": {
65
+ "hooks": {
66
+ "pre-commit": "lint-staged"
99
67
  }
100
68
  },
101
69
  "lint-staged": {
102
70
  "*.{js,jsx,ts,tsx}": [
103
- "prettier --write --ignore-path .gitignore",
104
- "eslint --fix --ignore-path .gitignore"
105
- ],
106
- "*.md": [
107
- "prettier --write"
71
+ "oxfmt",
72
+ "oxlint --fix"
108
73
  ]
109
74
  },
110
- "jest": {
111
- "testResultsProcessor": "jest-sonar-reporter",
112
- "coverageDirectory": "<rootDir>/__coverage__/",
113
- "collectCoverageFrom": [
114
- "<rootDir>/lib/*/**"
115
- ],
116
- "roots": [
117
- "<rootDir>/lib/"
118
- ],
119
- "moduleFileExtensions": [
120
- "js"
121
- ],
122
- "testRegex": "/lib/.*\\.test.js$",
123
- "moduleDirectories": [
124
- "node_modules"
125
- ],
126
- "globals": {
127
- "DEVELOPMENT": false
128
- },
129
- "reporters": [
130
- "default"
131
- ]
132
- },
133
- "husky": {
134
- "hooks": {
135
- "pre-commit": "lint-staged"
136
- }
75
+ "engines": {
76
+ "node": ">=22"
137
77
  },
138
78
  "migrations": {
139
79
  "storage": "content",
140
80
  "migrationContentTypeId": "contentful-migrations",
141
81
  "directory": "migrations"
142
82
  },
143
- "jestSonar": {
144
- "reportPath": "__coverage__",
145
- "reportFile": "test-report.xml",
146
- "indent": 2
147
- },
148
83
  "scripts": {
149
- "test": "jest --coverage && pnpm run lint",
150
- "lint": "eslint . --ext .js,.ts,.tsx --ignore-path .gitignore",
151
- "fix-lint": "pnpm run lint -- --fix"
84
+ "test": "vitest run --coverage && pnpm run lint",
85
+ "lint": "oxlint",
86
+ "fix-lint": "oxlint --fix",
87
+ "fmt": "oxfmt",
88
+ "fmt:check": "oxfmt --check"
152
89
  }
153
90
  }
@@ -1,381 +0,0 @@
1
- const { getValidationHelpers } = require('./validation');
2
-
3
- describe('getValidationHelpers', () => {
4
- const getTestContentType = () => ({
5
- fields: [
6
- {
7
- id: 'selectWithOtherValidationProps',
8
- type: 'Text',
9
- validations: [
10
- {
11
- foo: 'test',
12
- },
13
- {
14
- in: ['foo', 'bar', 'baz'],
15
- message: 'Some message',
16
- },
17
- ],
18
- },
19
- {
20
- id: 'select',
21
- type: 'Text',
22
- validations: [
23
- {
24
- in: ['foo', 'bar', 'baz'],
25
- },
26
- ],
27
- },
28
- {
29
- id: 'reference',
30
- type: 'Text',
31
- validations: [
32
- {
33
- linkContentType: ['foo', 'bar', 'baz'],
34
- },
35
- ],
36
- },
37
- {
38
- id: 'string',
39
- type: 'Text',
40
- },
41
- {
42
- id: 'string-array',
43
- type: 'Array',
44
- items: [],
45
- },
46
- {
47
- id: 'richTextNoValidations',
48
- type: 'RichText',
49
- },
50
- {
51
- id: 'richTextFullValidations',
52
- type: 'RichText',
53
- validations: [
54
- {
55
- enabledMarks: ['bold', 'italic'],
56
- },
57
- {
58
- enabledNodeTypes: [
59
- 'blockquote',
60
- 'embedded-entry-block',
61
- 'hyperlink',
62
- 'entry-hyperlink',
63
- 'embedded-entry-inline',
64
- ],
65
- },
66
- {
67
- nodes: {
68
- 'embedded-entry-block': [
69
- {
70
- linkContentType: ['foo', 'baz'],
71
- },
72
- ],
73
- 'embedded-entry-inline': [
74
- {
75
- linkContentType: ['foo'],
76
- },
77
- ],
78
- },
79
- },
80
- ],
81
- },
82
- ],
83
- });
84
-
85
- const context = {
86
- makeRequest: () => Promise.resolve(getTestContentType()),
87
- };
88
-
89
- let resultValidation;
90
-
91
- const migration = {
92
- editContentType: () => ({
93
- editField: () => ({
94
- validations: (validationObject) => {
95
- resultValidation = validationObject;
96
- },
97
- }),
98
- }),
99
- };
100
-
101
- beforeEach(() => {
102
- resultValidation = undefined;
103
- });
104
-
105
- describe('addInValues', () => {
106
- it('should add values at the end', async () => {
107
- const validations = getValidationHelpers(migration, context);
108
- await validations.addInValues('some-content-type', 'selectWithOtherValidationProps', 'bat');
109
- expect(resultValidation).toEqual([
110
- {
111
- foo: 'test',
112
- },
113
- {
114
- in: ['foo', 'bar', 'baz', 'bat'],
115
- message: 'Some message',
116
- },
117
- ]);
118
- });
119
-
120
- it('should only add new values', async () => {
121
- const validations = getValidationHelpers(migration, context);
122
- await validations.addInValues('some-content-type', 'select', ['bat', 'foo', 'test']);
123
- expect(resultValidation).toEqual([
124
- {
125
- in: ['foo', 'bar', 'baz', 'bat', 'test'],
126
- },
127
- ]);
128
- });
129
-
130
- it('should add new values sorted', async () => {
131
- const validations = getValidationHelpers(migration, context);
132
- await validations.addInValues('some-content-type', 'select', ['bat', 'foo', 'test'], { mode: 'sorted' });
133
- expect(resultValidation).toEqual([
134
- {
135
- in: ['bar', 'bat', 'baz', 'foo', 'test'],
136
- },
137
- ]);
138
- });
139
-
140
- it('should add values where none where defined', async () => {
141
- const validations = getValidationHelpers(migration, context);
142
- await validations.addInValues('some-content-type', 'string', 'foo');
143
- expect(resultValidation).toEqual([
144
- {
145
- in: ['foo'],
146
- },
147
- ]);
148
- });
149
- });
150
-
151
- describe('removeInValues', () => {
152
- it('should remove values', async () => {
153
- const validations = getValidationHelpers(migration, context);
154
- await validations.removeInValues('some-content-type', 'select', ['foo', 'baz']);
155
- expect(resultValidation).toEqual([
156
- {
157
- in: ['bar'],
158
- },
159
- ]);
160
- });
161
- });
162
-
163
- describe('modifyInValues', () => {
164
- it('should modify values with custom function', async () => {
165
- const validations = getValidationHelpers(migration, context);
166
- await validations.modifyInValues('some-content-type', 'select', (values) => {
167
- const result = values.slice(0, values.length - 1); // remove bar
168
- result.push('test');
169
- return result;
170
- });
171
- expect(resultValidation).toEqual([
172
- {
173
- in: ['foo', 'bar', 'test'],
174
- },
175
- ]);
176
- });
177
- });
178
-
179
- describe('addLinkContentTypeValues', () => {
180
- it('should add values at the end', async () => {
181
- const validations = getValidationHelpers(migration, context);
182
- await validations.addLinkContentTypeValues('some-content-type', 'reference', 'bat');
183
- expect(resultValidation).toEqual([
184
- {
185
- linkContentType: ['foo', 'bar', 'baz', 'bat'],
186
- },
187
- ]);
188
- });
189
- });
190
-
191
- describe('removeLinkContentTypeValues', () => {
192
- it('should remove values', async () => {
193
- const validations = getValidationHelpers(migration, context);
194
- await validations.removeLinkContentTypeValues('some-content-type', 'reference', ['foo', 'baz']);
195
- expect(resultValidation).toEqual([
196
- {
197
- linkContentType: ['bar'],
198
- },
199
- ]);
200
- });
201
- });
202
-
203
- describe('modifyLinkContentTypeValues', () => {
204
- it('should modify unique values with custom function', async () => {
205
- const validations = getValidationHelpers(migration, context);
206
- await validations.modifyLinkContentTypeValues('some-content-type', 'reference', (values) => {
207
- const result = values.slice(0, values.length - 1); // remove bar
208
- result.push('test');
209
- result.push('foo'); // should be removed since it exists
210
- return result;
211
- });
212
- expect(resultValidation).toEqual([
213
- {
214
- linkContentType: ['foo', 'bar', 'test'],
215
- },
216
- ]);
217
- });
218
- });
219
-
220
- describe('richText', () => {
221
- describe('addEnabledMarksValue', () => {
222
- it('should add values at the end', async () => {
223
- const validations = getValidationHelpers(migration, context);
224
- await validations.richText.addEnabledMarksValues('some-content-type', 'richTextFullValidations', 'code');
225
- expect(resultValidation).toContainEqual({
226
- enabledMarks: ['bold', 'italic', 'code'],
227
- });
228
- });
229
- });
230
-
231
- describe('removeEnabledMarksValue', () => {
232
- it('should remove values', async () => {
233
- const validations = getValidationHelpers(migration, context);
234
- await validations.richText.removeEnabledMarksValues('some-content-type', 'richTextFullValidations', 'bold');
235
- expect(resultValidation).toContainEqual({
236
- enabledMarks: ['italic'],
237
- });
238
- });
239
- });
240
-
241
- describe('modifyEnabledMarksValue', () => {
242
- it('should modify unique values with custom function', async () => {
243
- const validations = getValidationHelpers(migration, context);
244
- await validations.richText.modifyEnabledMarksValues(
245
- 'some-content-type',
246
- 'richTextFullValidations',
247
- (values) => {
248
- const result = values.slice(0, values.length - 1); // remove italic
249
- result.push('code');
250
- result.push('bold'); // should be removed since it exists
251
- return result;
252
- }
253
- );
254
- expect(resultValidation).toContainEqual({
255
- enabledMarks: ['bold', 'code'],
256
- });
257
- });
258
- });
259
-
260
- describe('addEnabledNodeTypeValue', () => {
261
- it('should add values at the end', async () => {
262
- const validations = getValidationHelpers(migration, context);
263
- await validations.richText.addEnabledNodeTypeValues('some-content-type', 'richTextFullValidations', 'hr');
264
- expect(resultValidation).toContainEqual({
265
- enabledNodeTypes: [
266
- 'blockquote',
267
- 'embedded-entry-block',
268
- 'hyperlink',
269
- 'entry-hyperlink',
270
- 'embedded-entry-inline',
271
- 'hr',
272
- ],
273
- });
274
- });
275
- });
276
-
277
- describe('removeEnabledNodeTypeValue', () => {
278
- it('should remove values', async () => {
279
- const validations = getValidationHelpers(migration, context);
280
- await validations.richText.removeEnabledNodeTypeValues(
281
- 'some-content-type',
282
- 'richTextFullValidations',
283
- 'blockquote'
284
- );
285
- expect(resultValidation).toContainEqual({
286
- enabledNodeTypes: ['embedded-entry-block', 'hyperlink', 'entry-hyperlink', 'embedded-entry-inline'],
287
- });
288
- });
289
- });
290
-
291
- describe('modifyEnabledNodeTypeValue', () => {
292
- it('should modify unique values with custom function', async () => {
293
- const validations = getValidationHelpers(migration, context);
294
- await validations.richText.modifyEnabledNodeTypeValues(
295
- 'some-content-type',
296
- 'richTextFullValidations',
297
- (values) => {
298
- const result = values.slice(0, values.length - 1); // remove embedded-entry-inline
299
- result.push('hr');
300
- result.push('blockquote'); // should be removed since it exists
301
- return result;
302
- }
303
- );
304
- expect(resultValidation).toContainEqual({
305
- enabledNodeTypes: ['blockquote', 'embedded-entry-block', 'hyperlink', 'entry-hyperlink', 'hr'],
306
- });
307
- });
308
- });
309
-
310
- describe('addNodeContentTypeValues', () => {
311
- it('should add values at the end', async () => {
312
- const validations = getValidationHelpers(migration, context);
313
- await validations.richText.addNodeContentTypeValues(
314
- 'some-content-type',
315
- 'richTextFullValidations',
316
- 'embedded-entry-block',
317
- 'bar'
318
- );
319
- expect(resultValidation.find((v) => v.nodes).nodes['embedded-entry-block']).toEqual([
320
- {
321
- linkContentType: ['foo', 'baz', 'bar'],
322
- },
323
- ]);
324
- });
325
-
326
- it('should add complete entry if not existing', async () => {
327
- const validations = getValidationHelpers(migration, context);
328
- await validations.richText.addNodeContentTypeValues(
329
- 'some-content-type',
330
- 'richTextFullValidations',
331
- 'entry-hyperlink',
332
- 'bar'
333
- );
334
- expect(resultValidation.find((v) => v.nodes).nodes['entry-hyperlink']).toEqual([
335
- {
336
- linkContentType: ['bar'],
337
- },
338
- ]);
339
- });
340
- });
341
-
342
- describe('removeNodeContentTypeValues', () => {
343
- it('should remove values', async () => {
344
- const validations = getValidationHelpers(migration, context);
345
- await validations.richText.removeNodeContentTypeValues(
346
- 'some-content-type',
347
- 'richTextFullValidations',
348
- 'embedded-entry-block',
349
- 'foo'
350
- );
351
- expect(resultValidation.find((v) => v.nodes).nodes['embedded-entry-block']).toEqual([
352
- {
353
- linkContentType: ['baz'],
354
- },
355
- ]);
356
- });
357
- });
358
-
359
- describe('modifyNodeContentTypeValues', () => {
360
- it('should modify unique values with custom function', async () => {
361
- const validations = getValidationHelpers(migration, context);
362
- await validations.richText.modifyNodeContentTypeValues(
363
- 'some-content-type',
364
- 'richTextFullValidations',
365
- 'embedded-entry-block',
366
- (values) => {
367
- const result = values.slice(0, values.length - 1); // remove foo
368
- result.push('bar');
369
- result.push('baz'); // should be removed since it exists
370
- return result;
371
- }
372
- );
373
- expect(resultValidation.find((v) => v.nodes).nodes['embedded-entry-block']).toEqual([
374
- {
375
- linkContentType: ['foo', 'bar', 'baz'],
376
- },
377
- ]);
378
- });
379
- });
380
- });
381
- });
@@ -1,45 +0,0 @@
1
- const { addOrdered, addValues, unique } = require('./validation.utils');
2
-
3
- describe('unique', () => {
4
- it('should remove duplicates', async () => {
5
- expect(unique(['foo', 'bar', 'foo', 'baz', 'bar'])).toEqual(['foo', 'bar', 'baz']);
6
- });
7
- });
8
-
9
- describe('addOrdered', () => {
10
- const a1 = ['foo', 'bar'];
11
- const a2 = ['baz', 'bar', 'bat'];
12
-
13
- it('should add unique values and order the list', async () => {
14
- expect(addOrdered(a1, a2)).toEqual(['bar', 'bat', 'baz', 'foo']);
15
- });
16
- });
17
-
18
- describe('addValues', () => {
19
- const a1 = ['foo', 'bar', 'test'];
20
- const a2 = ['baz', 'bar', 'bat'];
21
-
22
- it('should add values sorted', async () => {
23
- expect(addValues(a1, a2, { mode: 'sorted' })).toEqual(['bar', 'bat', 'baz', 'foo', 'test']);
24
- });
25
-
26
- it('should add values at start', async () => {
27
- expect(addValues(a1, a2, { mode: 'start' })).toEqual(['baz', 'bar', 'bat', 'foo', 'test']);
28
- });
29
-
30
- it('should add values at end', async () => {
31
- expect(addValues(a1, a2, { mode: 'end' })).toEqual(['foo', 'bar', 'test', 'baz', 'bat']);
32
- });
33
-
34
- it('should add values before', async () => {
35
- expect(addValues(a1, a2, { mode: 'before', ref: 'bar' })).toEqual(['foo', 'baz', 'bar', 'bat', 'test']);
36
- });
37
-
38
- it('should add values before fallback', async () => {
39
- expect(addValues(a1, a2, { mode: 'before', ref: 'unknown' })).toEqual(['foo', 'bar', 'test', 'baz', 'bat']);
40
- });
41
-
42
- it('should add values after', async () => {
43
- expect(addValues(a1, a2, { mode: 'after', ref: 'bar' })).toEqual(['foo', 'bar', 'baz', 'bat', 'test']);
44
- });
45
- });