{"id":15245078,"url":"https://github.com/hicommon/contentful-sync","last_synced_at":"2025-10-05T06:31:19.393Z","repository":{"id":24462941,"uuid":"101428447","full_name":"HiCommon/contentful-sync","owner":"HiCommon","description":"Diffing and syncing of two Contentful spaces","archived":true,"fork":false,"pushed_at":"2022-12-08T17:31:39.000Z","size":244,"stargazers_count":7,"open_issues_count":8,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-01-10T03:23:46.908Z","etag":null,"topics":["contentful","contentful-js-sdk","diffing","sync"],"latest_commit_sha":null,"homepage":"https://github.com/HiCommon/contentful-sync","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HiCommon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-25T17:48:45.000Z","updated_at":"2024-12-05T08:39:06.000Z","dependencies_parsed_at":"2023-01-14T01:00:45.179Z","dependency_job_id":null,"html_url":"https://github.com/HiCommon/contentful-sync","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiCommon%2Fcontentful-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiCommon%2Fcontentful-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiCommon%2Fcontentful-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiCommon%2Fcontentful-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HiCommon","download_url":"https://codeload.github.com/HiCommon/contentful-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235370461,"owners_count":18979093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contentful","contentful-js-sdk","diffing","sync"],"created_at":"2024-09-29T13:06:17.503Z","updated_at":"2025-10-05T06:31:19.073Z","avatar_url":"https://github.com/HiCommon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n\n[Contentful Sync](https://github.com/HiCommon/contentful-sync) is a library for doing in-memory diffing of two [Contentful](https://www.contentful.com) spaces.\n\nRather than using the [contentful-import](https://github.com/contentful/contentful-import) library, which (as far as I understand) clones down the 'original' space and then makes an API request for each asset, entry, content type, etc., in the 'target' space to deduce which pieces of data need creating/updating, this library clones _both_ the original and target spaces and performs the diff in-memory. It then takes the result from the diff and performs a create, update, or delete request for the relevant pieces of content.\n\nAs it currently stands, this library does not handle API rate limiting well and thus should probably not be used to clone spaces within Contentful. This library is better suited to sync spaces that have fewer differences.\n\n## Assumptions and limitations\n### Limitations\nAt the moment, the library syncs just Entries, Assets, and Content Types.\n\n### Assumptions\nThis library assumes that:\n- You have two spaces that you need to keep in sync.\n- You only update the 'origin' (i.e., staging) space, and do not manually edit anything in your 'target' (i.e., production) space.\n- Both spaces are set the `en-US` locale (you can manually overcome this by editing `filterAssets` in `lib/Assets.js`).\n\nThis library will sync unidirectionally -- it will sync exclusively from origin -\u003e target. If that is not how you or your content team operates, this probably is not the tool for you.\n\n## Usage\nAdd the package to your repository:\n`yarn add contentful-sync` or `npm install contentful-sync --save`\n\nRequire in the library:\n```js\nconst contentfulSync = require('contentful-sync');\n```\n\nCreate a configuration object that contains the origin space's ID, the target space's ID, and your management token. These are all required.\n```js\nconst contentfulSync = require('contentful-sync');\n\nconst config = {\n  originSpaceId: 'XXXXXXXX',\n  targetSpaceId: 'YYYYYYYY',\n  managementToken: 'ABCDE12345'\n};\n```\n\nInvoke `contentfulSync` with the configuration object. `contentfulSync` will return a promise.\n```js\nconst contentfulSync = require('contentful-sync');\n\nconst config = {\n  originSpaceId: 'XXXXXXXX',\n  targetSpaceId: 'YYYYYYYY',\n  managementToken: 'ABCDE12345'\n};\n\ncontentfulSync(config)\n.then(setOfDifferences =\u003e {\n  console.log(setOfDifferences);\n  console.log('Synced successfully!');\n})\n.catch(err =\u003e {\n  console.log('Error!');\n  console.error(err);\n});\n```\n\n### `originSpaceId`\nThis is the space that's treated as the source of truth. `contentful-sync` will attempt to replicate this space in the target space but will not update any content in this space.\n\n### `targetSpaceId`\nThis is the space that will be updated based on the content in the origin space.\n\n## Contributing\nPlease feel free to create issues, make suggestions, and/or open a pull request! Any contributions are appreciated.\n\n**Battle tested at [Common](https://www.common.com)** ![Common Living](https://www.common.com/static/images/favicons/favicon-32x32.png \"Common Living\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhicommon%2Fcontentful-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhicommon%2Fcontentful-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhicommon%2Fcontentful-sync/lists"}