diff --git a/src/convert/transformers/decomposedMetadataTransformer.ts b/src/convert/transformers/decomposedMetadataTransformer.ts index 67b4bcc0e8..f0774b72f9 100644 --- a/src/convert/transformers/decomposedMetadataTransformer.ts +++ b/src/convert/transformers/decomposedMetadataTransformer.ts @@ -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 []; diff --git a/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/layouts/test__c-test Layout.layout-meta.xml b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/layouts/test__c-test Layout.layout-meta.xml new file mode 100644 index 0000000000..cfc52f06f4 --- /dev/null +++ b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/layouts/test__c-test Layout.layout-meta.xml @@ -0,0 +1,63 @@ + + + + false + false + true + + + + Required + Name + + + Edit + completion__c + + + Edit + status__c + + + + + Edit + OwnerId + + + + + + false + false + true + + + + Readonly + CreatedById + + + + + Readonly + LastModifiedById + + + + + + false + false + true + + + + + + false + false + false + false + false + diff --git a/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/fields/completion__c.field-meta.xml b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/fields/completion__c.field-meta.xml new file mode 100644 index 0000000000..f4c5dea603 --- /dev/null +++ b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/fields/completion__c.field-meta.xml @@ -0,0 +1,8 @@ + + + completion__c + false + + false + Checkbox + diff --git a/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/fields/status__c.field-meta.xml b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/fields/status__c.field-meta.xml new file mode 100644 index 0000000000..7ae99bd0e7 --- /dev/null +++ b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/fields/status__c.field-meta.xml @@ -0,0 +1,29 @@ + + + status__c + + false + false + Picklist + + true + + false + + done + false + + + + in progress + false + + + + broken + false + + + + + diff --git a/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/test__c.object-meta.xml b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/test__c.object-meta.xml new file mode 100644 index 0000000000..6d7cb19c02 --- /dev/null +++ b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/__snapshots__/will-not-overwrite-object-meta-xml-in-package-retrieval.expected/TestPackage/main/default/objects/test__c/test__c.object-meta.xml @@ -0,0 +1,165 @@ + + + + Accept + Default + + + Accept + Large + Default + + + Accept + 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 + + + List + Default + + + List + Large + Default + + + List + Small + Default + + + New + Default + + + New + Large + Default + + + New + Small + Default + + + SaveEdit + Default + + + SaveEdit + Large + Default + + + SaveEdit + Small + Default + + + Tab + Default + + + Tab + Large + Default + + + Tab + Small + Default + + + View + Default + + + View + Large + Default + + + View + Small + Default + + false + SYSTEM + Deployed + false + true + false + false + false + false + false + true + true + Private + + + + Text + + tests + + ReadWrite + Public + diff --git a/test/snapshot/sampleProjects/singleCustomFieldRetrieve/snapshots.test.ts b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/snapshots.test.ts index d62f38800d..9a8319c35d 100644 --- a/test/snapshot/sampleProjects/singleCustomFieldRetrieve/snapshots.test.ts +++ b/test/snapshot/sampleProjects/singleCustomFieldRetrieve/snapshots.test.ts @@ -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/aMBR951cg3tewaZqmKU3FaNkm0Q8V1mlPleNcwMOxM9uh5d/PiQmx+Wqqtaa85fj43nN9rm9DCc8eU9pegJCEs9PO+5Nupw0M84Sw6Wnn53jw7nPnLGqF/Vwqnl7HfwCrtt7C5GlnplT2JQgkR9mJnHCB4QTzNPjQ7X4Kuh+DFBRKkEKdqNXWnxBhpXNc61yCJCANaq1coRSiHsaQqTCwoJqnlhlE5zBBOdWU8smEDnbGfoGMuqp0oFe4iIZITCEMLOSNCBuliFKfwvqIYaAXCfHq05NZj+nVc8T594tyBl6tOpDwqC410+XdoHOgoLw6dDDjMS1qKsy7R77H3RsddG90xA2J9OrOgXzHdKeZLO/uXMGDT3P2pzumN41UebdmhBbge7Q9kfOYJjWX5t2pMYp9mr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3RQYWNrYWdlL29iamVjdHMvdGVzdF9fYy5vYmplY3RQSwECFAAUAAgICABpnz5ZNdylCcgBAACvCAAALgAAAAAAAAAAAAAAAACOAwAAVGVzdFBhY2thZ2UvbGF5b3V0cy90ZXN0X19jLXRlc3QgTGF5b3V0LmxheW91dFBLAQIUABQACAgIAGmfPlmUUyB43gAAAAcCAAAXAAAAAAAAAAAAAAAAALIFAABUZXN0UGFja2FnZS9wYWNrYWdlLnhtbFBLAQIUABQACAgIAGmfPlk/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); });