Giter VIP home page Giter VIP logo

x-oss-byte-_-contentful-import's Introduction

Contentful import tool

npm CircleCI Dependency Status devDependency Status

semantic-release js-standard-style

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.

This library helps you to import files generated by contentful-export to a destination space.

❗ Usage as CLI

We moved the CLI version of this tool into our Contentful CLI. This allows our users to use and install only one single CLI tool to get the full Contentful experience.

Please have a look at the Contentful CLI import command documentation to learn more about how to use this as command line tool.

☁️ Pre-requisites && Installation

Pre-requisites

  • Node LTS

Installation

npm install contentful-import

✋ Usage

const contentfulImport = require('contentful-import')

const options = {
  content: {entries:..., contentTypes:..., locales:...},
  spaceId: '<space_id>',
  managementToken: '<content_management_api_key>',
  ...
}

contentfulImport(options)
  .then(() => {
    console.log('Data imported successfully')
  })
  .catch((err) => {
    console.log('Oh no! Some errors occurred!', err)
  })

Using ESM:

import spaceImport from 'contentful-import';

or

const contentfulImport = require('contentful-import')

const options = {
  contentFile: '/path/to/result/of/contentful-export.json',
  spaceId: '<space_id>',
  managementToken: '<content_management_api_key>',
  ...
}

contentfulImport(options)
  .then(() => {
    console.log('Data imported successfully')
  })
  .catch((err) => {
    console.log('Oh no! Some errors occurred!', err)
  })

Import an environment

const contentfulImport = require('contentful-import')

const options = {
  contentFile: '/path/to/result/of/contentful-export.json',
  spaceId: '<space_id>',
  managementToken: '<content_management_api_key>',
  environmentId: '<environment_id>',
  ...
}

contentfulImport(options)
...

⚙️ Configuration options

Basics

spaceId [string] [required]

ID of the space to import into

environmentId [string] [default: 'master']

ID of the environment in the destination space

managementToken [string] [required]

Contentful management API token for the space to be imported to

contentFile [string]

Path to JSON file that contains data to be import to your space

content [object]

Content to import. Needs to match the expected structure (See below)

Filtering

contentModelOnly [boolean] [default: false]

Import content types only

skipContentModel [boolean] [default: false]

Skip importing of content types and locales

skipLocales [boolean] [default: false]

Skip importing of locales

skipContentPublishing [boolean] [default: false]

Skips content publishing. Creates content but does not publish it

Assets

uploadAssets [boolean] [default: false]

Upload local asset files downloaded via the downloadAssets option of the export. Requires assetsDirectory

assetsDirectory [string]

Path to a directory with an asset export made using the downloadAssets option of the export. Requires uploadAssets

Connection

host [string] [default: 'api.contentful.com']

The Management API host

proxy [string]

Proxy configuration in HTTP auth format: host:port or user:password@host:port

rawProxy [boolean]

Pass proxy config to Axios instead of creating a custom httpsAgent

rateLimit [number] [default: 7]

Maximum requests per second used for API requests

headers [object]

Additional headers to attach to the requests.

Other

errorLogFile [string]

Full path to the error log file

useVerboseRenderer [boolean] [default: false]

Display progress in new lines instead of displaying a busy spinner and the status in the same line. Useful for CI.

⛑️ Troubleshooting

Unable to connect to Contentful through your Proxy? Try to set the rawProxy option to true.

contentfulImport({
  proxy: 'https://cat:[email protected]:1234',
  rawProxy: true,
  ...
})

🗃️ Expected input data structure

The data to import should be structured like this:

{
  "contentTypes": [],
  "entries": [],
  "assets": [],
  "locales": [],
  "webhooks": [],
  "roles": [],
  "tags": [],
  "editorInterfaces": []
}

Note: tags are not available for all users. If you do not have access to this feature, any tags included in your import data will be skipped.

💡 Importing to a space with existing content

  • Both source space and destination space must share the same content model structure. In order to achieve that, please use contentful-migration.
  • Content transformations are also not supported, please use contentful-migration.
  • Entities existence are determined based on their ID:
    • If an entity does not exist in the destination space, it will be created.
    • If an entity already exists in the destination space, it will be updated.
  • Publishing strategy:
    • If an entity is in draft, it will be created as draft in the destination space.
    • If an entity is published and has pending changes (updated) in the source space, it will be published with the latest changes in the destination space.

⚠️ Limitations

  • This tool currently does not support the import of space memberships.
  • This tool currently does not support the import of roles.
  • This tool is expecting the target space to have the same default locale as your previously exported space.
  • Imported webhooks with credentials will be imported as normal webhooks. Credentials should be added manually afterwards.
  • Imported webhooks with secret headers will be imported without these headers. Secret headers should be added manuall afterwards.
  • If you have custom UI extensions, you need to reinstall them manually in the new space.

📝 Changelog

Read the releases page for more information.

📜 License

This project is licensed under MIT license

x-oss-byte-_-contentful-import's People

Contributors

alvinometric avatar andreascful avatar anho avatar axe312ger avatar bikappa avatar brad-turner avatar crissto avatar damienxy avatar danielruf avatar dborsatto avatar dependabot-preview[bot] avatar dependabot[bot] avatar erdener-cf avatar ewendel avatar fkiriakos avatar floelhoeffel avatar jwhiles avatar khaledgarbaya avatar kimberlycoy avatar makinwab avatar marcolink avatar mariobodemann avatar matthew-contentful avatar mrjman avatar phoebeschmidt avatar ruderngespra avatar thebiglabasky avatar timbeyer avatar vinz93 avatar z0al avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.