From 5cc0e8bf60774918c2ebaf2ba5b465f3dd6caf15 Mon Sep 17 00:00:00 2001 From: Peter Hale Date: Fri, 4 Mar 2022 13:32:34 -0700 Subject: [PATCH] fix: add styled header function to sf command Port of sandbox create references sytledHeader. Exposed styledHeader in SfCommand @W-10657688@ --- package.json | 2 +- src/ux/ux.ts | 4 ++++ test/unit/ux/ux.test.ts | 14 ++++++++++++++ yarn.lock | 8 ++++---- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c9e66931..7247623a 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "/messages" ], "dependencies": { - "@oclif/core": "^1.5.1", + "@oclif/core": "^1.5.2", "@salesforce/core": "^3.7.7", "@salesforce/kit": "^1.5.17", "@salesforce/ts-types": "^1.5.20", diff --git a/src/ux/ux.ts b/src/ux/ux.ts index 69adff56..77151804 100644 --- a/src/ux/ux.ts +++ b/src/ux/ux.ts @@ -29,6 +29,10 @@ export class Ux extends UxBase { public styledObject(obj: AnyJson): void { this.maybeNoop(() => CliUx.ux.styledObject(obj)); } + + public styledHeader(text: string): void { + this.maybeNoop(() => CliUx.ux.styledHeader(text)); + } } export namespace Ux { diff --git a/test/unit/ux/ux.test.ts b/test/unit/ux/ux.test.ts index ba6721f3..85edd06e 100644 --- a/test/unit/ux/ux.test.ts +++ b/test/unit/ux/ux.test.ts @@ -84,4 +84,18 @@ describe('Ux', () => { expect(infoStub.callCount).to.equal(0); }); }); + + describe('styledHeader', () => { + it('should log stylized header', () => { + const ux = new Ux(true); + ux.styledHeader('A Stylized Header'); + expect(infoStub.firstCall.args).to.deep.equal(['\u001b[2m=== \u001b[22m\u001b[1mA Stylized Header\u001b[22m\n']); + }); + + it('should not log anything if output is not enabled', () => { + const ux = new Ux(false); + ux.styledHeader('A Stylized Header'); + expect(infoStub.callCount).to.equal(0); + }); + }); }); diff --git a/yarn.lock b/yarn.lock index 3b46afd1..fa7ee15a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -492,10 +492,10 @@ widest-line "^3.1.0" wrap-ansi "^7.0.0" -"@oclif/core@^1.5.1": - version "1.5.1" - resolved "https://registry.yarnpkg.com/@oclif/core/-/core-1.5.1.tgz#29969ebd244d1bbf0d98418a3c3620909afa4367" - integrity sha512-dlJpww5UAHv46Z7p37ytQIKDkwOmA3uQY6ChPRY6Q9/YfDD4H0z3JfA+lfVfwHkZcIpiq9XsCkhCmBw7Uoh6Iw== +"@oclif/core@^1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@oclif/core/-/core-1.5.2.tgz#23800fe249283815fdd6f441d75cf862683ab58e" + integrity sha512-K2PtU9KyZuBhmpNxFN7vG2AbQtc4ndxDTuu+pa4iK3NtTUPiXReItVj9PKqKIOGMTN+KqiEMknSl1JGa1Fab2g== dependencies: "@oclif/linewrap" "^1.0.0" "@oclif/screen" "^3.0.2"