{"id":14991092,"url":"https://github.com/marcomontalbano/contentful-migration-tool","last_synced_at":"2025-04-12T03:25:46.014Z","repository":{"id":45163364,"uuid":"342638983","full_name":"marcomontalbano/contentful-migration-tool","owner":"marcomontalbano","description":"Run Contentful migrations more easily with just one command. It makes migration processes a breeze.","archived":false,"fork":false,"pushed_at":"2024-04-28T20:26:57.000Z","size":847,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T21:44:44.169Z","etag":null,"topics":["cli","contentful","contentful-migration","docker","jest","migrate","migration","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcomontalbano.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-26T16:46:24.000Z","updated_at":"2024-04-28T20:27:00.000Z","dependencies_parsed_at":"2024-04-22T21:25:04.007Z","dependency_job_id":"e204f7f3-50ab-4f66-91f4-f61cbf6a276d","html_url":"https://github.com/marcomontalbano/contentful-migration-tool","commit_stats":{"total_commits":55,"total_committers":1,"mean_commits":55.0,"dds":0.0,"last_synced_commit":"33a4679cb642efec4baecfdd66ab49f7ad1e5eef"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcomontalbano%2Fcontentful-migration-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcomontalbano%2Fcontentful-migration-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcomontalbano%2Fcontentful-migration-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcomontalbano%2Fcontentful-migration-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcomontalbano","download_url":"https://codeload.github.com/marcomontalbano/contentful-migration-tool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248511285,"owners_count":21116383,"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":["cli","contentful","contentful-migration","docker","jest","migrate","migration","typescript"],"created_at":"2024-09-24T14:21:27.818Z","updated_at":"2025-04-12T03:25:45.986Z","avatar_url":"https://github.com/marcomontalbano.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contentful Migration Tool\n\n[![Test](https://img.shields.io/github/actions/workflow/status/marcomontalbano/contentful-migration-tool/test.yml?style=for-the-badge\u0026label=test)](https://github.com/marcomontalbano/contentful-migration-tool/actions/workflows/test.yml)\n[![Npm](https://img.shields.io/npm/v/contentful-migration-tool.svg?logo=npm\u0026style=for-the-badge\u0026label=version)](https://www.npmjs.com/package/contentful-migration-tool)\n[![Docker](https://img.shields.io/docker/v/marcomontalbano/contentful-migration.svg?logo=docker\u0026logoColor=white\u0026style=for-the-badge)](https://hub.docker.com/r/marcomontalbano/contentful-migration)\n\nRun Contentful migrations more easily with just one command.\n\n## Why another CLI?\n\nI decided to create this CLI when I read this article: \"[Integrating migrations in a continuous delivery pipeline with CircleCI](https://www.contentful.com/developers/docs/tutorials/general/continuous-integration-with-circleci/)\". I found that approach very interesting, so I decided to build something very close to that.\n\nWith this CLI you can run migrations easier and keep track of migrations you already run.\n\nYou can integrate this into your existing CI without any effort.\n\n\n## CLI usage\n\nThe official [`contentful-migration`](https://github.com/contentful/contentful-migration) is a peerDependency, so it is required.\n\nYou can run this command:\n\n```sh\nnpx -p contentful-migration@latest -p contentful-migration-tool@latest contentful-migration-tool run ./migrations\n```\n\nOr you can install **contentful-migration** and **contentful-migration-tool** as devDependencies and then just run:\n\n```sh\n# install dependencies\nnpm install --save-dev contentful-migration@latest contentful-migration-tool@latest\n\n# run migrations\nnpx contentful-migration-tool run ./migrations\n```\n\nIf you use **TypeScript**, you will also need **tsx** to run TypeScript migrations:\n\n```sh\n# install dependencies\nnpm install --save-dev contentful-migration@latest contentful-migration-tool@latest tsx\n\n# run migrations\nnpx tsx ./node_modules/.bin/contentful-migration-tool run ./migrations\n```\n\nRemember to set the required environment variables before running the above commands.\n\n### Options\n\n#### Environment Variables\n\n* **`CONTENT_MANAGEMENT_TOKEN`** - ***required*** - Contentful Content Management Token. You can create one from the section *API keys* under your space settings.\n\n* **`SPACE_ID`** - ***required*** - Contentful Space ID. You can get the Space ID from the section *General settings* under your space settings. The Space ID is also visibile in the url.\n\n* **`ENVIRONMENT_ID`** - ***required*** - Contentful Environment ID.\n\n## Docker usage\n\nWith this Docker image, you don't even need Node.js\n\n```sh\ndocker run --rm --tty --name contentful-migration-runner -e CONTENT_MANAGEMENT_TOKEN=$CONTENT_MANAGEMENT_TOKEN -e SPACE_ID=$SPACE_ID -e ENVIRONMENT_ID=$ENVIRONMENT_ID -v $(pwd)/migrations:/app/migrations marcomontalbano/contentful-migration\n```\n\n### Options\n\n#### Environment Variables\n\n* **`CONTENT_MANAGEMENT_TOKEN`** - ***required*** - Contentful Content Management Token. You can create one from the section *API keys* under your space settings.\n\n* **`SPACE_ID`** - ***required*** - Contentful Space ID. You can get the Space ID from the section *General settings* under your space settings. The Space ID is also visible in the url.\n\n* **`ENVIRONMENT_ID`** - ***required*** - Contentful Environment ID.\n\n#### Volumes\n\n* **`/app/migrations`** - ***required*** - Migrations folder.\n\n#### Arguments\n\n* **`--cfmversion 4.0.0`** - ***optional*** - Use this argument if you want to change the `contentful-migration` version. (default to `latest`)\n\n\n## Migrations folder\n\nEither you use **Docker** or **CLI**, you should create a `/migrations` (or whatever name) folder. This folder will contain all your migration description files.\n\nA migration description file is a `.js` or `.ts` file that contains a migration script. These scripts are written using [Contentful Migration](https://github.com/contentful/contentful-migration) syntax *which you are already familiar with*.\n\nThe filename must follow this naming convention:\n\n**`\u003cversion\u003e` `-` `\u003cdescription\u003e`** `.ts`\n\n**version** starts from `1` and must be incremental.\n\n**description** is used to easily recognize the purpose of the migration.\n\nA real example can be: `1-create-author.ts`\n\n----\n\ne.g. `javascript`\n\n```js\nmodule.exports = function (migration, context) {\n  const author = migration.createContentType('author');\n  const name = author.createField('name');\n  name.type('Symbol').required(true);\n};\n```\n\ne.g. `typescript`\n\n```ts\nimport { MigrationFunction } from 'contentful-migration'\n\nconst migrate: MigrationFunction = (migration) =\u003e {\n  const author = migration.createContentType('author');\n  const name = author.createField('name');\n  name.type('Symbol').required(true);\n}\n\nexport = migrate\n```\n\n## Useful Readings\n\n* [Contentful Migration](https://github.com/contentful/contentful-migration)\n* [Contentful • CMS as code](https://www.contentful.com/help/cms-as-code/)\n* [Contentful • Scripting migrations with the Contentful CLI](https://www.contentful.com/developers/docs/tutorials/cli/scripting-migrations/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcomontalbano%2Fcontentful-migration-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcomontalbano%2Fcontentful-migration-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcomontalbano%2Fcontentful-migration-tool/lists"}