@cloudflare/cli-helpers
Advanced tools
Comparing version 2.1.12 to 2.1.13
@@ -6,2 +6,10 @@ # Change Log | ||
## [2.1.13](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/cli-helpers@2.1.12...@cloudflare/cli-helpers@2.1.13) (2021-10-21) | ||
**Note:** Version bump only for package @cloudflare/cli-helpers | ||
## [2.1.12](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/cli-helpers@2.1.11...@cloudflare/cli-helpers@2.1.12) (2021-03-03) | ||
@@ -8,0 +16,0 @@ |
103
es/index.js
@@ -1,40 +0,29 @@ | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
const chalk = require('chalk'); | ||
var chalk = require('chalk'); | ||
const identity = i => i; | ||
var identity = function identity(i) { | ||
return i; | ||
}; | ||
const buildLabel = (actionName, cliName = '') => ` ${cliName ? cliName + ':' : ''}${actionName} `.toUpperCase(); // Use to create a custom logger | ||
var buildLabel = function buildLabel(actionName) { | ||
var cliName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
return " ".concat(cliName ? cliName + ':' : '').concat(actionName, " ").toUpperCase(); | ||
}; // Use to create a custom logger | ||
const createLogger = ({ | ||
actionName, | ||
labelColorer = identity, | ||
msgColorer = identity, | ||
action | ||
}) => (msg, { | ||
cliName | ||
} = {}) => { | ||
let logMessage = msg; | ||
var createLogger = function createLogger(_ref) { | ||
var actionName = _ref.actionName, | ||
_ref$labelColorer = _ref.labelColorer, | ||
labelColorer = _ref$labelColorer === void 0 ? identity : _ref$labelColorer, | ||
_ref$msgColorer = _ref.msgColorer, | ||
msgColorer = _ref$msgColorer === void 0 ? identity : _ref$msgColorer, | ||
action = _ref.action; | ||
return function (msg) { | ||
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
cliName = _ref2.cliName; | ||
if (typeof msg === 'object') { | ||
logMessage = msg.message || JSON.stringify(msg, null, 2); | ||
} | ||
var logMessage = msg; | ||
if (_typeof(msg) === 'object') { | ||
logMessage = msg.message || JSON.stringify(msg, null, 2); | ||
} | ||
var label = buildLabel(actionName, cliName); | ||
console.log("".concat(labelColorer(label), " ").concat(msgColorer(logMessage))); | ||
action && action(); | ||
}; | ||
const label = buildLabel(actionName, cliName); | ||
console.log(`${labelColorer(label)} ${msgColorer(logMessage)}`); | ||
action && action(); | ||
}; // Use to display successful scenarios | ||
var success = createLogger({ | ||
const success = createLogger({ | ||
actionName: 'success', | ||
@@ -44,3 +33,3 @@ labelColorer: chalk.hex('#FFF').bold.bgGreen | ||
var info = createLogger({ | ||
const info = createLogger({ | ||
actionName: 'info', | ||
@@ -50,3 +39,3 @@ labelColorer: chalk.hex('#FFF').bold.bgCyan | ||
var debug = createLogger({ | ||
const debug = createLogger({ | ||
actionName: 'debug', | ||
@@ -57,3 +46,3 @@ labelColorer: chalk.hex('#333').bold.bgWhiteBright | ||
var warn = createLogger({ | ||
const warn = createLogger({ | ||
actionName: 'warn', | ||
@@ -63,28 +52,24 @@ labelColorer: chalk.hex('#FFF').bold.bgYellow | ||
var bail = createLogger({ | ||
const bail = createLogger({ | ||
actionName: 'bail', | ||
labelColorer: chalk.hex('#FFF').bold.bgRed, | ||
action: function action() { | ||
return process.exit(1); | ||
} | ||
action: () => process.exit(1) | ||
}); // Use to log errors without exiting | ||
var error = createLogger({ | ||
const error = createLogger({ | ||
actionName: 'error', | ||
labelColorer: chalk.hex('#FFF').bold.bgRed | ||
}); | ||
var helpers = { | ||
info: info, | ||
debug: debug, | ||
warn: warn, | ||
success: success, | ||
bail: bail, | ||
error: error | ||
const helpers = { | ||
info, | ||
debug, | ||
warn, | ||
success, | ||
bail, | ||
error | ||
}; // return helpers setup with specific options, i.e `cliName` | ||
var setup = function setup(options) { | ||
return Object.keys(helpers).reduce(function (configured, name) { | ||
configured[name] = function (msg) { | ||
return helpers[name](msg, options); | ||
}; | ||
const setup = options => { | ||
return Object.keys(helpers).reduce((configured, name) => { | ||
configured[name] = msg => helpers[name](msg, options); | ||
@@ -94,3 +79,3 @@ return configured; | ||
bold: chalk.bold, | ||
createLogger: createLogger | ||
createLogger | ||
}); | ||
@@ -100,11 +85,11 @@ }; | ||
module.exports = { | ||
info: info, | ||
debug: debug, | ||
warn: warn, | ||
success: success, | ||
bail: bail, | ||
error: error, | ||
setup: setup, | ||
createLogger: createLogger, | ||
info, | ||
debug, | ||
warn, | ||
success, | ||
bail, | ||
error, | ||
setup, | ||
createLogger, | ||
bold: chalk.bold | ||
}; |
"use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -5,0 +5,0 @@ var chalk = require('chalk'); |
{ | ||
"name": "@cloudflare/cli-helpers", | ||
"description": "Helpers for cli's written in node", | ||
"version": "2.1.12", | ||
"version": "2.1.13", | ||
"main": "src/index.js", | ||
@@ -9,3 +9,3 @@ "author": "James Culveyhouse <jculveyhouse@cloudflare.com>", | ||
"publishConfig": { | ||
"registry": "http://registry.npmjs.org/", | ||
"registry": "https://registry.npmjs.org/", | ||
"access": "public" | ||
@@ -24,3 +24,3 @@ }, | ||
}, | ||
"gitHead": "8670743768e197a55bfa4621640051b96c77f1c7" | ||
"gitHead": "9a93b982519e49f889a51a16b9f5766be70c443e" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11787
239