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
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/commands/org/create/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { Duration } from '@salesforce/kit';
import { Flags } from '@salesforce/sf-plugins-core';
import { Lifecycle, Messages, SandboxEvents, SandboxRequest, SfError } from '@salesforce/core';
import { Ux } from '@salesforce/sf-plugins-core';
import { Interfaces } from '@oclif/core';
import requestFunctions from '../../../shared/sandboxRequest.js';
import { SandboxCommandBase, SandboxCommandResponse } from '../../../shared/sandboxCommandBase.js';
Expand Down Expand Up @@ -215,14 +214,16 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxCommandResp
private async confirmSandboxReq(sandboxReq: SandboxConfirmData): 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(sandboxReq).map(([key, value]) => ({ key, value }));
this.styledHeader('Config Sandbox Request');
this.table(data, columns, {});
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' },
}
);


if (
!(await this.confirm({
Expand Down
13 changes: 12 additions & 1 deletion src/commands/org/list/metadata-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }])),
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.

{
'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;
}
Expand Down
6 changes: 5 additions & 1 deletion src/commands/org/list/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

'no-truncate': true,
title: flags['metadata-type'],
sort: 'fullName',
});
} else {
this.warn(messages.getMessage('noMatchingMetadata', [flags['metadata-type'], conn.getUsername()]));
}
Expand Down
17 changes: 9 additions & 8 deletions src/commands/org/refresh/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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' },
},
{}
);
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' },
}
);


if (
!(await this.confirm({
Expand Down