cute

Bulk upload and download of Contentful content (excel/csv/tsv/yaml/json/sql).

MIT License

Stars
3
Committers
4

Introduction

cute is a cross-platform CLI tool that brings several advanced features and capabilities to working with your content hosted on Contentful.

Key Features

  • Bulk processing capabilities lets you download, modify and upload data in most popular formats including Comma delimited files (CSV), Tab delimited files (TSV), MS-Excel workbooks (XLSX), Javascript Object Notation (JSON) and YAML.
  • Input data can be sourced and synced from many external sources including flat files, databases, webAPIs, your Contentful space or other popular sources like WikiData.
  • Content can be translated or even generated from scratch using popular technologies like OpenAI and Azure AI Translator.
  • Deploy cute as a Web Server with OpenTelemetry compliant logging and a service terminal to reflect health, configuration and scheduled tasks.
  • Support for structural subtyping through the typegen command option which exports TypeScript (TS) interface declarations. This feature is especially useful to keep your JavaScript or .NET projects in sync with your content types.
  • cute auto-magically "learns" your Contentful space and generates required configuration nodes to enable process automation.
  • Interact with Douglas, cute's very own AI assistant that will answer questions about your content, or even help formulate queries to interact with your content.

💡 Contentful is a content infrastructure platform that lets you create, manage and distribute content to any platform. Contentful offers a simple UI to declare and manage a content model, independent from the presentation layer.

Installation

Firstly, make sure you have the Dotnet SDK 8.0 package installed.

For windows (cmd or powershell):

winget install Microsoft.DotNet.SDK.8

Or, on linux and iOS

sudo apt-get update && sudo apt-get install -y dotnet-sdk-8.0

Then:

On windows you may have to close and re-open the command line prompt (or Windows Terminal).

Install the cute cli by typing.

dotnet tool install -g cute

To test whether the installation worked

Simply type

cute

This will display the cute help. You are ready to go! 🚀

Getting Help

cute --help

Logging into Contentful

Start your cute session by running the login command. This will configure your Contentful session profile using the selected space, environment and API keys. You can also enter your AI and translation services keys here.

cute login

Display a summary of your Contentful Space

Display a comprehensive overview of your Contentful session information including space, environment, content types and locales. Info related to CLI display settings is also shown.

cute info

Working with Content

The cute content and its respective command options represents the real workhorse of the cute tool. It essentially presents the user with a suite of bulk operation options to interact with their content in Contentful.

Downloading data

Content can easily be downloaded from your Contentful space in one of several popular formats including Excel, comma separated (CSV), tab separated (TSV), JSON and YAML. If no format is specified, the downloaded file with default to the Excel format.

cute content download --content-type <contentType> 
cute content download --content-type <contentType> --format [excel|csv|tsv|json|yaml]

Issuing any content download command will yield a result similar to the display below.

Typing cute download --help will list all currently available options and usage.

USAGE:
    cute content download [OPTIONS]

OPTIONS:
    -h, --help                  Prints help information
    -c, --content-type-id <ID>  The Contentful content type id
    -l, --locale <CODE>         The locale code (eg. 'en') to apply the command to. Default is all
    -f, --format <FORMAT>       The output format for the download operation (Excel/CSV/TSV/JSON/YAML)
    -p, --path <PATH>           The output path and filename for the download operation

Uploading/Synchronizing Content

You can upload content from a local file to your Contentful space. The local file can be a previously downloaded and updated Excel, CSV, TSV, JSON or YAML file.

cute will prompt you to confirm a 2-digit code to prevent you from updating your content accidentally.

Typing cute content upload --help will show the full usage and options.

USAGE:
    cute content upload [OPTIONS]

OPTIONS:
    -h, --help                  Prints help information
    -c, --content-type-id <ID>  The Contentful content type id
    -l, --locale <CODE>         The locale code (eg. 'en') to apply the command to. Default is all
    -p, --path <PATH>           The local path to the file containing the data to sync
    -f, --format <FORMAT>       The format of the file specified in '--path' (Excel/CSV/TSV/JSON/YAML)
    -m, --match-field <NAME>    The optional name of the field to match in addition to the entry id
    -a, --apply                 Apply and publish all the calculated changes. The default behaviour is to only list the detected changes

Generating strong JavaScript or .NET Types

cute supports structural subtyping through the type scaffold command option. You can export TypeScript (TS) or .NET (CS) interface declarations, or a simple Excel file with individual worksheets detailing your content model. This feature is especially useful to keep your JavaScript or .NET projects in sync with your content types.

USAGE:
    cute type scaffold [OPTIONS]

OPTIONS:
    -h, --help            Prints help information
    -c, --content-type    Specifies the content type to generate types for. Default is all
    -o, --output          The local path to output the generated types to
    -l, --language        The language to generate types for (TypeScript/CSharp)
    -n, --namespace       The optional namespace for the generated type

Content generation using OpenAI

You can generate content using OpenAI Generative Pre-trained Transformer (GPT) using the bulk operation feature of cute.

OpenAI ChatGPT uses a state-of-the-art Large Language Model (LLM) to generate text that is difficult to distinguish from human-written content.

Prompts and system messages that are generally used to interact with ChatGPT are configured and persisted in your Contentful space. This is especially useful as your AI prompts are persisted and backed up in the cloud right alongside your content.

Prompts can be added and configured in the 🤖 Cute / ContentGenerate section your Contentful space. A typical prompt entry has an id, a system message, a prompt, points to a content type and field. Something like :-

Title Note
title A short title by which the prompt entry is referred to.
systemMessage Used to communicate instructions or provide context to the model at the beginning of a conversation.
prompt A question or instruction that you issue to ChatGPT. This prompt is used to generate an appropriate response.
deploymentModel Select which Large Language Model (LLM) is used for your interaction.
maxTokenLimit The maximum tokens to be used for the interaction
temperature Controls the randomness of the generated response. A higher temperature value increases randomness, making the responses more diverse and creative, while a lower value makes them more focused and deterministic.
topP Controls the diversity of the generated output by truncating the probability distribution of words. It functions as a filter to determine the number of words or phrases the language model examines while predicting the next word. For instance, when the Top P value is set at 0.4, the model only considers 40% of the most probable words or phrases. A higher Top P value results in more diverse creative responses. A lower value will result in more focused and coherent responses.
frequencyPenalty Controls the repetitiveness of words in generated responses. Increasing this value is like telling ChatGPT not to use the same words too often.
presencePenalty Manages the appearance of words in generated text based on their position, rather than frequency. This parameter encourages ChatGPT to employ a more diverse vocabulary
cuteDataQueryEntry A link to the associated data query in 🤖 Cute / DataQuery
promptOutputContentField The target field of the content entry where the generated response is stored.
DESCRIPTION:
Generate content using a Large Language Model (LLM).

USAGE:
    cute content generate [OPTIONS]

OPTIONS:
    -h, --help          Prints help information
    -k, --key           The key of the 'cuteContentGenerate' entry
    -a, --apply         Apply and publish all the required edits
    -o, --operation     Specify the generation operation to perform. (GenerateSingle, GenerateParallel,
                                      GenerateBatch or ListBatches)

Command Structure for v2.0

The full command structure for the usage of version 2 of cute can be found in this document.

Contributing to Cute

We welcome community pull requests for bug fixes, enhancements, and documentation. See How to contribute for more information.

Badges
Extracted from project README's
Nuget contributors issues stars build forks
Related Projects