alias-hq icon indicating copy to clipboard operation
alias-hq copied to clipboard

Refactor CLI to a different module?

Open mikew opened this issue 1 year ago • 4 comments

Love the idea of the module, but for people who don't want to use the CLI ... quite a lot of modules are installed:

Yeah it's 48 thousand lines, I can't paste it in GitHub, Gist, or Pastebin, but the bulk of them come from jscodeshift, which isn't needed for people not looking to use the CLI.

mikew avatar Dec 02 '23 17:12 mikew

Hmmm, interesting!

I hadn't really thought about that.

I found this online tool which visualises the size:

https://arve0.github.io/npm-download-size/#alias-hq

image

From that it looks like jscodeshift is maybe 60% of the 5MB install.

I guess I would have to weigh up the pros and cons of whether it actually matters, vs maintaining two separate repositories, docs, issues, awareness, etc.

FWIW the CLI is also used to let folks configure paths and plugins which is nice as adding TS aliases by hand is a bit cumbersome.

Can you make any cases for why saving ~3MB really matters?

davestewart avatar Dec 04 '23 19:12 davestewart

Having reviewed my own docs again (it's been a while!) the CLI also helps folks debug their setups, as well as develop and publish plugins, so I think I'll close this issue for now; it's just simpler to keep everything together.

Hopefully a bit of the context there has been helpful though!

davestewart avatar Dec 04 '23 19:12 davestewart

Doesn't necessarily have to be two repositories, monorepos exist (but are not without complications, admittedly). Also, you only mentioned jscodeshift when I'm guessing these are only to do with the CLI:

  • jscodeshift
  • inquirer
  • vue-jscodeshift-adapter
  • node-fetch
  • colors

Which account for ~87% of the size. And the original 5MB isn't accurate:

$ du -sh node_modules 
520M    node_modules

mike at test-vscode-remote-arch in ~/Work/promoboxx/react-scripts-vite (swap-plugins●) 
$ pnpm install --save alias-hq

   ╭──────────────────────────────────────────────────────────────────╮
   │                                                                  │
   │                Update available! 8.6.11 → 8.11.0.                │
   │   Changelog: https://github.com/pnpm/pnpm/releases/tag/v8.11.0   │
   │                Run "pnpm add -g pnpm" to update.                 │
   │                                                                  │
   │      Follow @pnpmjs for updates: https://twitter.com/pnpmjs      │
   │                                                                  │
   ╰──────────────────────────────────────────────────────────────────╯

 WARN  deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
 WARN  deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
 WARN  deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
 WARN  deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
 WARN  deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
 WARN  deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
 WARN  deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
 WARN  deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
 WARN  deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
Packages: +156
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 756, reused 724, downloaded 0, added 143, done

dependencies:
+ alias-hq 6.2.3

Done in 5.8s

mike at test-vscode-remote-arch in ~/Work/promoboxx/react-scripts-vite (swap-plugins●) 
$ du -sh node_modules         
546M    node_modules

Edit: Just found about about this tool which seems more accurate: https://pkg-size.dev/alias-hq

mikew avatar Dec 04 '23 19:12 mikew

That's a nice tool! Though I'm not sure I totally understand the output for our use case; we want to know the total installed size of X vs Y dependencies, right?

So I did a quick test (Basic CLI = plugin management, Full CLI = code refactoring):

Alias CLI (Basic) CLI (Full)
Deps 3 4 7
Total Deps 4 95 197
Size 504 KB 30 MB 58 MB

So I think this proves your point very well... I'm just not convinced that it warrants a refactor, publishing to separate NPM packages, etc.

Although thinking about it, a workable option might be for developers who wish to create plugins or refactor code to install from GitHub using an alias:

npm i alias-cli@github:davestewart/alias-hq

I've just attempted this, and it works, as in, the user can run the cli:

dave@ds-m3 aliased % npm i alias-cli@github:davestewart/alias-hq
dave@ds-m3 aliased % alias-hq

  == Alias HQ ==

  -- Main Menu --

? What do you want to do? (Use arrow keys)
❯ - Configure paths 
  - Help 
  - Exit 

I tell you what, let me experiment with a stripped down version published to a personal namespace, then if it works, I think it could be a nice introduction.

I'm not going to get time to do this probably until Christmas though, but if you don't mind waiting (or installing!) until then, I will defo take a look.

davestewart avatar Dec 05 '23 10:12 davestewart