showdownjs / showdown

A bidirectional Markdown to HTML to Markdown converter written in Javascript
http://www.showdownjs.com/
MIT License
14.26k stars 1.56k forks source link

Separate CLI package #884

Closed greggman closed 2 years ago

greggman commented 2 years ago

I hope this will be received in a positive spirit.

This was requested before: https://github.com/showdownjs/showdown/issues/348

Isn't in clear now why they should be separated?

Yargs is not needed by anyone using this package as a library but it adds 16 dependencies (it and 15 more).

└─┬ yargs@17.3.1
  ├─┬ cliui@7.0.4
  │ ├── string-width@4.2.3 deduped
  │ ├─┬ strip-ansi@6.0.1
  │ │ └── ansi-regex@5.0.1
  │ └─┬ wrap-ansi@7.0.0
  │   ├─┬ ansi-styles@4.3.0
  │   │ └─┬ color-convert@2.0.1
  │   │   └── color-name@1.1.4
  │   ├── string-width@4.2.3 deduped
  │   └── strip-ansi@6.0.1 deduped
  ├── escalade@3.1.1
  ├── get-caller-file@2.0.5
  ├── require-directory@2.1.1
  ├─┬ string-width@4.2.3
  │ ├── emoji-regex@8.0.0
  │ ├── is-fullwidth-code-point@3.0.0
  │ └── strip-ansi@6.0.1 deduped
  ├── y18n@5.0.8
  └── yargs-parser@21.0.0

Every one of those is yet

And multiply all of that by every user of this package as a library (that's 1000s and 1000s of users).

Doesn't seem like it would be better to remove those 15 packages that are not needed by people using this as a library?

As another possibility, you could make showdown-lib (the lib only version) and then either keep showdown as is or make showdown the cli part plus the dependencies on showdown-lib.

Note: I get that I can fork this project and do it myself. I thought I'd ask though before I go do that.

SyntaxRules commented 2 years ago

I love the idea. Personally I would prefer to make showdown the core library and add a new package called showdown-cli. To me it seems the cli is less used then the library itself.

Let me know what idea you might have, and if you are adventurous enough to create a PR, I can even create a repo for it.

tivie commented 2 years ago

The issue is that the CLI is dependant on some functionalities and implementation details of the main library, it might become a challenge to maintain them in sync. Also, version mismatch might occur.

However, the CLI does not really need yargs.

I think a more favourable approach would be to refactor the CLI, to remove yargs dependency, and keep the libraries together. All yargs is doing is making it easier to create the CLI code boilerplate. Shouldn't be too hard to refactor, since the CLI doesn't implement many commands anyway.

tivie commented 2 years ago

This is fixed in the latest release