@contentstack/cli-variants 1.1.1 → 1.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.
|
@@ -133,7 +133,7 @@ class VariantEntries extends variant_api_adapter_1.default {
|
|
|
133
133
|
const ctConfig = this.config.modules['content-types'];
|
|
134
134
|
const contentType = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), (0, cli_utilities_1.sanitizePath)(ctConfig.dirName), `${(0, cli_utilities_1.sanitizePath)(content_type)}.json`), 'utf8'));
|
|
135
135
|
const variantEntryBasePath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.entriesDirPath), (0, cli_utilities_1.sanitizePath)(content_type), (0, cli_utilities_1.sanitizePath)(locale), (0, cli_utilities_1.sanitizePath)(variantEntry.dirName), (0, cli_utilities_1.sanitizePath)(entry_uid));
|
|
136
|
-
const fs = new cli_utilities_1.FsUtility({ basePath: variantEntryBasePath });
|
|
136
|
+
const fs = new cli_utilities_1.FsUtility({ basePath: variantEntryBasePath, createDirIfNotExist: false });
|
|
137
137
|
for (const _ in fs.indexFileContent) {
|
|
138
138
|
try {
|
|
139
139
|
const variantEntries = (yield fs.readChunkFiles.next());
|
|
@@ -176,12 +176,12 @@ class VariantEntries extends variant_api_adapter_1.default {
|
|
|
176
176
|
const start = Date.now();
|
|
177
177
|
for (let [, variantEntry] of (0, entries_1.default)(batch)) {
|
|
178
178
|
const onSuccess = ({ response, apiData: { entryUid, variantUid }, log }) => {
|
|
179
|
-
log(this.config, `Created entry variant: '${variantUid}' of entry uid ${entryUid}`, 'info');
|
|
179
|
+
log(this.config, `Created entry variant: '${variantUid}' of entry uid ${entryUid} locale '${locale}'`, 'info');
|
|
180
180
|
};
|
|
181
181
|
const onReject = ({ error, apiData, log }) => {
|
|
182
182
|
const { entryUid, variantUid } = apiData;
|
|
183
183
|
this.failedVariantEntries.set(variantUid, apiData);
|
|
184
|
-
log(this.config, `Failed to create entry variant: '${variantUid}' of entry uid ${entryUid}`, 'error');
|
|
184
|
+
log(this.config, `Failed to create entry variant: '${variantUid}' of entry uid ${entryUid} locale '${locale}'`, 'error');
|
|
185
185
|
log(this.config, error, 'error');
|
|
186
186
|
};
|
|
187
187
|
// NOTE Find new variant Id by old Id
|
|
@@ -352,10 +352,10 @@ class VariantEntries extends variant_api_adapter_1.default {
|
|
|
352
352
|
return;
|
|
353
353
|
}
|
|
354
354
|
const onSuccess = ({ response, apiData: { entryUid, variantUid }, log }) => {
|
|
355
|
-
log(this.config, `Entry variant: '${variantUid}' of entry
|
|
355
|
+
log(this.config, `Entry variant: '${variantUid}' of entry '${entryUid}' published on locales '${locales.join(',')}'`, 'info');
|
|
356
356
|
};
|
|
357
357
|
const onReject = ({ error, apiData: { entryUid, variantUid }, log }) => {
|
|
358
|
-
log(this.config, `Failed to publish entry variant: '${variantUid}' of entry uid ${entryUid}`, 'error');
|
|
358
|
+
log(this.config, `Failed to publish entry variant: '${variantUid}' of entry uid ${entryUid} on locales '${locales.join(',')}'`, 'error');
|
|
359
359
|
log(this.config, (0, utils_1.formatError)(error), 'error');
|
|
360
360
|
};
|
|
361
361
|
const { environments, locales } = this.serializePublishEntries(variantEntry);
|
|
@@ -188,10 +188,10 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
|
|
|
188
188
|
const { reject, resolve, log, variantUid } = apiParams;
|
|
189
189
|
const { entry_uid, content_type_uid } = options;
|
|
190
190
|
let endpoint = `content_types/${content_type_uid}/entries/${entry_uid}/publish`;
|
|
191
|
-
const onSuccess = (response) => resolve({ response, apiData: { entryUid: entry_uid, variantUid }, log });
|
|
191
|
+
const onSuccess = (response) => resolve({ response, apiData: { entryUid: entry_uid, variantUid, locales: input.entry.locales }, log });
|
|
192
192
|
const onReject = (error) => reject({
|
|
193
193
|
error,
|
|
194
|
-
apiData: { entryUid: entry_uid, variantUid },
|
|
194
|
+
apiData: { entryUid: entry_uid, variantUid, locales: input.entry.locales },
|
|
195
195
|
log,
|
|
196
196
|
});
|
|
197
197
|
try {
|
package/package.json
CHANGED
|
@@ -54,16 +54,9 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
|
|
|
54
54
|
},
|
|
55
55
|
};
|
|
56
56
|
super(Object.assign(omit(config, ['helpers']), conf));
|
|
57
|
-
this.entriesMapperPath = resolve(
|
|
58
|
-
sanitizePath(config.backupDir),
|
|
59
|
-
'mapper',
|
|
60
|
-
'entries',
|
|
61
|
-
);
|
|
57
|
+
this.entriesMapperPath = resolve(sanitizePath(config.backupDir), 'mapper', 'entries');
|
|
62
58
|
this.personalizeConfig = this.config.modules.personalize;
|
|
63
|
-
this.entriesDirPath = resolve(
|
|
64
|
-
sanitizePath(config.backupDir),
|
|
65
|
-
sanitizePath(config.modules.entries.dirName),
|
|
66
|
-
);
|
|
59
|
+
this.entriesDirPath = resolve(sanitizePath(config.backupDir), sanitizePath(config.modules.entries.dirName));
|
|
67
60
|
this.failedVariantPath = resolve(sanitizePath(this.entriesMapperPath), 'failed-entry-variants.json');
|
|
68
61
|
this.failedVariantEntries = new Map();
|
|
69
62
|
}
|
|
@@ -169,7 +162,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
|
|
|
169
162
|
sanitizePath(variantEntry.dirName),
|
|
170
163
|
sanitizePath(entry_uid),
|
|
171
164
|
);
|
|
172
|
-
const fs = new FsUtility({ basePath: variantEntryBasePath });
|
|
165
|
+
const fs = new FsUtility({ basePath: variantEntryBasePath, createDirIfNotExist: false });
|
|
173
166
|
|
|
174
167
|
for (const _ in fs.indexFileContent) {
|
|
175
168
|
try {
|
|
@@ -217,13 +210,21 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
|
|
|
217
210
|
|
|
218
211
|
for (let [, variantEntry] of entries(batch)) {
|
|
219
212
|
const onSuccess = ({ response, apiData: { entryUid, variantUid }, log }: any) => {
|
|
220
|
-
log(
|
|
213
|
+
log(
|
|
214
|
+
this.config,
|
|
215
|
+
`Created entry variant: '${variantUid}' of entry uid ${entryUid} locale '${locale}'`,
|
|
216
|
+
'info',
|
|
217
|
+
);
|
|
221
218
|
};
|
|
222
219
|
|
|
223
220
|
const onReject = ({ error, apiData, log }: any) => {
|
|
224
221
|
const { entryUid, variantUid } = apiData;
|
|
225
222
|
this.failedVariantEntries.set(variantUid, apiData);
|
|
226
|
-
log(
|
|
223
|
+
log(
|
|
224
|
+
this.config,
|
|
225
|
+
`Failed to create entry variant: '${variantUid}' of entry uid ${entryUid} locale '${locale}'`,
|
|
226
|
+
'error',
|
|
227
|
+
);
|
|
227
228
|
log(this.config, error, 'error');
|
|
228
229
|
};
|
|
229
230
|
// NOTE Find new variant Id by old Id
|
|
@@ -440,10 +441,18 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
|
|
|
440
441
|
}
|
|
441
442
|
|
|
442
443
|
const onSuccess = ({ response, apiData: { entryUid, variantUid }, log }: any) => {
|
|
443
|
-
log(
|
|
444
|
+
log(
|
|
445
|
+
this.config,
|
|
446
|
+
`Entry variant: '${variantUid}' of entry '${entryUid}' published on locales '${locales.join(',')}'`,
|
|
447
|
+
'info',
|
|
448
|
+
);
|
|
444
449
|
};
|
|
445
450
|
const onReject = ({ error, apiData: { entryUid, variantUid }, log }: any) => {
|
|
446
|
-
log(
|
|
451
|
+
log(
|
|
452
|
+
this.config,
|
|
453
|
+
`Failed to publish entry variant: '${variantUid}' of entry uid ${entryUid} on locales '${locales.join(',')}'`,
|
|
454
|
+
'error',
|
|
455
|
+
);
|
|
447
456
|
log(this.config, formatError(error), 'error');
|
|
448
457
|
};
|
|
449
458
|
|
|
@@ -226,11 +226,12 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
|
|
|
226
226
|
const { entry_uid, content_type_uid } = options;
|
|
227
227
|
let endpoint = `content_types/${content_type_uid}/entries/${entry_uid}/publish`;
|
|
228
228
|
|
|
229
|
-
const onSuccess = (response: any) =>
|
|
229
|
+
const onSuccess = (response: any) =>
|
|
230
|
+
resolve({ response, apiData: { entryUid: entry_uid, variantUid, locales: input.entry.locales }, log });
|
|
230
231
|
const onReject = (error: any) =>
|
|
231
232
|
reject({
|
|
232
233
|
error,
|
|
233
|
-
apiData: { entryUid: entry_uid, variantUid },
|
|
234
|
+
apiData: { entryUid: entry_uid, variantUid, locales: input.entry.locales },
|
|
234
235
|
log,
|
|
235
236
|
});
|
|
236
237
|
|