(Moderator note: Copied Github issue text to the post body here to make the idea more easily readable / discussable)
The idea
As the CLI is already reading out the
DATOCMS_API_TOKEN
, would it be an option to useDATOCMS_ENVIRONMENT
to use if available for the--autogenerate
command?Bonus points to use a third env variable
DATOCMS_ENVIRONMENT_SOURCE
from which the user can tell the CLI the fork has been created.The potential way of working
So the CLI would run something like this automagically when env vars are available:
npx datocms migration:new someMigrationFileName --autogenerate=$DATOCMS_ENVIRONMENT:$DATOCMS_ENVIRONMENT_SOURCE
Reasoning behind the idea
When developing in larger teams it might happen that you create new features and new DatoCMS environments async and create new environment on a frequent basis (especially with continuous deployments).
When one developer brings their changes to
main
and deploy it to a new environment, the other developers still might need to generate their migration based on an older environment. If they in this case forget to set the source environment, they will end up generating a migration, removing all new fields/models/blocks that have been brought to primary environment.This feature would make that process slightly less error prone
Original post:
I did not know if I should add this inside the git repository or here so I created this issue in GitHub and post it here