Is the 'directus' command in the Docker image officially supported?

An AI bot suggested the directus command to get the current schema and apply it on a different server using these commands:

docker compose exec directus npx directus schema snapshot /directus/schema.yaml
docker compose exec directus npx directus schema apply /directus/schema.yaml

In the documentation I can’t find any reference to this command. But I did find an archived GitHub repo with a Directus CLI at GitHub - directus/cli: Directus Client CLI · GitHub

My question: is this command officially supported? I think we could use it to save and update server configurations between developers and test/production servers.

2 Answers

2

The cli is technically still supported, however, this functionality was added to the REST APIs a couple of years ago: Schema | Directus Docs

Recommend using the API’s.

OK, understood. I tried the API's first, but applying a snapshot from instance A on instance B did not produce the same result. So I was looking for an alternative that does a better job.

The schema endpoint should indeed produce the same result as the CLI does.

Nice to know perhaps (hence my reply), instead of using npx directus .. from inside the official container you can also do node cli.js <blabla>. I think that should be a bit more efficient then the npx command.

Don't know exactly what you mean, we run Directus in a custom configured container. It's not part of a npm package and we don't have a cli.js program to call. But instead of the CLI we will first try the API. Either way, CLI and API both seem to require quite some custom programming to let multiple developers work on the application and push changes to test and later to production servers.