New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

contentful-space-sync

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-space-sync - npm Package Compare versions

Comparing version 2.1.9 to 3.0.1

contentful-space-sync-token-zz2okzf5k4px-to-8lz2thfr0a37

31

dist/dump-error-buffer.js
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = dumpErrorBuffer;
exports.default = dumpErrorBuffer;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _object = require('lodash/object');
var _lodashObject = require('lodash/object');
var _function = require('lodash/function');
var _lodashFunction = require('lodash/function');
var _npmlog = require('npmlog');

@@ -22,6 +20,8 @@

var _contentfulBatchLibsUtilsErrorBuffer = require('contentful-batch-libs/utils/error-buffer');
var _errorBuffer = require('contentful-batch-libs/utils/error-buffer');
var _contentfulBatchLibsUtilsErrorBuffer2 = _interopRequireDefault(_contentfulBatchLibsUtilsErrorBuffer);
var _errorBuffer2 = _interopRequireDefault(_errorBuffer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function dumpErrorBuffer(params) {

@@ -33,8 +33,8 @@ var message = arguments.length <= 1 || arguments[1] === undefined ? 'Additional errors were found' : arguments[1];

var loggedErrors = _contentfulBatchLibsUtilsErrorBuffer2['default'].drain();
var loggedErrors = _errorBuffer2.default.drain();
if (loggedErrors.length > 0) {
var errors = loggedErrors.reduce((0, _lodashFunction.partialRight)(logErrorsWithAppLinks, sourceSpace, destinationSpace), '');
_fs2['default'].writeFileSync(errorLogFile, errors);
_npmlog2['default'].warn(message);
_npmlog2['default'].warn('Check ' + errorLogFile + ' for details.');
var errors = loggedErrors.reduce((0, _function.partialRight)(logErrorsWithAppLinks, sourceSpace, destinationSpace), '');
_fs2.default.writeFileSync(errorLogFile, errors);
_npmlog2.default.warn(message);
_npmlog2.default.warn('Check ' + errorLogFile + ' for details.');
}

@@ -44,3 +44,3 @@ }

function logErrorsWithAppLinks(accumulatedErrorStr, err, idx, loggedErrors, sourceSpace, destinationSpace) {
var requestUri = (0, _lodashObject.get)(err, 'request.uri');
var requestUri = (0, _object.get)(err, 'request.uri');
if (requestUri) {

@@ -55,3 +55,2 @@ return accumulatedErrorStr + ('Error ' + (idx + 1) + ':\n') + 'in ' + parseEntityUrl(sourceSpace, destinationSpace, requestUri) + '\n' + JSON.stringify(err, null, ' ') + '\n\n';

return url.replace(/api.contentful/, 'app.contentful').replace(/:443/, '').replace(destinationSpace, sourceSpace).split('/').splice(0, 7).join('/');
}
module.exports = exports['default'];
}
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = getTransformedDestinationResponse;
exports.default = getTransformedDestinationResponse;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _npmlog = require('npmlog');

@@ -14,6 +12,8 @@

var _contentfulBatchLibsGetGetOutdatedDestinationContent = require('contentful-batch-libs/get/get-outdated-destination-content');
var _getOutdatedDestinationContent = require('contentful-batch-libs/get/get-outdated-destination-content');
var _contentfulBatchLibsGetGetOutdatedDestinationContent2 = _interopRequireDefault(_contentfulBatchLibsGetGetOutdatedDestinationContent);
var _getOutdatedDestinationContent2 = _interopRequireDefault(_getOutdatedDestinationContent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -28,5 +28,4 @@ * Gets the response from the destination space with the content that needs

*/
function getTransformedDestinationResponse(managementClient, spaceId, sourceResponse, opts) {
return (0, _contentfulBatchLibsGetGetOutdatedDestinationContent2['default'])(managementClient, spaceId, sourceResponse).then(function (destinationResponse) {
return (0, _getOutdatedDestinationContent2.default)(managementClient, spaceId, sourceResponse).then(function (destinationResponse) {
if (opts.skipContentModel) {

@@ -38,3 +37,3 @@ destinationResponse.contentTypes = [];

if (sourceResponse.isInitialSync && (destinationResponse.contentTypes.length > 0 || destinationResponse.assets.length > 0) && !opts.forceOverwrite) {
_npmlog2['default'].error('Your destination space already has some content.\nIf this is a fresh sync, please clear the content before synchronizing, otherwise\nconflicts can occur. If it\'s not a fresh sync, make sure you provide the tool\nwith a sync token for the last sync (see the README to understand how).\n\nIf you know what you\'re doing, you can use the parameter --force-overwrite\nwhich will overwite any entities with the same ID on the destination space.\n\nBe aware that any existing content types on the destination space that do not\nexist on the source space with the same ID will be deleted on future syncs.\n\nSee the README file for a more thorough explanation of this.');
_npmlog2.default.error('Your destination space already has some content.\nIf this is a fresh sync, please clear the content before synchronizing, otherwise\nconflicts can occur. If it\'s not a fresh sync, make sure you provide the tool\nwith a sync token for the last sync (see the README to understand how).\n\nIf you know what you\'re doing, you can use the parameter --force-overwrite\nwhich will overwite any entities with the same ID on the destination space.\n\nBe aware that any existing content types on the destination space that do not\nexist on the source space with the same ID will be deleted on future syncs.\n\nSee the README file for a more thorough explanation of this.');
throw new Error('EXISTING_CONTENT');

@@ -44,4 +43,2 @@ }

});
}
module.exports = exports['default'];
}
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = runSpaceSync;
exports.default = runSpaceSync;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _bluebird = require('bluebird');

@@ -22,19 +20,19 @@

var _lodashCollection = require('lodash/collection');
var _collection = require('lodash/collection');
var _contentfulBatchLibsUtilsCreateClients = require('contentful-batch-libs/utils/create-clients');
var _createClients = require('contentful-batch-libs/utils/create-clients');
var _contentfulBatchLibsUtilsCreateClients2 = _interopRequireDefault(_contentfulBatchLibsUtilsCreateClients);
var _createClients2 = _interopRequireDefault(_createClients);
var _contentfulBatchLibsGetGetSourceSpace = require('contentful-batch-libs/get/get-source-space');
var _getSourceSpace = require('contentful-batch-libs/get/get-source-space');
var _contentfulBatchLibsGetGetSourceSpace2 = _interopRequireDefault(_contentfulBatchLibsGetGetSourceSpace);
var _getSourceSpace2 = _interopRequireDefault(_getSourceSpace);
var _contentfulBatchLibsTransformTransformSpace = require('contentful-batch-libs/transform/transform-space');
var _transformSpace = require('contentful-batch-libs/transform/transform-space');
var _contentfulBatchLibsTransformTransformSpace2 = _interopRequireDefault(_contentfulBatchLibsTransformTransformSpace);
var _transformSpace2 = _interopRequireDefault(_transformSpace);
var _contentfulBatchLibsPushPushToSpace = require('contentful-batch-libs/push/push-to-space');
var _pushToSpace = require('contentful-batch-libs/push/push-to-space');
var _contentfulBatchLibsPushPushToSpace2 = _interopRequireDefault(_contentfulBatchLibsPushPushToSpace);
var _pushToSpace2 = _interopRequireDefault(_pushToSpace);

@@ -49,17 +47,19 @@ var _dumpErrorBuffer = require('./dump-error-buffer');

_bluebird2['default'].promisifyAll(_fs2['default']);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function runSpaceSync(usage) {
var opts = usage.opts;
var syncTokenFile = usage.syncTokenFile;
var errorLogFile = usage.errorLogFile;
_bluebird2.default.promisifyAll(_fs2.default);
var clients = (0, _contentfulBatchLibsUtilsCreateClients2['default'])(opts);
return (0, _contentfulBatchLibsGetGetSourceSpace2['default'])(clients.source.delivery, clients.source.management, clients.source.spaceId, syncTokenFile, opts.fresh)
function runSpaceSync(usageParams) {
var opts = usageParams.opts;
var syncTokenFile = usageParams.syncTokenFile;
var errorLogFile = usageParams.errorLogFile;
var clients = (0, _createClients2.default)(opts);
return (0, _getSourceSpace2.default)(clients.source.delivery, clients.source.management, clients.source.spaceId, syncTokenFile, opts.fresh)
// Prepare object with both source and destination existing content
.then(function (sourceResponse) {
return _bluebird2['default'].props({
return _bluebird2.default.props({
source: sourceResponse,
destination: (0, _getTransformedDestinationResponse2['default'])(clients.destination.management, clients.destination.spaceId, sourceResponse, {
destination: (0, _getTransformedDestinationResponse2.default)(clients.destination.management, clients.destination.spaceId, sourceResponse, {
forceOverwrite: opts.forceOverwrite,

@@ -70,4 +70,4 @@ skipContentModel: opts.skipContentModel

}).then(function (responses) {
return _bluebird2['default'].props({
source: (0, _contentfulBatchLibsTransformTransformSpace2['default'])(responses.source, responses.destination),
return _bluebird2.default.props({
source: (0, _transformSpace2.default)(responses.source, responses.destination),
destination: responses.destination

@@ -79,7 +79,7 @@ });

.then(function (responses) {
responses.source.deletedContentTypes = (0, _lodashCollection.filter)(responses.destination.contentTypes, function (contentType) {
return !(0, _lodashCollection.find)(responses.source.contentTypes, 'original.sys.id', contentType.sys.id);
responses.source.deletedContentTypes = (0, _collection.filter)(responses.destination.contentTypes, function (contentType) {
return !(0, _collection.find)(responses.source.contentTypes, 'original.sys.id', contentType.sys.id);
});
responses.source.deletedLocales = (0, _lodashCollection.filter)(responses.destination.locales, function (locale) {
return !(0, _lodashCollection.find)(responses.source.locales, 'original.code', locale.code);
responses.source.deletedLocales = (0, _collection.filter)(responses.destination.locales, function (locale) {
return !(0, _collection.find)(responses.source.locales, 'original.code', locale.code);
});

@@ -91,3 +91,3 @@ return responses;

.then(function (responses) {
return (0, _contentfulBatchLibsPushPushToSpace2['default'])(responses, clients.destination.management, clients.destination.spaceId, {
return (0, _pushToSpace2.default)(responses, clients.destination.management, clients.destination.spaceId, {
prePublishDelay: opts.prePublishDelay,

@@ -99,8 +99,8 @@ contentModelOnly: opts.contentModelOnly,

if (!opts.contentModelOnly) {
_fs2['default'].writeFileSync(syncTokenFile, nextSyncToken);
_npmlog2['default'].info('Successfully sychronized the content and saved the sync token to:\n ', syncTokenFile);
_fs2.default.writeFileSync(syncTokenFile, nextSyncToken);
_npmlog2.default.info('Successfully sychronized the content and saved the sync token to:\n ', syncTokenFile);
} else {
_npmlog2['default'].info('Successfully sychronized the content model');
_npmlog2.default.info('Successfully sychronized the content model');
}
(0, _dumpErrorBuffer2['default'])({
(0, _dumpErrorBuffer2.default)({
destinationSpace: opts.destinationSpace,

@@ -114,4 +114,4 @@ sourceSpace: opts.sourceSpace,

// Output any errors caught along the way
['catch'](function (err) {
(0, _dumpErrorBuffer2['default'])({
.catch(function (err) {
(0, _dumpErrorBuffer2.default)({
destinationSpace: opts.destinationSpace,

@@ -123,4 +123,2 @@ sourceSpace: opts.sourceSpace,

});
}
module.exports = exports['default'];
}

@@ -5,2 +5,3 @@ {

"bin": "bin/space-sync",
"main": "index.js",
"scripts": {

@@ -13,4 +14,4 @@ "build": "rimraf dist && mkdirp dist && babel lib --out-dir dist",

"test": "npm run test:cover",
"test:cover": "BABEL_ENV=test isparta cover test/runner",
"test:only": "BABEL_ENV=test ./test/runner",
"test:cover": "BABEL_ENV=test babel-node ./node_modules/istanbul/lib/cli.js cover test/runner",
"test:only": "BABEL_ENV=test babel-node ./test/runner",
"browser-coverage": "npm run test:cover && opener coverage/lcov-report/index.html",

@@ -21,5 +22,4 @@ "semantic-release": "semantic-release pre && npm publish && semantic-release post",

"dependencies": {
"babel-polyfill": "^6.0.16",
"bluebird": "^3.0.5",
"contentful-batch-libs": "^1.2.0",
"contentful-batch-libs": "^2.0.0",
"lodash": "^3.10.1",

@@ -30,12 +30,13 @@ "npmlog": "^2.0.0",

"devDependencies": {
"babel": "^5.8.29",
"babel-core": "^5.8.33",
"babel-eslint": "^4.1.3",
"babel-plugin-rewire": "^0.1.22",
"babel-cli": "^6.3.17",
"babel-eslint": "^4.1.6",
"babel-plugin-rewire": "^1.0.0-beta-3",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.3.13",
"cz-conventional-changelog": "^1.1.4",
"isparta": "^3.5.3",
"istanbul": "^1.0.0-alpha.2",
"mkdirp": "^0.5.1",
"opener": "^1.4.1",
"require-all": "^2.0.0",
"rimraf": "^2.4.3",
"rimraf": "^2.5.0",
"semantic-release": "^4.3.5",

@@ -69,3 +70,3 @@ "sinon": "^1.17.2",

},
"version": "2.1.9"
}
"version": "3.0.1"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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