diff --git a/src/common/constants.ts b/src/common/constants.ts index dfc7a65306..778afc639e 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -11,3 +11,4 @@ export const META_XML_SUFFIX = '-meta.xml'; export const XML_DECL = '\n'; export const XML_NS_URL = 'http://soap.sforce.com/2006/04/metadata'; export const XML_NS_KEY = '@_xmlns'; +export const XML_COMMENT_PROP_NAME = '#xml__comment'; diff --git a/src/convert/streams.ts b/src/convert/streams.ts index 6e5cf3b689..1f4703ec8c 100644 --- a/src/convert/streams.ts +++ b/src/convert/streams.ts @@ -15,7 +15,7 @@ import { XMLBuilder } from 'fast-xml-parser'; import { Logger } from '@salesforce/core'; import { SourceComponent } from '../resolve/sourceComponent'; import { SourcePath } from '../common/types'; -import { XML_DECL } from '../common/constants'; +import { XML_COMMENT_PROP_NAME, XML_DECL } from '../common/constants'; import { ComponentSet } from '../collections/componentSet'; import { RegistryAccess } from '../registry/registryAccess'; import { ensureFileExists } from '../utils/fileSystemHandler'; @@ -255,6 +255,7 @@ export class JsToXml extends Readable { indentBy: ' ', ignoreAttributes: false, cdataPropName: '__cdata', + commentPropName: XML_COMMENT_PROP_NAME, }); const builtXml = String(builder.build(this.xmlObject)); diff --git a/src/resolve/sourceComponent.ts b/src/resolve/sourceComponent.ts index b40afa0672..ce059aac78 100644 --- a/src/resolve/sourceComponent.ts +++ b/src/resolve/sourceComponent.ts @@ -9,6 +9,7 @@ import { Messages, SfError } from '@salesforce/core'; import { XMLParser, XMLValidator } from 'fast-xml-parser'; import { get, getString, JsonMap } from '@salesforce/ts-types'; import { ensureArray } from '@salesforce/kit'; +import { XML_COMMENT_PROP_NAME } from '../common/constants'; import { getXmlElement } from '../utils/decomposed'; import { baseName, baseWithoutSuffixes, parseMetadataXml, calculateRelativePath } from '../utils/path'; import { replacementIterations } from '../convert/replacements'; @@ -271,6 +272,7 @@ export class SourceComponent implements MetadataComponent { cdataPropName: '__cdata', ignoreDeclaration: true, numberParseOptions: { leadingZeros: false, hex: false }, + commentPropName: XML_COMMENT_PROP_NAME, }); const parsed = parser.parse(String(contents)) as T; const [firstElement] = Object.keys(parsed); diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objectTranslations/Contact-en_US.objectTranslation b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objectTranslations/Contact-en_US.objectTranslation new file mode 100644 index 0000000000..c32c0757ac --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objectTranslations/Contact-en_US.objectTranslation @@ -0,0 +1,24 @@ + + + + + + + + Example__c + + One + + + + + + Two + + + + + + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objects/Contact.object b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objects/Contact.object new file mode 100644 index 0000000000..38862da41d --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objects/Contact.object @@ -0,0 +1,499 @@ + + + + AddCampaign + Default + + + AddCampaign + Large + Default + + + AddCampaign + Small + Default + + + AddToCampaign + Default + + + AddToCampaign + Large + Default + + + AddToCampaign + Small + Default + + + CallHighlightAction + Default + + + CallHighlightAction + Large + Default + + + CallHighlightAction + Small + Default + + + CancelEdit + Default + + + CancelEdit + Large + Default + + + CancelEdit + Small + Default + + + Clone + Default + + + Clone + Large + Default + + + Clone + Small + Default + + + Delete + Default + + + Delete + Large + Default + + + Delete + Small + Default + + + Edit + Default + + + Edit + Large + Default + + + Edit + Small + Default + + + EmailHighlightAction + Default + + + EmailHighlightAction + Large + Default + + + EmailHighlightAction + Small + Default + + + EnableCustomerPortal + Default + + + EnableCustomerPortal + Large + Default + + + EnableCustomerPortal + Small + Default + + + EnablePartnerPortalUser + Default + + + EnablePartnerPortalUser + Large + Default + + + EnablePartnerPortalUser + Small + Default + + + EnableSelfService + Default + + + EnableSelfService + Large + Default + + + EnableSelfService + Small + Default + + + List + Default + + + List + Large + Default + + + List + Small + Default + + + ListClean + Default + + + ListClean + Large + Default + + + ListClean + Small + Default + + + Merge + Default + + + Merge + Large + Default + + + Merge + Small + Default + + + NewContact + Default + + + NewContact + Large + Default + + + NewContact + Small + Default + + + RequestUpdate + Default + + + RequestUpdate + Large + Default + + + RequestUpdate + Small + Default + + + SaveEdit + Default + + + SaveEdit + Large + Default + + + SaveEdit + Small + Default + + + SmsHighlightAction + Default + + + SmsHighlightAction + Large + Default + + + SmsHighlightAction + Small + Default + + + Tab + Default + + + Tab + Large + Default + + + Tab + Small + Default + + + View + Default + + + View + Large + Default + + + View + Small + Default + + + ViewCustomerPortal + Default + + + ViewCustomerPortal + Large + Default + + + ViewCustomerPortal + Small + Default + + + ViewPartnerPortalUser + Default + + + ViewPartnerPortalUser + Large + Default + + + ViewPartnerPortalUser + Small + Default + + + ViewSelfService + Default + + + ViewSelfService + Large + Default + + + ViewSelfService + Small + Default + + SYSTEM + true + false + ControlledByParent + + FULL_NAME + ACCOUNT.NAME + CONTACT.PHONE1 + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + CONTACT.PHONE1 + CONTACT.PHONE3 + CONTACT.PHONE4 + CONTACT.PHONE5 + CONTACT.PHONE6 + ACCOUNT.PHONE1 + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + CONTACT.PHONE1 + CONTACT.EMAIL + CORE.USERS.ALIAS + + ControlledByParent + + AccountId + true + Lookup + + + AssistantName + false + + + AssistantPhone + false + + + Birthdate + false + + + CleanStatus + false + + + Department + false + + + Description + false + + + DoNotCall + false + + + Email + false + + + Example__c + This is an example picklist field + false + Please choose an option + + false + false + Picklist + + + false + + One + false + + + + Two + false + + + + + + + Fax + false + + + GenderIdentity + false + Picklist + + + HasOptedOutOfEmail + false + + + HasOptedOutOfFax + false + + + HomePhone + false + + + IndividualId + false + Lookup + + + Jigsaw + false + + + LastCURequestDate + + + LastCUUpdateDate + + + LeadSource + false + Picklist + + + MailingAddress + false + + + MobilePhone + false + + + Name + true + + + OtherAddress + false + + + OtherPhone + false + + + OwnerId + true + Lookup + + + Phone + false + + + Pronouns + false + Picklist + + + ReportsToId + false + Lookup + + + Title + false + + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/package.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/package.xml new file mode 100644 index 0000000000..6c82bf2c78 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/package.xml @@ -0,0 +1,45 @@ + + + + Contact.AccountId + Contact.AssistantName + Contact.AssistantPhone + Contact.Birthdate + Contact.CleanStatus + Contact.Department + Contact.Description + Contact.DoNotCall + Contact.Email + Contact.Example__c + Contact.Fax + Contact.GenderIdentity + Contact.HasOptedOutOfEmail + Contact.HasOptedOutOfFax + Contact.HomePhone + Contact.IndividualId + Contact.Jigsaw + Contact.LastCURequestDate + Contact.LastCUUpdateDate + Contact.LeadSource + Contact.MailingAddress + Contact.MobilePhone + Contact.Name + Contact.OtherAddress + Contact.OtherPhone + Contact.OwnerId + Contact.Phone + Contact.Pronouns + Contact.ReportsToId + Contact.Title + CustomField + + + Contact + CustomObject + + + Contact-en_US + CustomObjectTranslation + + 60.0 + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Contact-en_US.objectTranslation-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Contact-en_US.objectTranslation-meta.xml new file mode 100644 index 0000000000..1163ad6825 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Contact-en_US.objectTranslation-meta.xml @@ -0,0 +1,2 @@ + + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Example__c.fieldTranslation-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Example__c.fieldTranslation-meta.xml new file mode 100644 index 0000000000..a4e92fd529 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Example__c.fieldTranslation-meta.xml @@ -0,0 +1,22 @@ + + + + + + + Example__c + + One + + + + + + Two + + + + + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/Contact.object-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/Contact.object-meta.xml new file mode 100644 index 0000000000..551593004a --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/Contact.object-meta.xml @@ -0,0 +1,353 @@ + + + + AddCampaign + Default + + + AddCampaign + Large + Default + + + AddCampaign + Small + Default + + + AddToCampaign + Default + + + AddToCampaign + Large + Default + + + AddToCampaign + Small + Default + + + CallHighlightAction + Default + + + CallHighlightAction + Large + Default + + + CallHighlightAction + Small + Default + + + CancelEdit + Default + + + CancelEdit + Large + Default + + + CancelEdit + Small + Default + + + Clone + Default + + + Clone + Large + Default + + + Clone + Small + Default + + + Delete + Default + + + Delete + Large + Default + + + Delete + Small + Default + + + Edit + Default + + + Edit + Large + Default + + + Edit + Small + Default + + + EmailHighlightAction + Default + + + EmailHighlightAction + Large + Default + + + EmailHighlightAction + Small + Default + + + EnableCustomerPortal + Default + + + EnableCustomerPortal + Large + Default + + + EnableCustomerPortal + Small + Default + + + EnablePartnerPortalUser + Default + + + EnablePartnerPortalUser + Large + Default + + + EnablePartnerPortalUser + Small + Default + + + EnableSelfService + Default + + + EnableSelfService + Large + Default + + + EnableSelfService + Small + Default + + + List + Default + + + List + Large + Default + + + List + Small + Default + + + ListClean + Default + + + ListClean + Large + Default + + + ListClean + Small + Default + + + Merge + Default + + + Merge + Large + Default + + + Merge + Small + Default + + + NewContact + Default + + + NewContact + Large + Default + + + NewContact + Small + Default + + + RequestUpdate + Default + + + RequestUpdate + Large + Default + + + RequestUpdate + Small + Default + + + SaveEdit + Default + + + SaveEdit + Large + Default + + + SaveEdit + Small + Default + + + SmsHighlightAction + Default + + + SmsHighlightAction + Large + Default + + + SmsHighlightAction + Small + Default + + + Tab + Default + + + Tab + Large + Default + + + Tab + Small + Default + + + View + Default + + + View + Large + Default + + + View + Small + Default + + + ViewCustomerPortal + Default + + + ViewCustomerPortal + Large + Default + + + ViewCustomerPortal + Small + Default + + + ViewPartnerPortalUser + Default + + + ViewPartnerPortalUser + Large + Default + + + ViewPartnerPortalUser + Small + Default + + + ViewSelfService + Default + + + ViewSelfService + Large + Default + + + ViewSelfService + Small + Default + + SYSTEM + true + false + ControlledByParent + + FULL_NAME + ACCOUNT.NAME + CONTACT.PHONE1 + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + CONTACT.PHONE1 + CONTACT.PHONE3 + CONTACT.PHONE4 + CONTACT.PHONE5 + CONTACT.PHONE6 + ACCOUNT.PHONE1 + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + CONTACT.PHONE1 + CONTACT.EMAIL + CORE.USERS.ALIAS + + ControlledByParent + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AccountId.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AccountId.field-meta.xml new file mode 100644 index 0000000000..30ad0b581a --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AccountId.field-meta.xml @@ -0,0 +1,6 @@ + + + AccountId + true + Lookup + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AssistantName.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AssistantName.field-meta.xml new file mode 100644 index 0000000000..480cebbd5f --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AssistantName.field-meta.xml @@ -0,0 +1,5 @@ + + + AssistantName + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AssistantPhone.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AssistantPhone.field-meta.xml new file mode 100644 index 0000000000..bd5f07dc3e --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/AssistantPhone.field-meta.xml @@ -0,0 +1,5 @@ + + + AssistantPhone + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Birthdate.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Birthdate.field-meta.xml new file mode 100644 index 0000000000..693bc78e14 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Birthdate.field-meta.xml @@ -0,0 +1,5 @@ + + + Birthdate + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/CleanStatus.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/CleanStatus.field-meta.xml new file mode 100644 index 0000000000..41ca5c55bd --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/CleanStatus.field-meta.xml @@ -0,0 +1,5 @@ + + + CleanStatus + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Department.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Department.field-meta.xml new file mode 100644 index 0000000000..b49a475b08 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Department.field-meta.xml @@ -0,0 +1,5 @@ + + + Department + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Description.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Description.field-meta.xml new file mode 100644 index 0000000000..ce7f9cab05 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Description.field-meta.xml @@ -0,0 +1,5 @@ + + + Description + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/DoNotCall.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/DoNotCall.field-meta.xml new file mode 100644 index 0000000000..1a3b35a108 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/DoNotCall.field-meta.xml @@ -0,0 +1,5 @@ + + + DoNotCall + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Email.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Email.field-meta.xml new file mode 100644 index 0000000000..c4cc433459 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Email.field-meta.xml @@ -0,0 +1,5 @@ + + + Email + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Example__c.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Example__c.field-meta.xml new file mode 100644 index 0000000000..43c3fde31c --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Example__c.field-meta.xml @@ -0,0 +1,26 @@ + + + Example__c + This is an example picklist field + false + Please choose an option + + false + false + Picklist + + + false + + One + false + + + + Two + false + + + + + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Fax.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Fax.field-meta.xml new file mode 100644 index 0000000000..f3894e998e --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Fax.field-meta.xml @@ -0,0 +1,5 @@ + + + Fax + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/GenderIdentity.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/GenderIdentity.field-meta.xml new file mode 100644 index 0000000000..e35011eb39 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/GenderIdentity.field-meta.xml @@ -0,0 +1,6 @@ + + + GenderIdentity + false + Picklist + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HasOptedOutOfEmail.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HasOptedOutOfEmail.field-meta.xml new file mode 100644 index 0000000000..9e970341c2 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HasOptedOutOfEmail.field-meta.xml @@ -0,0 +1,5 @@ + + + HasOptedOutOfEmail + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HasOptedOutOfFax.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HasOptedOutOfFax.field-meta.xml new file mode 100644 index 0000000000..a3fa8fe5dd --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HasOptedOutOfFax.field-meta.xml @@ -0,0 +1,5 @@ + + + HasOptedOutOfFax + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HomePhone.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HomePhone.field-meta.xml new file mode 100644 index 0000000000..05bec5b71f --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/HomePhone.field-meta.xml @@ -0,0 +1,5 @@ + + + HomePhone + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/IndividualId.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/IndividualId.field-meta.xml new file mode 100644 index 0000000000..c7d685b8e4 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/IndividualId.field-meta.xml @@ -0,0 +1,6 @@ + + + IndividualId + false + Lookup + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Jigsaw.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Jigsaw.field-meta.xml new file mode 100644 index 0000000000..4732860979 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Jigsaw.field-meta.xml @@ -0,0 +1,5 @@ + + + Jigsaw + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LastCURequestDate.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LastCURequestDate.field-meta.xml new file mode 100644 index 0000000000..cc57180e30 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LastCURequestDate.field-meta.xml @@ -0,0 +1,4 @@ + + + LastCURequestDate + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LastCUUpdateDate.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LastCUUpdateDate.field-meta.xml new file mode 100644 index 0000000000..fe119f33dc --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LastCUUpdateDate.field-meta.xml @@ -0,0 +1,4 @@ + + + LastCUUpdateDate + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LeadSource.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LeadSource.field-meta.xml new file mode 100644 index 0000000000..56a54c8da0 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/LeadSource.field-meta.xml @@ -0,0 +1,6 @@ + + + LeadSource + false + Picklist + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/MailingAddress.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/MailingAddress.field-meta.xml new file mode 100644 index 0000000000..0e8f4b7805 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/MailingAddress.field-meta.xml @@ -0,0 +1,5 @@ + + + MailingAddress + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/MobilePhone.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/MobilePhone.field-meta.xml new file mode 100644 index 0000000000..d7fac71713 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/MobilePhone.field-meta.xml @@ -0,0 +1,5 @@ + + + MobilePhone + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Name.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Name.field-meta.xml new file mode 100644 index 0000000000..6d55d1636a --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Name.field-meta.xml @@ -0,0 +1,5 @@ + + + Name + true + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OtherAddress.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OtherAddress.field-meta.xml new file mode 100644 index 0000000000..84a58bd589 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OtherAddress.field-meta.xml @@ -0,0 +1,5 @@ + + + OtherAddress + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OtherPhone.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OtherPhone.field-meta.xml new file mode 100644 index 0000000000..ad55322eae --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OtherPhone.field-meta.xml @@ -0,0 +1,5 @@ + + + OtherPhone + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OwnerId.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OwnerId.field-meta.xml new file mode 100644 index 0000000000..6d49c53cf6 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/OwnerId.field-meta.xml @@ -0,0 +1,6 @@ + + + OwnerId + true + Lookup + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Phone.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Phone.field-meta.xml new file mode 100644 index 0000000000..8537db4a98 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Phone.field-meta.xml @@ -0,0 +1,5 @@ + + + Phone + false + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Pronouns.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Pronouns.field-meta.xml new file mode 100644 index 0000000000..47b7449b87 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Pronouns.field-meta.xml @@ -0,0 +1,6 @@ + + + Pronouns + false + Picklist + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/ReportsToId.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/ReportsToId.field-meta.xml new file mode 100644 index 0000000000..14a28c83f5 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/ReportsToId.field-meta.xml @@ -0,0 +1,6 @@ + + + ReportsToId + false + Lookup + diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Title.field-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Title.field-meta.xml new file mode 100644 index 0000000000..25b5e6cbc2 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objects/Contact/fields/Title.field-meta.xml @@ -0,0 +1,5 @@ + + + Title + false + diff --git a/test/snapshot/sampleProjects/xmlComments/originalMdapi/objectTranslations/Contact-en_US.objectTranslation b/test/snapshot/sampleProjects/xmlComments/originalMdapi/objectTranslations/Contact-en_US.objectTranslation new file mode 100644 index 0000000000..aea360b1f4 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/originalMdapi/objectTranslations/Contact-en_US.objectTranslation @@ -0,0 +1,16 @@ + + + + + + Example__c + + One + + + + Two + + + + diff --git a/test/snapshot/sampleProjects/xmlComments/originalMdapi/objects/Contact.object b/test/snapshot/sampleProjects/xmlComments/originalMdapi/objects/Contact.object new file mode 100644 index 0000000000..21261683d7 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/originalMdapi/objects/Contact.object @@ -0,0 +1,499 @@ + + + + AddCampaign + Default + + + AddCampaign + Large + Default + + + AddCampaign + Small + Default + + + AddToCampaign + Default + + + AddToCampaign + Large + Default + + + AddToCampaign + Small + Default + + + CallHighlightAction + Default + + + CallHighlightAction + Large + Default + + + CallHighlightAction + Small + Default + + + CancelEdit + Default + + + CancelEdit + Large + Default + + + CancelEdit + Small + Default + + + Clone + Default + + + Clone + Large + Default + + + Clone + Small + Default + + + Delete + Default + + + Delete + Large + Default + + + Delete + Small + Default + + + Edit + Default + + + Edit + Large + Default + + + Edit + Small + Default + + + EmailHighlightAction + Default + + + EmailHighlightAction + Large + Default + + + EmailHighlightAction + Small + Default + + + EnableCustomerPortal + Default + + + EnableCustomerPortal + Large + Default + + + EnableCustomerPortal + Small + Default + + + EnablePartnerPortalUser + Default + + + EnablePartnerPortalUser + Large + Default + + + EnablePartnerPortalUser + Small + Default + + + EnableSelfService + Default + + + EnableSelfService + Large + Default + + + EnableSelfService + Small + Default + + + List + Default + + + List + Large + Default + + + List + Small + Default + + + ListClean + Default + + + ListClean + Large + Default + + + ListClean + Small + Default + + + Merge + Default + + + Merge + Large + Default + + + Merge + Small + Default + + + NewContact + Default + + + NewContact + Large + Default + + + NewContact + Small + Default + + + RequestUpdate + Default + + + RequestUpdate + Large + Default + + + RequestUpdate + Small + Default + + + SaveEdit + Default + + + SaveEdit + Large + Default + + + SaveEdit + Small + Default + + + SmsHighlightAction + Default + + + SmsHighlightAction + Large + Default + + + SmsHighlightAction + Small + Default + + + Tab + Default + + + Tab + Large + Default + + + Tab + Small + Default + + + View + Default + + + View + Large + Default + + + View + Small + Default + + + ViewCustomerPortal + Default + + + ViewCustomerPortal + Large + Default + + + ViewCustomerPortal + Small + Default + + + ViewPartnerPortalUser + Default + + + ViewPartnerPortalUser + Large + Default + + + ViewPartnerPortalUser + Small + Default + + + ViewSelfService + Default + + + ViewSelfService + Large + Default + + + ViewSelfService + Small + Default + + SYSTEM + true + false + ControlledByParent + + AccountId + true + Lookup + + + AssistantName + false + + + AssistantPhone + false + + + Birthdate + false + + + CleanStatus + false + + + Department + false + + + Description + false + + + DoNotCall + false + + + Email + false + + + Example__c + This is an example picklist field + false + Please choose an option + + false + false + Picklist + + + false + + One + false + + + + Two + false + + + + + + + Fax + false + + + GenderIdentity + false + Picklist + + + HasOptedOutOfEmail + false + + + HasOptedOutOfFax + false + + + HomePhone + false + + + IndividualId + false + Lookup + + + Jigsaw + false + + + LastCURequestDate + + + LastCUUpdateDate + + + LeadSource + false + Picklist + + + MailingAddress + false + + + MobilePhone + false + + + Name + true + + + OtherAddress + false + + + OtherPhone + false + + + OwnerId + true + Lookup + + + Phone + false + + + Pronouns + false + Picklist + + + ReportsToId + false + Lookup + + + Title + false + + + FULL_NAME + ACCOUNT.NAME + CONTACT.PHONE1 + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + CONTACT.PHONE1 + CONTACT.PHONE3 + CONTACT.PHONE4 + CONTACT.PHONE5 + CONTACT.PHONE6 + ACCOUNT.PHONE1 + FULL_NAME + ACCOUNT.NAME + ACCOUNT.SITE + CONTACT.PHONE1 + CONTACT.EMAIL + CORE.USERS.ALIAS + + ControlledByParent + diff --git a/test/snapshot/sampleProjects/xmlComments/originalMdapi/package.xml b/test/snapshot/sampleProjects/xmlComments/originalMdapi/package.xml new file mode 100644 index 0000000000..3285ee8583 --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/originalMdapi/package.xml @@ -0,0 +1,12 @@ + + + + Contact + CustomObject + + + Contact-en_US + CustomObjectTranslation + + 60.0 + diff --git a/test/snapshot/sampleProjects/xmlComments/sfdx-project.json b/test/snapshot/sampleProjects/xmlComments/sfdx-project.json new file mode 100644 index 0000000000..fc5278b51d --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/sfdx-project.json @@ -0,0 +1,9 @@ +{ + "packageDirectories": [ + { + "default": true, + "path": "force-app" + } + ], + "sourceApiVersion": "59.0" +} diff --git a/test/snapshot/sampleProjects/xmlComments/snapshots.test.ts b/test/snapshot/sampleProjects/xmlComments/snapshots.test.ts new file mode 100644 index 0000000000..cfcc0bd65e --- /dev/null +++ b/test/snapshot/sampleProjects/xmlComments/snapshots.test.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import { + FORCE_APP, + MDAPI_OUT, + dirsAreIdentical, + fileSnap, + mdapiToSource, + sourceToMdapi, +} from '../../helper/conversions'; + +// we don't want failing tests outputting over each other +/* eslint-disable no-await-in-loop */ + +// decomposition was removing xml comments see https://github.com/forcedotcom/cli/issues/2830 + +describe('converting mdapi => source preserves xml comments', () => { + const testDir = path.join('test', 'snapshot', 'sampleProjects', 'xmlComments'); + let sourceFiles: string[]; + let mdFiles: string[]; + + before(async () => { + await fs.promises.mkdir(path.join(testDir, FORCE_APP), { recursive: true }); + sourceFiles = await mdapiToSource(testDir); + mdFiles = await sourceToMdapi(testDir); + }); + + it('verify source files', async () => { + for (const file of sourceFiles) { + await fileSnap(file, testDir); + } + dirsAreIdentical( + path.join(testDir, FORCE_APP), + path.join(testDir, '__snapshots__', 'verify-source-files.expected', FORCE_APP) + ); + }); + it('verify md files', async () => { + for (const file of mdFiles) { + await fileSnap(file, testDir); + } + }); + + after(async () => { + await Promise.all([ + fs.promises.rm(path.join(testDir, FORCE_APP), { recursive: true, force: true }), + fs.promises.rm(path.join(testDir, MDAPI_OUT), { recursive: true, force: true }), + ]); + }); +});