@contentstack/cli-cm-bulk-publish 1.6.0 → 1.7.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/README.md +391 -232
- package/package.json +5 -5
- package/src/commands/cm/assets/publish.js +17 -19
- package/src/commands/cm/assets/unpublish.js +11 -12
- package/src/commands/cm/bulk-publish/cross-publish.js +18 -7
- package/src/commands/cm/entries/publish-modified.js +16 -16
- package/src/commands/cm/entries/publish-non-localized-fields.js +14 -16
- package/src/commands/cm/entries/publish-only-unpublished.js +17 -17
- package/src/commands/cm/entries/publish.js +37 -19
- package/src/commands/cm/entries/unpublish.js +21 -14
- package/src/commands/cm/entries/update-and-publish.js +24 -17
- package/src/commands/cm/stacks/publish-configure.js +2 -2
- package/src/commands/cm/stacks/publish-revert.js +4 -4
- package/src/commands/cm/stacks/unpublish.js +2 -2
- package/src/producer/cross-publish.js +84 -5
- package/src/producer/publish-entries.js +100 -7
- package/src/producer/unpublish.js +77 -10
|
@@ -21,11 +21,19 @@ class PublishEntriesCommand extends Command {
|
|
|
21
21
|
entriesFlags.publishAllContentTypes =
|
|
22
22
|
entriesFlags['publish-all-content-types'] || entriesFlags.publishAllContentTypes || false;
|
|
23
23
|
entriesFlags.apiVersion = entriesFlags['api-version'] || '3';
|
|
24
|
+
entriesFlags.includeVariants = entriesFlags['include-variants'] || entriesFlags.includeVariants || false;
|
|
25
|
+
entriesFlags.entryUid = entriesFlags['entry-uid'] || entriesFlags.entryUid;
|
|
26
|
+
|
|
27
|
+
if (entriesFlags.entryUid === undefined) {
|
|
28
|
+
delete entriesFlags['entryUid'];
|
|
29
|
+
}
|
|
24
30
|
delete entriesFlags['api-version'];
|
|
25
31
|
delete entriesFlags['retry-failed'];
|
|
26
32
|
delete entriesFlags['content-types'];
|
|
27
33
|
delete entriesFlags['bulk-publish'];
|
|
28
34
|
delete entriesFlags['publish-all-content-types'];
|
|
35
|
+
delete entriesFlags['include-variants'];
|
|
36
|
+
delete entriesFlags['entry-uid'];
|
|
29
37
|
|
|
30
38
|
let updatedFlags;
|
|
31
39
|
try {
|
|
@@ -168,82 +176,86 @@ But, if retry-failed flag is set, then only a logfile is required
|
|
|
168
176
|
`;
|
|
169
177
|
|
|
170
178
|
PublishEntriesCommand.flags = {
|
|
171
|
-
alias: flags.string({ char: 'a', description: 'Alias(name)
|
|
179
|
+
alias: flags.string({ char: 'a', description: 'Alias (name) of the management token. You must use either the --alias flag or the --stack-api-key flag.' }),
|
|
172
180
|
'stack-api-key': flags.string({
|
|
173
181
|
char: 'k',
|
|
174
|
-
description: '
|
|
182
|
+
description: 'API key of the source stack. You must use either the --stack-api-key flag or the --alias flag.',
|
|
175
183
|
}),
|
|
176
184
|
retryFailed: flags.string({
|
|
177
185
|
char: 'r',
|
|
178
186
|
description:
|
|
179
|
-
'
|
|
187
|
+
'(optional) Use this option to retry publishing the failed entries/ assets from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.',
|
|
180
188
|
hidden: true,
|
|
181
189
|
parse: printFlagDeprecation(['-r', '--retryFailed'], ['--retry-failed']),
|
|
182
190
|
}),
|
|
183
191
|
'retry-failed': flags.string({
|
|
184
192
|
description:
|
|
185
|
-
'(optional)
|
|
193
|
+
'(optional) Use this option to retry publishing the failed entries/ assets from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.',
|
|
186
194
|
}),
|
|
187
195
|
bulkPublish: flags.string({
|
|
188
196
|
char: 'b',
|
|
189
|
-
description:
|
|
190
|
-
"This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to publish the entries",
|
|
197
|
+
description: `Set this flag to use Contentstack\'s Bulk Publish APIs. This flag is set to true, by default.`,
|
|
191
198
|
hidden: true,
|
|
192
199
|
parse: printFlagDeprecation(['-b', '--bulkPublish'], ['--bulk-publish']),
|
|
193
200
|
}),
|
|
194
201
|
'bulk-publish': flags.string({
|
|
195
202
|
description:
|
|
196
|
-
|
|
203
|
+
`Set this flag to use Contentstack\'s Bulk Publish APIs. This flag is set to true, by default.`,
|
|
197
204
|
default: 'true',
|
|
198
205
|
}),
|
|
199
206
|
'api-version': flags.string({
|
|
200
|
-
description :
|
|
207
|
+
description : 'API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].',
|
|
201
208
|
}),
|
|
202
209
|
'publish-all-content-types': flags.boolean({
|
|
203
|
-
description: '(optional)
|
|
210
|
+
description: '(optional) Set it to true to bulk publish entries from all content types. If the --content-types option is already used, then you cannot use this option.',
|
|
204
211
|
}),
|
|
205
212
|
publishAllContentTypes: flags.boolean({
|
|
206
213
|
char: 'o',
|
|
207
|
-
description: '
|
|
214
|
+
description: '(optional) Set it to true to bulk publish entries from all content types. If the --content-types option is already used, then you cannot use this option.',
|
|
208
215
|
hidden: true,
|
|
209
216
|
parse: printFlagDeprecation(['-o', '--publishAllContentTypes'], ['--publish-all-content-types']),
|
|
210
217
|
}),
|
|
211
218
|
'content-types': flags.string({
|
|
212
|
-
description: 'The
|
|
219
|
+
description: 'The UID of the content type(s) whose entries you want to publish in bulk. In case of multiple content types, specify the IDs separated by spaces.',
|
|
213
220
|
multiple: true,
|
|
214
221
|
}),
|
|
215
222
|
contentTypes: flags.string({
|
|
216
223
|
char: 't',
|
|
217
|
-
description: 'The
|
|
224
|
+
description: 'The UID of the content type(s) whose entries you want to publish in bulk. In case of multiple content types, specify the IDs separated by spaces.',
|
|
218
225
|
multiple: true,
|
|
219
226
|
parse: printFlagDeprecation(['-t', '--contentTypes'], ['--content-types']),
|
|
220
227
|
hidden: true,
|
|
221
228
|
}),
|
|
222
229
|
locales: flags.string({
|
|
223
230
|
char: 'l',
|
|
224
|
-
description: 'Locales
|
|
231
|
+
description: ' Locales in which entries will be published, e.g., en-us. In the case of multiple locales, specify the codes separated by spaces.',
|
|
225
232
|
multiple: true,
|
|
226
233
|
parse: printFlagDeprecation(['-l'], ['--locales']),
|
|
227
234
|
}),
|
|
228
235
|
environments: flags.string({
|
|
229
236
|
char: 'e',
|
|
230
|
-
description: '
|
|
237
|
+
description: 'The name of the environment on which entries will be published. In case of multiple environments, specify their names separated by spaces.',
|
|
231
238
|
multiple: true,
|
|
232
239
|
}),
|
|
233
240
|
config: flags.string({
|
|
234
241
|
char: 'c',
|
|
235
242
|
description:
|
|
236
|
-
'
|
|
243
|
+
'(optional) The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.',
|
|
237
244
|
}),
|
|
238
|
-
yes: flags.boolean({ char: 'y', description: '
|
|
245
|
+
yes: flags.boolean({ char: 'y', description: 'Set it to true to process the command with the current configuration.' }),
|
|
239
246
|
branch: flags.string({
|
|
240
247
|
char: 'B',
|
|
241
248
|
default: 'main',
|
|
242
|
-
description: '
|
|
249
|
+
description: 'The name of the branch where you want to perform the bulk publish operation. If you don’t mention the branch name, then by default the content from main branch will be published.',
|
|
243
250
|
parse: printFlagDeprecation(['-B'], ['--branch']),
|
|
244
251
|
}),
|
|
245
|
-
'delivery-token': flags.string({ description: '
|
|
252
|
+
'delivery-token': flags.string({ description: 'The delivery token of the source environment.' }),
|
|
246
253
|
'source-env': flags.string({ description: 'Source environment' }),
|
|
254
|
+
'entry-uid': flags.string({ description: 'Entry Uid for publish all associated variant entries.' }),
|
|
255
|
+
'include-variants': flags.boolean({
|
|
256
|
+
default: false, // set the default value to false
|
|
257
|
+
description: 'Include Variants flag will publish all associated variant entries with base entry.',
|
|
258
|
+
}),
|
|
247
259
|
};
|
|
248
260
|
|
|
249
261
|
PublishEntriesCommand.examples = [
|
|
@@ -267,11 +279,17 @@ PublishEntriesCommand.examples = [
|
|
|
267
279
|
'',
|
|
268
280
|
'Using --stack-api-key',
|
|
269
281
|
'csdx cm:entries:publish -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN]',
|
|
282
|
+
'',
|
|
283
|
+
'Using --include-variants',
|
|
284
|
+
'csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] [--include-variants]',
|
|
285
|
+
'',
|
|
286
|
+
'Using --entry-uid and --include-variants',
|
|
287
|
+
'csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] --entry-uid [ENTRY UID] [--include-variants]',
|
|
270
288
|
];
|
|
271
289
|
|
|
272
290
|
PublishEntriesCommand.aliases = ['cm:bulk-publish:entries'];
|
|
273
291
|
|
|
274
292
|
PublishEntriesCommand.usage =
|
|
275
|
-
'cm:entries:publish [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--publish-all-content-types] [--content-types <value>] [--locales <value>] [-e <value>] [-c <value>] [-y] [--branch <value>] [--delivery-token <value>] [--source-env <value>]';
|
|
293
|
+
'cm:entries:publish [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--publish-all-content-types] [--content-types <value>] [--locales <value>] [-e <value>] [-c <value>] [-y] [--branch <value>] [--delivery-token <value>] [--source-env <value>] [--entry-uid <value>] [--include-variants]';
|
|
276
294
|
|
|
277
295
|
module.exports = PublishEntriesCommand;
|
|
@@ -19,11 +19,13 @@ class UnpublishCommand extends Command {
|
|
|
19
19
|
unpublishFlags.onlyAssets = false;
|
|
20
20
|
unpublishFlags.onlyEntries = true;
|
|
21
21
|
unpublishFlags.apiVersion = unpublishFlags['api-version'] || '3';
|
|
22
|
+
unpublishFlags.includeVariants = unpublishFlags['include-variants'] || false;
|
|
22
23
|
delete unpublishFlags['api-version'];
|
|
23
24
|
delete unpublishFlags['retry-failed'];
|
|
24
25
|
delete unpublishFlags['bulk-unpublish'];
|
|
25
26
|
delete unpublishFlags['content-type'];
|
|
26
27
|
delete unpublishFlags['delivery-token'];
|
|
28
|
+
delete unpublishFlags['include-variants'];
|
|
27
29
|
|
|
28
30
|
let updatedFlags;
|
|
29
31
|
try {
|
|
@@ -59,7 +61,6 @@ class UnpublishCommand extends Command {
|
|
|
59
61
|
updatedFlags.deliveryToken = await cliux.prompt('Enter delivery token of your source environment');
|
|
60
62
|
}
|
|
61
63
|
updatedFlags.bulkUnpublish = updatedFlags.bulkUnpublish === 'false' ? false : true;
|
|
62
|
-
|
|
63
64
|
stack = await getStack(config);
|
|
64
65
|
}
|
|
65
66
|
if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) {
|
|
@@ -135,47 +136,50 @@ But, if retry-failed flag is set, then only a logfile is required`;
|
|
|
135
136
|
UnpublishCommand.flags = {
|
|
136
137
|
alias: flags.string({
|
|
137
138
|
char: 'a',
|
|
138
|
-
description: 'Alias(name) for the management token',
|
|
139
|
+
description: 'Alias (name) for the management token. You must use either the --alias flag or the --stack-api-key flag.',
|
|
139
140
|
}),
|
|
140
141
|
'stack-api-key': flags.string({
|
|
141
142
|
char: 'k',
|
|
142
|
-
description: '
|
|
143
|
+
description: 'API key of the source stack. You must use either the --stack-api-key flag or the --alias flag.',
|
|
143
144
|
}),
|
|
144
145
|
environment: flags.string({
|
|
145
146
|
char: 'e',
|
|
146
|
-
description: '
|
|
147
|
+
description: 'The name of the environment from where entries/assets need to be unpublished.',
|
|
147
148
|
}),
|
|
148
149
|
config: flags.string({
|
|
149
150
|
char: 'c',
|
|
150
|
-
description: 'Path to the
|
|
151
|
+
description: '(optional) Path to the configuration JSON file containing all options for a single run. Refer to the configure command to create a configuration file.',
|
|
151
152
|
}),
|
|
152
153
|
yes: flags.boolean({
|
|
153
154
|
char: 'y',
|
|
154
|
-
description: '
|
|
155
|
+
description: 'Set to true to process the command with the current configuration.',
|
|
155
156
|
}),
|
|
156
157
|
locale: flags.string({
|
|
157
|
-
description: 'Locale
|
|
158
|
+
description: 'Locale from which entries/assets will be unpublished, e.g., en-us.',
|
|
158
159
|
}),
|
|
159
160
|
branch: flags.string({
|
|
160
161
|
default: 'main',
|
|
161
|
-
description: 'Specify the branch to fetch the content
|
|
162
|
+
description: 'Specify the branch to fetch the content. If not mentioned, the main branch will be used by default.',
|
|
162
163
|
}),
|
|
163
164
|
'retry-failed': flags.string({
|
|
164
|
-
description: '
|
|
165
|
+
description: '(optional) Use this option to retry unpublishing the failed entries from the logfile. Specify the name of the logfile that lists failed unpublish calls. If used, this option will override all other flags.',
|
|
165
166
|
}),
|
|
166
167
|
'bulk-unpublish': flags.string({
|
|
167
|
-
description:
|
|
168
|
-
"This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to unpublish the entries",
|
|
168
|
+
description: "This flag is set to true by default. It indicates that Contentstack's Bulk Publish APIs will be used to unpublish the entries.",
|
|
169
169
|
default: 'true',
|
|
170
170
|
}),
|
|
171
171
|
'api-version': flags.string({
|
|
172
|
-
description
|
|
172
|
+
description: 'API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].',
|
|
173
173
|
}),
|
|
174
174
|
'content-type': flags.string({
|
|
175
|
-
description: '
|
|
175
|
+
description: 'The UID of the content type whose entries you want to unpublish in bulk.',
|
|
176
176
|
}),
|
|
177
177
|
'delivery-token': flags.string({
|
|
178
|
-
description: '
|
|
178
|
+
description: 'The delivery token of the source environment.',
|
|
179
|
+
}),
|
|
180
|
+
'include-variants': flags.boolean({
|
|
181
|
+
default: false, // set the default value to false
|
|
182
|
+
description: 'Include Variants flag will unpublish all associated variant entries.'
|
|
179
183
|
}),
|
|
180
184
|
};
|
|
181
185
|
|
|
@@ -196,6 +200,9 @@ UnpublishCommand.examples = [
|
|
|
196
200
|
'',
|
|
197
201
|
'Using --stack-api-key flag',
|
|
198
202
|
'csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN]',
|
|
203
|
+
'',
|
|
204
|
+
'Using --include-variants flag',
|
|
205
|
+
'csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN] --include-variants',
|
|
199
206
|
];
|
|
200
207
|
|
|
201
208
|
module.exports = UnpublishCommand;
|
|
@@ -117,67 +117,74 @@ But, if retry-failed flag is set, then only a logfile is required
|
|
|
117
117
|
`;
|
|
118
118
|
|
|
119
119
|
UpdateAndPublishCommand.flags = {
|
|
120
|
-
alias: flags.string({
|
|
120
|
+
alias: flags.string({
|
|
121
|
+
char: 'a',
|
|
122
|
+
description: 'Alias (name) of the management token. You must use either the --alias flag or the --stack-api-key flag.',
|
|
123
|
+
}),
|
|
121
124
|
'stack-api-key': flags.string({
|
|
122
125
|
char: 'k',
|
|
123
|
-
description: '
|
|
126
|
+
description: 'API key of the source stack. You must use either the --stack-api-key flag or the --alias flag.',
|
|
124
127
|
}),
|
|
125
128
|
'retry-failed': flags.string({
|
|
126
|
-
description: '
|
|
129
|
+
description: 'Use this option to retry publishing the failed entries from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.',
|
|
127
130
|
}),
|
|
128
131
|
'bulk-publish': flags.string({
|
|
129
|
-
description:
|
|
130
|
-
"This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to publish the entries",
|
|
132
|
+
description: "Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.",
|
|
131
133
|
default: 'true',
|
|
132
134
|
}),
|
|
133
135
|
'api-version': flags.string({
|
|
134
|
-
description
|
|
136
|
+
description: "API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
|
|
135
137
|
}),
|
|
136
138
|
'content-types': flags.string({
|
|
137
|
-
description: 'The
|
|
139
|
+
description: 'The UID of the content type ID whose entries you want to publish in bulk. In case of multiple content types, specify their IDs separated by spaces.',
|
|
138
140
|
multiple: true,
|
|
139
141
|
}),
|
|
140
142
|
environments: flags.string({
|
|
141
143
|
char: 'e',
|
|
142
|
-
description: '
|
|
144
|
+
description: 'The name of the environment on which entries will be published. In case of multiple environments, specify their names separated by spaces.',
|
|
143
145
|
multiple: true,
|
|
144
146
|
}),
|
|
145
|
-
config: flags.string({
|
|
146
|
-
|
|
147
|
+
config: flags.string({
|
|
148
|
+
char: 'c',
|
|
149
|
+
description: '(optional) The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.',
|
|
150
|
+
}),
|
|
151
|
+
yes: flags.boolean({
|
|
152
|
+
char: 'y',
|
|
153
|
+
description: 'Set it to true to process the command with the current configuration.',
|
|
154
|
+
}),
|
|
147
155
|
locales: flags.string({
|
|
148
156
|
char: 'l',
|
|
149
|
-
description: 'Locales
|
|
157
|
+
description: 'Locales in which entries will be published, e.g., en-us. In the case of multiple locales, specify the codes separated by spaces.',
|
|
150
158
|
multiple: true,
|
|
151
159
|
parse: printFlagDeprecation(['-l'], ['--locales']),
|
|
152
160
|
}),
|
|
153
161
|
branch: flags.string({
|
|
154
162
|
char: 'B',
|
|
155
163
|
default: 'main',
|
|
156
|
-
description: '
|
|
164
|
+
description: 'The name of the branch where you want to perform the bulk publish operation. If you don’t mention the branch name, then by default the content from the main branch will be published.',
|
|
157
165
|
parse: printFlagDeprecation(['-B'], ['--branch']),
|
|
158
166
|
}),
|
|
159
167
|
force: flags.boolean({
|
|
160
168
|
default: false,
|
|
161
|
-
description: 'Update and publish all entries even if no fields have been added',
|
|
169
|
+
description: 'Update and publish all entries even if no fields have been added.',
|
|
162
170
|
}),
|
|
163
171
|
|
|
164
172
|
// To be deprecated
|
|
165
173
|
retryFailed: flags.string({
|
|
166
174
|
char: 'r',
|
|
167
|
-
description: 'Retry publishing failed entries from the logfile (optional, overrides all other flags)',
|
|
175
|
+
description: 'Retry publishing failed entries from the logfile (optional, overrides all other flags).',
|
|
168
176
|
hidden: true,
|
|
169
177
|
parse: printFlagDeprecation(['-r', '--retryFailed'], ['--retry-failed']),
|
|
170
178
|
}),
|
|
171
179
|
bulkPublish: flags.string({
|
|
172
180
|
char: 'b',
|
|
173
|
-
description:
|
|
174
|
-
"This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to publish the entries",
|
|
181
|
+
description: "This flag is set to true by default. It indicates that contentstack's bulk publish API will be used to publish the entries.",
|
|
175
182
|
hidden: true,
|
|
176
183
|
parse: printFlagDeprecation(['-b', '--bulkPublish'], ['--bulk-publish']),
|
|
177
184
|
}),
|
|
178
185
|
contentTypes: flags.string({
|
|
179
186
|
char: 't',
|
|
180
|
-
description: 'The Contenttypes from which entries will be published',
|
|
187
|
+
description: 'The Contenttypes from which entries will be published.',
|
|
181
188
|
multiple: true,
|
|
182
189
|
parse: printFlagDeprecation(['-t', '--contentTypes'], ['--content-types']),
|
|
183
190
|
}),
|
|
@@ -35,8 +35,8 @@ class ConfigureCommand extends Command {
|
|
|
35
35
|
ConfigureCommand.description = `The configure command is used to generate a configuration file for publish scripts.`;
|
|
36
36
|
|
|
37
37
|
ConfigureCommand.flags = {
|
|
38
|
-
alias: flags.string({ char: 'a', description: '
|
|
39
|
-
'stack-api-key': flags.string({ char: 'k', description: '
|
|
38
|
+
alias: flags.string({ char: 'a', description: 'Name (alias) of the management token you want to use. You must use either the --alias flag or the --stack-api-key flag.' }),
|
|
39
|
+
'stack-api-key': flags.string({ char: 'k', description: 'API key of the source stack. You must use either the --stack-api-key flag or the --alias flag.' }),
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
ConfigureCommand.examples = [
|
|
@@ -71,19 +71,19 @@ A log file name is required to execute revert command
|
|
|
71
71
|
`;
|
|
72
72
|
|
|
73
73
|
RevertCommand.flags = {
|
|
74
|
-
'retry-failed': flags.string({ description: 'retry publishing failed entries from the logfile' }),
|
|
75
|
-
'log-file': flags.string({ description: 'logfile
|
|
74
|
+
'retry-failed': flags.string({ description: '(optional) Use this option to retry publishing the failed entries from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.' }),
|
|
75
|
+
'log-file': flags.string({ description: 'Path of the success logfile of a particular publish action.' }),
|
|
76
76
|
|
|
77
77
|
//To be deprecated
|
|
78
78
|
retryFailed: flags.string({
|
|
79
79
|
char: 'r',
|
|
80
|
-
description: 'retry publishing failed entries from the logfile',
|
|
80
|
+
description: '(optional) Use this option to retry publishing the failed entries from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.',
|
|
81
81
|
hidden: true,
|
|
82
82
|
parse: printFlagDeprecation(['-r', '--retryFailed'], ['--retry-failed']),
|
|
83
83
|
}),
|
|
84
84
|
logFile: flags.string({
|
|
85
85
|
char: 'l',
|
|
86
|
-
description: 'logfile
|
|
86
|
+
description: 'Path of the success logfile of a particular publish action.',
|
|
87
87
|
hidden: true,
|
|
88
88
|
parse: printFlagDeprecation(['-l', '--logFile'], ['--log-file']),
|
|
89
89
|
}),
|
|
@@ -203,13 +203,13 @@ UnpublishCommand.flags = {
|
|
|
203
203
|
default: 'true',
|
|
204
204
|
}),
|
|
205
205
|
'api-version': flags.string({
|
|
206
|
-
description : "API
|
|
206
|
+
description : "API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
|
|
207
207
|
}),
|
|
208
208
|
'content-type': flags.string({
|
|
209
209
|
description: 'Content type filter',
|
|
210
210
|
}),
|
|
211
211
|
'delivery-token': flags.string({
|
|
212
|
-
description: '
|
|
212
|
+
description: 'The delivery token of the source environment.',
|
|
213
213
|
}),
|
|
214
214
|
'only-assets': flags.boolean({
|
|
215
215
|
description: 'Unpublish only assets',
|
|
@@ -16,6 +16,7 @@ const { Command } = require('@contentstack/cli-command');
|
|
|
16
16
|
const command = new Command();
|
|
17
17
|
const { isEmpty } = require('../util');
|
|
18
18
|
const { fetchBulkPublishLimit } = require('../util/common-utility');
|
|
19
|
+
const VARIANTS_PUBLISH_API_VERSION = '3.2';
|
|
19
20
|
|
|
20
21
|
let bulkPublishSet = [];
|
|
21
22
|
let bulkPublishAssetSet = [];
|
|
@@ -34,20 +35,30 @@ function getQueryParams(filter) {
|
|
|
34
35
|
return queryString;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion, bulkPublishLimit) {
|
|
38
|
+
async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion, bulkPublishLimit, variantsFlag = false) {
|
|
38
39
|
return new Promise(async (resolve) => {
|
|
39
40
|
for (let index = 0; index < items.length; index++) {
|
|
40
41
|
changedFlag = true;
|
|
41
42
|
|
|
42
43
|
if (bulkPublish) {
|
|
43
44
|
if (bulkPublishSet.length < bulkPublishLimit && items[index].type === 'entry_published') {
|
|
44
|
-
|
|
45
|
+
const entry = {
|
|
45
46
|
uid: items[index].data.uid,
|
|
46
47
|
content_type: items[index].content_type_uid,
|
|
47
48
|
locale: items[index].data.locale || 'en-us',
|
|
48
49
|
version: items[index].data._version,
|
|
49
50
|
publish_details: [items[index].data.publish_details] || [],
|
|
50
|
-
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (variantsFlag && Array.isArray(items[index].data.variants) && items[index].data.variants.length > 0) {
|
|
54
|
+
entry.variants = items[index].data.variants || [];
|
|
55
|
+
entry.variant_rules = {
|
|
56
|
+
publish_latest_base: false,
|
|
57
|
+
publish_latest_base_conditionally: true
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
bulkPublishSet.push(JSON.parse(JSON.stringify(entry)));
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
if (bulkPublishAssetSet.length < bulkPublishLimit && items[index].type === 'asset_published') {
|
|
@@ -145,6 +156,7 @@ async function getSyncEntries(
|
|
|
145
156
|
destEnv,
|
|
146
157
|
apiVersion,
|
|
147
158
|
bulkPublishLimit,
|
|
159
|
+
variantsFlag = false,
|
|
148
160
|
paginationToken = null,
|
|
149
161
|
) {
|
|
150
162
|
return new Promise(async (resolve, reject) => {
|
|
@@ -200,8 +212,19 @@ async function getSyncEntries(
|
|
|
200
212
|
);
|
|
201
213
|
}
|
|
202
214
|
|
|
215
|
+
if (variantsFlag) {
|
|
216
|
+
for (let index = 0; index < entriesResponse?.items?.length; index++) {
|
|
217
|
+
let variants = [];
|
|
218
|
+
const entries = entriesResponse.items[index];
|
|
219
|
+
variants = await getVariantEntries(stack, entries.content_type_uid, entriesResponse, index, queryParamsObj);
|
|
220
|
+
if (variants.length > 0) {
|
|
221
|
+
entriesResponse.items[index].data.variants = variants;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
203
226
|
if (entriesResponse.items.length > 0) {
|
|
204
|
-
await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv, apiVersion, bulkPublishLimit);
|
|
227
|
+
await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv, apiVersion, bulkPublishLimit, variantsFlag);
|
|
205
228
|
}
|
|
206
229
|
if (!entriesResponse.pagination_token) {
|
|
207
230
|
if (!changedFlag) console.log('No Entries/Assets Found published on specified environment');
|
|
@@ -244,6 +267,48 @@ function setConfig(conf, bp) {
|
|
|
244
267
|
filePath = initializeLogger(logFileName);
|
|
245
268
|
}
|
|
246
269
|
|
|
270
|
+
async function getVariantEntries(stack, contentType, entries, index, queryParams, skip = 0) {
|
|
271
|
+
try {
|
|
272
|
+
let variantQueryParams = {
|
|
273
|
+
locale: queryParams.locale || 'en-us',
|
|
274
|
+
include_count: true,
|
|
275
|
+
skip: skip, // Adding skip parameter for pagination
|
|
276
|
+
limit: 100, // Set a limit to fetch up to 100 entries per request
|
|
277
|
+
};
|
|
278
|
+
const entryUid = entries.items[index].data.uid
|
|
279
|
+
const variantsEntriesResponse = await stack
|
|
280
|
+
.contentType(contentType)
|
|
281
|
+
.entry(entryUid)
|
|
282
|
+
.variants()
|
|
283
|
+
.query(variantQueryParams)
|
|
284
|
+
.find();
|
|
285
|
+
|
|
286
|
+
const variants = variantsEntriesResponse.items.map((entry) => ({
|
|
287
|
+
uid: entry.variants._variant._uid,
|
|
288
|
+
}));
|
|
289
|
+
|
|
290
|
+
if (variantsEntriesResponse.items.length === variantQueryParams.limit) {
|
|
291
|
+
const nextVariants = await getVariantEntries(
|
|
292
|
+
stack,
|
|
293
|
+
contentType,
|
|
294
|
+
entries,
|
|
295
|
+
index,
|
|
296
|
+
queryParams,
|
|
297
|
+
skip + variantQueryParams.limit,
|
|
298
|
+
);
|
|
299
|
+
return Array.isArray(nextVariants) ? variants.concat(nextVariants) : variants;
|
|
300
|
+
}
|
|
301
|
+
return variants;
|
|
302
|
+
} catch (error) {
|
|
303
|
+
const errorMessage =
|
|
304
|
+
error?.errorMessage ||
|
|
305
|
+
error?.message ||
|
|
306
|
+
error?.errors ||
|
|
307
|
+
'Falied to fetch the variant entries, Please contact the admin for support.';
|
|
308
|
+
throw new Error(`Error fetching variants: ${errorMessage}`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
247
312
|
async function start(
|
|
248
313
|
{
|
|
249
314
|
retryFailed,
|
|
@@ -258,6 +323,7 @@ async function start(
|
|
|
258
323
|
destEnv,
|
|
259
324
|
f_types,
|
|
260
325
|
apiVersion,
|
|
326
|
+
includeVariants,
|
|
261
327
|
},
|
|
262
328
|
stack,
|
|
263
329
|
config,
|
|
@@ -310,7 +376,20 @@ async function start(
|
|
|
310
376
|
// filter.type = (f_types) ? f_types : types // types mentioned in the config file (f_types) are given preference
|
|
311
377
|
const queryParams = getQueryParams(filter);
|
|
312
378
|
const bulkPublishLimit = fetchBulkPublishLimit(stack?.org_uid);
|
|
313
|
-
|
|
379
|
+
if (includeVariants) {
|
|
380
|
+
apiVersion = VARIANTS_PUBLISH_API_VERSION;
|
|
381
|
+
}
|
|
382
|
+
await getSyncEntries(
|
|
383
|
+
stack,
|
|
384
|
+
config,
|
|
385
|
+
queryParams,
|
|
386
|
+
bulkPublish,
|
|
387
|
+
filter,
|
|
388
|
+
deliveryToken,
|
|
389
|
+
destEnv,
|
|
390
|
+
apiVersion, bulkPublishLimit,
|
|
391
|
+
includeVariants,
|
|
392
|
+
);
|
|
314
393
|
}
|
|
315
394
|
}
|
|
316
395
|
|