on 01-12-2022 4:14 PM
Hello experts,
I am trying to set a specific profile for my CAP project.
If I follow this description (https://cap.cloud.sap/docs/node.js/cds-env#profiles), I would expect to be able to set a profile using the NODE_ENV environment variable as long as I don't use any flags.
For example, if I set NODE_ENV = 'test', I would expect the profile to be set to 'test' only.
However, if I execute the following
$env:NODE_ENV='test'
cds env
The following profiles are set:
Why is the profile 'development' still active?
How can I remove this profile?
Note: When I set NODE_ENV = 'production', the development profile disappears from the profiles variable:
Thanks for your help
Hi armin.hatting ,
I looked at the code so it seems to be the following (which makes sense): If NODE_ENV/CDS_ENV is not `production`, then we add `development` to the profiles, or in words:
"When you're not in production, you're developing".
I will update the documentation accordingly.
If you want to have a profile which is only enabled if you explicitly set it, you must not use `development`.
Best regards,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi david.kunz2,
thanks for your explanation.
However, the logic you describe does not seem to apply to the environment variable CDS_ENV:
echo $CDS_ENV
production
echo $NODE_ENV
<undefined>
cds env get profiles
[ 'production', 'development' ]
What would be the best practice for using different profiles in a BTP landscape with three environments?
Does the active development profile have any other effects on the CDS framework?
Best regards,
Armin
Hi armin.hatting ,
> For production environment I would use the 'production' profile and set it via NODE_ENV
Yes, that's what production environments usually do (e.g. Cloud Foundry does it). That's why the special case `NODE_ENV != production && CDS_ENV == production` doesn't exist in practise, but I can fix that.
> For the test environment, I would set NODE_ENV='test' and ensure that the development profile is not used.
Usually, test runners set that automatically (e.g. Jest).> For the development environment, I can't use the development profile (because it would interfere in the test environment). So I define a new environment, e.g. NODE_ENV='dev'?david.kunz2, has this been incorporated into the documentation yet?
I am currently struggling with the case where I want to set a credentials.url in the case of development but a credentials.destination in the case of hybrid or production. Unfortunately, when hybrid is loaded, both the URL and the destination are loaded, resulting in an error.
Do you have any recommendations on how to avoid this?
Hi tobias_steckenborn ,
Yes, I changed the documentation to
> If the profile is not set to production
, the development
profile is automatically enabled.
I see, I guess in this case you'd need to use a 'custom' development profile (e.g. `dev`) because `development` would be active.
Maybe we can tweak the mechanism a bit and not merge configurations of two (active) profiles but only use the one which is explicitly enabled, in your case `hybrid`.
I will discuss this with the team.
Best regards,
David
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.