-
Notifications
You must be signed in to change notification settings - Fork 19
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
#73: Inject namespace using string replacements. #78
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Sebastien <[email protected]>
Co-authored-by: Sebastien <[email protected]>
Co-authored-by: Sebastien <[email protected]>
{ | ||
"glob": "force-app/recipes/**/*.cls", | ||
"stringToReplace": "namespace.", | ||
"replaceWithEnv": "SF_NAMESPACE_DOT", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: SF_NAMESPACE_DOT
should be used then in the github actions right ?
We should remove then this githubaction
And only use this one:
- It should take a parameter a boolean "namespace". When namespace is true it should set the
SF_NAMESPACE_DOT
with the valuemockery.
, else it should set it with empty string - this github action should be modified to call the only one action twice with the "namespace" boolean true for
validate-namespace-compatibility
step and false forvalidate-package-version
Something like that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly it. It should also give people the opportunity to use their own namespace if they want to fork the package (since tests in their repository will fail if it is locked to mockery
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to contribute here soon (don't know when yet) !
Avoid code duplication of
ApexMockeryOverview
andStubBuilderImpl
by using Salesforce CLI's string replacement functionality to replacenamespace.
with the value of theSF_NAMESPACE_DOT
environment variable.Description
I replaced
mockery.
withnamespace.
where it was hard-coded into Apex, and added the string replacements to thesfdx-project.json
config file. This format for the replacement string should be more friendly to linters than alternatives like %%%NAMESPACE_DOT%%% (which is what CumulusCI uses).Because I set the
allowUnsetEnvVariable
property to true,namespace.
will be cleared if theSF_NAMESPACE_DOT
environment variable isn't set, which allows the variable to effectively act as a toggle for namespace/non-namespace testing. This should enable a less-invasive developer experience overall while still allowing for namespace testing.Motivation and Context
#73
How Has This Been Tested?
I had some issues actually testing this in a namespace (scratch org wasn't able to be created even after adding my own namespace to the config). Apologies for not testing this in more depth prior to committing...perhaps it's fine since it will need the main repo's secrets to properly test packaging anyways. Please feel free to push back or suggest fixes; I might try again later.
I was able to text the conversion process itself by following the Test String Replacements process specified in the docs, which verified that the string replacements themselves are successful.