{"id":15143745,"url":"https://github.com/contentful/contentful-bootstrap.rb","last_synced_at":"2025-09-29T12:31:01.614Z","repository":{"id":66184173,"uuid":"45053656","full_name":"contentful/contentful-bootstrap.rb","owner":"contentful","description":"Contentful CLI tool for getting started with Contentful","archived":true,"fork":false,"pushed_at":"2023-10-26T13:44:21.000Z","size":749,"stargazers_count":24,"open_issues_count":1,"forks_count":6,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-09-22T15:33:02.593Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/contentful.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2015-10-27T16:19:25.000Z","updated_at":"2024-05-08T10:49:00.000Z","dependencies_parsed_at":"2023-07-13T16:31:17.356Z","dependency_job_id":null,"html_url":"https://github.com/contentful/contentful-bootstrap.rb","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentful%2Fcontentful-bootstrap.rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentful%2Fcontentful-bootstrap.rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentful%2Fcontentful-bootstrap.rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentful%2Fcontentful-bootstrap.rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contentful","download_url":"https://codeload.github.com/contentful/contentful-bootstrap.rb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219874544,"owners_count":16554590,"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":[],"created_at":"2024-09-26T10:03:24.371Z","updated_at":"2025-09-29T12:30:56.209Z","avatar_url":"https://github.com/contentful.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/contentful/contentful-bootstrap.rb.svg)](https://travis-ci.org/contentful/contentful-bootstrap.rb)\n\n# Contentful Bootstrap\n\nA small CLI tool for getting started with Contentful\n\n## Contentful\n[[Contentful](https://www.contentful.com) provides a content infrastructure for digital teams to power content in websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster.\n\n## What does `contentful_bootstrap` do?\n`contentful_bootstrap` let's you set up a new Contentful environment with a single command.\n\n## How to Use\n\n### Installation\n\n```bash\n$ gem install contentful_bootstrap\n```\n\n### Usage\n\nYou can create spaces by doing:\n\n```bash\n$ contentful_bootstrap create_space \u003cspace_name\u003e [--template template_name] [--json-template template_path] [--locale locale_code] [--mark-processed] [--no-publish] [--config CONFIG_PATH] [--quiet]\n```\n\nYou can also generate new Delivery API Tokens by doing:\n\n```bash\n$ contentful_bootstrap generate_token \u003cspace_id\u003e [--name token_name] [--config CONFIG_PATH] [--quiet]\n```\n\nYou can also generate JSON Templates from existing spaces by doing:\n\n```bash\n$ contentful_bootstrap generate_json \u003cspace_id\u003e \u003cdelivery_api_access_token\u003e [--environment ENVIRONMENT_ID] [--output-file OUTPUT PATH] [--content-type-ids ct_id_1,ct_id_2] [--content-types-only] [--use-preview] [--quiet]\n```\n\nYou can update existing spaces from JSON Templates by doing:\n\n```bash\n$ contentful_bootstrap update_space \u003cspace_id\u003e -j template_path [--environment ENVIRONMENT_ID] [--mark-processed] [--skip-content-types] [--no-publish] [--quiet]\n```\n\n### Built-in templates\n\nJust getting started with Contentful? We have included the following built-in templates:\n\n```\nblog\ngallery\ncatalogue\n```\n\nYou can use these with the `--template` option to create some demo data and start developing\nagainst our APIs right away. Once you've gotten comfortable, you can\n[create your own templates](#json-templates) for quickly replicating testing \u0026 development spaces.\n\n### Using from within other applications\n\nInclude `contentful_bootstrap` to your project's `Gemfile`\n\n```ruby\ngem \"contentful_bootstrap\"\n```\n\nRequire `contentful_bootstrap`\n\n```ruby\nrequire 'contentful/bootstrap'\n```\n\nTo Create a new Space\n\n```ruby\nContentful::Bootstrap::CommandRunner.new.create_space(\"space_name\")\n```\n\nAdditionally, you can send an options hash with the following keys:\n\n```ruby\noptions = {\n  template: \"blog\", # Will use one of the predefined templates and create Content Types, Assets and Entries\n  json_template: \"/path/to/template.json\", # Will use the JSON file specified as a Template\n  locale: \"es-AR\", # Will create the space with the specified locale code as default locale, defaults to \"en-US\"\n  mark_processed: false, # if true will mark all resources as 'bootstrapProcessed' and will be avoided for update_space calls (doesnt affect create_space)\n  no_publish: false, # if true it won't publish your entries or assets\n  trigger_oauth: true, # if true will trigger OAuth process\n  quiet: false, # if true will not output to STDOUT\n  no_input: false # if true all input operations won't be done, exceptions thrown with alternatives through configuration file in cases in which it cannot proceed\n}\nContentful::Bootstrap::CommandRunner.new.create_space(\"space_name\", options)\n```\n\nTo Update an existing Space\n\n```ruby\noptions = {\n  json_template: \"/path/to/template.json\", # Will use the JSON file specified as a Template\n  environment: \"master\", # Will update the specified environment, will NOT create the environment if it doesn't exist, defaults to \"master\"\n  locale: \"es-AR\", # Will create the space with the specified locale code as default locale, defaults to \"en-US\"\n  mark_processed: false, # if true will mark all resources as 'bootstrapProcessed and will be avoided on future update_space calls\n  trigger_oauth: true, # if true will trigger OAuth process\n  skip_content_types: false, # if true will avoid creating the content types\n  no_publish: false, # if true it won't publish your entries or assets\n  quiet: false, # if true will not output to STDOUT\n  no_input: false # if true all input operations won't be done, exceptions thrown with alternatives through configuration file in cases in which it cannot proceed\n}\nContentful::Bootstrap::CommandRunner.new.update_space(\"space_id\", options)\n```\n\nTo Create a new Delivery API Token\n\n```ruby\nContentful::Bootstrap::CommandRunner.new.generate_token(\"space_id\")\n```\n\nAdditionally, you can send an options hash with the following keys:\n\n```ruby\noptions = {\n  name: \"Some Nice Token Name\", # Will Create the Delivery API Token with the specified name\n  trigger_oauth: true, # if true will trigger OAuth process\n  quiet: false, # if true will not output to STDOUT\n  no_input: false # if true all input operations won't be done, exceptions thrown with alternatives through configuration file in cases in which it cannot proceed\n}\nContentful::Bootstrap::CommandRunner.new.generate_token(\"space_id\", options)\n```\n\nTo Generate a JSON Template from an exising Space\n\n```ruby\nContentful::Bootstrap::CommandRunner.new.generate_json(\n  \"space_id\",\n  access_token: \"delivery_or_preview_api_access_token\",\n  environment: \"master\", # Will fetch content from the specified environment, defaults to \"master\"\n  use_preview: false, # if true will fetch from the Preview API instead of Delivery API\n  filename: nil, # path to file in which to store JSON\n  content_types_only: false, # if true will not fetch Entries and Assets\n  content_type_ids: [], # if any ID is specified, JSON will only include those content types and entries that have that content type\n  quiet: false, # if true will not output to STDOUT - only when filename is provided\n  no_input: false # if true all input operations won't be done, exceptions thrown with alternatives through configuration file in cases in which it cannot proceed\n)\n```\n\nAdditionally, you can send an options hash with the following keys:\n**NOTE**: The `:access_token` key is required in the options hash\n\n```ruby\noptions = {\n  access_token: \"access_token\" # REQUIRED\n  environment: \"master\", # Will fetch content from the specified environment, defaults to \"master\"\n  use_preview: false, # if true will fetch from the Preview API instead of Delivery API\n  filename: \"template.json\", # Will save the JSON to the specified file\n  content_types_only: false, # if true will not fetch Entries and Assets\n  content_type_ids: [], # if any ID is specified, JSON will only include those content types and entries that have that content type\n  quiet: false, # if true will not output to STDOUT\n  no_input: false # if true all input operations won't be done, exceptions thrown with alternatives through configuration file in cases in which it cannot proceed\n}\nContentful::Bootstrap::CommandRunner.new.generate_json(\"space_id\", options)\n```\n\nOptionally, `CommandRunner#new` will take a parameter for specifying a configuration path\n\n### Configuration\n\nContentful Bootstrap will read by default from `~/.contentfulrc`, but you can provide your own\nfile by using the `--config CONFIG_PATH` parameter\n\nIf you don't have `~/.contentfulrc` created, you will be prompted if you want to create it\n\n#### Configuration Format\n\nThe configuration file will be in `ini` format and looks like the following\n\n```ini\n[global]\nCONTENTFUL_ORGANIZATION_ID = an_organization_id\nCONTENTFUL_MANAGEMENT_ACCESS_TOKEN = a_management_access_token\n\n[space_name]\nSPACE_ID = some_space_id ; Space configurations are not required by this tool, but can be generated by it\nCONTENTFUL_DELIVERY_ACCESS_TOKEN = a_delivery_acces_token\n```\n\n### JSON Templates\n\nUsing the `--json-template` option, you can create spaces with your own predefined content.\nThis can be useful for creating testing \u0026 development spaces or just starting new projects from\na common baseline. You can find a complete example [here](./examples/templates/catalogue.json)\n\nUsing the `--mark-processed` option alongside `--json-template` will mark all resources as `bootstrapProcessed`,\nwhich will make it so `update_space` calls avoid already created resources. (A resource being either a Content Type, Entry or Asset).\n\n## Workflow for backing up draft/updated content\n\nIn many cases, you want to have a dump of your whole space, including draft/updated content.\nTo achieve this, do the following:\n\n1. Export the content:\n\n```bash\n# Export published content\ncontentful_bootstrap generate_json \u003cSPACE_ID\u003e \u003cDELIVERY_TOKEN\u003e -o bootstrap-published.json\n\n# Export draft/updated content\ncontentful_bootstrap generate_json \u003cSPACE_ID\u003e \u003cPREVIEW_TOKEN\u003e -o bootstrap-preview.json --use-preview\n```\n\n\u003e Notice that on the second command we're using the `--use-preview` flag to use the Preview API to fetch the content.\n\n2. Create or update a space with the templates:\n\n```bash\n# Import published content\ncontentful_bootstrap update_space \u003cSPACE_ID\u003e -j bootstrap-published.json\n\n# Import draft/updated content\ncontentful_bootstrap update_space \u003cSPACE_ID\u003e -j bootstrap-preview.json --no-publish\n```\n\n\u003e Notice that on the second command we're using the `--no-publish` flag to avoid publishing content that was originally draft/updated.\n\nWith this simple two-step process, you ensure that your content is fully reproducible, even if it's in draft state.\n\n## Contributing\n\nFeel free to improve this tool by submitting a Pull Request. For more information,\nplease check [CONTRIBUTING.md](./CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentful%2Fcontentful-bootstrap.rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontentful%2Fcontentful-bootstrap.rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentful%2Fcontentful-bootstrap.rb/lists"}