cost-of-modules icon indicating copy to clipboard operation
cost-of-modules copied to clipboard

Extract CLI from module

Open RoM4iK opened this issue 7 years ago • 10 comments

Hi @siddharthkp, thank you for good package. I think your package shouldn't be bound to command line interface and can be decomposed to API and CLI, to allow users write their own interfaces. What do you think about this?

RoM4iK avatar Apr 23 '17 19:04 RoM4iK

@RoM4iK Ooh, I like that idea.

It is easily achievable too. All the heavy lifting happens in helpers functions and the cli entry point reads the options and calls the helper functions

Would you like to have a go at this?

P.S. What is the application that you have in mind for this? It would probably make more sense the whole service is exposed as an http API that accepts the contents of package.json and a returns a json with size information.

siddharthkp avatar Apr 23 '17 21:04 siddharthkp

@siddharthkp, I just thought about creating http API, as you said. I will start working on core extraction.

RoM4iK avatar Apr 24 '17 13:04 RoM4iK

Sorry man, but I can't agree with your code style and lint config. So I gave up on this. I won't close PR, since this idea still has sense.

RoM4iK avatar Apr 25 '17 20:04 RoM4iK

Ah, don't give up because of that :pensive:

Can we use prettier?

siddharthkp avatar Apr 26 '17 03:04 siddharthkp

Yes, we can, but this will make a lot of changes. If u want to go this way, I'll help you:)

RoM4iK avatar Apr 26 '17 05:04 RoM4iK

I have added prettier, would you like to review https://github.com/siddharthkp/cost-of-modules/pull/38?

siddharthkp avatar Apr 26 '17 07:04 siddharthkp

Was there any progress made on this in the end? I'm pretty keen on tying this module in with my build system, but I'd like to use a custom reporter function. Something like:

const costOfModules = require('cost-of-modules')
const data = await costOfModules.scan('.')
/*
[
  {name: 'express', children: 112, size: '64.2M'}
]
*/
myReport(data)

rgrannell1 avatar Jul 08 '18 19:07 rgrannell1

@rgrannell1 Would you like to take a shot at it?

https://github.com/siddharthkp/cost-of-modules/blob/master/src/index.js contains the required flow

siddharthkp avatar Jul 09 '18 05:07 siddharthkp

@siddharthkp Sure, thanks for pointing me to that file. I'm working on a forked copy at the moment, as soon as I get tests passing I'll send in a PR.

Do you have any objections to me adding prettier to a dev dependency, and rewiring package.json to look for local copies of babel, prettier instead of globally installed versions? It makes it a bit quicker for contributors to get set up :smile:. E.g

node_modules/.bin/prettier --write --single-quote --no-semi --trailing-comma es5

rgrannell1 avatar Jul 09 '18 22:07 rgrannell1

Sure, go for it

siddharthkp avatar Jul 10 '18 01:07 siddharthkp