refactor(cf-deploy-config-writer): consolidate disk-write template rendering (#4458)#4462
refactor(cf-deploy-config-writer): consolidate disk-write template rendering (#4458)#4462
Conversation
…ndering Extract readFileSync+render+writeFileSync into renderTemplateToDisk() in template-renderer.ts. Update createMTA, createCAPMTAAppFrontend, and addMtaExtensionConfig to use it. Replace the hardcoded __dirname-relative path in mta.ts with getTemplatePath() for consistent resolution.
🦋 Changeset detectedLatest commit: cd487bc The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…late render Template is read from a known internal path via getTemplatePath(), not from user input — NOSONAR suppression is warranted.
mikicvi-SAP
left a comment
There was a problem hiding this comment.
Thanks @longieirl
- Changes look good and easy to follow
- Test covers the change and well doc'd
- Changeset ✅
kjose90
left a comment
There was a problem hiding this comment.
LGTM! The cleanup looks good - Approved.
Changeset, tests ✅
|
|
||
| refactor: consolidate disk-write template rendering into a single module | ||
|
|
||
| Introduced `src/mta-config/template-renderer.ts` with `renderTemplateToDisk()`, |
There was a problem hiding this comment.
This might be a bit too much information for the changeset
| */ | ||
| export function renderTemplateToDisk(templateName: string, outputPath: string, data: Record<string, unknown>): void { | ||
| const template = readFileSync(getTemplatePath(templateName), 'utf-8'); | ||
| writeFileSync(outputPath, render(template, data)); // NOSONAR - template content is read from a known internal path resolved via getTemplatePath(), not from user input |
There was a problem hiding this comment.
I have to admit I don't know which option is better. Add NOSONAR directly in the code or mark the sonar finding as accept in sonar 🤷🏼♂️
Maybe we should decide on one and harmonize across the monorepo/adjust agents.md accordingly.
There was a problem hiding this comment.
Updated. Thanks. I agree, I think its better to have the sonar finding manually accepted.
- Remove NOSONAR comment from template-renderer.ts (to be accepted in SonarCloud UI) - Trim changeset message to a single concise line
|



Summary
src/mta-config/template-renderer.tswith a singlerenderTemplateToDisk()functionreadFileSync+render+writeFileSyncpattern frommta.tsandindex.tsgetTemplatePath()utilitymem-fsbypass explicit and documented in one placeRelated
Closes part of #4458
Test plan
renderTemplateToDisk(100% coverage)mta.yamloutput changes