@jungvonmatt/contentful-migrations 5.0.1 → 5.0.2
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/index.js +2 -1
- package/lib/backend.js +3 -1
- package/lib/migration.js +15 -2
- package/package.json +10 -11
package/index.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
/* eslint-env node */
|
|
5
5
|
const fs = require('fs-extra');
|
|
6
6
|
const path = require('path');
|
|
7
|
-
const pkgUp = require('pkg-up');
|
|
8
7
|
const chalk = require('chalk');
|
|
9
8
|
const { Command } = require('commander');
|
|
10
9
|
|
|
@@ -79,6 +78,8 @@ program
|
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
// try to store in package.json
|
|
81
|
+
|
|
82
|
+
const {pkgUp} = await import('pkg-up');
|
|
82
83
|
const localPkg = await pkgUp();
|
|
83
84
|
if (localPkg) {
|
|
84
85
|
const packageJson = await fs.readJson(localPkg);
|
package/lib/backend.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const globby = require('globby');
|
|
3
2
|
const chalk = require('chalk');
|
|
4
3
|
const cliProgress = require('cli-progress');
|
|
5
4
|
const { getEnvironment, getDefaultLocale } = require('./contentful');
|
|
@@ -192,6 +191,8 @@ const migrateToContentStorage = async (config) => {
|
|
|
192
191
|
|
|
193
192
|
const client = await getEnvironment(config);
|
|
194
193
|
const version = await getMigrationVersionFromTag(config);
|
|
194
|
+
|
|
195
|
+
const {globby} = await import('globby');
|
|
195
196
|
const migrations = await globby(`${directory}/*.js`);
|
|
196
197
|
const environmentId = client.sys.id;
|
|
197
198
|
const filtered = migrations.filter((file) => {
|
|
@@ -357,6 +358,7 @@ const getLatestVersion = async (config) => {
|
|
|
357
358
|
*/
|
|
358
359
|
const getNewMigrations = async (config) => {
|
|
359
360
|
const { directory, storage } = config || {};
|
|
361
|
+
const {globby} = await import('globby');
|
|
360
362
|
const migrations = await globby(`${directory}/*.js`);
|
|
361
363
|
|
|
362
364
|
if (storage === STORAGE_CONTENT) {
|
package/lib/migration.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const fs = require('fs-extra');
|
|
2
|
+
const prettier = require('prettier');
|
|
2
3
|
const path = require('path');
|
|
3
4
|
const { stripIndent } = require('common-tags');
|
|
4
5
|
const runMigration = require('contentful-migration/built/bin/cli').runMigration;
|
|
@@ -33,10 +34,18 @@ const createMigration = async (config) => {
|
|
|
33
34
|
// See: https://github.com/contentful/contentful-migration
|
|
34
35
|
}`;
|
|
35
36
|
|
|
36
|
-
await fs.outputFile(filename, content);
|
|
37
|
+
await fs.outputFile(filename, await format(filename, content));
|
|
37
38
|
console.log(`Generated new migration file to ${chalk.green(filename)}`);
|
|
38
39
|
};
|
|
39
40
|
|
|
41
|
+
const format = async (file, content) => {
|
|
42
|
+
const prettierOptions = await prettier.resolveConfig(file, {editorconfig: true});
|
|
43
|
+
return prettier.format(content, {
|
|
44
|
+
parser: 'babel',
|
|
45
|
+
...prettierOptions,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
/**
|
|
41
50
|
* Fetch migration from contentful
|
|
42
51
|
* @param {Object} config The config object including all required data
|
|
@@ -51,8 +60,12 @@ const fetchMigration = async (config) => {
|
|
|
51
60
|
|
|
52
61
|
const promises = contentTypes.map(async (entry) => {
|
|
53
62
|
const filename = path.join(directory, `${timestamp++}-create-${entry.sys.id}-migration.js`);
|
|
63
|
+
|
|
64
|
+
|
|
54
65
|
const content = await generateMigrationScript(client, [entry]);
|
|
55
|
-
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
await fs.outputFile(filename, await format(filename, content));
|
|
56
69
|
console.log(`Generated new migration file to ${chalk.green(filename)}`);
|
|
57
70
|
});
|
|
58
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jungvonmatt/contentful-migrations",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Helper to handle migrations in contentful",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -30,39 +30,39 @@
|
|
|
30
30
|
"content-type"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@contentful/rich-text-plain-text-renderer": "^15.
|
|
33
|
+
"@contentful/rich-text-plain-text-renderer": "^15.6.2",
|
|
34
34
|
"array.prototype.flatmap": "^1.2.5",
|
|
35
35
|
"ascii-tree": "^0.3.0",
|
|
36
36
|
"chalk": "^4.1.2",
|
|
37
37
|
"cli-progress": "^3.9.1",
|
|
38
38
|
"commander": "^8.3.0",
|
|
39
|
-
"common-tags": "^1.8.
|
|
39
|
+
"common-tags": "^1.8.2",
|
|
40
40
|
"contentful-cli": "^1.8.23",
|
|
41
41
|
"contentful-import": "^8.2.22",
|
|
42
|
-
"contentful-management": "^7.
|
|
42
|
+
"contentful-management": "^7.45.2",
|
|
43
43
|
"contentful-migration": "^4.3.0",
|
|
44
44
|
"cosmiconfig": "^7.0.1",
|
|
45
45
|
"deep-diff": "^1.0.2",
|
|
46
46
|
"diff": "^5.0.0",
|
|
47
47
|
"dotenv": "^10.0.0",
|
|
48
48
|
"fs-extra": "^10.0.0",
|
|
49
|
-
"globby": "^
|
|
49
|
+
"globby": "^12.0.2",
|
|
50
50
|
"inquirer": "^8.2.0",
|
|
51
51
|
"markdown-table": "^3.0.1",
|
|
52
52
|
"merge-options": "^3.0.4",
|
|
53
53
|
"mustache": "^4.2.0",
|
|
54
|
-
"node-fetch": "^3.
|
|
54
|
+
"node-fetch": "^3.1.0",
|
|
55
55
|
"node-object-hash": "^2.3.10",
|
|
56
|
-
"
|
|
56
|
+
"prettier": "^2.4.1",
|
|
57
|
+
"pkg-up": "^4.0.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"babel-eslint": "^10.1.0",
|
|
60
|
-
"eslint": "^8.
|
|
61
|
+
"eslint": "^8.3.0",
|
|
61
62
|
"eslint-config-prettier": "^8.3.0",
|
|
62
63
|
"eslint-plugin-prettier": "^4.0.0",
|
|
63
64
|
"husky": "^7.0.4",
|
|
64
|
-
"lint-staged": "^
|
|
65
|
-
"prettier": "^2.4.1"
|
|
65
|
+
"lint-staged": "^12.1.2"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
@@ -108,7 +108,6 @@
|
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
"migrations": {
|
|
111
|
-
"spaceId": "89na9aswdzfj",
|
|
112
111
|
"storage": "content",
|
|
113
112
|
"migrationContentTypeId": "contentful-migrations",
|
|
114
113
|
"directory": "migrations"
|