Skip to content

Commit 5cb39d0

Browse files
committed
localized entry sync bug fixed
1 parent 5224f0c commit 5cb39d0

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

lib/publish.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ Publish.prototype.init = function() {
205205
} else if (body && body.user && body.user.authtoken) {
206206
return cb(null, body.user.authtoken);
207207
}
208-
log(error('Something went wrong while logging in..'));
208+
debug('Something went wrong while logging in..');
209209
return cb(body);
210210
});
211211
},
@@ -241,7 +241,7 @@ Publish.prototype.init = function() {
241241
var envNotPresent = [];
242242
inputs.environment.forEach(function (envName) {
243243
if (envNames.indexOf(envName) === -1) {
244-
log(error(`${envName} was not found!`));
244+
debug(`${envName} was not found!`);
245245
envNotPresent.push(envName);
246246
}
247247
});
@@ -306,7 +306,7 @@ Publish.prototype.loadEntries = function(contentTypes, callback) {
306306
}
307307
entries = entries || [];
308308
log(success(`A total of ${entries.length} were found in '${contentType.title}' content type`));
309-
log(info(`Sending ${contentType.title} content type entries for publish`));
309+
debug(`Sending ${contentType.title} content type entries for publish`);
310310
// TODO: Important
311311
return self.publishEntries(entries, contentType, inputs.language, cb);
312312
});
@@ -351,7 +351,7 @@ Publish.prototype.content_types = function(callback) {
351351
});
352352
}
353353
}
354-
log(info('Sending content types to load and publish entries'));
354+
debug('Sending content types to load and publish entries');
355355
return self.loadEntries(content_types_bucket, callback);
356356
}
357357
return callback(null, null);

lib/request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ var makeCall = module.exports = function(req, cb, RETRY) {
5353
} else if (RETRY > MAX_RETRY_LIMIT) {
5454
return cb(new Error('Max retry limit exceeded!'));
5555
}
56-
log(info(`${req.method.toUpperCase()}: ${req.uri || req.url}`));
5756
return request(req, function(err, response, body) {
5857
if (err) {
58+
log(error(err));
5959
return cb(err);
6060
}
6161
var timeDelay;
@@ -72,7 +72,7 @@ var makeCall = module.exports = function(req, cb, RETRY) {
7272
} else if (response.statusCode >= 500) {
7373
// retry, with delay
7474
timeDelay = Math.pow(Math.SQRT2, RETRY) * 100;
75-
log(warning(`Recevied ${response.statusCode} status\nBody ${JSON.stringify(body)}`));
75+
log(warning(`SERVER ERROR\nRecevied ${response.statusCode} status from Contentstack!\nBody ${JSON.stringify(body)}`));
7676
log(warning(`Retrying ${req.uri || req.url} with ${timeDelay} sec delay`));
7777
RETRY++;
7878
return setTimeout(function (req, cb, RETRY) {

lib/sync.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function Sync(args) {
5555
// initalise the Synchronize command
5656
this.initialise(args, function (err) {
5757
if (err) {
58-
log('Content sync failed with errors');
58+
log(error('Content sync failed with errors'));
5959
log(error(err.message || JSON.stringify(err)));
6060
process.exit(1);
6161
}
@@ -66,7 +66,6 @@ function Sync(args) {
6666
if (self.q.length > 0) {
6767
var entryData = self.q.shift();
6868
self.sync.start(entryData);
69-
log(info(`\nRequest details\n${JSON.stringify(entryData.message.body)}`));
7069
} else {
7170
inProgress = false;
7271
log(success('Cotentnstack \'SYNC\' completed successfully!!'));
@@ -236,7 +235,7 @@ Sync.prototype.loadEntries = function(contentTypes, finalCallback) {
236235
};
237236
}
238237
return async.eachLimit(contentTypes, 1, function (contentType, cb) {
239-
return utility.getEntries(contentType, self.inputs.language, query, ['title', 'publish_details', '_version'], self.inputs.environment.name, function(error, entries) {
238+
return utility.getEntries(contentType, self.inputs.language, query, ['title', 'publish_details', '_version', 'locale'], self.inputs.environment.name, function(error, entries) {
240239
if (error) {
241240
return cb(error);
242241
} else if (entries.length === 0) {
@@ -305,7 +304,7 @@ Sync.prototype.parseEntries = function(entries, contentType, fn) {
305304
entry: {
306305
title: entry.title || entry.uid,
307306
// TODO: clarify/confirm
308-
locale: entry.locale || 'en-us',
307+
locale: entry.locale || self.inputs.language || 'en-us',
309308
version: entry.version || entry._version,
310309
entry_uid: entry.uid
311310
},
@@ -323,10 +322,9 @@ Sync.prototype.parseEntries = function(entries, contentType, fn) {
323322

324323
if (!inProgress) {
325324
var entryData = self.q.shift();
326-
log(success(`Started content sync for ${contentType} entries`));
325+
debug(`Started content sync for ${contentType} entries`);
327326
self.sync.start(entryData);
328327
inProgress = true;
329-
log(info(`\nRequest details:\n${JSON.stringify(entryData.message.body)}`));
330328
}
331329
return fn(null, null);
332330
} catch (e) {
@@ -408,10 +406,9 @@ Sync.prototype.parseAssets = function(assets, finalCallback) {
408406

409407
if (!inProgress && self.q.length) {
410408
var assetData = self.q.shift();
411-
log(info('Started content sync for assets'));
409+
debug('Started content sync for assets');
412410
self.sync.start(assetData);
413411
inProgress = true;
414-
log(info(`\nRequest details:\n${JSON.stringify(assetData.message.body)}`));
415412
}
416413
return finalCallback(null, null);
417414
};
@@ -427,7 +424,7 @@ Sync.prototype.assets = function(callback) {
427424
if (error) {
428425
return callback(error);
429426
} else if (assets.length === 0) {
430-
log(warning('No assets were found in the specified environment/stack'));
427+
debug('No assets were found in the specified environment/stack');
431428
return callback(null, null);
432429
}
433430
log(info(`${assets.length} assets were retrieved`));

0 commit comments

Comments
 (0)