Our development flow involve in each developer having its own “draft” app in our Shopify Partner dashboard. We use the shopify.app.toml as the development file which is not commited.
An issue we just came across is a team member who:
Started the CLI from scratch with npm run dev.
It launched the prompt and ask to choose one of the apps.
He chose the main production app, probably because the name is the app/company’s name.
Chose to update urls, this question is not so clear when you’re not familiar with shopify local development.
Result:
It started the process with the main production app, and updated the urls with those development tunnel urls.
So our clients were not able to access our website nor register since auth and main urls were changed.
Luckily we found the issue quickly. He should have chose his development app during the launch, or chose to not update urls. But it pose a serious risk to not be able to guard this. I’m not sure on which solution would be the best, some I got:
Have the ability to refuse updating urls via a flag, so we could override the command in the package.json and prevent this. But it would not prevent pushing a new extension, or update existing extension with development version accessible for example.
Have tokens and be able to protect some apps.
Prevent npm run dev on live app.
Have the ability to prevent running dev on some app
Add a clear confirmation prompt when running dev the command on live app.
Is it better to make this post here or create a issue in github repo?
The risk of accidentally deploying development settings to a production environment can have significant consequences, as you’ve experienced. Here are a couple strategies you might consider to prevent these issues, combining your ideas and adding a few more:
Environment Separation and Access Control:
Strictly separate development and production environments. Ensure that developers do not have access to modify production settings directly.
Use different user roles and permissions in the Partner dashboard to restrict who can update the production app.
Implement a Flag to Prevent URL Updates:
Modify your npm run dev script to include a flag or an environment variable that prevents updating URLs in the production environment. This can act as a safeguard against accidental changes.
Automate Environment Validation:
Implement a script that runs before npm run dev to check the current environment. If the script detects a production environment, it could either abort the process or require additional confirmation.
This script could also validate whether the current user has permissions to make changes in the production environment.
Clear Confirmation Prompts:
Enhance the CLI tool to include clearer warnings or confirmation prompts when making changes that could affect the production environment.
For example, a prompt like “You are about to update URLs in a production environment. Are you sure? (yes/no)” can be effective.
Education and Process Improvements:
Conduct regular training sessions for your development team, emphasizing the importance of environment awareness.
Develop a checklist or a standard operating procedure for starting development sessions, which includes checking the environment and app selection.
Version Control and Change Management:
Ensure shopify.app.toml and other critical configuration files are under version control, even if they are not committed to the main branch. This allows you to track changes and roll back if necessary.