consola icon indicating copy to clipboard operation
consola copied to clipboard

Issue with prompt (clack) cancellation detect

Open samuelstroschein opened this issue 1 year ago • 6 comments

Environment

/

Reproduction

  • https://github.com/natemoo-re/clack/issues/83#issuecomment-1564470873
  • https://github.com/unjs/consola/issues/234
  • https://github.com/unjs/consola/issues/239

Describe the bug

Consola bundles the NPM package, leading to downstream bugs.

Proposal

Stop bundling consola.

If bundling is important, the consumer of consola can use a bundler. A consumer using a bundler means the complexity of consola is reduced, bugs that bundling consola introduces are removed, and consola becomes more useful.

Additional context

No response

Logs

No response

samuelstroschein avatar Oct 19 '23 17:10 samuelstroschein

Hi dear @samuelstroschein. Thanks for your suggestion. Consola, because of many ecosystem reasons, is zero dependency so it bundles all deps. But it shouldn't be an issue since we can release with new versions fixed deps and there is an automated CI that regularly updates dependencies.

Regarding Clack, as also mentioned in initial integration PR notes, we only inline/fork clack source code because it lacked ability to configure formatting options and inlining code in repo means sadly we miss important upstream fixes unless manually rebasing. Once this is possible, i would be more than happy to also use upstream clack.

pi0 avatar Oct 19 '23 18:10 pi0

Hi @pi0,

Thanks for the response. The bundling/inlining seems to cause bugs, though; see https://github.com/unjs/consola/issues/234 and https://github.com/natemoo-re/clack/issues/83#issuecomment-1564470873 specifically.

I don't have enough background to evaluate whether bundling is worth the ecosystem impact.

samuelstroschein avatar Oct 19 '23 20:10 samuelstroschein

Thanks for clarification by linking issue. I have shared a suggestion for them there.

We can easily solve it earlier for consola btw as consola API is dedicated to itself .

pi0 avatar Oct 25 '23 08:10 pi0

I got it working btw

https://github.com/inlang/monorepo/blob/02856c466a9198c1ccf9d277af3189bb18a42f3c/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts#L308-L314

samuelstroschein avatar Oct 25 '23 08:10 samuelstroschein

nice workaround!

pi0 avatar Oct 25 '23 08:10 pi0

Thanks for the workaround @samuelstroschein I moved the solution into my options and ignore the clashing types.

export const logger = createConsola({
  async prompt(...params) {
    const response = await consola.prompt(...params);
    if (isSymbol(response) && response.toString() === "Symbol(clack:cancel)") {
      process.exit(10);
    }
    // types clash massivly. consider switching to clack directly
    return response as never;
  },
});

GerroDen avatar Nov 14 '23 14:11 GerroDen