-
Notifications
You must be signed in to change notification settings - Fork 13
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
Changes from 2 commits
7cac63c
5f52788
ed60e3c
ba32079
b0a4957
77a6811
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,18 @@ export class ListMetadataTypes extends SfCommand<DescribeMetadataResult> { | |
await fs.promises.writeFile(flags['output-file'], JSON.stringify(describeResult, null, 2)); | ||
this.logSuccess(`Wrote result file to ${flags['output-file']}.`); | ||
} else { | ||
this.styledJSON(describeResult); | ||
this.table( | ||
describeResult.metadataObjects, | ||
Object.fromEntries(Object.keys(describeResult.metadataObjects[0]).map((k) => [k, { header: k }])), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{ | ||
'no-truncate': true, | ||
title: 'Metadata', | ||
sort: 'xmlName', | ||
} | ||
); | ||
this.log(`Organizational Namespace: ${describeResult.organizationNamespace}`); | ||
this.log(`Partial Save Allowed: ${describeResult.partialSaveAllowed}`); | ||
this.log(`Test Required: ${describeResult.testRequired}`); | ||
} | ||
return describeResult; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }])), { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
'no-truncate': true, | ||
title: flags['metadata-type'], | ||
sort: 'fullName', | ||
}); | ||
} else { | ||
this.warn(messages.getMessage('noMatchingMetadata', [flags['metadata-type'], conn.getUsername()])); | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,8 +7,7 @@ | |||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
import { Duration, omit } from '@salesforce/kit'; | ||||||||||||||||||||||||||||||||
import { Flags } from '@salesforce/sf-plugins-core'; | ||||||||||||||||||||||||||||||||
import { Lifecycle, Messages, SandboxInfo, SandboxEvents, SfError } from '@salesforce/core'; | ||||||||||||||||||||||||||||||||
import { Ux } from '@salesforce/sf-plugins-core'; | ||||||||||||||||||||||||||||||||
import { Lifecycle, Messages, SandboxEvents, SandboxInfo, SfError } from '@salesforce/core'; | ||||||||||||||||||||||||||||||||
import { Interfaces } from '@oclif/core'; | ||||||||||||||||||||||||||||||||
import requestFunctions from '../../../shared/sandboxRequest.js'; | ||||||||||||||||||||||||||||||||
import { SandboxCommandBase, SandboxCommandResponse } from '../../../shared/sandboxCommandBase.js'; | ||||||||||||||||||||||||||||||||
|
@@ -249,14 +248,16 @@ export default class RefreshSandbox extends SandboxCommandBase<SandboxCommandRes | |||||||||||||||||||||||||||||||
private async confirmSandboxRefresh(sandboxInfo: SandboxInfo): Promise<void> { | ||||||||||||||||||||||||||||||||
if (this.flags['no-prompt'] || this.jsonEnabled()) return; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const columns: Ux.Table.Columns<{ key: string; value: unknown }> = { | ||||||||||||||||||||||||||||||||
key: { header: 'Field' }, | ||||||||||||||||||||||||||||||||
value: { header: 'Value' }, | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const data = Object.entries(sandboxInfo).map(([key, value]) => ({ key, value: value ?? 'null' })); | ||||||||||||||||||||||||||||||||
this.styledHeader('Config Sandbox Refresh'); | ||||||||||||||||||||||||||||||||
this.table(data, columns, {}); | ||||||||||||||||||||||||||||||||
this.table( | ||||||||||||||||||||||||||||||||
data, | ||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||
key: { header: 'Field' }, | ||||||||||||||||||||||||||||||||
value: { header: 'Value' }, | ||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||
{} | ||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if ( | ||||||||||||||||||||||||||||||||
!(await this.confirm({ | ||||||||||||||||||||||||||||||||
|
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.