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

feat: list metadata/-types stdout is table #1141

Merged
merged 6 commits into from
Jul 23, 2024
Merged

feat: list metadata/-types stdout is table #1141

merged 6 commits into from
Jul 23, 2024

Conversation

WillieRuemmele
Copy link
Contributor

What does this PR do?

moves regular output into a table for
list metadata
list metadata-types

What issues does this PR fix or reference?

@W-6015646@

Copy link
Contributor

@mshanemc mshanemc left a comment

Choose a reason for hiding this comment

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

I think you gotta choose between hardcoding the columns OR scanning the full results set to build the Set of fields for the columns.

They could share a function to do that.

and then I think you probably want to capitalize them and split with spaces to make it look nicer than

createdById: string;
createdByName: string;
createdDate: string;
fileName: string;
fullName: string;
id: string;
lastModifiedById: string;
lastModifiedByName: string;
lastModifiedDate: string;
manageableState?: string | null | undefined;
namespacePrefix?: string | null | undefined;
type: string;

wouldl provide

this.styledJSON(describeResult);
this.table(
describeResult.metadataObjects,
Object.fromEntries(Object.keys(describeResult.metadataObjects[0]).map((k) => [k, { header: k }])),
Copy link
Contributor

Choose a reason for hiding this comment

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

the type says that suffix is potentially undefined. If that's true (?), and the first item didn't have a suffix, then the suffix column wouldn't exist even if other items did have one.

Comment on lines 219 to 226
this.table(
data,
{
key: { header: 'Field' },
value: { header: 'Value' },
},
{}
);
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
this.table(
data,
{
key: { header: 'Field' },
value: { header: 'Value' },
},
{}
);
this.table(
data,
{
key: { header: 'Field' },
value: { header: 'Value' },
}
);

Comment on lines 253 to 260
this.table(
data,
{
key: { header: 'Field' },
value: { header: 'Value' },
},
{}
);
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
this.table(
data,
{
key: { header: 'Field' },
value: { header: 'Value' },
},
{}
);
this.table(
data,
{
key: { header: 'Field' },
value: { header: 'Value' },
}
);

@@ -62,7 +62,11 @@ export class ListMetadata extends SfCommand<ListMetadataCommandResult> {
fs.writeFileSync(flags['output-file'], JSON.stringify(listResult, null, 2));
this.logSuccess(`Wrote result file to ${flags['output-file']}.`);
} else if (listResult?.length) {
this.styledJSON(listResult);
this.table(listResult, Object.fromEntries(Object.keys(listResult[0]).map((k) => [k, { header: k }])), {
Copy link
Contributor

Choose a reason for hiding this comment

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

FileProperties also has 2 potentially undefined fields. If the first item doesn't have them, those columns will be missing from all the other items that might

@mshanemc
Copy link
Contributor

mshanemc commented Jul 23, 2024

QA:
org list metadata-types -o hub
✅ works, columns look fine
🎨 I think these should be sorted by Xml Names. I'd also maybe alphabetize the childXmlNames (nit)

./bin/run.js org list metadata -o hub -m CustomObject
✅ works
type column is lowercased. I'm not sure it should be there at all (is there a case where it wouldn't just be the type you just asked for?)

💡 I only see Id and Namespace Prefix when there's a Manageable State. I wonder if there should be 2 or 3 tables, grouped by Manageable state, so that the table without manageable state doesn't need those fields?

🎨 I think a reasonable sort order for these would be state, prefix (unless you decide to do separate tables), full name.
🎨 I'm not a fan of the 1970-01-01. I think I'd rather those be empty than "obviously wrong date." And they really weren't Created or Modified on that date by somebody, either. They were just Standard Objects that predate the org?
🎨 maybe if created and modified by/date are the same, omit the values for modified so that "real" data is more obvious?

@mshanemc mshanemc merged commit 361fb6c into main Jul 23, 2024
15 checks passed
@mshanemc mshanemc deleted the wr/tableOutput branch July 23, 2024 22:26
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.

2 participants