Skip to content

Commit 1f1e163

Browse files
committed
Merge branch 'master' into feature/3.1.0
2 parents eb4bd7d + a99a416 commit 1f1e163

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 built.io
3+
Copyright (c) 2018 Contentstack
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ $ contentstack plugin create YOUR_PLUGIN_NAME
9393
Once the plugin is created, you can activate it in config/all.js file.
9494

9595
## Links
96-
- [Website](https://www.built.io/products/contentstack/overview)
97-
- [Official Documentation](https://contentstackdocs.built.io/developer/web/framework-cli)
96+
- [Website](https://www.contentstack.com/)
97+
- [Official Documentation](https://www.contentstack.com/docs/)
9898

9999
### License
100100
Copyright © 2018 [Contentstack](https://www.contentstack.com/). All Rights Reserved.

lib/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Publish.prototype.init = function() {
246246
}
247247
});
248248
if (envNotPresent.length > 0) {
249-
return cb(`The following environments were not found in the stack!\n${envNotPresent}`);
249+
return cb(`The following environments were not found in the stack: ${JSON.stringify(envNotPresent)}!`);
250250
}
251251
return cb(null);
252252
}

lib/request.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@
1111
*/
1212
var request = require('request');
1313
var chalk = require('chalk');
14-
// var config = require('./config').config();
14+
var debug = require('debug')('request');
1515
var pkg = require('../package');
16-
17-
var warning = chalk.yellow;
18-
var succcess = chalk.green;
19-
var error = chalk.red;
20-
var info = chalk.blue;
21-
var log = console.log;
2216
var MAX_RETRY_LIMIT = 5;
2317

2418
function validate(req, cb) {
@@ -53,34 +47,34 @@ var makeCall = module.exports = function(req, cb, RETRY) {
5347
} else if (RETRY > MAX_RETRY_LIMIT) {
5448
return cb(new Error('Max retry limit exceeded!'));
5549
}
50+
debug(`Requesting API\n${JSON.stringify(req, null, 2)}`);
5651
return request(req, function(err, response, body) {
5752
if (err) {
58-
log(error(err));
5953
return cb(err);
6054
}
6155
var timeDelay;
6256
if (response.statusCode >= 200 && response.statusCode <= 399) {
63-
log(succcess(`${req.method}: ${req.uri || req.url} completed succcessfully with ${response.statusCode} statusCode!`));
57+
debug(`${req.method}: ${req.uri || req.url} completed succcessfully with ${response.statusCode} statusCode!`);
6458
return cb(null, body);
6559
} else if (response.statusCode === 429) {
6660
timeDelay = Math.pow(Math.SQRT2, RETRY) * 100;
67-
log(warning(`API rate limit exceeded.\nReceived ${response.statusCode} status\nBody ${JSON.stringify(body)}`));
68-
log(warning(`Retrying ${req.uri || req.url} with ${timeDelay} sec delay`));
61+
debug(`API rate limit exceeded.\nReceived ${response.statusCode} status\nBody ${JSON.stringify(body)}`);
62+
debug(`Retrying ${req.uri || req.url} with ${timeDelay} sec delay`);
6963
return setTimeout(function (req, cb, RETRY) {
7064
return makeCall(req, cb, RETRY);
7165
}, timeDelay, req, cb, RETRY);
7266
} else if (response.statusCode >= 500) {
7367
// retry, with delay
7468
timeDelay = Math.pow(Math.SQRT2, RETRY) * 100;
75-
log(warning(`SERVER ERROR\nRecevied ${response.statusCode} status from Contentstack!\nBody ${JSON.stringify(body)}`));
76-
log(warning(`Retrying ${req.uri || req.url} with ${timeDelay} sec delay`));
69+
debug(`SERVER ERROR\nRecevied ${response.statusCode} status from Contentstack!\nBody ${JSON.stringify(body)}`);
70+
debug(`Retrying ${req.uri || req.url} with ${timeDelay} sec delay`);
7771
RETRY++;
7872
return setTimeout(function (req, cb, RETRY) {
7973
return makeCall(req, cb, RETRY);
8074
}, timeDelay, req, cb, RETRY);
8175
} else {
82-
log(error(`Request failed\n${JSON.stringify(req)}`));
83-
log(error(`Response received\n${JSON.stringify(body)}`));
76+
debug(`Request failed\n${JSON.stringify(req)}`);
77+
debug(`Response received\n${JSON.stringify(body)}`);
8478
return cb(body);
8579
}
8680
});

0 commit comments

Comments
 (0)