Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contentful-batch-libs

Package Overview
Dependencies
Maintainers
4
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-batch-libs - npm Package Compare versions

Comparing version 6.0.2 to 6.0.3

60

dist/push/publishing.js

@@ -20,2 +20,4 @@ 'use strict';

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
/**

@@ -27,13 +29,5 @@ * Publish a list of entities.

function publishEntities(entities) {
if (entities.length === 0) {
_logging.logEmitter.emit('info', 'Skipping publishing since zero entities passed');
return entities;
}
var entity = entities[0].original || entities[0];
var type = entity.sys.type || 'unknown type';
_logging.logEmitter.emit('info', `Publishing ${entities.length} ${type}s`);
var entitiesToPublish = entities.filter(function (entity) {
if (!entity || !entity.publish) {
_logging.logEmitter.emit('warning', `Unable to publish entity ${(0, _getEntityName2.default)(entity)}`);
_logging.logEmitter.emit('warning', `Unable to publish ${(0, _getEntityName2.default)(entity)}`);
return false;

@@ -44,3 +38,22 @@ }

return _bluebird2.default.map(entitiesToPublish, function (entity, index) {
if (entitiesToPublish.length === 0) {
_logging.logEmitter.emit('info', 'Skipping publishing since zero valid entities passed');
return _bluebird2.default.resolve([]);
}
var entity = entities[0].original || entities[0];
var type = entity.sys.type || 'unknown type';
_logging.logEmitter.emit('info', `Publishing ${entities.length} ${type}s`);
return runQueue(entitiesToPublish).then(function (result) {
_logging.logEmitter.emit('info', `Successfully published ${result.length} ${type}s`);
return result;
});
}
function runQueue(queue, result) {
if (!result) {
result = [];
}
return _bluebird2.default.map(queue, function (entity, index) {
_logging.logEmitter.emit('info', `Publishing ${entity.sys.type} ${(0, _getEntityName2.default)(entity)}`);

@@ -55,6 +68,29 @@ return entity.publish().then(function (entity) {

});
}, { concurrency: 1 }).then(function (result) {
_logging.logEmitter.emit('info', `Successfully published ${result.length} ${type}s.`);
}, { concurrency: 1 }).then(function (entities) {
return entities.filter(function (entity) {
return entity;
});
}).then(function (publishedEntities) {
result = [].concat(_toConsumableArray(result), _toConsumableArray(publishedEntities));
var publishedEntityIds = publishedEntities.map(function (entitiy) {
return entitiy.sys.id;
});
var unpublishedEntities = queue.filter(function (entity) {
return !publishedEntityIds.includes(entity.sys.id);
});
return unpublishedEntities;
}).then(function (unpublishedEntities) {
if (unpublishedEntities.length > 0) {
if (queue.length === unpublishedEntities.length) {
// Fail when queue could not publish at least one item
var unpublishedEntityNames = unpublishedEntities.map(_getEntityName2.default).join(', ');
_logging.logEmitter.emit('error', `Could not publish the following entities: ${unpublishedEntityNames}`);
} else {
// Rerun queue with unpublished entities
return runQueue(unpublishedEntities, result);
}
}
// Return only published entities + last result
return result;
});
}

2

package.json
{
"name": "contentful-batch-libs",
"version": "6.0.2",
"version": "6.0.3",
"description": "Library modules used by contentful batch utility CLI tools.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc