Skip to content

Commit

Permalink
Merge pull request #1026 from salesforcecli/updateTable
Browse files Browse the repository at this point in the history
fix: update dependency and new table format
  • Loading branch information
WillieRuemmele authored Oct 21, 2024
2 parents 671d501 + 3a11f3a commit c2977fc
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@salesforce/core": "^8.5.7",
"@salesforce/sf-plugins-core": "^11.3.12"
"@salesforce/sf-plugins-core": "^12.0.4"
},
"devDependencies": {
"@oclif/core": "^4.0.29",
Expand Down
7 changes: 5 additions & 2 deletions src/commands/org/list/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Result = {
Max: number;
Remaining: number;
};
}
};

export type ApiLimits = ApiLimit[];

Expand All @@ -54,7 +54,10 @@ export class LimitsApiDisplayCommand extends SfCommand<ApiLimits> {
remaining: Remaining,
}));

this.table(limits, { name: { header: 'Name' }, remaining: { header: 'Remaining' }, max: { header: 'Max' } });
this.table({
data: limits,
columns: ['name', 'remaining', 'max'],
});

return limits;
} catch (err) {
Expand Down
18 changes: 14 additions & 4 deletions src/commands/org/list/sobject/record-counts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type RecordCounts = RecordCount[];

type Result = {
sObjects: RecordCounts;
}
};

export class LimitsRecordCountsDisplayCommand extends SfCommand<RecordCounts> {
public static readonly aliases = ['force:limits:recordcounts:display', 'limits:recordcounts:display'];
Expand Down Expand Up @@ -59,10 +59,20 @@ export class LimitsRecordCountsDisplayCommand extends SfCommand<RecordCounts> {
.filter((record) => (flags.sobject.length > 0 ? flags.sobject.includes(record.name) : result.sObjects))
.sort((a, b) => a.name.localeCompare(b.name));

this.table(recordCounts, {
name: { header: 'sObject' },
count: { header: 'Record Count' },
this.table({
data: recordCounts,
columns: [
{
key: 'name',
name: 'sObject',
},
{
key: 'count',
name: 'Record Count',
},
],
});

return recordCounts;
} catch (err) {
if (err instanceof Error || typeof err === 'string') {
Expand Down
4 changes: 2 additions & 2 deletions test/commands/display.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ describe('Limits display', () => {
});

it('Displays the limits (json)', () => {
const output = execCmd<ListApiDisplayOutput>(`limits:api:display -u ${username} --json`, {
const output = execCmd<ListApiDisplayOutput>(`org:list:limits -o ${username} --json`, {
ensureExitCode: 0,
}).jsonOutput;
expect(output?.result).length.greaterThan(0);
expect(output?.status).to.equal(0);
});

it('Displays the limits (human readable)', () => {
const command = `limits:api:display -u ${username}`;
const command = `org:list:limits -o ${username}`;
const result = execCmd(command, { ensureExitCode: 0 });
const output = getString(result, 'shellOutput.stdout');
expect(output).to.include('ActiveScratchOrgs');
Expand Down
6 changes: 3 additions & 3 deletions test/commands/recordcounts.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('recordcounts:display', () => {
});

it('Displays the records (json)', () => {
const output = execCmd<RecordCount[]>(`limits:recordcounts:display -s Account,Contact -u ${username} --json`, {
const output = execCmd<RecordCount[]>(`org list sobject record-counts -s Account,Contact -o ${username} --json`, {
ensureExitCode: 0,
}).jsonOutput;
expect(output?.result).length.greaterThan(0);
Expand All @@ -36,7 +36,7 @@ describe('recordcounts:display', () => {
});

it('Displays all records (json)', () => {
const output = execCmd<RecordCount[]>(`limits:recordcounts:display -u ${username} --json`, {
const output = execCmd<RecordCount[]>(`org list sobject record-counts -o ${username} --json`, {
ensureExitCode: 0,
}).jsonOutput;

Expand All @@ -45,7 +45,7 @@ describe('recordcounts:display', () => {
});

it('Displays the records (human readable)', () => {
const command = `limits:recordcounts:display -s Account -u ${username}`;
const command = `org list sobject record-counts -s Account -o ${username}`;
const result = execCmd(command, { ensureExitCode: 0 });
const output = getString(result, 'shellOutput.stdout');
expect(output).to.include('Account');
Expand Down
Loading

0 comments on commit c2977fc

Please sign in to comment.