Prismic CLI and environments

Describe your question/issue in detail

I have just migrated to Type Builder from Slice Machine. The migration seemed to quite well. I now have a prismic.config.json instead of a slicemachine.config.json.

Unfortunately, I am facing an issue with the method of syncing my code with my types and slices in Type Builder when I am developing. If I run npx prismic pull as instructed, my code is synced with my production repository. But I do my development in my staging repository.

It seems that to sync with my staging repository, I have to change repositoryName in prismic.config.json. Which then requires me to update this again before merging my staging and development environments – a step I can easily see being accidentally skipped.

Is there a work around? It doesn't appear to be possible to flag a repository with the CLI.

Hi Ben,

Yes, there is a way to do this without changing repositoryName in prismic.config.json.

The CLI lets you explicitly specify the repository with the --repo option. For example, for continuous sync:

npx prismic sync --watch --repo your-staging-repository

So you should not need to edit prismic.config.json every time you switch between production and staging. You can keep the committed config pointing to the default repository, and use --repo when you want to work against a different target locally.

For one-time pulls, the CLI help says to use prismic pull, so I would also check:

npx prismic pull --help

to confirm the same options for your exact command. But for sync and --repo are available.