cli icon indicating copy to clipboard operation
cli copied to clipboard

[do not merge] Clack POC

Open sarahetter opened this issue 2 years ago • 2 comments

Related to: CT-101 (design system) and CT-102 (removing bloat)

This is a POC of using @clack/prompts instead of inquirer for our prompting package.

Reasons we'd like to do this:

  • Inquirer (and inquirer-autocomplete-prompt) brings in rxjs which is a huge sub dependency, and we'd like to remove it. (Ends up being around 17MB on filesystem)
Screenshot 2023-11-09 at 4 24 25 PM Screenshot 2023-11-09 at 4 24 37 PM
  • Clack is more customizable than inquirer

Description of clack

Clack has two packages - @clack/core and @clack/prompts.

@clack/core is a group of plain, unstyled prompts. When instantiating a new prompt, you pass a render callback in, and it is updated along with the state when it changes. You can see an example of using @clack/core in src/commands/clack/clack-core.mjs or by running `./bin/run.mjs clack:core.

Prompts is just a pre-styled use of @clack/core with (imo) a pleasant to use interface, and could save us a lot of design and dev time. It also contains some non-prompt utilities such as logging methods to match with the prompts. You can see an example of using @clack/prompts in src/commands/clack/clack-prompts.mjs, or by running ./bin/run.mjs clack:prompts

Screenshots / Gifs

I've converted one command netlify sites:create-template over to @clack/prompts from inquirer

Inquirer (before) @clack/prompts (after)
withinquirer withclack
withinquirer withclack

sarahetter avatar Nov 09 '23 21:11 sarahetter

📊 Benchmark results

Comparing with 7dd41c4ef55823c846d58646d1316d5916489e93

  • Dependency count: 1,399 ⬆️ 0.29% increase vs. 7dd41c4ef55823c846d58646d1316d5916489e93
  • Package size: 404 MB ⬆️ 0.06% increase vs. 7dd41c4ef55823c846d58646d1316d5916489e93

github-actions[bot] avatar Nov 09 '23 21:11 github-actions[bot]

Paired with Sarah today. Small pieces of feedback:

  • Change dim to white on input lines (is that what they're called?)
  • Switch Success and step green to cyan by default to nod to Netlify branding.

samkap avatar Nov 21 '23 20:11 samkap