Skip to content

Commit 58229bb

Browse files
authored
Merge pull request #624 from salesforcecli/mdonnalley/bump-sf-plugins-core
feat: use new table
2 parents 315eab3 + b066db3 commit 58229bb

File tree

5 files changed

+293
-65
lines changed

5 files changed

+293
-65
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@salesforce/apex-node": "^8.1.15",
99
"@salesforce/core": "^8.6.4",
1010
"@salesforce/kit": "^3.2.2",
11-
"@salesforce/sf-plugins-core": "^11.3.12",
11+
"@salesforce/sf-plugins-core": "^12",
1212
"ansis": "^3.3.1"
1313
},
1414
"devDependencies": {

src/commands/apex/list/log.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,22 @@ export default class Log extends SfCommand<LogListResult> {
4646

4747
if (!flags.json) {
4848
// while not required to prevent table output, save a few iterations if only printing json
49-
this.table(logRecords.map(formatForTable), tableHeaders, { 'no-truncate': true });
49+
this.table({
50+
data: logRecords.map(formatForTable),
51+
columns: [
52+
'Application',
53+
{ key: 'DurationMilliseconds', name: 'Duration (ms)' },
54+
'Id',
55+
'Location',
56+
{ key: 'LogLength', name: 'Size (B)' },
57+
{ key: 'User', name: 'Log User' },
58+
'Operation',
59+
'Request',
60+
{ key: 'StartTime', name: 'Start Time' },
61+
'Status',
62+
],
63+
overflow: 'wrap',
64+
});
5065
}
5166

5267
return logRecords;
@@ -65,16 +80,3 @@ const formatTime = (time: string): string => {
6580
const msIndex = time.indexOf('.');
6681
return msIndex !== -1 ? time.substring(0, msIndex) + time.substring(msIndex + 4) : time;
6782
};
68-
69-
const tableHeaders = {
70-
Application: { header: 'Application' },
71-
DurationMilliseconds: { header: 'Duration (ms)' },
72-
Id: { header: 'Id' },
73-
Location: { header: 'Location' },
74-
LogLength: { header: 'Size (B)' },
75-
User: { header: 'Log User' },
76-
Operation: { header: 'Operation' },
77-
Request: { header: 'Request' },
78-
StartTime: { header: 'Start Time' },
79-
Status: { header: 'Status' },
80-
};

test/commands/apex/list/log.test.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,38 +80,32 @@ describe('apex:log:list', () => {
8080
it('will list multiple logs', async () => {
8181
sandbox.stub(LogService.prototype, 'getLogRecords').resolves(structuredClone(logRecords));
8282
await Log.run([]);
83-
expect(uxStub.table.args[0][0]).to.deep.equal([
83+
expect(uxStub.table.args[0][0].data).to.deep.equal([
8484
{
85+
Id: '07L5tgg0005PGdTnEAL',
8586
Application: 'Unknown',
8687
DurationMilliseconds: '75',
87-
Id: '07L5tgg0005PGdTnEAL',
8888
Location: 'Unknown',
89+
LogLength: 450,
90+
LogUser: { Name: 'Test User', attributes: {} },
8991
Operation: 'API',
9092
Request: 'API',
91-
LogLength: 450,
92-
Status: 'Assertion Failed',
9393
StartTime: '2020-10-13T05:39:43+0000',
94+
Status: 'Assertion Failed',
9495
User: 'Test User',
95-
LogUser: {
96-
Name: 'Test User',
97-
attributes: {},
98-
},
9996
},
10097
{
98+
Id: '07L5tgg0005PGdTnFPL',
10199
Application: 'Unknown',
102100
DurationMilliseconds: '75',
103-
Id: '07L5tgg0005PGdTnFPL',
104101
Location: 'Unknown',
102+
LogLength: 450,
103+
LogUser: { Name: 'Test User2', attributes: {} },
105104
Operation: 'API',
106105
Request: 'API',
107-
LogLength: 450,
108-
Status: 'Successful',
109106
StartTime: '2020-10-13T05:39:43+0000',
107+
Status: 'Successful',
110108
User: 'Test User2',
111-
LogUser: {
112-
Name: 'Test User2',
113-
attributes: {},
114-
},
115109
},
116110
]);
117111
});

test/commands/apex/loggingCommands.nut.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ describe('apex log *', () => {
8383
});
8484

8585
it('will list the debug logs', async () => {
86-
const result = execCmd('apex:list:log', { ensureExitCode: 0 }).shellOutput.stdout;
86+
const result = execCmd('apex:list:log', { ensureExitCode: 0, env: { ...process.env, SF_NO_TABLE_STYLE: 'true' } })
87+
.shellOutput.stdout;
88+
8789
expect(result).to.match(
88-
/ Application Duration \(ms\) Id\s+Location\s+Size \(B\) Log User\s+Operation Request Start Time\s+Status /
90+
/Application\s+Duration \(ms\)\s+Id\s+Location\s+Size \(B\)\s+Log User\s+Operation\s+Request\s+Start Time\s+Status/
8991
);
90-
expect(result).to.match(/User User Api\s+Api\s+\d{4}-\d{2}-.* Success /);
92+
expect(result).to.match(/User User\s+Api\s+Api\s+\d{4}-\d{2}-.*\s+Success/);
9193
});
9294

9395
it('will list the debug logs --json', async () => {

0 commit comments

Comments
 (0)