contentful-batch-libs
Advanced tools
Comparing version 6.0.0 to 6.0.1
@@ -12,6 +12,2 @@ 'use strict'; | ||
var _figures = require('figures'); | ||
var _figures2 = _interopRequireDefault(_figures); | ||
var _listr = require('listr'); | ||
@@ -36,24 +32,2 @@ | ||
function logToTaskOutput(task) { | ||
function logInfo(info) { | ||
task.output = `${_figures2.default.tick} ${info}`; | ||
} | ||
function logWarning(warning) { | ||
task.output = `${_figures2.default.warning} ${warning}`; | ||
} | ||
function logError(error) { | ||
var formattedError = (0, _logging.formatErrorOneLine)(error); | ||
task.output = `${_figures2.default.cross} ${formattedError}`; | ||
} | ||
_logging.logEmitter.on('info', logInfo); | ||
_logging.logEmitter.on('warning', logWarning); | ||
_logging.logEmitter.on('error', logError); | ||
return function () { | ||
_logging.logEmitter.removeListener('info', logInfo); | ||
_logging.logEmitter.removeListener('warning', logWarning); | ||
_logging.logEmitter.removeListener('error', logError); | ||
}; | ||
} | ||
/** | ||
@@ -83,3 +57,3 @@ * Gets all the content from a space via the management API. This includes | ||
task: function task(ctx, _task) { | ||
var teardownTaskListeners = logToTaskOutput(_task); | ||
var teardownTaskListeners = (0, _logging.logToTaskOutput)(_task); | ||
return managementClient.getSpace(spaceId).then(function (space) { | ||
@@ -93,3 +67,3 @@ ctx.space = space; | ||
task: function task(ctx, _task2) { | ||
var teardownTaskListeners = logToTaskOutput(_task2); | ||
var teardownTaskListeners = (0, _logging.logToTaskOutput)(_task2); | ||
return pagedGet(ctx.space, 'getContentTypes').then(extractItems).then(function (items) { | ||
@@ -106,3 +80,3 @@ ctx.data.contentTypes = items; | ||
task: function task(ctx, _task3) { | ||
var teardownTaskListeners = logToTaskOutput(_task3); | ||
var teardownTaskListeners = (0, _logging.logToTaskOutput)(_task3); | ||
return getEditorInterfaces(ctx.data.contentTypes).then(function (editorInterfaces) { | ||
@@ -121,3 +95,3 @@ ctx.data.editorInterfaces = editorInterfaces.filter(function (editorInterface) { | ||
task: function task(ctx, _task4) { | ||
var teardownTaskListeners = logToTaskOutput(_task4); | ||
var teardownTaskListeners = (0, _logging.logToTaskOutput)(_task4); | ||
return pagedGet(ctx.space, 'getEntries').then(extractItems).then(_sortEntries2.default).then(function (items) { | ||
@@ -136,3 +110,3 @@ return filterDrafts(items, includeDrafts); | ||
task: function task(ctx, _task5) { | ||
var teardownTaskListeners = logToTaskOutput(_task5); | ||
var teardownTaskListeners = (0, _logging.logToTaskOutput)(_task5); | ||
return pagedGet(ctx.space, 'getAssets').then(extractItems).then(function (items) { | ||
@@ -149,3 +123,3 @@ ctx.data.assets = items; | ||
task: function task(ctx, _task6) { | ||
var teardownTaskListeners = logToTaskOutput(_task6); | ||
var teardownTaskListeners = (0, _logging.logToTaskOutput)(_task6); | ||
return pagedGet(ctx.space, 'getLocales').then(extractItems).then(function (items) { | ||
@@ -162,3 +136,3 @@ ctx.data.locales = items; | ||
task: function task(ctx, _task7) { | ||
var teardownTaskListeners = logToTaskOutput(_task7); | ||
var teardownTaskListeners = (0, _logging.logToTaskOutput)(_task7); | ||
return pagedGet(ctx.space, 'getWebhooks').then(extractItems).then(function (items) { | ||
@@ -175,3 +149,3 @@ ctx.data.webhooks = items; | ||
task: function task(ctx, _task8) { | ||
var teardownTaskListeners = logToTaskOutput(_task8); | ||
var teardownTaskListeners = (0, _logging.logToTaskOutput)(_task8); | ||
return pagedGet(ctx.space, 'getRoles').then(extractItems).then(function (items) { | ||
@@ -178,0 +152,0 @@ ctx.data.roles = items; |
@@ -12,16 +12,27 @@ 'use strict'; | ||
var name = (0, _lodash.get)(entity, 'name'); | ||
var titleField = (0, _lodash.get)(entity, 'fields.title'); | ||
var id = (0, _lodash.get)(entity, 'sys.id'); | ||
if (name) { | ||
return name; | ||
return attachId(name, entity); | ||
} | ||
var titleField = (0, _lodash.get)(entity, 'fields.title'); | ||
if (titleField) { | ||
var locales = Object.keys(titleField); | ||
return titleField[locales[0]]; | ||
return attachId(titleField[locales[0]], entity); | ||
} | ||
var id = (0, _lodash.get)(entity, 'sys.id'); | ||
if (id) { | ||
return id; | ||
} | ||
return 'unknown'; | ||
} | ||
function attachId(val, entity) { | ||
var id = (0, _lodash.get)(entity, 'sys.id'); | ||
if (id) { | ||
return `${val} (${id})`; | ||
} | ||
return val; | ||
} | ||
module.exports = exports['default']; |
@@ -12,2 +12,3 @@ 'use strict'; | ||
exports.setupErrorLogging = setupErrorLogging; | ||
exports.logToTaskOutput = logToTaskOutput; | ||
@@ -24,2 +25,6 @@ var _events = require('events'); | ||
var _figures = require('figures'); | ||
var _figures2 = _interopRequireDefault(_figures); | ||
var _moment = require('moment'); | ||
@@ -71,2 +76,5 @@ | ||
} catch (err) { | ||
if (!error.hasOwnProperty('error')) { | ||
error = { error }; | ||
} | ||
return error.error.toString().replace(/[\n\r]/, ' '); | ||
@@ -148,2 +156,24 @@ } | ||
}); | ||
} | ||
function logToTaskOutput(task) { | ||
function logInfo(info) { | ||
task.output = `${_figures2.default.tick} ${info}`; | ||
} | ||
function logWarning(warning) { | ||
task.output = `${_figures2.default.warning} ${warning}`; | ||
} | ||
function logError(error) { | ||
var formattedError = formatErrorOneLine(error); | ||
task.output = `${_figures2.default.cross} ${formattedError}`; | ||
} | ||
logEmitter.on('info', logInfo); | ||
logEmitter.on('warning', logWarning); | ||
logEmitter.on('error', logError); | ||
return function () { | ||
logEmitter.removeListener('info', logInfo); | ||
logEmitter.removeListener('warning', logWarning); | ||
logEmitter.removeListener('error', logError); | ||
}; | ||
} |
{ | ||
"name": "contentful-batch-libs", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "Library modules used by contentful batch utility CLI tools.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
55480
1169
0