@contentstack/cli-cm-branches 1.0.20 → 1.0.22
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 +1 -1
- package/lib/branch/merge-handler.js +19 -22
- package/lib/utils/create-merge-scripts.js +5 -6
- package/lib/utils/entry-create-script.js +1 -1
- package/lib/utils/entry-create-update-script.js +1 -1
- package/lib/utils/entry-update-script.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches
|
|
|
37
37
|
$ csdx COMMAND
|
|
38
38
|
running command...
|
|
39
39
|
$ csdx (--version)
|
|
40
|
-
@contentstack/cli-cm-branches/1.0.
|
|
40
|
+
@contentstack/cli-cm-branches/1.0.22 linux-x64 node-v18.19.0
|
|
41
41
|
$ csdx --help [COMMAND]
|
|
42
42
|
USAGE
|
|
43
43
|
$ csdx COMMAND
|
|
@@ -218,29 +218,21 @@ class MergeHandler {
|
|
|
218
218
|
async executeEntryExpFlow(mergeJobUID, mergePayload) {
|
|
219
219
|
const { mergeContent } = this.mergeSettings;
|
|
220
220
|
let mergePreference = await (0, utils_1.selectContentMergePreference)();
|
|
221
|
-
let selectedMergePreference;
|
|
222
221
|
const updateEntryMergeStrategy = (items, mergeStrategy) => {
|
|
223
222
|
items &&
|
|
224
223
|
items.forEach((item) => {
|
|
225
224
|
item.entry_merge_strategy = mergeStrategy;
|
|
226
225
|
});
|
|
227
226
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
break;
|
|
238
|
-
case 'existing':
|
|
239
|
-
selectedMergePreference = 'merge_existing';
|
|
240
|
-
updateEntryMergeStrategy(mergeContent.content_types.modified, selectedMergePreference);
|
|
241
|
-
break;
|
|
242
|
-
case 'ask_preference':
|
|
243
|
-
selectedMergePreference = 'custom';
|
|
227
|
+
const mergePreferencesMap = {
|
|
228
|
+
'existing_new': 'merge_existing_new',
|
|
229
|
+
'new': 'merge_new',
|
|
230
|
+
'existing': 'merge_existing',
|
|
231
|
+
'ask_preference': 'custom',
|
|
232
|
+
};
|
|
233
|
+
const selectedMergePreference = mergePreferencesMap[mergePreference];
|
|
234
|
+
if (selectedMergePreference) {
|
|
235
|
+
if (selectedMergePreference === 'custom') {
|
|
244
236
|
const selectedMergeItems = await (0, utils_1.selectContentMergeCustomPreferences)(mergeContent.content_types);
|
|
245
237
|
mergeContent.content_types = {
|
|
246
238
|
added: [],
|
|
@@ -250,10 +242,15 @@ class MergeHandler {
|
|
|
250
242
|
selectedMergeItems === null || selectedMergeItems === void 0 ? void 0 : selectedMergeItems.forEach((item) => {
|
|
251
243
|
mergeContent.content_types[item.status].push(item.value);
|
|
252
244
|
});
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
updateEntryMergeStrategy(mergeContent.content_types.added, selectedMergePreference);
|
|
248
|
+
updateEntryMergeStrategy(mergeContent.content_types.modified, selectedMergePreference);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
cli_utilities_1.cliux.error(`error: Invalid preference ${mergePreference}`);
|
|
253
|
+
process.exit(1);
|
|
257
254
|
}
|
|
258
255
|
let scriptFolderPath = (0, utils_1.generateMergeScripts)(mergeContent.content_types, mergeJobUID);
|
|
259
256
|
if (scriptFolderPath !== undefined) {
|
|
@@ -261,7 +258,7 @@ class MergeHandler {
|
|
|
261
258
|
cli_utilities_1.cliux.print('\nWARNING!!! Migration is not intended to be run more than once. Migrated(entries/assets) will be duplicated if run more than once', { color: 'yellow' });
|
|
262
259
|
let migrationCommand;
|
|
263
260
|
if (os_1.default.platform() === 'win32') {
|
|
264
|
-
migrationCommand = `csdx cm:stacks:migration --multiple --file-path ./${scriptFolderPath} --config compare-branch:${mergePayload.compare_branch}
|
|
261
|
+
migrationCommand = `csdx cm:stacks:migration --multiple --file-path ./${scriptFolderPath} --config compare-branch:${mergePayload.compare_branch} file-path:./${scriptFolderPath} --branch ${mergePayload.base_branch} --stack-api-key ${this.stackAPIKey}`;
|
|
265
262
|
}
|
|
266
263
|
else {
|
|
267
264
|
migrationCommand = `csdx cm:stacks:migration --multiple --file-path ./${scriptFolderPath} --config {compare-branch:${mergePayload.compare_branch},file-path:./${scriptFolderPath}} --branch ${mergePayload.base_branch} --stack-api-key ${this.stackAPIKey}`;
|
|
@@ -29,18 +29,16 @@ function generateMergeScripts(mergeSummary, mergeJobUID) {
|
|
|
29
29
|
};
|
|
30
30
|
const processContentTypes = (contentTypes, messageType) => {
|
|
31
31
|
if (contentTypes && contentTypes.length > 0) {
|
|
32
|
-
processContentType({ type: 'assets', uid: '', entry_merge_strategy: '' }, mergeStrategies['asset_create_folder']);
|
|
33
32
|
contentTypes.forEach((contentType) => {
|
|
34
33
|
const mergeStrategy = contentType.entry_merge_strategy;
|
|
35
34
|
if (mergeStrategies.hasOwnProperty(mergeStrategy)) {
|
|
36
35
|
processContentType(contentType, mergeStrategies[mergeStrategy]);
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
|
-
|
|
40
|
-
else {
|
|
41
|
-
cli_utilities_1.cliux.print(`No ${messageType} entries selected for merge`, { color: 'yellow' });
|
|
38
|
+
cli_utilities_1.cliux.print(`Info: Entries of ${messageType} content types selected for the migration`, { color: 'blue' });
|
|
42
39
|
}
|
|
43
40
|
};
|
|
41
|
+
processContentType({ type: 'assets', uid: '', entry_merge_strategy: '' }, mergeStrategies['asset_create_folder']);
|
|
44
42
|
processContentTypes(mergeSummary.modified, 'Modified');
|
|
45
43
|
processContentTypes(mergeSummary.added, 'New');
|
|
46
44
|
return scriptFolderPath;
|
|
@@ -85,11 +83,12 @@ function createMergeScripts(contentType, mergeJobUID, content) {
|
|
|
85
83
|
fs_1.default.mkdirSync(fullPath);
|
|
86
84
|
}
|
|
87
85
|
let filePath;
|
|
86
|
+
let milliSeconds = date.getMilliseconds().toString().padStart(3, '0');
|
|
88
87
|
if (contentType.type === 'assets') {
|
|
89
|
-
filePath = `${fullPath}/${fileCreatedAt}_create_assets_folder.js`;
|
|
88
|
+
filePath = `${fullPath}/${fileCreatedAt}${milliSeconds}_create_assets_folder.js`;
|
|
90
89
|
}
|
|
91
90
|
else {
|
|
92
|
-
filePath = `${fullPath}/${fileCreatedAt}_${getContentTypeMergeStatus(contentType.entry_merge_strategy)}_${contentType.uid}.js`;
|
|
91
|
+
filePath = `${fullPath}/${fileCreatedAt}${milliSeconds}_${getContentTypeMergeStatus(contentType.entry_merge_strategy)}_${contentType.uid}.js`;
|
|
93
92
|
}
|
|
94
93
|
fs_1.default.writeFileSync(filePath, content, 'utf-8');
|
|
95
94
|
}
|
|
@@ -185,7 +185,7 @@ function entryCreateScript(contentType) {
|
|
|
185
185
|
text = JSON.stringify(_entry);
|
|
186
186
|
}
|
|
187
187
|
markdownRegEx = new RegExp(
|
|
188
|
-
'(https://(assets|(eu-|azure-na-|azure-eu-)?images).contentstack.(io|com)/v3/assets/(.*?)/(.*?)/(.*?)/(.*?)(?="))',
|
|
188
|
+
'(https://(assets|(eu-|azure-na-|azure-eu-|gcp-na-)?images).contentstack.(io|com)/v3/assets/(.*?)/(.*?)/(.*?)/(.*?)(?="))',
|
|
189
189
|
'g',
|
|
190
190
|
);
|
|
191
191
|
while ((markdownMatch = markdownRegEx.exec(text)) !== null) {
|
|
@@ -207,7 +207,7 @@ function entryCreateUpdateScript(contentType) {
|
|
|
207
207
|
text = JSON.stringify(_entry);
|
|
208
208
|
}
|
|
209
209
|
markdownRegEx = new RegExp(
|
|
210
|
-
'(https://(assets|(eu-|azure-na-|azure-eu-)?images).contentstack.(io|com)/v3/assets/(.*?)/(.*?)/(.*?)/(.*?)(?="))',
|
|
210
|
+
'(https://(assets|(eu-|azure-na-|azure-eu-|gcp-na-)?images).contentstack.(io|com)/v3/assets/(.*?)/(.*?)/(.*?)/(.*?)(?="))',
|
|
211
211
|
'g',
|
|
212
212
|
);
|
|
213
213
|
while ((markdownMatch = markdownRegEx.exec(text)) !== null) {
|
|
@@ -207,7 +207,7 @@ function entryUpdateScript(contentType) {
|
|
|
207
207
|
text = JSON.stringify(_entry);
|
|
208
208
|
}
|
|
209
209
|
markdownRegEx = new RegExp(
|
|
210
|
-
'(https://(assets|(eu-|azure-na-|azure-eu-)?images).contentstack.(io|com)/v3/assets/(.*?)/(.*?)/(.*?)/(.*?)(?="))',
|
|
210
|
+
'(https://(assets|(eu-|azure-na-|azure-eu-|gcp-na-)?images).contentstack.(io|com)/v3/assets/(.*?)/(.*?)/(.*?)/(.*?)(?="))',
|
|
211
211
|
'g',
|
|
212
212
|
);
|
|
213
213
|
while ((markdownMatch = markdownRegEx.exec(text)) !== null) {
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-branches",
|
|
3
3
|
"description": "Contentstack CLI plugin to do branches operations",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.22",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@contentstack/cli-command": "~1.2.16",
|
|
9
|
-
"@contentstack/cli-utilities": "~1.5.
|
|
9
|
+
"@contentstack/cli-utilities": "~1.5.11",
|
|
10
10
|
"@oclif/core": "^2.9.3",
|
|
11
11
|
"async": "^3.2.4",
|
|
12
12
|
"big-json": "^3.2.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@contentstack/cli-auth": "~1.3.17",
|
|
29
|
-
"@contentstack/cli-config": "~1.
|
|
29
|
+
"@contentstack/cli-config": "~1.6.0",
|
|
30
30
|
"@contentstack/cli-dev-dependencies": "~1.2.4",
|
|
31
31
|
"@oclif/plugin-help": "^5.1.19",
|
|
32
32
|
"@oclif/test": "^1.2.6",
|
|
@@ -95,4 +95,4 @@
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
"repository": "https://github.com/contentstack/cli"
|
|
98
|
-
}
|
|
98
|
+
}
|