Contentful CLI

repository·main·Indexed 18 days ago

https://github.com/contentful/contentful-cli

A command-line tool for managing Contentful spaces, performing imports and exports, executing migrations, and managing extensions. It includes capabilities for configuring environment settings, retrieving and listing Content Types, and full lifecycle management of extensions (create, update, delete, get, and list).

Tokens
22K
Snippets
105
Records
121
Agent score
62%

What's inside contentful-cli

  1. Manage Contentful Spaces with the CLI

    main

    The space command is the primary entry point for managing Contentful Spaces via the CLI. It allows you to perform lifecycle operations such as creating spaces, listing accessible spaces, and managing environments and aliases. You can also use it to move data between spaces using import and export commands, or to seed a space with a predefined template.

    contentful space [subcommand]
  2. Logout of the Contentful CLI

    main

    Use the logout command to end your current session with the Contentful CLI. This action removes the CMA (Content Management API) access token from the .contentfulrc.json file located in your local user directory. After logging out, you will need to use the login command to re-authenticate.

    contentful logout
  3. Manage Space Environment Aliases with Contentful CLI

    main

    The space environment-alias command allows you to manage Environment Aliases within a Contentful Space. Environment Aliases provide a stable name that points to a specific environment, allowing you to switch the target environment (e.g., from master to staging) without changing your application configuration.

    You can use the following subcommands to manage these aliases:

    contentful space environment-alias [subcommand]
  4. Generate a migration file with `space generate migration`

    main

    Use the space generate migration command to create a migration file for your entire content model or for a specific content type. This file can then be used to automate content model changes.

    If you have previously used space use and space environment use, the CLI will attempt to use those saved Space and Environment IDs automatically. Otherwise, you must provide them via flags.

    contentful space generate migration -s space_id -e master
  5. Export a diff between two environments as a migration

    main

    Use the contentful merge export command to generate a migration file that represents the differences (diff) between two Contentful environments. This is useful for capturing changes made in a source environment and preparing them to be applied to a target environment.

    contentful merge export --source-environment-id staging --target-environment-id master
  6. Create a new environment alias with `space environment-alias create`

    main

    Use the space environment-alias create command to create a new alias for an existing environment.

    Prerequisite: You must opt-in to this feature in the Contentful web app by navigating to Settings > Environments before attempting to use this command via the CLI.

    Required flags:

    • --alias-id, -a: The ID of the new alias you want to create.
    • --target-environment-id, -e: The ID of the existing environment that the alias will point to.
    contentful space environment-alias create --alias-id 'staging' --target-environment-id 'release-2'
  7. Delete an extension using `extension delete`

    main

    Use the contentful extension delete command to remove an existing extension from a Contentful space. You must provide the extension ID and either a specific version or the --force flag to confirm the deletion.

    Required Arguments/Flags:

    • --id: The unique identifier of the extension you want to delete.
    • Either --version (to target a specific version) or --force (to bypass confirmation/version checks) must be provided.
    contentful extension delete --space-id xxx --id test