Closed stevemao closed 5 years ago
Great idea! Would you like to makeapullrequest.com?
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!
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.
@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 :(
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.
@kentcdodds any news about this?
Got a few things on my plate today. Will hopefully get to it tonight though. It's in my inbox.
No problem & sorry for my eagerness. Just planning my "webpack-validator" evening for tomorrow. Home alone ;)
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.
Oh snap
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?
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 :-)
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
@nyrosmith this definitely isn't a final best solution, but if you just need something in the short term that will work :)
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?
@kentcdodds Can we make it this way? If yes I would make the appropriate PRs to both repos.
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!
@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\"
@xjamundx of course. But for my playground I just ignored them.
I'd suggest that setting an On Hold tag should always imply adding a comment what is holding up the task.
Sorry for Delay. Weekends belong to the family. Implementing the CLI is on hold until configuration-validator gets its new API.
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. :)