An open API service indexing awesome lists of open source software.

https://github.com/andresharpe/cute

Bulk upload and download of Contentful content (excel/csv/tsv/yaml/json/sql).
https://github.com/andresharpe/cute

cli contentful csv excel json yaml

Last synced: 14 days ago
JSON representation

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

Awesome Lists containing this project

README

        

[![Nuget][version-shield]][version-url][![contributors][contributors-shield]][contributors-url][![issues][issues-shield]][issues-url][![stars][stars-shield]][stars-url][![build][build-shield]][build-url][![forks][forks-shield]][forks-url]


Logo

A Contentful Update Tool & Extractor


View the Source Code ยท Download @ Nuget

# Introduction

***cute*** is a cross-platform CLI tool that brings several advanced features and capabilities to working with your content hosted on [Contentful](https://www.contentful.com).



cute help screenshot

## 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](https://www.wikidata.org/).
- Content can be translated or even generated from scratch using popular technologies like [OpenAI](https://openai.com/) and [Azure AI Translator](https://azure.microsoft.com/en-us/products/ai-services/ai-translator).
- Deploy ***cute*** as a Web Server with [OpenTelemetry](https://opentelemetry.io/) 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](https://www.contentful.com) 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
```
![cute help screenshot](https://raw.githubusercontent.com/andresharpe/cute/master/docs/images/help.png)

# 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
```

![cute login --help screenshot](https://raw.githubusercontent.com/andresharpe/cute/master/docs/images/login.png)

# 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
```
![cute info screenshot](https://raw.githubusercontent.com/andresharpe/cute/master/docs/images/info.png)

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

![cute content --help screenshot](https://raw.githubusercontent.com/andresharpe/cute/master/docs/images/content-help.png)

## 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
cute content download --content-type --format [excel|csv|tsv|json|yaml]
```
Issuing any ```content download``` command will yield a result similar to the display below.

![cute download screenshot](https://raw.githubusercontent.com/andresharpe/cute/master/docs/images/download.png)

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 The Contentful content type id
-l, --locale The locale code (eg. 'en') to apply the command to. Default is all
-f, --format The output format for the download operation (Excel/CSV/TSV/JSON/YAML)
-p, --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 upload progress screenshot](https://raw.githubusercontent.com/andresharpe/cute/master/docs/images/upload-progress.png)

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

![cute upload screenshot](https://raw.githubusercontent.com/andresharpe/cute/master/docs/images/upload.png)

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 The Contentful content type id
-l, --locale The locale code (eg. 'en') to apply the command to. Default is all
-p, --path The local path to the file containing the data to sync
-f, --format The format of the file specified in '--path' (Excel/CSV/TSV/JSON/YAML)
-m, --match-field 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](./docs/CUTE-USAGE.md).

# Contributing to Cute

We welcome community pull requests for bug fixes, enhancements, and documentation. See [How to contribute](./docs/CONTRIBUTING.md) for more information.

[version-shield]: https://img.shields.io/nuget/v/cute.svg?style=for-the-badge

[version-url]: https://www.nuget.org/packages/cute

[build-shield]: https://img.shields.io/github/actions/workflow/status/andresharpe/cute/cute-cd.yaml?branch=main&event=push&label=Build&style=for-the-badge

[build-url]: https://github.com/andresharpe/cute/actions/workflows/cute-cd.yaml?query=branch%3Amain

[contributors-shield]: https://img.shields.io/github/contributors/andresharpe/cute.svg?style=for-the-badge

[contributors-url]: https://github.com/andresharpe/cute/graphs/contributors

[forks-shield]: https://img.shields.io/github/forks/andresharpe/cute.svg?style=for-the-badge

[forks-url]: https://github.com/andresharpe/cute/network/members

[stars-shield]: https://img.shields.io/github/stars/andresharpe/cute.svg?style=for-the-badge

[stars-url]: https://github.com/andresharpe/cute/stargazers

[issues-shield]: https://img.shields.io/github/issues/andresharpe/cute.svg?style=for-the-badge

[issues-url]: https://github.com/andresharpe/cute/issues