-
Notifications
You must be signed in to change notification settings - Fork 159
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
DXCDT-383: Integrate preserveKeywords
function into export process
#751
DXCDT-383: Integrate preserveKeywords
function into export process
#751
Conversation
…T-375-rename-load-to-loadAssetsFromAuth0
src/context/yaml/index.ts
Outdated
|
||
const shouldPreserveKeywords = | ||
//@ts-ignore because the string=>boolean conversion may not have happened if passed-in as env var | ||
this.config.AUTH0_PRESERVE_KEYWORDS === 'true' || | ||
this.config.AUTH0_PRESERVE_KEYWORDS === true; | ||
if (shouldPreserveKeywords) { | ||
await this.loadAssetsFromLocal({ disableKeywordReplacement: true }); | ||
const localAssets = { ...this.assets }; | ||
//@ts-ignore | ||
delete this['assets']; | ||
|
||
this.assets = preserveKeywords( | ||
localAssets, | ||
auth0.assets, | ||
this.config.AUTH0_KEYWORD_REPLACE_MAPPINGS || {} | ||
); | ||
} else { | ||
this.assets = auth0.assets; | ||
} |
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.
One of the integration points; into the yaml context handler.
src/context/directory/index.ts
Outdated
await this.loadAssetsFromLocal({ disableKeywordReplacement: true }); //Need to disable keyword replacement to retrieve the raw keyword markers (ex: ##KEYWORD##) | ||
|
||
const shouldPreserveKeywords = | ||
//@ts-ignore because the string=>boolean conversion may not have happened if passed-in as env var | ||
this.config.AUTH0_PRESERVE_KEYWORDS === 'true' || | ||
this.config.AUTH0_PRESERVE_KEYWORDS === true; | ||
if (shouldPreserveKeywords) { | ||
const localAssets = { ...this.assets }; | ||
//@ts-ignore | ||
delete this['assets']; | ||
|
||
this.assets = preserveKeywords( | ||
localAssets, | ||
auth0.assets, | ||
this.config.AUTH0_KEYWORD_REPLACE_MAPPINGS || {} | ||
); | ||
} else { | ||
this.assets = auth0.assets; | ||
} |
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.
One of the integration points; into the directory context handler.
@@ -205,6 +205,7 @@ export type Config = { | |||
AUTH0_ALLOW_DELETE: boolean; | |||
AUTH0_EXCLUDED?: AssetTypes[]; | |||
AUTH0_INCLUDED_ONLY?: AssetTypes[]; | |||
AUTH0_PRESERVE_KEYWORDS: boolean; |
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.
Introduction of the configuration to enable user opt-in behavior. Will be integrated as a flag in a later PR.
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.
💡 🤔 What if we keep it as a config key only?
a02e799
to
df66ab0
Compare
Codecov ReportBase: 83.93% // Head: 84.30% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #751 +/- ##
==========================================
+ Coverage 83.93% 84.30% +0.36%
==========================================
Files 115 115
Lines 3462 3486 +24
Branches 650 659 +9
==========================================
+ Hits 2906 2939 +33
+ Misses 324 311 -13
- Partials 232 236 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
🔧 Changes
This PR takes the highest-order
preserveKeywords
function (#745) and introduces it into the export process. It does this by introducing aAUTH0_PRESERVE_KEYWORDS
boolean configuration property that indicates wether to call that function, otherwise it will run as normal.The majority of these changes are to alter the existing export process to disable keyword replacement. Previously, there was never a need to retrieve the raw, unreplaced resource configuration files, but with keyword preservation there needs to be a mechanism to disable replacement to identify where the raw keyword markers exist in the asset tree.
📚 References
Related PR: #745
🔬 Testing
Introducing unit tests for both the directory and YAML context handlers.
📝 Checklist