Skip to content
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

fix: calculate if parent exists, return path to be calculated #1431

Merged
merged 2 commits into from
Oct 4, 2024
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: 2 additions & 2 deletions src/convert/transformers/decomposedMetadataTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ export const getWriteInfosWithoutMerge =
(defaultDirectory: string | undefined) =>
(parentXmlObject: XmlObj) =>
(component: SourceComponent): WriteInfo[] => {
const output = join(defaultDirectory ?? '', getOutputFile(component));
const output = getOutputFile(component);
// if the parent would be empty
// and it exists
// and every child is addressable
// don't overwrite the existing parent
if (
!objectHasSomeRealValues(component.type)(parentXmlObject) &&
fs.existsSync(output) &&
fs.existsSync(join(defaultDirectory ?? '', output)) &&
Object.values(component.type.children ?? {}).every((child) => !child.isAddressable)
) {
return [];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<Layout xmlns="http://soap.sforce.com/2006/04/metadata">
<layoutSections>
<customLabel>false</customLabel>
<detailHeading>false</detailHeading>
<editHeading>true</editHeading>
<label>Information</label>
<layoutColumns>
<layoutItems>
<behavior>Required</behavior>
<field>Name</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>completion__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>status__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
<behavior>Edit</behavior>
<field>OwnerId</field>
</layoutItems>
</layoutColumns>
<style>TwoColumnsTopToBottom</style>
</layoutSections>
<layoutSections>
<customLabel>false</customLabel>
<detailHeading>false</detailHeading>
<editHeading>true</editHeading>
<label>System Information</label>
<layoutColumns>
<layoutItems>
<behavior>Readonly</behavior>
<field>CreatedById</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
<behavior>Readonly</behavior>
<field>LastModifiedById</field>
</layoutItems>
</layoutColumns>
<style>TwoColumnsTopToBottom</style>
</layoutSections>
<layoutSections>
<customLabel>false</customLabel>
<detailHeading>false</detailHeading>
<editHeading>true</editHeading>
<layoutColumns/>
<layoutColumns/>
<layoutColumns/>
<style>CustomLinks</style>
</layoutSections>
<showEmailCheckbox>false</showEmailCheckbox>
<showHighlightsPanel>false</showHighlightsPanel>
<showInteractionLogPanel>false</showInteractionLogPanel>
<showRunAssignmentRulesCheckbox>false</showRunAssignmentRulesCheckbox>
<showSubmitAndAttachButton>false</showSubmitAndAttachButton>
</Layout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>completion__c</fullName>
<defaultValue>false</defaultValue>
<label>completion</label>
<trackTrending>false</trackTrending>
<type>Checkbox</type>
</CustomField>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>status__c</fullName>
<label>status</label>
<required>false</required>
<trackTrending>false</trackTrending>
<type>Picklist</type>
<valueSet>
<restricted>true</restricted>
<valueSetDefinition>
<sorted>false</sorted>
<value>
<fullName>done</fullName>
<default>false</default>
<label>done</label>
</value>
<value>
<fullName>in progress</fullName>
<default>false</default>
<label>in progress</label>
</value>
<value>
<fullName>broken</fullName>
<default>false</default>
<label>broken</label>
</value>
</valueSetDefinition>
</valueSet>
</CustomField>
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<actionOverrides>
<actionName>Accept</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Accept</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Accept</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>CancelEdit</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>CancelEdit</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>CancelEdit</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Clone</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Clone</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Clone</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Delete</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Delete</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Delete</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Edit</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Edit</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Edit</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>List</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>List</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>List</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>New</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>New</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>New</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>SaveEdit</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>SaveEdit</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>SaveEdit</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Tab</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Tab</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>Tab</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>View</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>View</actionName>
<formFactor>Large</formFactor>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>View</actionName>
<formFactor>Small</formFactor>
<type>Default</type>
</actionOverrides>
<allowInChatterGroups>false</allowInChatterGroups>
<compactLayoutAssignment>SYSTEM</compactLayoutAssignment>
<deploymentStatus>Deployed</deploymentStatus>
<enableActivities>false</enableActivities>
<enableBulkApi>true</enableBulkApi>
<enableFeeds>false</enableFeeds>
<enableHistory>false</enableHistory>
<enableLicensing>false</enableLicensing>
<enableReports>false</enableReports>
<enableSearch>false</enableSearch>
<enableSharing>true</enableSharing>
<enableStreamingApi>true</enableStreamingApi>
<externalSharingModel>Private</externalSharingModel>
<label>test</label>
<nameField>
<label>test Name</label>
<type>Text</type>
</nameField>
<pluralLabel>tests</pluralLabel>
<searchLayouts></searchLayouts>
<sharingModel>ReadWrite</sharingModel>
<visibility>Public</visibility>
</CustomObject>
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,107 @@ describe('a single field in a CustomObject xml does not overwrite (blank) the ex
expect(fs.readdirSync(path.join(pathToBroker, 'fields')).length).to.equal(3);
});

it('will not overwrite .object-meta.xml in package retrieval ', async () => {
const TEST_PACKAGE = 'TestPackage';

const result: MetadataApiRetrieveStatus = {
done: true,
fileProperties: [
{
createdById: '005bm000006BUfFAAW',
createdByName: 'William Ruemmele',
createdDate: '2024-09-30T18:10:44.000Z',
fileName: 'TestPackage/objects/test__c.object',
fullName: 'test__c',
id: '01Ibm000001ZQS5EAO',
lastModifiedById: '005bm000006BUfFAAW',
lastModifiedByName: 'William Ruemmele',
lastModifiedDate: '2024-09-30T18:10:44.000Z',
manageableState: ManageableState.Unmanaged,
type: 'CustomObject',
},
{
createdById: '005bm000006BUfFAAW',
createdByName: 'William Ruemmele',
createdDate: '2024-09-30T18:10:44.000Z',
fileName: 'TestPackage/layouts/test__c-test Layout.layout',
fullName: 'test__c-test Layout',
id: '00hbm000006bcEHAAY',
lastModifiedById: '005bm000006BUfFAAW',
lastModifiedByName: 'William Ruemmele',
lastModifiedDate: '2024-09-30T18:11:30.000Z',
manageableState: ManageableState.Unmanaged,
type: 'Layout',
},
{
createdById: '005bm000006BUfFAAW',
createdByName: 'William Ruemmele',
createdDate: '2024-09-30T18:12:05.000Z',
fileName: 'TestPackage/package.xml',
fullName: 'package',
id: '0A2bm000000eGN7CAM',
lastModifiedById: '005bm000006BUfFAAW',
lastModifiedByName: 'William Ruemmele',
lastModifiedDate: '2024-09-30T18:12:05.000Z',
manageableState: ManageableState.Unmanaged,
type: 'Package',
},
{
createdById: '005bm000006BUfFAAW',
createdByName: 'William Ruemmele',
createdDate: '2024-09-30T19:59:19.089Z',
fileName: 'unpackaged/package.xml',
fullName: 'unpackaged/package.xml',
id: '',
lastModifiedById: '005bm000006BUfFAAW',
lastModifiedByName: 'William Ruemmele',
lastModifiedDate: '2024-09-30T19:59:19.089Z',
manageableState: ManageableState.Unmanaged,
type: 'Package',
},
],
id: '09Sbm000001mg2nEAA',
status: RequestStatus.Succeeded,
success: true,
zipFile:
'UEsDBBQACAgIAGmfPlkAAAAAAAAAAAAAAAAiAAAAVGVzdFBhY2thZ2Uvb2JqZWN0cy90ZXN0X19jLm9iamVjdM1ZXW/aMBR951cg3tewaZqmKU3FaNkm0Q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lyb/XFcKsHPKVeZp2m8ZzHWK9d5noNTKgwMFZhiy9QSwcIlFMgeN4AAAAHAgAAUEsDBBQACAgIAGmfPlkAAAAAAAAAAAAAAAAWAAAAdW5wYWNrYWdlZC9wYWNrYWdlLnhtbLOxr8jNUShLLSrOzM+zVTLUM1BSSM1Lzk/JzEu3VQoNcdO1ULK347IJSEzOTkxPVQCqziu2VcooKSmw0tcvzk8s0CtOyy9KTtVLzs/VNzIwMNM3MNHPTS1JTEksSVSy41IAAhuo+XZmQPNt9GE8Lht9qLF2XABQSwcIP5GioHYAAACIAAAAUEsBAhQAFAAICAgAaZ8+WZ5Ue4I+AwAAtxgAACIAAAAAAAAAAAAAAAAAAAAAAFRlc3RQYWNrYWdlL29iamVjdHMvdGVzdF9fYy5vYmplY3RQSwECFAAUAAgICABpnz5ZNdylCcgBAACvCAAALgAAAAAAAAAAAAAAAACOAwAAVGVzdFBhY2thZ2UvbGF5b3V0cy90ZXN0X19jLXRlc3QgTGF5b3V0LmxheW91dFBLAQIUABQACAgIAGmfPlmUUyB43gAAAAcCAAAXAAAAAAAAAAAAAAAAALIFAABUZXN0UGFja2FnZS9wYWNrYWdlLnhtbFBLAQIUABQACAgIAGmfPlk/kaKgdgAAAIgAAAAWAAAAAAAAAAAAAAAAANUGAAB1bnBhY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAAEAAQANQEAAI8HAAAAAA==',
messages: [],
};

const retrieve = new MetadataApiRetrieve({
singlePackage: true,
packageOptions: [{ name: TEST_PACKAGE, outputDir: path.join(testDir, TEST_PACKAGE) }],
merge: true,
output: path.join(testDir, TEST_PACKAGE),
usernameOrConnection: 'abc',
});
await retrieve.post(result);
expect(
fs.existsSync(
path.join(testDir, TEST_PACKAGE, 'main', 'default', 'objects', 'test__c', 'test__c.object-meta.xml')
)
).to.be.true;
expect(
fs.existsSync(
path.join(testDir, TEST_PACKAGE, 'main', 'default', 'objects', 'test__c', 'fields', 'status__c.field-meta.xml')
)
).to.be.true;
expect(
fs.existsSync(
path.join(
testDir,
TEST_PACKAGE,
'main',
'default',
'objects',
'test__c',
'fields',
'completion__c.field-meta.xml'
)
)
).to.be.true;
});

it(`verify ${FORCE_APP}`, async () => {
await validateSourceDir(FORCE_APP);
});
Expand Down
Loading