A CLI tool to make applying or extracting Directus "templates" a little easier...well a lot easier.
Notes:
- This is a pre-release. It is recommended for use on POC or demo projects only.
⚠️ Known issues with using MySQL currently, please use ONLY PostgreSQL or SQLite for your database provider.- Templates are applied / extracted on an all or nothing basis – meaning that all the schema, content, and system settings are extracted or applied. We'd love to support more granular operations in the future. (PRs welcome 🙏)
- If you are extracting or applying from a remote source, the script can take quite a while depedning on the "size" of your instance (how many collections, how many items in each collection, number and size of assets, etc). The script applies a strict rate limit of 10 requests per second using bottleneck.
To avoid potential conflicts and bad outcomes, templates can only be applied to a blank instance currently.
- Create a Directus instance on Directus Cloud or using self-hosted version.
- Login and create a Static Access Token for the admin user.
- Copy the static token and your Directus URL.
- Run the following command on the terminal and follow the prompts.
$ npx directus-template-cli apply
You can choose from our templates bundled with the CLI or you can also choose a template from a local directory.
The CLI can also extract a template from a Directus instance so that it can be applied to other instances.
- Make sure you remove any sensitive data from the Directus instance you don't want to include in the template.
- Login and create a Static Access Token for the admin user.
- Copy the static token and your Directus URL.
- Run the following command on the terminal and follow the prompts.
$ npx directus-template-cli extract
This tool is licensed under the MIT License.