diff --git a/src/convert/transformers/decomposedMetadataTransformer.ts b/src/convert/transformers/decomposedMetadataTransformer.ts index bcbf83dbc3..a5b8397c92 100644 --- a/src/convert/transformers/decomposedMetadataTransformer.ts +++ b/src/convert/transformers/decomposedMetadataTransformer.ts @@ -5,6 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import { join } from 'path'; +import * as path from 'path'; import { JsonMap } from '@salesforce/ts-types'; import { ensureArray } from '@salesforce/kit'; import { Messages } from '@salesforce/core'; @@ -108,7 +109,7 @@ export class DecomposedMetadataTransformer extends BaseMetadataTransformer { } // if there's nothing to merge with, push write operation now to default location - if (!mergeWith) { + if (!mergeWith && !childType.unaddressableWithoutParent) { writeInfos.push({ source, output: getDefaultOutput(childComponent), @@ -127,16 +128,23 @@ export class DecomposedMetadataTransformer extends BaseMetadataTransformer { }); this.setDecomposedState(childComponent, { foundMerge: true }); } - // if no child component is found to merge with yet, mark it as so in - // the state + // if no child component is found to merge with yet, mark it as so in the state else if (!this.getDecomposedState(childComponent)?.foundMerge) { - this.setDecomposedState(childComponent, { - foundMerge: false, - writeInfo: { + // if the child can't exist without the parent, redirect the output to the parents output, rather than the default output + if (mergeWith?.content && childComponent.type.unaddressableWithoutParent && childComponent.type.suffix) { + writeInfos.push({ source, - output: getDefaultOutput(childComponent), - }, - }); + output: path.join(mergeWith.content, entryName + '.' + childComponent.type.suffix + '-meta.xml'), + }); + } else { + this.setDecomposedState(childComponent, { + foundMerge: false, + writeInfo: { + source, + output: getDefaultOutput(childComponent), + }, + }); + } } } } diff --git a/src/resolve/adapters/decomposedSourceAdapter.ts b/src/resolve/adapters/decomposedSourceAdapter.ts index 4d2fe2367a..f9d3669ed2 100644 --- a/src/resolve/adapters/decomposedSourceAdapter.ts +++ b/src/resolve/adapters/decomposedSourceAdapter.ts @@ -114,33 +114,6 @@ export class DecomposedSourceAdapter extends MixedContentSourceAdapter { this.forceIgnore ); } - } else if ( - triggerIsAChild && - this.type.children && - !component && - this.type.children.types[childTypeId].unaddressableWithoutParent - ) { - /* - if we're parsing an unaddressableWithoutParent type, and there's no component for it, then it's likely that the parent resides outside the current package we're building - e.g. a COT in a managed package, with the COFT in a different package, so we'll address the child as a parent so that the two will be built together - - this will result in a incorrect type being displayed - - STATE FULL NAME TYPE PROJECT PATH - ─────── ────────────────── ─────────────────────── ───────────────────────────────────────────────────────────────────────────────────────── - Changed customObject__c-es CustomObjectTranslation ...default/objectTranslations/customObject__c-es/customField__c.fieldTranslation-meta.xml - - notice how it says CustomObjectTranslation even though the suffix is a .fieldTranslation - */ - return new SourceComponent( - { - name: baseName(pathToContent), - type: this.type, - content: pathToContent, - }, - this.tree, - this.forceIgnore - ); } else if (!component) { // This is most likely metadata found within a CustomObject folder that is not a // child type of CustomObject. E.g., Layout, SharingRules, ApexClass.