CLI application for starting Gatsby or NextJS project with Flotiq integration fast.
MIT License
Flotiq is a modern and highly customizable headless CMS that offers a seamless content management experience for developers and content creators alike. With its intuitive API-first approach and flexible data model, Flotiq enables businesses to easily create, manage, and distribute content across multiple channels and platforms.
CLI application for starting your next project with Flotiq fast. Currently supports the following commands:
See our docs 📜
npm install -g flotiq-cli
flotiq export [directory] [flotiqApiKey]
This command exports data from the Flotiq account to local JSON files. If the key is limited to selected Content Types, then the data available for this key will be exported.
Parameters
directory
- path to the directory where the files will be savedflotiqApiKey
- read-only or read and write API key to your Flotiq accountFlags
--only-definitions
- use this flag to run export only for Content Type Definitions, ignore Content Objectsflotiq import [projectName] [flotiqApiKey]
This command imports Content Types and Content Objects to your Flotiq account using the API key.
Source directory must include directory with ContentType[0-9]
folders, each of them containing ContentTypeDefinition.json file, and contentObject[0-9].json
files.
The number at the end of the directory or file name defines the file import order.
The ./images
directory in a particular starter stores images that will be imported into your Media Library.
The command can import data output of the flotiq export
command.
Parameters
projectName
- project name or project path (if you wish to start or import data from the directory you are in, use .
)flotiqApiKey
- read and write API key to your Flotiq accountIt is also possible to perform the import and export manually, using the Flotiq API without relying on the CLI importer. However, when doing this, you need to ensure that image URLs are updated, as images will receive new IDs during the migration process. This requires careful handling to avoid broken links in your Content Objects. For more details on how to properly handle this, refer to the Flotiq API documentation.
flotiq start [projectName] [flotiqStarterUrl] [flotiqApiKey]
This command will:
gatsby develop
to start your Gatsby starter.Parameters
projectName
- project name or project path (if you wish to start or import data from the directory you are in, use .
)flotiqStarterUrl
- full link to the starter, the list belowflotiqApiKey
- API key to your Flotiq account, if you wish to import data it must be read and write API key (more about Flotiq API keys in the documentation)Flags
--framework
- framework of the starter i.e. --framework=nextjs
or --fw=gatsby
. If no framework parameter is given, the URL will be searched for phrases i.e. Set to gatsby
by default--no-import
- skip example data importThere is a possibility to use dynamic data in JSON files.
We implemented our parser to create a dynamic date value, but it can be extended in the future.
To use dynamic date in imported contentObject.json
files use {{date}}
function:
{{date}}
means now
, outputs e.g. 2022-01-01{{date:+5d}}
means now + 5 days
, outputs e.g. 2022-01-06{{date:-5m}}
means now - 5 months
, outputs e.g. 2021-06-01{{date:+5y}}
means now + 5 years
, outputs e.g. 2027-01-01flotiq wordpress-import [wordpressUrl] [flotiqApiKey]
This command will:
Parameters
wordpressUrl
- full link to WordPress site from which you wish to migrate content to FlotiqflotiqApiKey
- read and write API key to your Flotiq accountflotiq purge [flotiqApiKey]
This command will remove all data from your account. Great for testing imports. Command requires additional confirmation.
Parameters
flotiqApiKey
- read and write API key to your Flotiq accountFlags
--withInternal
or --internal
- purge will also remove internal type objects like (_media
)--force
or --f
- purge will remove data even if Content Types relations loop to each other.flotiq sdk install [language] [directory] [flotiqApiKey]
Parameters
language
- SDK language: csharp, go, java, javascript, php, python, typescriptdirectory
- path to the directory where the files will be savedflotiqApiKey
- read and write API key to your Flotiq accountflotiq contentful-import [contentfulSpaceId] [contentfulContentManagementToken] [flotiqApiKey] [translation]
This command will automatically pull content types, assets and content objects from Contentful space to your Flotiq account.
Parameters
[translation]
- selection of Contentful's locale. en-US by defaultflotiq excel-export [ctdName] [filePath] [flotiqApiKey]
This command will export Content Objects from the given Content Type to an MS Excel file in .xlsx format.
Parameters
ctdName
- API name of Content Type Definition you wish to exportfilePath
- the directory to which the xlsx file is to be saved. Type in "." if you want to save the file inside the current directoryflotiqApiKey
- API key to your Flotiq account with read permissionFlags
--limit=[number]
or --l=[number]
- number of Content Objects to export counting from the top row, default: 10000--hideResults
or --hr
- information about the export process will not appear in the consoleflotiq excel-import [ctdName] [filePath] [flotiqApiKey]
This command will import Content Objects from an MS Excel file to the given Content Type.
Parameters
ctdName
- API name of Content Type Definition you wish to import data tofilePath
- the path to the xlsx file you wish to import data fromflotiqApiKey
- API key to your Flotiq account with read and write permissionsFlags
--limit=[number]
or --l=[number]
- number of Content Objects imported counting from the top row, default: 10 000--batchLimit
or --bl
- number of Content Objects imported per batch call, default: 100--hideResults
or --hr
- information about the import process will not appear in the console--updateExisting
or --ue
- if content objects with a given id already exist in the Flotiq account, they will be updatedflotiq stats [flotiqApiKey]
This command displays your Flotiq API Key's following statistics:
Parameters
flotiqApiKey
- API key to your Flotiq account, if you wish to import data it must be read and write API key (more about Flotiq API keys in the documentation)--json-output
, -j
- Error and console output will be additionally written into json file named output.json
You can choose one of our starters:
https://github.com/flotiq/flotiq-gatsby-recipe-1
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-recipe-2
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-event-1
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-event-2
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-portfolio-1
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-portfolio-2
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-blog-1
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-blog-2
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-shop-1
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-gatsby-shop-2
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-nextjs-recipe-2
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-nextjs-event-2
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-nextjs-portfolio-2
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-nextjs-blog-1
as the flotiqStarterUrl
https://github.com/flotiq/flotiq-nextjs-shop-2
as the flotiqStarterUrl
Clone this repository:
git clone https://github.com/flotiq/flotiq-cli.git
Enter the directory:
cd flotiq-cli
Install dependencies:
npm install
Usage
node bin/flotiq [command]
, for example node bin/flotiq stats [flotiqApiKey]
If you wish to talk with us about this project, feel free to hop on .
If you found a bug, please report it in issues.
To make your life and ours easier, we have prepared error codes.
Writing or reading a file error.
Gatsby's error, more info is in the output.
Problem with adding Content Object.
Incorrect WordPress URL.
To publish a new package in NPM, you need to update the version in the packages.json and packages-lock.json files and then commit the changes with the message "Release x.y.z". Where x.y.z is the new version of the package. Commit about this on the master branch will start building a tag about this version and publishing a new version to npm.