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: ignored, decomposed parent #1053

Merged
merged 1 commit into from
Jul 24, 2023
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
17 changes: 13 additions & 4 deletions src/convert/transformers/decomposedMetadataTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,20 @@ export class DecomposedMetadataTransformer extends BaseMetadataTransformer {
return [];
}

// eslint-disable-next-line complexity
public async toSourceFormat(component: SourceComponent, mergeWith?: SourceComponent): Promise<WriteInfo[]> {
const outputFile = mergeWith?.xml ?? getDefaultOutput(component);
const forceIgnore = component.getForceIgnore();

// if the whole parent is ignored, we won't worry about decomposing things
// this can happen if the manifest had a *; all the members will be retrieved.
if (forceIgnore.denies(outputFile)) {
return [];
}

const writeInfos: WriteInfo[] = [];
const childrenOfMergeComponent = new ComponentSet(mergeWith?.getChildren());
const { type, fullName: parentFullName } = component;
const forceIgnore = component.getForceIgnore();

let parentXmlObject: JsonMap | undefined;
const composedMetadata = await getComposedMetadataEntries(component);
Expand Down Expand Up @@ -147,20 +156,20 @@ export class DecomposedMetadataTransformer extends BaseMetadataTransformer {
if (!mergeWith) {
writeInfos.push({
source: parentSource,
output: getDefaultOutput(component),
output: outputFile,
});
} else if (mergeWith.xml) {
writeInfos.push({
source: parentSource,
output: mergeWith.xml,
output: outputFile,
});
this.setDecomposedState(component, { foundMerge: true });
} else {
this.setDecomposedState(component, {
foundMerge: false,
writeInfo: {
source: parentSource,
output: getDefaultOutput(component),
output: outputFile,
},
});
}
Expand Down
25 changes: 25 additions & 0 deletions test/convert/transformers/decomposedMetadataTransformer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,31 @@ describe('DecomposedMetadataTransformer', () => {
expect(result).to.deep.equal([]);
});

it('should return no files when the parent is forceIgnored', async () => {
const { fullName } = component;
const context = new ConvertContext();
const transformer = new DecomposedMetadataTransformer(registryAccess, context);

$$.SANDBOX.stub(component, 'parseXml').resolves({
CustomObject: {
fullName,
customField: [{ fullName: 'child', test: 'testVal' }],
validationRules: [
{ fullName: 'child2', test: 'testVal2' },
{ fullName: 'child3', test: 'testVal3' },
],
},
});
$$.SANDBOX.stub(ForceIgnore.prototype, 'denies')
.returns(false)
.withArgs(join('main', 'default', 'objects', 'customObject__c', 'customObject__c.object-meta.xml'))
.returns(true);

const result = await transformer.toSourceFormat(component);

expect(result).to.deep.equal([]);
});

describe('Merging Components', () => {
it('should merge output with merge component that only has children', async () => {
assert(registry.types.customobject.children?.types.customfield.name);
Expand Down