Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: slimmer ux #1056

Merged
merged 11 commits into from
Apr 22, 2024
Merged

feat: slimmer ux #1056

merged 11 commits into from
Apr 22, 2024

Conversation

mdonnalley
Copy link
Contributor

@mdonnalley mdonnalley commented Apr 15, 2024

Slimmer ux

As described here, we're removing most of the methods in the ux module. We're simply unable to adequately support the feature set that ux offers and think that most people would benefit from using dedicated libraries that are better supported.

We are, however, keeping some of the functionality. The new ux module will contain the following:

Unchanged

  • colorize
  • error
  • exit
  • action - will be unchanged from previous version except that the spinner color will be configurable using themes.
  • warn

Renamed

  • stdout - rename of ux.log
  • stderr - rename of ux.logToStderr

New

  • colorizeJson - Apply color theme to arbitrary JSON.

What you'll need to do

You will need to replace everything that ux was doing with dedicated libraries. Here are a few suggestions:

No fancy-tests

  • Removes all uses of @oclif/test and fancy-test
  • Adds new test utilities in test/test.ts, which will soon become the next major of @oclif/test

this.theme = theme
this.theme = await this.loadTheme()

const s3 = this.pjson.oclif.update?.s3 ?? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this style (declaring a const object with placeholders).

could there be a function whose single responsibility is to build the s3 object, or the updateConfig object?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and if the property is optional, we could type it that way rather than using empty string

@@ -97,11 +97,13 @@ export class Config implements IConfig {
public shell!: string
public theme?: Theme
public topicSeparator: ' ' | ':' = ':'
public updateConfig!: NonNullable<PJSON.CLI['oclif']['update']>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're doing breaking changes, maybe we could make the types honest? Like, these ! are kinda true as long as you've called the static load method?

And TS can't help developers avoid runtime undefineds if we do stuff like that.

noodle on it

/**
* Prints a pretty warning message to stderr.
*/
export function warn(input: Error | string, options?: {ignoreDuplicates: boolean}): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe jsdoc the ignoreDuplicates option?

return stripAnsi(this.formatIfCommand(example)).startsWith(
`${colorize(this.config?.theme?.dollarSign, '$')} ${this.config.bin}`,
)
return ansis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh, that's nice

src/ux/theme.ts Outdated
Comment on lines 33 to 36
.map(([key, value]) => {
if (typeof value === 'string') return [key, isValid(value)]
return [key, parseTheme(value)]
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(([key, value]) => {
if (typeof value === 'string') return [key, isValid(value)]
return [key, parseTheme(value)]
})
.map(([key, value]) => [key, typeof value === 'string' ? isValid(value) : parseTheme(value)]})

@mdonnalley mdonnalley changed the base branch from prerelease/v4 to prerelease/beta April 18, 2024 16:43
@mshanemc mshanemc merged commit 879cac9 into prerelease/beta Apr 22, 2024
24 of 79 checks passed
@mshanemc mshanemc deleted the mdonnalley/slimmer-ux branch April 22, 2024 21:15
mdonnalley added a commit that referenced this pull request Jun 4, 2024
* chore: bump major version

* feat: slimmer ux (#1056)

* chore: bump major version

* feat: slimmer ux module

* test: no fancy-tests

* chore(release): 4.0.0-v4.0 [skip ci]

* chore: code review

* chore(release): 4.0.0-v4.1 [skip ci]

* chore(release): 4.0.0-beta.1 [skip ci]

* chore: remove duplicate dep

* test: windows unit tests

* test: windows unit tests

---------

Co-authored-by: svc-cli-bot <Svc_cli_bot@salesforce.com>

* chore(release): 4.0.0-beta.2 [skip ci]

* feat: add customizable logger

* feat: remove native error logger

* fix: cache child loggers

* chore(release): 4.0.0-beta.3 [skip ci]

* chore(release): 4.0.0-beta.4 [skip ci]

* feat: support rc files (#1067)

* feat: support rc files

* chore: code review

* chore(release): 4.0.0-beta.5 [skip ci]

* chore(release): 4.0.0-beta.6 [skip ci]

* fix: revert ignoreDuplicates in warn

* chore(release): 4.0.0-beta.7 [skip ci]

* feat: improved types and top-level exports (#1076)

* feat: improved PJSON type

* feat: enable exactOptionalPropertyTypes

* feat: theme can be object or file path

* feat: support target and identifier for helpClass

* chore: add jsdocs to Configuration type

* fix: add back scope to pjson type

* feat: top level exports

* fix: simplify ux export

* chore: cleanup

* feat: export logger too

* chore(release): 4.0.0-beta.8 [skip ci]

* feat: remove baseFlags

* test: use oclif/test v4 and improve test coverage

* fix: clarify types

* test: use default sinon sandbox

* test: use new major of oclif/test

* test: add interop test for core v3

* test: skip spinner test on windows

* chore: code review

* chore(release): 4.0.0-beta.9 [skip ci]

* fix: restore baseFlags support (#1085)

* chore(release): 4.0.0-beta.10 [skip ci]

* fix: improve types and ProdOnlyCache

* chore(release): 4.0.0-beta.11 [skip ci]

* fix: update hook type

* chore(release): 4.0.0-beta.12 [skip ci]

* fix: allow empty ux.stdout

* chore(release): 4.0.0-beta.13 [skip ci]

* chore: add ux README

* fix: check supports-color in colorize

* chore(release): 4.0.0-beta.14 [skip ci]

* feat: support tsx for runtime transpilation

* chore(release): 4.0.0-beta.15 [skip ci]

* chore(release): 4.0.0-beta.16 [skip ci]

---------

Co-authored-by: svc-cli-bot <Svc_cli_bot@salesforce.com>
Co-authored-by: Steve Hetzel <shetzel@salesforce.com>
Co-authored-by: Willie Ruemmele <willieruemmele@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants