kentcdodds / webpack-validator-DEPRECATED

Use this to save yourself some time when working on a webpack configuration.
MIT License
93 stars 8 forks source link

CLI support? #5

Closed stevemao closed 5 years ago

stevemao commented 8 years ago
npm install -g webpack-validator
webpack-validator webpack.config.js
Valid!
kentcdodds commented 8 years ago

Great idea! Would you like to makeapullrequest.com?

nyrosmith commented 8 years ago

I am reading https://leanpub.com/theclibook ATM and would love to make a PR when I am done. If you can wait a few days I am in!

kentcdodds commented 8 years ago

Cool! I'm sure it can wait a bit. Please let me know what you're thinking about doing before you start so we can talk about what kind of implementation we want.

nyrosmith commented 8 years ago

@kentcdodds I'd like to create a repo for fiddling around the cli-tool and to have a discussion basis. Is this ok for you?

Edit I created a playground repo to get started. I have no idea how to get the result of the validations printed to the console :(

kentcdodds commented 8 years ago

I'd like to create a repo for fiddling around the cli-tool and to have a discussion basis. Is this ok for you?

Totally!

I have no idea how to get the result of the validations printed to the console :(

Yeah, right now the configuration-validator module itself does the logging. It should work just fine as you're using it though... I'll be able to give more direction soonish hopefully.

nyrosmith commented 8 years ago

@kentcdodds any news about this?

kentcdodds commented 8 years ago

Got a few things on my plate today. Will hopefully get to it tonight though. It's in my inbox.

netflix-full-house-fuller-3ornjKEREhVsOmQG1q

nyrosmith commented 8 years ago

No problem & sorry for my eagerness. Just planning my "webpack-validator" evening for tomorrow. Home alone ;)

xjamundx commented 8 years ago

command line already supported!

Just add this to your package.json file under scripts:

"validate": "node -e 'require(\"webpack-validator\")(require(\"./webpack.config.js\"))'",

And then call npm run validate

Or call this directly:

node -e "require('webpack-validator')(require('./webpack.config.js'))"

Putting a wrapper around that should be pretty straight forward :) Mainly just need to add an exit code on failure.

kentcdodds commented 8 years ago

Oh snap reaction-13ywUiX9SwSlGM

nyrosmith commented 8 years ago

Maybe I am just too stupid. @xjamundx can you explain why my solution doesnot print to the console? And why call node inside a Node application?

kentcdodds commented 8 years ago

can you explain why my solution doesnot print to the console

@nyrosmith, I'm not sure why your solution's not priting to the console.

why call node inside a Node application

Actually, he's suggesting that you do this via the command line, not in a node application/code :-)

nyrosmith commented 8 years ago

I understand. But making this direct via cli eliminates lots of possibilities eg nice output of what went wrong, defining configs via regex, ... I'd like to make it more user friendly like npm or git cli

xjamundx commented 8 years ago

@nyrosmith this definitely isn't a final best solution, but if you just need something in the short term that will work :)

nyrosmith commented 8 years ago

Ok, I fiddled around and got it working. The problem of getting no console output was just because if validation succeeds there is nothing but silence...

I had to make the following changes:

I changed the sources locally and included the dist output to folders of my playground. @kentcdodds Is it ok if I change configuration-validator & webpack-validator to this behavior?

nyrosmith commented 8 years ago

@kentcdodds Can we make it this way? If yes I would make the appropriate PRs to both repos.

kentcdodds commented 8 years ago

configuration-validator returns an object {errors, warnings, config} so we know what happened

:+1:

I also removed the configName prop

Not sure what you mean, but let's see the diff :+1:

webpack-validator returns the result object from configuration-validator

That wouldn't allow me to do:

module.exports = validateWebpack(config)

in my webpack config, which was kind of my original use case, but I think it's acceptable to change that to:

validateWebpack(config)
module.exports = config

So we're good to discuss that.

The CLI gets the validation result and can provide nice messages

Not sure what you'd be changing here, but let's see it!

Is it ok if I change configuration-validator & webpack-validator to this behavior?

Let's see a diff in a pull request. I think that's :+1:

Thanks!

xjamundx commented 8 years ago

@nyrosmith I think you also want to add proper exit codes, because then you could do something like this, which will only show "webpack validated" on success

node -e 'require(\"webpack-validator\")(require(\"./webpack.config.js\"))' && echo \"webpack validated\"
nyrosmith commented 8 years ago

@xjamundx of course. But for my playground I just ignored them.

jonathanglasmeyer commented 8 years ago

I'd suggest that setting an On Hold tag should always imply adding a comment what is holding up the task.

nyrosmith commented 8 years ago

Sorry for Delay. Weekends belong to the family. Implementing the CLI is on hold until configuration-validator gets its new API.

jonathanglasmeyer commented 8 years ago

No stress. My weekends are the only part of the week were I have time for OSS stuff, so i'll be only active from Fri-Sun. Shiftwork. :)