Contentful CLI

官方的 Contentful 命令行界面。直接从命令行使用 Contentful 功能。「The official Contentful command line interface. Use Contentful features straight from the command line!」

Github星跟蹤圖

Contentful CLI

Contentful's command line interface tool. Use Contentful features straight from your CLI.

npm
Contentful

Contentful 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.

:rocket: Features

  • Get started with Contentful with the init command.
  • Manage spaces - list, create, delete,...
  • Export your space to a JSON file.
  • Import your space from a JSON file.
  • Execute migration scripts written in the Contentful Migration DSL
  • Generate migration scripts for the Contentful Migration DSL from existing spaces.
  • Seed your space with example data.
  • Manage installation of extensions in a space.
  • Securely login and logout with our OAuth service.
  • Find all available commands in the docs section.

:cloud: Installation

Make sure you have Node LTS installed

Then using npm or yarn:

npm install -g contentful-cli
# Or
yarn global add contentful-cli

Please note that for the non standalone versions you need Node LTS to use the CLI.

:hand: Usage

Use the --help parameter to display the help section for CLI tool or combined with a specific command to get the help section for that command.

contentful --help
# Or
contentful space --help

:books: Documentation

More detailed documentation for every command can be found in the docs section.

Using the CLI tool with a proxy

You can save the proxy configuration in your .contentfulrc.json via:

contentful config add --proxy user:auth@host:port

We also respect the http(s)_proxy environment variables:

https_proxy=user:auth@host:port contentful

When multiple proxy configurations exists, precedence is taken in this form:

  1. http_proxy takes precedence over .contentfulrc.json
  2. https_proxy takes precedence over .contentfulrc.json
  3. https_proxy takes precedence over http_proxy

:rescue_worker_helmet: Troubleshooting

  • Unable to connect to Contentful through your Proxy? Try settings rawProxy: true in your .contentfulrc.json via:
contentful config add --raw-proxy

:hammer_and_wrench: Development

  1. Install dependencies
    npm i
    
  2. To avoid development version colliding with your already installed Contentful CLI, change the command name in package.json
      "bin": {
    -     "contentful": "bin/contentful.js"
    +     "ctfl": "bin/contentful.js"
      }
    
  3. Link your local version, and happy hacking :tada:
    npm link
    

:robot: Testing

Integration tests

To run integration tests locally, you'll need the following:

  1. Set environment variables in .jest/env.js (can be found in 1Password)
    process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN = '<cma_auth_token>'
    process.env.CLI_E2E_ORG_ID = '<organization_id>'
    
  2. Run talkback proxy to record and playback http requests
    npm run talkback-proxy
    
  3. In another terminal shell run your preferred tests
    ## Run all integration tests
    npm run test:jest
    ## Or run specific tests
    npx jest test/integration/cmds/space/* --watch
    

Unit tests

Simply run:

# Run all unit tests
npm run test:unit:watch
# Or run specific tests
npx jest /test/unit/cmds/* --watch

See jest documentation for more details about running tests and optional flags.

Updating Snapshots

You might need to update snapshots and it's challenging with the recordings.

Tip: run tests without recordings to update the snapshots.

npx jest test/integration/cmds/<path to the affected test file> --updateSnapshot

:question: Support

If you have a problem with this tool, please file an issue here on Github.

If you have other problems with Contentful not related to this library, you can contact Customer Support.

:writing_hand: Contributing

See CONTRIBUTING.md

:scroll: License

MIT

主要指標

概覽
名稱與所有者mysticatea/abort-controller
主編程語言TypeScript
編程語言JavaScript (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2017-09-29 04:05:44
推送於2021-03-30 17:01:33
最后一次提交2019-03-30 18:14:46
發布數10
最新版本名稱v3.0.0 (發布於 2019-03-30 18:14:46)
第一版名稱v1.0.0 (發布於 2017-10-03 10:43:01)
用户参与
星數308
關注者數8
派生數34
提交數49
已啟用問題?
問題數29
打開的問題數17
拉請求數5
打開的拉請求數6
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?