From 53f4cf4e80f4cd9b6438148be1a46df638edd576 Mon Sep 17 00:00:00 2001 From: Roy Razon Date: Tue, 24 Oct 2023 12:26:25 +0300 Subject: [PATCH 1/2] cli: add logo --- packages/cli-common/src/lib/text.ts | 20 ++++++++++++++++++++ packages/cli/package.json | 1 + packages/cli/src/commands/init.ts | 4 ++++ packages/cli/src/help.ts | 11 +++++++++++ 4 files changed, 36 insertions(+) create mode 100644 packages/cli/src/help.ts diff --git a/packages/cli-common/src/lib/text.ts b/packages/cli-common/src/lib/text.ts index 3be6754f..d362cb69 100644 --- a/packages/cli-common/src/lib/text.ts +++ b/packages/cli-common/src/lib/text.ts @@ -1,5 +1,6 @@ import { Config } from '@oclif/core' import chalk from 'chalk' +import { EOL } from 'os' export const code = (c: string) => chalk.bold(c) @@ -12,3 +13,22 @@ export const highlight = (s: string) => chalk.greenBright(s) export const success = (s: string) => chalk.greenBright(s) export const recommendation = (s: string) => chalk.cyan(s) + +const mag = chalk.rgb(255, 128, 197) + +export const logo = [ + '', + `${mag('@@@@')} @@@@`, + `${mag('@@@@@')}@@@@@@`, + `${mag('@@@@@')}@@@@@@@@ @@@@@@@@@@`, + `${mag('@@@@@')}@@@@@@@@@ @@@ @@@ @@ @@@ @@@@@% @@@@@ @@ @@@ @@@ @@@`, + `${mag('@@@@@')}@@@@@@@@@ @@@ @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@`, + `${mag('@@@@@@@@@')} @@@@@@@@@ @@ @@@@@@@@@ @@@@@@@@@ @@@ @@ @@ @@`, + `${mag('@@@@@@@@@')} @@@ @@ @@@ @@@ @@@@@@ @@@@`, + ` ${mag('@@@@@@@@')} @@@ @@ @@@@@@@@ @@@@@@@@ @@@@ @@@@`, + ` ${mag('@@@@@@')} @@@`, + ` ${mag('@@@')} @@@@@`, + '', +].join(EOL) + +export const { supportsColor } = chalk diff --git a/packages/cli/package.json b/packages/cli/package.json index edd77a8e..e1ffa075 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -68,6 +68,7 @@ "plugins": [ "@oclif/plugin-help" ], + "helpClass": "./dist/help", "hooks": { "init": [ "./dist/hooks/init/sync-logging", diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 6869d867..781afb1f 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -144,6 +144,10 @@ export default class Init extends BaseCommand { return undefined } + if (text.supportsColor) { + this.log(text.logo) + } + const driver = await chooseDriver() const driverStatic = machineDrivers[driver] diff --git a/packages/cli/src/help.ts b/packages/cli/src/help.ts new file mode 100644 index 00000000..d415b1e0 --- /dev/null +++ b/packages/cli/src/help.ts @@ -0,0 +1,11 @@ +import { Help as HelpBase } from '@oclif/core' +import { logo } from '@preevy/cli-common/src/lib/text' + +export default class Help extends HelpBase { + override async showRootHelp(): Promise { + if (!this.opts.stripAnsi) { + this.log(logo) + } + return await super.showRootHelp() + } +} From 439cc537c1ed63f50dc2080a79531384efccd2eb Mon Sep 17 00:00:00 2001 From: Roy Razon Date: Thu, 26 Oct 2023 11:01:37 +0300 Subject: [PATCH 2/2] fix build --- packages/cli/src/help.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/help.ts b/packages/cli/src/help.ts index d415b1e0..968e38fc 100644 --- a/packages/cli/src/help.ts +++ b/packages/cli/src/help.ts @@ -1,10 +1,10 @@ import { Help as HelpBase } from '@oclif/core' -import { logo } from '@preevy/cli-common/src/lib/text' +import { text } from '@preevy/cli-common' export default class Help extends HelpBase { override async showRootHelp(): Promise { if (!this.opts.stripAnsi) { - this.log(logo) + this.log(text.logo) } return await super.showRootHelp() }