Skip to content

Commit

Permalink
chore: now CFTs retrieve into parent COT pkg dir
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Oct 30, 2023
1 parent 5a0d1c4 commit 0239392
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 36 deletions.
26 changes: 17 additions & 9 deletions src/convert/transformers/decomposedMetadataTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
Expand All @@ -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),
},
});
}
}
}
}
Expand Down
27 changes: 0 additions & 27 deletions src/resolve/adapters/decomposedSourceAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0239392

Please sign in to comment.