b2c-crm-sync icon indicating copy to clipboard operation
b2c-crm-sync copied to clipboard

Documentation for multiple destination environments .env files

Open olegforce opened this issue 3 years ago • 5 comments

I can see that .dotenv is used on the project, but there is no documentation on how to define and switch between at least 2 environments. What exact change should be done and how to trigger deployment to different environments?

If I have multiple CRM orgs and will create: .env.dev - for development on my personal CC sandbox and CRM org .env.ci - for CI/CD instance of the another CC sandbox and another CRM org

and will not have .env, what should I update and how to trigger CLI commands?

olegforce avatar Aug 20 '21 06:08 olegforce

we can create the multiple.env files and based on the env just change the initialization path. No change in CLI command. In b2c-crm-sync\cli.js line no 14 : pass the path based on env condition require('dotenv').config(); e.g. require('dotenv').config({ path: '/custom/path/to/.env' }) Refer https://www.npmjs.com/package/dotenv#path for more details Cheers

chandanrjit2021 avatar Aug 20 '21 10:08 chandanrjit2021

@chandanrjit2021 I just tried and it doesn't work:

// Initialize the .env confirmation
require('dotenv').config({path: '/.env.devorgpersonaccounts'});

I have the .env file and .env.devorgpersonaccounts, both for different CC and CRM environments. When I run npm run crm-sync:b2c:verify and above code is in the cli.js it still pick .env file and not .env.devorgpersonaccounts

olegforce avatar Aug 22 '21 00:08 olegforce

@olegforce Maybe the file name and structure need changes to support the node modules. I have tried .looks fine to me

image

chandanrjit2021 avatar Aug 22 '21 01:08 chandanrjit2021

@chandanrjit2021 Thanks, mate! I made it work, as per your example.

I think this is a valid issue ticket so project documentation can be updated on how to use multiple .env files: image

So filename can't change and it should be always .env while manipulation with multiple environments should be done via a folder tree structure.

olegforce avatar Aug 22 '21 09:08 olegforce

@chandanrjit2021 looks like this one caused another issue -> https://github.com/SalesforceCommerceCloud/b2c-crm-sync/issues/20 now in order to run multi-cloud use-cases I have to copy the proper .env file into root folder as dotenv is not used for multi-cloud testing from what I see now.

I guess it is just again confirms this is a valid issue ticket and following issue should be addressed.

olegforce avatar Aug 23 '21 01:08 olegforce