@jungvonmatt/contentful-migrations 6.1.1 → 6.1.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/cli.js +19 -9
- package/lib/config.js +1 -0
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -82,8 +82,6 @@ program
|
|
|
82
82
|
]
|
|
83
83
|
);
|
|
84
84
|
|
|
85
|
-
const { managementToken, accessToken, environmentId, spaceId, ...rest } = config;
|
|
86
|
-
|
|
87
85
|
if (config.storage === STORAGE_CONTENT) {
|
|
88
86
|
await initializeContentModel(config);
|
|
89
87
|
await migrateToContentStorage(config);
|
|
@@ -92,24 +90,35 @@ program
|
|
|
92
90
|
await migrateToTagStorage(config);
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
if (!process.env.CONTENTFUL_SPACE_ID) {
|
|
96
|
-
rest.spaceId = spaceId;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
93
|
const storeConfig = await confirm({ message: 'Do you want to store the configuration?' });
|
|
100
94
|
|
|
101
95
|
if (storeConfig) {
|
|
96
|
+
// only store relevant config values without management token
|
|
97
|
+
// management token should not be stored inside the project
|
|
98
|
+
const { host, spaceId, environmentId, storage, fieldId, migrationContentTypeId, directory } = config;
|
|
99
|
+
|
|
100
|
+
const data = {
|
|
101
|
+
host,
|
|
102
|
+
spaceId,
|
|
103
|
+
environmentId,
|
|
104
|
+
directory,
|
|
105
|
+
storage,
|
|
106
|
+
...(storage === STORAGE_CONTENT ? { migrationContentTypeId } : { fieldId }),
|
|
107
|
+
};
|
|
108
|
+
|
|
102
109
|
// try to store in package.json
|
|
103
110
|
const { pkgUp } = await import('pkg-up');
|
|
104
111
|
const localPkg = await pkgUp();
|
|
105
112
|
if (localPkg) {
|
|
106
113
|
const packageJson = await fs.readJson(localPkg);
|
|
107
|
-
|
|
108
|
-
packageJson.migrations =
|
|
114
|
+
data.directory = path.relative(path.dirname(localPkg), data.directory);
|
|
115
|
+
packageJson.migrations = data;
|
|
109
116
|
await fs.outputJson(localPkg, packageJson, { spaces: 2 });
|
|
110
117
|
} else {
|
|
111
118
|
// store in .migrationsrc if no package.json is available
|
|
112
|
-
|
|
119
|
+
const cwd = cmd.cwd ? path.resolve(cmd.cwd) : process.cwd();
|
|
120
|
+
data.directory = path.relative(cwd, data.directory);
|
|
121
|
+
await fs.outputJson(path.join(cwd, '.migrationsrc.json'), data, { spaces: 2 });
|
|
113
122
|
}
|
|
114
123
|
}
|
|
115
124
|
})
|
|
@@ -134,6 +143,7 @@ program
|
|
|
134
143
|
'environmentId',
|
|
135
144
|
'directory',
|
|
136
145
|
]);
|
|
146
|
+
|
|
137
147
|
await fetchMigration({ ...config, contentType: cmd.contentType });
|
|
138
148
|
})
|
|
139
149
|
);
|
package/lib/config.js
CHANGED
|
@@ -16,6 +16,7 @@ const STATE_FAILURE = 'failure';
|
|
|
16
16
|
const getConfig = async (args, required = [], prompt = []) => {
|
|
17
17
|
const { configFile, cwd, ...overrides } = args;
|
|
18
18
|
const { loadContentfulConfig } = await import('@jungvonmatt/contentful-config');
|
|
19
|
+
|
|
19
20
|
const result = await loadContentfulConfig('migrations', {
|
|
20
21
|
configFile,
|
|
21
22
|
cwd,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jungvonmatt/contentful-migrations",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.2",
|
|
4
4
|
"description": "Helper to handle migrations in contentful",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@contentful/rich-text-plain-text-renderer": "^15.12.1",
|
|
38
|
-
"@jungvonmatt/contentful-config": "^3.0.
|
|
38
|
+
"@jungvonmatt/contentful-config": "^3.0.5",
|
|
39
39
|
"array.prototype.flatmap": "^1.3.3",
|
|
40
40
|
"ascii-tree": "^0.3.0",
|
|
41
41
|
"cli-progress": "^3.11.2",
|