fix: digitalExperiences create files to right folders @W-20967044@#1680
Conversation
WillieRuemmele
left a comment
There was a problem hiding this comment.
seems like the correct, and most minimal fix
| @@ -92,7 +92,9 @@ const getContentSourceDestination = ( | |||
| if ( | |||
There was a problem hiding this comment.
The scope of this if block now is becoming somewhat unwieldy and requires a bit of effort expenditure for the reader.
This is probably a good candidate for partitioning into its own private function:
function shouldFlattenDigitalExperienceContentToViewFolder(source: SourcePath, dir: string): boolean {
const isViewRootFile =
source.slice(-12) === 'content.json' || source.slice(-10) === '_meta.json';
const isMobileOrTabletFile =
source.slice(-11) === 'mobile.json' || source.slice(-11) === 'tablet.json';
const subfolderExists = fs.existsSync(dir) && fs.statSync(dir).isDirectory();
return (
isViewRootFile || (!subfolderExists && !isMobileOrTabletFile)
);
}// ...
if (shouldFlattenDigitalExperienceContentToViewFolder(source, dir)) {
return join(mergeWith.content, basename(source));
}
//...That said - the entire function is quite difficult to understand in its current state. We may want to just refactor the whole thing to save headaches for the next person who has to read this.
There was a problem hiding this comment.
I agree that this is prime territory for a refactoring. Given the tight timeframe for releasing the fix, I'd rather keep the changes minimal, and then just note this as a great area for us to go back to during a tech debt sprint.

What does this PR do?
Fixes issue wherein digital experience bundle pages could be fetched to the root folder by mistake if the correct subfolder didn't already exist.
What issues does this PR fix or reference?
@W-20967044@
Functionality Before
If you created a page in a digital experience bundle and fetched it via
sf project retrieve startand thenchanged somethign about the mobile layout and fetched again, themobile.jsonfile would be created at the top-level for the page instead of nested inmobile/mobile.json.Functionality After
The file is created in the correct subdirectory.
<insert gif and/or summary>