Skip to content

Commit

Permalink
chore: move styled headers into table title
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Oct 30, 2024
1 parent 197bc69 commit 15927e7
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/commands/package/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export class PackageCreateCommand extends SfCommand<PackageCreate> {
}

private display(result: PackageCreate): void {
this.styledHeader('Ids');
this.table({ data: [{ name: 'Package Id', value: result.Id }] });
this.table({ data: [{ name: 'Package Id', value: result.Id }], title: 'Ids' });
}
}
4 changes: 1 addition & 3 deletions src/commands/package/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export class PackageListCommand extends SfCommand<PackageListCommandResult> {
}

private displayResults(results: Package2Result[], verbose = false, apiVersion: string): void {
this.styledHeader(chalk.blue(`Packages [${results.length}]`));

const data = results.map((r) => ({
'Namespace Prefix': r.NamespacePrefix,
Name: r.Name,
Expand All @@ -80,7 +78,7 @@ export class PackageListCommand extends SfCommand<PackageListCommandResult> {
}
: {}),
}));
this.table({ data });
this.table({ data, title: chalk.blue(`Packages [${results.length}]`) });
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/commands/package/version/create/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export class PackageVersionCreateListCommand extends SfCommand<CreateListCommand
if (results.length === 0) {
this.warn('No results found');
} else {
this.styledHeader(chalk.blue(`Package Version Create Requests [${results.length}]`));

if (flags.verbose) {
try {
results = await this.fetchVerboseData(results);
Expand All @@ -93,7 +91,7 @@ export class PackageVersionCreateListCommand extends SfCommand<CreateListCommand
...(flags.verbose ? { 'Version Name': r.VersionName, 'Version Number': r.VersionNumber } : {}),
}));

this.table({ data, overflow: 'wrap' });
this.table({ data, overflow: 'wrap', title: chalk.blue(`Package Version Create Requests [${results.length}]`) });
}

return results;
Expand Down
3 changes: 1 addition & 2 deletions src/commands/package/version/create/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ export class PackageVersionCreateReportCommand extends SfCommand<ReportCommandRe
});
}

this.styledHeader(chalk.blue('Package Version Create Request'));
this.table({ data });
this.table({ data, title: chalk.blue('Package Version Create Request') });

if (record.Error?.length > 0) {
this.log('');
Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
Language: record.Language,
});
});
this.styledHeader(`Package Versions [${results.length}]`);
this.table({
title: `Package Versions [${results.length}]`,
data: results,
overflow: 'wrap',
columns: getColumnData(flags.concise, flags.verbose, flags['show-conversions-only']),
Expand Down
3 changes: 1 addition & 2 deletions src/commands/package/version/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ export class PackageVersionReportCommand extends SfCommand<PackageVersionReportR
);
displayCoverageRecords.splice(0, displayCoverageRecords.length);
}
this.styledHeader(chalk.blue('Package Version'));
this.table({ data: displayRecords });
this.table({ data: displayRecords, title: chalk.blue('Package Version') });
if (displayCoverageRecords.length > 0) {
this.table({ data: displayCoverageRecords });
}
Expand Down
4 changes: 0 additions & 4 deletions test/commands/package/packageVersionCreateReport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ describe('package:version:create:report - tests', () => {
const testOrg = new MockTestOrgData();
let createStatusStub = $$.SANDBOX.stub(PackageVersion, 'getCreateStatus');
let tableStub: sinon.SinonStub;
let styledHeaderStub: sinon.SinonStub;
let warnStub: sinon.SinonStub;
const config = new Config({ root: import.meta.url });

beforeEach(async () => {
warnStub = $$.SANDBOX.stub(SfCommand.prototype, 'warn');
styledHeaderStub = $$.SANDBOX.stub(SfCommand.prototype, 'styledHeader');
tableStub = $$.SANDBOX.stub(SfCommand.prototype, 'table');
});

Expand Down Expand Up @@ -129,7 +127,6 @@ describe('package:version:create:report - tests', () => {
},
]);
expect(tableStub.callCount).to.equal(1);
expect(styledHeaderStub.callCount).to.equal(1);
});

it('should report on a new package version with async validation', async () => {
Expand Down Expand Up @@ -157,7 +154,6 @@ describe('package:version:create:report - tests', () => {
},
]);
expect(tableStub.callCount).to.equal(1);
expect(styledHeaderStub.callCount).to.equal(1);
});

it('should report multiple errors', async () => {
Expand Down
2 changes: 0 additions & 2 deletions test/commands/package/versionReport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ describe('package:version:report - tests', () => {
expect(result).to.deep.equal(pkgVersionReportResultModified);
expect(uxLogStub.calledOnce).to.be.false;
expect(uxTableStub.calledOnce).to.be.true;
expect(uxStyledHeaderStub.calledOnce).to.be.true;
expect(uxStyledHeaderStub.args[0][0]).to.include('Package Version');
});
it('should produce package version report - json result', async () => {
const reportResult = Object.assign({}, pkgVersionReportResult);
Expand Down

0 comments on commit 15927e7

Please sign in to comment.