Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract CLI from module #37

Open
RoM4iK opened this issue Apr 23, 2017 · 10 comments
Open

Extract CLI from module #37

RoM4iK opened this issue Apr 23, 2017 · 10 comments

Comments

@RoM4iK
Copy link
Contributor

RoM4iK commented Apr 23, 2017

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?

@siddharthkp
Copy link
Owner

@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.

@RoM4iK
Copy link
Contributor Author

RoM4iK commented Apr 24, 2017

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

@RoM4iK
Copy link
Contributor Author

RoM4iK commented Apr 25, 2017

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.

@siddharthkp
Copy link
Owner

Ah, don't give up because of that 😔

Can we use prettier?

@RoM4iK
Copy link
Contributor Author

RoM4iK commented Apr 26, 2017

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

@siddharthkp
Copy link
Owner

I have added prettier, would you like to review #38?

@rgrannell1
Copy link

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)

@siddharthkp
Copy link
Owner

@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

@rgrannell1
Copy link

@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 😄. E.g

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

@siddharthkp
Copy link
Owner

Sure, go for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants