Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: using .env variable for auto generate commands #28

Open
thomasverleye opened this issue Sep 11, 2024 · 1 comment
Open

Idea: using .env variable for auto generate commands #28

thomasverleye opened this issue Sep 11, 2024 · 1 comment

Comments

@thomasverleye
Copy link

The idea

As the CLI is already reading out the DATOCMS_API_TOKEN, would it be an option to use DATOCMS_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 ✌🏻

@arcataroger
Copy link
Member

arcataroger commented Sep 12, 2024

In case anyone else sees this, there is a workaround on the forum: https://community.datocms.com/t/datocms-cli-env-variable-usage-for-environment-names/5304/3?u=roger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants