@jungvonmatt/contentful-migrations 6.2.2 → 6.2.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JvM Contentful Migrations
2
2
 
3
- [![NPM Version][npm-image]][npm-url] [![Sonarcloud Status][sonarcloud-image]][sonarcloud-url]
3
+ [![NPM Version][npm-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Sonarcloud Status][sonarcloud-image]][sonarcloud-url]
4
4
 
5
5
  JvM Contentful Migrations offers additional functionality on top of the existing migration functionality of the [Contentful CLI](https://github.com/contentful/contentful-cli). It makes it easy and safe to deploy changes to your content model in a way that can be reviewed and tested before being deployed to production. With migrations you can do almost everything with your content and your content model. See the [official documentation](https://github.com/contentful/contentful-migration) for more information.
6
6
 
@@ -9,7 +9,14 @@ JvM Contentful Migrations offers additional functionality on top of the existing
9
9
  ### Install
10
10
 
11
11
  ```bash
12
+ # pnpm
13
+ pnpm add @jungvonmatt/contentful-migrations
14
+
15
+ # npm
12
16
  npm i @jungvonmatt/contentful-migrations
17
+
18
+ # yarn
19
+ yarn add @jungvonmatt/contentful-migrations
13
20
  ```
14
21
 
15
22
  ### Initialize
@@ -296,3 +303,5 @@ free to open up an issue and we can discuss it.
296
303
  [npm-image]: https://img.shields.io/npm/v/@jungvonmatt/contentful-migrations.svg
297
304
  [sonarcloud-url]: https://sonarcloud.io/dashboard?id=jungvonmatt_contentful-migrations
298
305
  [sonarcloud-image]: https://sonarcloud.io/api/project_badges/measure?project=jungvonmatt_contentful-migrations&metric=alert_status
306
+ [ci-url]: https://github.com/jungvonmatt/contentful-migrations/actions?workflow=Tests
307
+ [ci-image]: https://github.com/jungvonmatt/contentful-migrations/workflows/Tests/badge.svg
package/lib/backend.js CHANGED
@@ -136,11 +136,15 @@ const addMigrationEntry = async (data, config) => {
136
136
  entry.fields.name = { [defaultLocale]: name };
137
137
  entry.fields.state = { [defaultLocale]: state };
138
138
  entry.fields.message = { [defaultLocale]: message || '' };
139
- await entry.update();
139
+ }
140
+
141
+ try {
140
142
  if (state === STATE_SUCCESS) {
141
143
  await entry.publish();
144
+ } else {
145
+ await entry.unpublish();
142
146
  }
143
- }
147
+ } catch {}
144
148
  };
145
149
 
146
150
  /**
package/lib/contentful.js CHANGED
@@ -120,6 +120,11 @@ const getSpace = async (options) => {
120
120
  return spaceCache.get(spaceId);
121
121
  };
122
122
 
123
+ const getOrganizationId = async (options) => {
124
+ const space = await getSpace(options);
125
+ return space?.sys?.organization?.sys?.id;
126
+ };
127
+
123
128
  const getEnvironments = async (options) => {
124
129
  const space = await getSpace(options);
125
130
  const { items: environments } = await space.getEnvironments();
@@ -354,6 +359,7 @@ const getEditorInterfaces = async (options) => {
354
359
  exports.getClient = getClient;
355
360
  exports.getSpaces = getSpaces;
356
361
  exports.getSpace = getSpace;
362
+ exports.getOrganizationId = getOrganizationId;
357
363
  exports.getEnvironments = getEnvironments;
358
364
  exports.getEnvironment = getEnvironment;
359
365
  exports.getDefaultLocale = getDefaultLocale;
package/lib/migration.js CHANGED
@@ -141,6 +141,7 @@ const executeMigration = async (file, config) => {
141
141
  const { managementToken, requestBatchSize, spaceId } = config || {};
142
142
  const client = await getEnvironment(config);
143
143
  const environmentId = client.sys.id;
144
+ const organizationId = await getOrganizationId(config);
144
145
  const name = path.basename(file);
145
146
  const [, version] = /^(\d+)-/.exec(name);
146
147
 
@@ -149,6 +150,7 @@ const executeMigration = async (file, config) => {
149
150
  accessToken: managementToken,
150
151
  spaceId,
151
152
  environmentId,
153
+ organizationId,
152
154
  requestBatchSize,
153
155
  yes: true,
154
156
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jungvonmatt/contentful-migrations",
3
- "version": "6.2.2",
3
+ "version": "6.2.4",
4
4
  "description": "Helper to handle migrations in contentful",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -14,11 +14,6 @@
14
14
  "contentful-migrations": "cli.js",
15
15
  "migrations": "cli.js"
16
16
  },
17
- "scripts": {
18
- "test": "jest --coverage && npm run lint",
19
- "lint": "eslint . --ext .js,.ts,.tsx --ignore-path .gitignore",
20
- "fix-lint": "npm run lint -- --fix"
21
- },
22
17
  "repository": {
23
18
  "type": "git",
24
19
  "url": "git+https://github.com/jungvonmatt/contentful-migrations.git"
@@ -34,17 +29,17 @@
34
29
  "content-type"
35
30
  ],
36
31
  "dependencies": {
37
- "@contentful/rich-text-plain-text-renderer": "^17.1.0",
38
- "@jungvonmatt/contentful-config": "^4.0.1",
32
+ "@contentful/rich-text-plain-text-renderer": "^17.1.6",
33
+ "@jungvonmatt/contentful-config": "^4.0.3",
39
34
  "array.prototype.flatmap": "^1.3.3",
40
35
  "ascii-tree": "^0.3.0",
41
36
  "cli-progress": "^3.12.0",
42
37
  "commander": "^8.3.0",
43
38
  "common-tags": "^1.8.2",
44
- "contentful-cli": "^3.8.12",
45
- "contentful-import": "^9.4.111",
46
- "contentful-management": "^11.54.4",
47
- "contentful-migration": "^4.31.1",
39
+ "contentful-cli": "^3.10.2",
40
+ "contentful-import": "^9.4.129",
41
+ "contentful-management": "^11.67.0",
42
+ "contentful-migration": "^4.31.5",
48
43
  "deep-diff": "^1.0.2",
49
44
  "diff": "^5.1.0",
50
45
  "enquirer": "^2.4.1",
@@ -61,7 +56,7 @@
61
56
  "read-pkg-up": "^9.1.0"
62
57
  },
63
58
  "devDependencies": {
64
- "@babel/eslint-parser": "^7.18.2",
59
+ "@babel/eslint-parser": "^7.28.5",
65
60
  "eslint": "^8.20.0",
66
61
  "eslint-config-prettier": "^8.5.0",
67
62
  "eslint-plugin-prettier": "^4.2.1",
@@ -149,5 +144,10 @@
149
144
  "reportPath": "__coverage__",
150
145
  "reportFile": "test-report.xml",
151
146
  "indent": 2
147
+ },
148
+ "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"
152
152
  }
153
- }
153
+ }