Skip to content

Commit 361fb6c

Browse files
feat: list metadata/-types stdout is table (#1141)
* feat: list metadata/-types stdout is table * chore: add missed info as log lines * chore: hardcode columns * chore: fix sorting, omit extra columns --------- Co-authored-by: mshanemc <[email protected]>
1 parent a869c05 commit 361fb6c

File tree

4 files changed

+56
-18
lines changed

4 files changed

+56
-18
lines changed

src/commands/org/create/sandbox.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import { Duration } from '@salesforce/kit';
99
import { Flags } from '@salesforce/sf-plugins-core';
1010
import { Lifecycle, Messages, SandboxEvents, SandboxRequest, SfError } from '@salesforce/core';
11-
import { Ux } from '@salesforce/sf-plugins-core';
1211
import { Interfaces } from '@oclif/core';
1312
import requestFunctions from '../../../shared/sandboxRequest.js';
1413
import { SandboxCommandBase, SandboxCommandResponse } from '../../../shared/sandboxCommandBase.js';
@@ -215,14 +214,12 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxCommandResp
215214
private async confirmSandboxReq(sandboxReq: SandboxConfirmData): Promise<void> {
216215
if (this.flags['no-prompt'] || this.jsonEnabled()) return;
217216

218-
const columns: Ux.Table.Columns<{ key: string; value: unknown }> = {
219-
key: { header: 'Field' },
220-
value: { header: 'Value' },
221-
};
222-
223217
const data = Object.entries(sandboxReq).map(([key, value]) => ({ key, value }));
224218
this.styledHeader('Config Sandbox Request');
225-
this.table(data, columns, {});
219+
this.table(data, {
220+
key: { header: 'Field' },
221+
value: { header: 'Value' },
222+
});
226223

227224
if (
228225
!(await this.confirm({

src/commands/org/list/metadata-types.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import fs from 'node:fs';
88

99
import { Messages } from '@salesforce/core';
10-
import type { DescribeMetadataResult } from '@jsforce/jsforce-node/lib/api/metadata.js';
10+
import type { DescribeMetadataObject, DescribeMetadataResult } from '@jsforce/jsforce-node/lib/api/metadata.js';
1111
import { RegistryAccess } from '@salesforce/source-deploy-retrieve';
1212
import { Flags, loglevel, requiredOrgFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
1313

@@ -68,7 +68,29 @@ export class ListMetadataTypes extends SfCommand<DescribeMetadataResult> {
6868
await fs.promises.writeFile(flags['output-file'], JSON.stringify(describeResult, null, 2));
6969
this.logSuccess(`Wrote result file to ${flags['output-file']}.`);
7070
} else {
71-
this.styledJSON(describeResult);
71+
this.table(
72+
describeResult.metadataObjects,
73+
{
74+
xmlName: { header: 'Xml Names' },
75+
childXmlNames: {
76+
header: 'Child Xml Names',
77+
get: (row: DescribeMetadataObject) =>
78+
row.childXmlNames.length ? `[ ${row.childXmlNames.join('\n')} ]` : '',
79+
},
80+
directoryName: { header: 'Directory Name' },
81+
inFolder: { header: 'In Folder' },
82+
metaFile: { header: 'Meta File' },
83+
suffix: { header: 'Suffix' },
84+
},
85+
{
86+
'no-truncate': true,
87+
title: 'Metadata',
88+
sort: 'Xml Names',
89+
}
90+
);
91+
this.log(`Organizational Namespace: ${describeResult.organizationNamespace}`);
92+
this.log(`Partial Save Allowed: ${describeResult.partialSaveAllowed}`);
93+
this.log(`Test Required: ${describeResult.testRequired}`);
7294
}
7395
return describeResult;
7496
}

src/commands/org/list/metadata.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,29 @@ export class ListMetadata extends SfCommand<ListMetadataCommandResult> {
6262
fs.writeFileSync(flags['output-file'], JSON.stringify(listResult, null, 2));
6363
this.logSuccess(`Wrote result file to ${flags['output-file']}.`);
6464
} else if (listResult?.length) {
65-
this.styledJSON(listResult);
65+
this.table(
66+
listResult,
67+
{
68+
createdByName: { header: 'Created By' },
69+
createdDate: {
70+
header: 'Created Date',
71+
get: (row: FileProperties) => row.createdDate.split('T')[0],
72+
},
73+
fullName: { header: 'Full Name' },
74+
id: { header: 'Id' },
75+
lastModifiedByName: { header: 'Last Modified By' },
76+
lastModifiedDate: {
77+
header: 'Last Modified',
78+
get: (row: FileProperties) => row.createdDate.split('T')[0],
79+
},
80+
manageableState: { header: 'Manageable State' },
81+
namespacePrefix: { header: 'Namespace Prefix' },
82+
},
83+
{
84+
title: flags['metadata-type'],
85+
sort: 'Manageable State',
86+
}
87+
);
6688
} else {
6789
this.warn(messages.getMessage('noMatchingMetadata', [flags['metadata-type'], conn.getUsername()]));
6890
}

src/commands/org/refresh/sandbox.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
import { Duration, omit } from '@salesforce/kit';
99
import { Flags } from '@salesforce/sf-plugins-core';
10-
import { Lifecycle, Messages, SandboxInfo, SandboxEvents, SfError } from '@salesforce/core';
11-
import { Ux } from '@salesforce/sf-plugins-core';
10+
import { Lifecycle, Messages, SandboxEvents, SandboxInfo, SfError } from '@salesforce/core';
1211
import { Interfaces } from '@oclif/core';
1312
import requestFunctions from '../../../shared/sandboxRequest.js';
1413
import { SandboxCommandBase, SandboxCommandResponse } from '../../../shared/sandboxCommandBase.js';
@@ -249,14 +248,12 @@ export default class RefreshSandbox extends SandboxCommandBase<SandboxCommandRes
249248
private async confirmSandboxRefresh(sandboxInfo: SandboxInfo): Promise<void> {
250249
if (this.flags['no-prompt'] || this.jsonEnabled()) return;
251250

252-
const columns: Ux.Table.Columns<{ key: string; value: unknown }> = {
253-
key: { header: 'Field' },
254-
value: { header: 'Value' },
255-
};
256-
257251
const data = Object.entries(sandboxInfo).map(([key, value]) => ({ key, value: value ?? 'null' }));
258252
this.styledHeader('Config Sandbox Refresh');
259-
this.table(data, columns, {});
253+
this.table(data, {
254+
key: { header: 'Field' },
255+
value: { header: 'Value' },
256+
});
260257

261258
if (
262259
!(await this.confirm({

0 commit comments

Comments
 (0)