Multi-Developer Workflow
This guide outlines the steps for contributing to a project that another developer is currently working on. It assumes that you have already set up the project on your local machine and are familiar with the app template.
Our app setup utilizes a Cloudflare Tunnel to route requests securely between your development server and Cloudflare. Each tunnel can only be used by one developer at a time so multiple developers working on the same project will need to setup their own tunnel.
Shopify apps only have one application URL so each developer will require their own version of the app to work on too.
Creating a Dev Version of the App
Next, you'll create your own dev version of the app:
- Run the following command:
npm run shopify app config link
- Name your dev app using the format "[merchant name] by BAO (Dev [developer initials])"
- eg P448 by BAO (Dev MM)
- When prompted, use the format "dev-[developer initials]" for the "Configuration file name"
- eg dev-mm
- This will create two new files in the project, "shopify.app.dev-mm.toml" and ".env.dev-mm"
Update the
application_urlandredirect_urlsin the new app configuration file (shopify.app.dev-mm.toml) with the URL of the new tunnel (https://p448-mm.beeayo.com).Copy the
scopesfromshopify.app.tomlfile and add them to your new app configuration file.Ensure you're using the new app configuration by running
npm run shopify app config useand selecting your configurationDeploy your configuration to Shopify using
npm run shopify app deploy
Creating a New Cloudflare Tunnel
- Run the following command in your terminal and follow the prompts:
npm run tunnel:create
This command creates a Cloudflare Tunnel and a .env file in the route of the project. If you already have a .env file, it will be updated. The content added will look like:
APP_TUNNEL_CONFIG=.cloudflared/config-mm.yml
APP_TUNNEL_NAME=p448-mm
APP_TUNNEL_URL=https://p448-mm.beeayo.com
Move these environment variables (prefixed with
APP_TUNNEL_) into the env file which was created with the new dev app eg.env.dev-mmTo ensure your shell is using these environment variables you will need to run the following in your terminal:
source .env
source .envwill load the variables into your current shell but doesn't export them so they won't be available to child processes (such asnpm run dev)Use
export $(grep -v '^#' .env | xargs)to export the variables and make them available to child processes
- To avoid manually running the above command before starting the development server each time you can duplicate the dev script in the
package.jsonto create your own and include the command to export the environment variables. Example below:
"dev": "shopify app dev --no-update",
"dev:mm": "export $(grep -v '^#' .env.dev-mm | xargs) && shopify app dev --no-update",
Considerations and Troubleshooting
When multiple developers are working on the same project, there may be data clashes as both apps will be saving to the same metafield namespace and keys. To minimize conflicts, coordinate with your team and consider using unique prefixes or suffixes for your development data.
If you encounter any issues during the tunnel creation or app linking process, double-check that you've followed the naming conventions and provided the correct URLs. Reach out to your team lead or consult the project documentation for further assistance.
Regularly communicate with your team members to ensure a smooth collaboration and to avoid any conflicts in the codebase.
By following these steps and considerations, you'll be able to set up your own development environment and contribute to the project effectively while minimizing conflicts with other developers' work.