Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/convert/transformers/defaultMetadataTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ const getContentSourceDestination = (
if (
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

source.endsWith('content.json') ||
source.endsWith('_meta.json') ||
!(fs.existsSync(dir) && fs.statSync(dir).isDirectory())
(!(fs.existsSync(dir) && fs.statSync(dir).isDirectory()) &&
!source.endsWith('mobile.json') &&
!source.endsWith('tablet.json'))
) {
return join(mergeWith.content, basename(source));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ describe('DefaultMetadataTransformer', () => {
});

it('should merge output with merge component when content is a directory', async () => {
assert(typeof bundle.COMPONENT.name === 'string');
const root = join('path', 'to', 'another', bundle.COMPONENT.type.directoryName, bundle.COMPONENT.name);
const component = SourceComponent.createVirtualComponent(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The way this test works is a little complicated. What's happening here is as follows:

- `force-app` contains a source-formatted project with the folder `main/default/digitalExperiences/site/DemoSite/sfdc_cms__view/demo1/mobile` containing a `mobile.json` file
- `force-app-destination` is identical except it lacks this folder
- The snapshot test merges `force-app` into `force-app-destination` and verifies that the `mobile.json` file is placed into a `mobile` folder instead of placed at the root of the `demo1` page

This snapshot locks in the fix for @W-20967044@
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<DigitalExperienceBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<digitalExperienceFolderShares/>
<label>DemoSite1</label>
<modules>
<module>
<fullyQualifiedName>sfdc_cms__collection</fullyQualifiedName>
<status>ENABLED</status>
</module>
<module>
<fullyQualifiedName>sfdc_cms__mobilePublisherConfig</fullyQualifiedName>
<status>ENABLED</status>
</module>
</modules>
</DigitalExperienceBundle>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"apiName": "mainAppPage",
"type": "sfdc_cms__appPage",
"path": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "sfdc_cms__appPage",
"title": "main",
"contentBody": {
"currentThemeId": "Build_Your_Own_LWR",
"headMarkup": "<title>Welcome to LWC Communities!</title>\n\n<!-- branding stylesheets -->\n\r\n<link rel=\"stylesheet\" href=\"{ basePath }/assets/styles/slds/salesforce-lightning-design-system-part1.css?{ versionKey }\"/>\n<link rel=\"stylesheet\" href=\"{ basePath }/assets/styles/slds/salesforce-lightning-design-system-part2.css?{ versionKey }\"/>\n<link rel=\"stylesheet\" href=\"{ basePath }/assets/styles/slds/salesforce-lightning-design-system-part3.css?{ versionKey }\"/>\n<link rel=\"stylesheet\" href=\"{ basePath }/assets/styles/slds/salesforce-lightning-design-system-part4.css?{ versionKey }\"/>\r\n<link rel=\"stylesheet\" href=\"{ basePath }/assets/styles/dxp-site-spacing-styling-hooks.min.css?{ versionKey }\" />\n<link rel=\"stylesheet\" href=\"{ basePath }/assets/styles/dxp-styling-hooks.min.css?{ versionKey }\" />\n<link rel=\"stylesheet\" href=\"{ basePath }/assets/styles/dxp-slds-extensions.min.css?{ versionKey }\" />\n\n\n\n<!-- branding stylesheets-->\n\n<link rel=\"stylesheet\" href=\"{ styles/styles.css }\" />\n<link rel=\"stylesheet\" href=\"{ styles/print.css }\" media=\"print\"/>\n",
"isLockerServiceEnabled": true,
"isRelaxedCSPLevel": false,
"templateName": "talon-template-byo"
},
"urlName": "main"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"apiName": "Build_Your_Own_LWR",
"type": "sfdc_cms__brandingSet",
"path": "brandingSets"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
{
"type": "sfdc_cms__brandingSet",
"title": "Build Your Own (LWR)",
"contentBody": {
"brandingSetType": "APP",
"definitionName": "talon-template-byo:branding",
"values": {
"BackgroundColor": "#ffffff",
"BaseFont": "var(--dxp-g-root-font-family)",
"BaseFontSize": "1rem",
"BodyFont": "var(--dxp-s-html-font-family)",
"BodyFontSize": "1rem",
"BodyFontStyle": "normal",
"BodyFontWeight": "400",
"BodyLetterSpacing": "0em",
"BodyLineHeight": "1.5",
"BodySmallFont": "var(--dxp-s-html-font-family)",
"BodySmallFontSize": "0.75rem",
"BodySmallFontStyle": "normal",
"BodySmallFontWeight": "400",
"BodySmallLetterSpacing": "0em",
"BodySmallLineHeight": "1.25",
"BodySmallTextColor": "var(--dxp-g-root-contrast)",
"BodySmallTextDecoration": "none",
"BodySmallTextTransform": "none",
"BodyTextColor": "var(--dxp-g-root-contrast)",
"BodyTextDecoration": "none",
"BodyTextTransform": "none",
"ButtonBorderColor": "var(--dxp-s-button-color)",
"ButtonBorderRadius": "4px",
"ButtonColor": "var(--dxp-g-brand)",
"ButtonFocusBorderColor": "var(--dxp-s-button-color-focus)",
"ButtonFocusColor": "var(--dxp-s-button-color-1)",
"ButtonFocusTextColor": "var(--dxp-s-button-color-contrast-1)",
"ButtonFont": "var(--dxp-s-html-font-family)",
"ButtonFontSize": "1rem",
"ButtonFontStyle": "normal",
"ButtonFontWeight": "400",
"ButtonHoverBorderColor": "var(--dxp-s-button-color-hover)",
"ButtonHoverColor": "var(--dxp-s-button-color-1)",
"ButtonHoverTextColor": "var(--dxp-s-button-color-contrast-1)",
"ButtonLargeBorderRadius": "4px",
"ButtonLargeFontSize": "1.25rem",
"ButtonLargePadding": "1.25rem",
"ButtonLargeVerticalPadding": "0rem",
"ButtonLetterSpacing": "0em",
"ButtonLineHeight": "2",
"ButtonPadding": "1rem",
"ButtonSmallBorderRadius": "4px",
"ButtonSmallFontSize": "0.75rem",
"ButtonSmallPadding": "0.75rem",
"ButtonSmallVerticalPadding": "0rem",
"ButtonTextColor": "var(--dxp-g-brand-contrast)",
"ButtonTextDecoration": "none",
"ButtonTextTransform": "none",
"ButtonVerticalPadding": "0rem",
"ColumnSpacerSizeDesktop": "1rem",
"ColumnSpacerSizeMobile": "0.75rem",
"ComponentSpacerSizeDesktop": "1.5rem",
"ComponentSpacerSizeMobile": "1.5rem",
"DropdownBackgroundColor": "var(--dxp-g-root)",
"DropdownBackgroundHoverColor": "var(--dxp-g-neutral)",
"DropdownBorderColor": "var(--dxp-g-neutral)",
"DropdownTextColor": "var(--dxp-g-root-contrast)",
"DropdownTextHoverColor": "var(--dxp-g-neutral-contrast)",
"FormElementBackgroundColor": "var(--dxp-g-root)",
"FormElementBackgroundFocusColor": "var(--dxp-s-form-element-color-background)",
"FormElementBorderColor": "var(--dxp-g-neutral-3)",
"FormElementBorderFocusColor": "var(--dxp-g-brand)",
"FormElementBorderRadius": "4px",
"FormElementBorderWidth": "1px",
"FormElementCaptionTextDecoration": "none",
"FormElementCaptionTextFont": "var(--dxp-s-html-font-family)",
"FormElementCaptionTextFontSize": "0.75rem",
"FormElementCaptionTextFontStyle": "normal",
"FormElementCaptionTextFontWeight": "400",
"FormElementCaptionTextLetterSpacing": "0",
"FormElementCaptionTextLineHeight": "1.5",
"FormElementCaptionTextTransform": "none",
"FormElementCheckboxBackgroundColor": "var(--dxp-s-form-element-color-background)",
"FormElementCheckboxBackgroundColorChecked": "var(--dxp-s-form-checkbox-color-background)",
"FormElementCheckboxBorderColor": "var(--dxp-s-form-element-color-border)",
"FormElementCheckboxBorderColorChecked": "var(--dxp-s-form-checkbox-color-border)",
"FormElementCheckboxBorderRadius": "4px",
"FormElementCheckboxBorderWidth": "1px",
"FormElementInputPlaceholderColor": "var(--dxp-g-neutral-3)",
"FormElementLabelColor": "var(--dxp-g-root-contrast)",
"FormElementLabelFont": "var(--dxp-s-html-font-family)",
"FormElementLabelFontSize": "1rem",
"FormElementLabelFontStyle": "normal",
"FormElementLabelFontWeight": "400",
"FormElementLabelLetterSpacing": "0",
"FormElementLabelLineHeight": "1.5",
"FormElementLabelTextDecoration": "none",
"FormElementLabelTextTransform": "none",
"FormElementLetterSpacing": "0",
"FormElementPaddingBottom": "0px",
"FormElementPaddingLeft": "12px",
"FormElementPaddingRight": "16px",
"FormElementPaddingTop": "0px",
"FormElementTextColor": "var(--dxp-g-root-contrast)",
"FormElementTextDecoration": "none",
"FormElementTextFocusColor": "var(--dxp-s-form-element-text-color)",
"FormElementTextFont": "var(--dxp-s-html-font-family)",
"FormElementTextFontSize": "1rem",
"FormElementTextFontStyle": "normal",
"FormElementTextFontWeight": "400",
"FormElementTextLineHeight": "1.5",
"FormElementTextTransform": "none",
"HeadingExtraExtraSmallColor": "var(--dxp-g-root-contrast)",
"HeadingExtraExtraSmallFont": "var(--dxp-s-html-font-family)",
"HeadingExtraExtraSmallFontSize": "0.625rem",
"HeadingExtraExtraSmallFontStyle": "normal",
"HeadingExtraExtraSmallFontWeight": "600",
"HeadingExtraExtraSmallLetterSpacing": "0em",
"HeadingExtraExtraSmallLineHeight": "1.25",
"HeadingExtraExtraSmallTextDecoration": "none",
"HeadingExtraExtraSmallTextTransform": "none",
"HeadingExtraLargeColor": "var(--dxp-g-root-contrast)",
"HeadingExtraLargeFont": "var(--dxp-s-html-font-family)",
"HeadingExtraLargeFontSize": "2.5rem",
"HeadingExtraLargeFontStyle": "normal",
"HeadingExtraLargeFontWeight": "300",
"HeadingExtraLargeLetterSpacing": "0em",
"HeadingExtraLargeLineHeight": "1.25",
"HeadingExtraLargeTextDecoration": "none",
"HeadingExtraLargeTextTransform": "none",
"HeadingExtraSmallColor": "var(--dxp-g-root-contrast)",
"HeadingExtraSmallFont": "var(--dxp-s-html-font-family)",
"HeadingExtraSmallFontSize": "0.8125rem",
"HeadingExtraSmallFontStyle": "normal",
"HeadingExtraSmallFontWeight": "600",
"HeadingExtraSmallLetterSpacing": "0em",
"HeadingExtraSmallLineHeight": "1.25",
"HeadingExtraSmallTextDecoration": "none",
"HeadingExtraSmallTextTransform": "none",
"HeadingLargeColor": "var(--dxp-g-root-contrast)",
"HeadingLargeFont": "var(--dxp-s-html-font-family)",
"HeadingLargeFontSize": "1.75rem",
"HeadingLargeFontStyle": "normal",
"HeadingLargeFontWeight": "300",
"HeadingLargeLetterSpacing": "0em",
"HeadingLargeLineHeight": "1.25",
"HeadingLargeTextDecoration": "none",
"HeadingLargeTextTransform": "none",
"HeadingMediumColor": "var(--dxp-g-root-contrast)",
"HeadingMediumFont": "var(--dxp-s-html-font-family)",
"HeadingMediumFontSize": "1.25rem",
"HeadingMediumFontStyle": "normal",
"HeadingMediumFontWeight": "300",
"HeadingMediumLetterSpacing": "0em",
"HeadingMediumLineHeight": "1.25",
"HeadingMediumTextDecoration": "none",
"HeadingMediumTextTransform": "none",
"HeadingSmallColor": "var(--dxp-g-root-contrast)",
"HeadingSmallFont": "var(--dxp-s-html-font-family)",
"HeadingSmallFontSize": "1.125rem",
"HeadingSmallFontStyle": "normal",
"HeadingSmallFontWeight": "300",
"HeadingSmallLetterSpacing": "0em",
"HeadingSmallLineHeight": "1.25",
"HeadingSmallTextDecoration": "none",
"HeadingSmallTextTransform": "none",
"HorizontalRowPaddingDesktop": "1rem",
"HorizontalRowPaddingMobile": "0.75rem",
"LinkColor": "var(--dxp-g-brand)",
"LinkHoverColor": "var(--dxp-s-link-text-color-1)",
"LinkTextDecoration": "none",
"LinkTextDecorationFocus": "underline",
"LinkTextDecorationHover": "underline",
"MaxContentWidthDesktop": "1800px",
"MaxContentWidthMobile": "none",
"MobileBaseFontSize": "1rem",
"PrimaryAccentColor": "#005fb2",
"PrimaryAccentForegroundColor": "#ffffff",
"SecondaryButtonBorderColor": "var(--dxp-s-button-color)",
"SecondaryButtonColor": "var(--dxp-g-root)",
"SecondaryButtonFocusBorderColor": "var(--dxp-s-secondary-button-border-color-1)",
"SecondaryButtonFocusColor": "var(--dxp-s-secondary-button-color-1)",
"SecondaryButtonFocusTextColor": "var(--dxp-s-secondary-button-text-color-1)",
"SecondaryButtonHoverBorderColor": "var(--dxp-s-secondary-button-border-color-1)",
"SecondaryButtonHoverColor": "var(--dxp-s-secondary-button-color-1)",
"SecondaryButtonHoverTextColor": "var(--dxp-s-secondary-button-text-color-1)",
"SecondaryButtonTextColor": "var(--dxp-s-button-color)",
"SiteLogo": "",
"TertiaryButtonBorderColor": "rgba(0,0,0,0)",
"TertiaryButtonColor": "rgba(0,0,0,0)",
"TertiaryButtonFocusBorderColor": "var(--dxp-s-tertiary-button-border-color-1)",
"TertiaryButtonFocusColor": "var(--dxp-s-tertiary-button-color-1)",
"TertiaryButtonFocusTextColor": "var(--dxp-s-tertiary-button-text-color-1)",
"TertiaryButtonHoverBorderColor": "var(--dxp-s-tertiary-button-border-color-1)",
"TertiaryButtonHoverColor": "var(--dxp-s-tertiary-button-color-1)",
"TertiaryButtonHoverTextColor": "var(--dxp-s-tertiary-button-text-color-1)",
"TertiaryButtonTextColor": "var(--dxp-s-button-color)",
"TextColor": "#1a1b1e",
"VerticalRowPaddingDesktop": "1rem",
"VerticalRowPaddingMobile": "0.75rem",
"_BackgroundColor1": "#ebebeb",
"_BackgroundColor2": "#c2c2c2",
"_BackgroundColor3": "#858585",
"_ButtonActiveBorderColor": "var(--dxp-s-button-border-color-focus)",
"_ButtonActiveColor": "var(--dxp-s-button-color-focus)",
"_ButtonActiveTextColor": "var(--dxp-s-button-color-focus-contrast)",
"_ButtonColor1": "var(--dxp-g-brand-1)",
"_ButtonTextColor1": "var(--dxp-g-brand-contrast-1)",
"_DestructiveColor": "#c23934",
"_DestructiveColor1": "#a2302b",
"_DestructiveColor2": "#611d1a",
"_DestructiveColor3": "#010000",
"_DestructiveForegroundColor": "#ffffff",
"_DestructiveForegroundColor1": "#ffffff",
"_DestructiveForegroundColor2": "#ffffff",
"_DestructiveForegroundColor3": "#ffffff",
"_InfoColor": "#16325c",
"_InfoColor1": "#0e203b",
"_InfoColor2": "#000000",
"_InfoColor3": "#000000",
"_InfoForegroundColor": "#ffffff",
"_InfoForegroundColor1": "#ffffff",
"_InfoForegroundColor2": "#ffffff",
"_InfoForegroundColor3": "#ffffff",
"_LinkColor1": "var(--dxp-g-brand-1)",
"_NeutralColor": "#ecebea",
"_NeutralColor1": "#d9d7d5",
"_NeutralColor2": "#b2aeaa",
"_NeutralColor3": "#76716b",
"_NeutralForegroundColor": "#000000",
"_NeutralForegroundColor1": "#000000",
"_NeutralForegroundColor2": "#000000",
"_NeutralForegroundColor3": "#ffffff",
"_OfflineColor": "#444444",
"_OfflineColor1": "#303030",
"_OfflineColor2": "#070707",
"_OfflineColor3": "#000000",
"_OfflineForegroundColor": "#ffffff",
"_OfflineForegroundColor1": "#ffffff",
"_OfflineForegroundColor2": "#ffffff",
"_OfflineForegroundColor3": "#ffffff",
"_PrimaryAccentColor1": "#004989",
"_PrimaryAccentColor2": "#001e38",
"_PrimaryAccentColor3": "#000000",
"_PrimaryAccentForegroundColor1": "#ffffff",
"_PrimaryAccentForegroundColor2": "#ffffff",
"_PrimaryAccentForegroundColor3": "#ffffff",
"_SecondaryButtonActiveBorderColor": "var(--dxp-s-secondary-button-border-color-focus)",
"_SecondaryButtonActiveColor": "var(--dxp-s-secondary-button-color-focus)",
"_SecondaryButtonActiveTextColor": "var(--dxp-s-secondary-button-text-color-focus)",
"_SecondaryButtonBorderColor1": "var(--dxp-s-button-color-1)",
"_SecondaryButtonColor1": "var(--dxp-g-root-1)",
"_SecondaryButtonTextColor1": "var(--dxp-s-button-color-1)",
"_SiteLogoUrl": "",
"_SuccessColor": "#4bca81",
"_SuccessColor1": "#36b66c",
"_SuccessColor2": "#237747",
"_SuccessColor3": "#07190f",
"_SuccessForegroundColor": "#000000",
"_SuccessForegroundColor1": "#000000",
"_SuccessForegroundColor2": "#ffffff",
"_SuccessForegroundColor3": "#ffffff",
"_TertiaryButtonActiveBorderColor": "var(--dxp-s-tertiary-button-border-color-focus)",
"_TertiaryButtonActiveColor": "var(--dxp-s-tertiary-button-color-focus)",
"_TertiaryButtonActiveTextColor": "var(--dxp-s-tertiary-button-text-color-focus)",
"_TertiaryButtonBorderColor1": "rgba(0,0,0,0)",
"_TertiaryButtonColor1": "rgba(0,0,0,0)",
"_TertiaryButtonTextColor1": "var(--dxp-s-button-color-1)",
"_TextColor1": "#000000",
"_TextColor2": "#000000",
"_TextColor3": "#000000",
"_WarningColor": "#ffb75d",
"_WarningColor1": "#ffa534",
"_WarningColor2": "#e27d00",
"_WarningColor3": "#673900",
"_WarningForegroundColor": "#000000",
"_WarningForegroundColor1": "#000000",
"_WarningForegroundColor2": "#000000",
"_WarningForegroundColor3": "#ffffff"
}
},
"urlName": "build-your-own-lwr"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"apiName": "languages",
"type": "sfdc_cms__languageSettings",
"path": "_settings"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "sfdc_cms__languageSettings",
"title": "LanguageContent",
"contentBody": {
"languages": [
{
"locale": "en_US",
"label": "English (US)",
"isActive": true,
"isAuthoringOnly": false
}
],
"defaultLocale": "en_US"
},
"urlName": "languagecontent"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"apiName": "mobilePublisherConfig",
"type": "sfdc_cms__mobilePublisherConfig",
"path": "_settings"
}
Loading
Loading