Closed ulken closed 1 year ago
Hi, could you send some simple instructions on how to reproduce this please..
Hi, could you send some simple instructions on how to reproduce this please..
Sure thing. Would you prefer a sandbox or instructions how to reproduce it locally?
instructions on how to reproduce it locally please..
Got it! I'll get back to you.
mkdir cli-usage-deno && cd $_
deno init
main.ts
with
import cliUsage from "npm:command-line-usage";
if (import.meta.main) { console.log(cliUsage([ { header: "Deno CLI usage", content: "Best thing ever" } ])); }
5. `deno run --allow-read --allow-env main.ts` (could also pass `--allow-all` if you prefer)
Let me know if you get stuck on something.
Let me know if a PR would help.
I had a look last night, chalk v5 is ESM only, meaning the command-line-usage project would need to be upgraded to a ESM project ("type": "module"
).. which is fine, but it would also still need to support CJS as we don't have an "ESM only" policy on these projects meaning rollup would need to be introduced to build a CJS option, which is fine too but it's probably not as quick a fix as you were hoping
also, the tagged template support was removed from chalk v5.. this library uses that feature to give users the ability to colour usage docs, e.g. some {red important} text
.. so a bit of extra work required there too..
Right, which is why I wrote:
Please consider upgrading to at least 4.X, where the issue above is fixed. If you want to take the step to ESM, you might want to take it to 5.X+ even.
From the Chalk README:
IMPORTANT: Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now.
and
It's totally fine to stay on Chalk v4. It's been stable for years.
I.e v4 should solve the problem equally well.
also, the tagged template support was removed from chalk v5.. this library uses that feature to give users the ability to colour usage docs, e.g.
some {red important} text
.. so a bit of extra work required there too..
Moved to a separate package, though, so shouldn't be too bad?
i thought the Deno fix was from chalk v5.2 onward.. may be wrong..
i thought the Deno fix was from chalk v5.2 onward.. may be wrong..
To my understanding, this is the crucial fix, introduced in 4.0.0.
If so, 4.1.2 should cut it.
Other problems might show up further down the road, though. I can give it a try, if you'd like.
since implementing this fix will introduce a breaking change to command-line-usage, we might as upgrade all deps to all latest versions (v5, not v4 chalk) and rewrite the project as ESM.. that way we can squeeze as many breaking upgrades into the next release as possible.. since this update will result in changes right across the project (in /examples and /test too) I will do it this time.. otherwise, yes I'd welcome your PR..
All right, by all means. Thank you for taking the leap. You know where to find me. Good luck!
I've published a beta version for testing.. please update your import
with the following and give it a try..
import cliUsage from "npm:command-line-usage@next"
Hey, look at that!
For unknown reason, the formatting is not displayed in Warp, but that is on them (works in Hyper and Terminal.app)...
https://app.warp.dev/block/nvpi0MT2iXS45OmFaVQyjT
Is it erroneously thinking it's piped and strips the formatting? Idk. Don't bother.
I'm about to move this out of beta and make it live, please let me know if there are any further deno issues I might not know about.. Cheers!
Cool! Will do 👍
Due to https://github.com/denoland/deno/issues/13321, the library fails with
The version of
chalk
used is really old. Please consider upgrading to at least 4.X, where the issue above is fixed. If you want to take the step to ESM, you might want to take it to 5.X+ even.If you're up for it, let me know if you want me to help out in any way.
PS. Even if you have no intention of supporting Deno, I think it would still be worth to upgrade Chalk to a more modern (and safer) version.