-
Notifications
You must be signed in to change notification settings - Fork 125
feat: support decomposed components across multiple directories #224
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
Conversation
src/convert/convertTransaction.ts
Outdated
private async recompose(children: SourceComponent[], baseXmlObj: any): Promise<JsonMap> { | ||
for (const child of children) { | ||
const { directoryName: groupNode } = child.type; | ||
const { name: parentName } = child.parent.type; | ||
const childContents = (await child.parseXml())[child.type.name]; | ||
if (!baseXmlObj[parentName]) { | ||
baseXmlObj[parentName] = { '@_xmlns': XML_NS_URL }; | ||
} | ||
|
||
if (!baseXmlObj[parentName][groupNode]) { | ||
baseXmlObj[parentName][groupNode] = []; | ||
} | ||
(baseXmlObj[parentName][groupNode] as JsonArray).push(childContents); | ||
} | ||
return baseXmlObj; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this logic from the source adapter to the finalizer since its only used here now
|
||
return [DecomposedMetadataTransformer.createParentWriteInfo(component, recomposedXmlObj)]; | ||
// noop since the finalizer will push the writes to the component writer | ||
return []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toMetadataFormat
now only ever contributes to the convert transaction and doesn't directly create write infos anymore.
type: this.type, | ||
}, | ||
this.tree, | ||
this.forceIgnore | ||
); | ||
} | ||
parent.content = pathToContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now assign the CustomObject bundle path to the content property, like how bundle types work. This is so that even if there isn't a CustomObject xml, we can walk the folder to see all the children present.
src/collections/types.ts
Outdated
registry?: RegistryAccess; | ||
} | ||
|
||
export interface FromSourceOptions extends ComponentSetOptions { | ||
filter?: Iterable<ComponentLike> | ComponentSet; | ||
resolveChildrenWithParent?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new option allows us to directly include children in component resolution when we encounter parent components
@@ -0,0 +1,131 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a refactor of the ConvertTransaction concept, but performs the same job
for await (const finalizerResult of this.context.executeFinalizers()) { | ||
finalizerResult.forEach((result) => this.push(result)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could simplify this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, I meant that I did simplify it. push is a stream method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok cool
public static async recompose( | ||
children: SourceComponent[], | ||
baseXmlObj: XmlJson = {} | ||
): Promise<JsonMap> { | ||
for (const child of children) { | ||
const { directoryName: groupNode } = child.type; | ||
const { name: parentName } = child.parent.type; | ||
const childContents = (await child.parseXml())[child.type.name]; | ||
if (!baseXmlObj[parentName]) { | ||
baseXmlObj[parentName] = { '@_xmlns': XML_NS_URL }; | ||
} | ||
|
||
if (!baseXmlObj[parentName][groupNode]) { | ||
baseXmlObj[parentName][groupNode] = []; | ||
} | ||
(baseXmlObj[parentName][groupNode] as JsonArray).push(childContents); | ||
} | ||
return baseXmlObj; | ||
} | ||
|
||
public static createParentWriteInfo(trigger: SourceComponent, xmlObject: JsonMap): WriteInfo { | ||
return { | ||
source: new JsToXml(xmlObject), | ||
output: join(trigger.type.directoryName, `${trigger.fullName}.${trigger.type.suffix}`), | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this logic to the RecompositionFinalizer in ConvertContext
Apologies for the big change - feature was a bit complex |
What does this PR do?
Supports the use case of dividing a single decomposed component across different folders (package directories). For instance - a CustomObject can have some of its fields in one package, while the rest of its parts live in another.
What issues does this PR fix or reference?
@W-8527909@