Skip to content

feat: support split CustomLabels on deploy and retrieve #278

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

Merged
merged 4 commits into from
Apr 8, 2021

Conversation

mdonnalley
Copy link
Contributor

What does this PR do?

Support deploying and retrieving CustomLabels that are split across multiple package directories

The following configuration options are added to the metadata registry:

  • ignoreParentName: indicates whether or not the parent name should be included when building out the component's fullName
  • uniqueIdAttribute: indicates which xml attribute has the type's unique name. Required in order to matchup incoming children with existing children
  • strategies.recomposition: Used to change the behavior of RecompositionFinalizer.recompose. Only option is startEmpty which indicates whether or not the parent object should be read via parseXml or instantiated as an empty object

What issues does this PR fix or reference?

@W-9016030@

Functionality Before

All labels were retrieved into default package directory

Functionality After

Labels are retrieved into the directory to which they belong. New labels are added to the default directory

@mdonnalley mdonnalley requested a review from a team as a code owner March 29, 2021 16:56
@mdonnalley mdonnalley mentioned this pull request Mar 29, 2021
2 tasks
@mdonnalley mdonnalley self-assigned this Mar 29, 2021
@mdonnalley mdonnalley force-pushed the mdonnalley/custom-labels-deploy-retrieve branch from c29849e to c64aaee Compare March 29, 2021 17:07
Copy link
Contributor

@shetzel shetzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -52,6 +52,7 @@ export class MetadataConverter {
try {
// it's possible the components came from a component set, so this may be redundant in some cases...
const manifestContents = new ComponentSet(components, this.registry).getPackageXml();
console.log(manifestContents);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth converting to Logger.debug()?

Comment on lines 76 to 80
if (this.content && !this.parent && this.type.children) {
return this.getDecomposedChildren(this.content);
} else if (!this.parent && this.type.children) {
return this.getNonDecomposedChildren();
} else {
return [];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (this.content && !this.parent && this.type.children) {
return this.getDecomposedChildren(this.content);
} else if (!this.parent && this.type.children) {
return this.getNonDecomposedChildren();
} else {
return [];
}
if (!this.parent && this.type.children) {
if (this.content) {
return this.getDecomposedChildren(this.content);
}
return this.getNonDecomposedChildren();
}
return [];

const contents = fs.readFileSync(this.xml);
return this.parse<T>(contents.toString());
Copy link
Contributor

@brpowell brpowell Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I try to use the tree to do IO, in this case this.tree.readFile. There isn't a "sync" method on the tree interface yet but you could add one - should be pretty simple. Especially if modifying getChildren to be async is too destructive with the resolver and everything

Copy link
Contributor Author

@mdonnalley mdonnalley Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brpowell I originally tried adding a readSync to the treeContainer classes but I got stumped by ZipTreeContainer which cannot be implemented synchronously because of the zip library we're using.

I wasn't sure if the ZipTreeContainer was ever used in this code path, so I decided the safest thing was to just use fs instead

const xmlPathToChildren = `${this.type.name}.${this.type.directoryName}`;
// WARNING: for NonDecomposed children we expect the first child type to be the only child type,
// which might not be a valid assumption long term
const [childTypeId] = Object.keys(this.type.children.types);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if instead we iterate through Object.values(this.type.children.types) and concat the components for each type?

@@ -52,6 +52,7 @@ export class MetadataConverter {
try {
// it's possible the components came from a component set, so this may be redundant in some cases...
const manifestContents = new ComponentSet(components, this.registry).getPackageXml();
console.log(manifestContents);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(manifestContents);

@mdonnalley mdonnalley force-pushed the mdonnalley/custom-labels-deploy-retrieve branch from 94cfd40 to 9e58fe0 Compare April 1, 2021 14:34
@mdonnalley mdonnalley requested a review from brpowell April 1, 2021 14:52
@mdonnalley mdonnalley force-pushed the mdonnalley/custom-labels-deploy-retrieve branch 3 times, most recently from c78ca35 to 8cbe41f Compare April 5, 2021 20:14
@brpowell
Copy link
Contributor

brpowell commented Apr 5, 2021

@mdonnalley Looking good on the tests 👍 . Few more places to increase coverage on:

  • The new child parsing code in the SourceComponent class
  • The new switch case in the SourceAdapterFactory
  • Possibly increase the Branch category for ConvertContext stuff. It's actually a higher percentage than what it was which is good. If it's easy enough to bump to green go for it, otherwise no worries.

@mdonnalley mdonnalley force-pushed the mdonnalley/custom-labels-deploy-retrieve branch from e723338 to 14c112a Compare April 6, 2021 20:44
Comment on lines 73 to 75
* The xml attribute used as the unique identifier when parsing the xml
*/
uniqueIdAttribute?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nit, but is it the XML attribute or element?

@mdonnalley mdonnalley force-pushed the mdonnalley/custom-labels-deploy-retrieve branch from 1752ce1 to a771804 Compare April 7, 2021 14:51
@mdonnalley mdonnalley requested a review from brpowell April 7, 2021 14:53
@mdonnalley mdonnalley force-pushed the mdonnalley/custom-labels-deploy-retrieve branch from ba4cc8c to f4dc49d Compare April 7, 2021 16:57
@mdonnalley mdonnalley force-pushed the mdonnalley/custom-labels-deploy-retrieve branch from f4dc49d to 992830b Compare April 8, 2021 18:49
@mdonnalley mdonnalley merged commit 82826ff into develop Apr 8, 2021
@mdonnalley mdonnalley deleted the mdonnalley/custom-labels-deploy-retrieve branch April 8, 2021 21:35
sfsholden pushed a commit that referenced this pull request Apr 14, 2021
* feat: support split CustomLabels on deploy and retrieve

* chore: rename uniqueIdAttribute to uniqueIdElement

* fix: allow unprocessed component to be the default component

* chore: bump shelljs
sfsholden pushed a commit that referenced this pull request Apr 14, 2021
* feat: support split CustomLabels on deploy and retrieve

* chore: rename uniqueIdAttribute to uniqueIdElement

* fix: allow unprocessed component to be the default component

* chore: bump shelljs
sfsholden pushed a commit that referenced this pull request May 6, 2021
* feat: support split CustomLabels on deploy and retrieve

* chore: rename uniqueIdAttribute to uniqueIdElement

* fix: allow unprocessed component to be the default component

* chore: bump shelljs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants