Feature/yeoman generators#93
Conversation
Changes the structure to the init feature a bit. We’re now making the parser validate everything, as we can later run the inquirer prompt after running yeoman, reading from a json file. This will allow us to have a more fluid process and removes a lot of «trash» code. Disabled listing for now, as this is work in progress.
|
|
||
| class WebpackGenerator extends Generator { | ||
| constructor(args, opts) { | ||
| super(args, opts); |
There was a problem hiding this comment.
No need for constructor in this case.
There was a problem hiding this comment.
Yeoman needs it, and I'm passing something to it later
Makes it possible to make a inquirer prompt with a remote package.
| @@ -1,4 +1,5 @@ | |||
| const Generator = require('yeoman-generator'); | |||
| // eslint-disable-next-line | |||
There was a problem hiding this comment.
Why have you disabled the next line? AFAIK destructuring won't work in Node 4.x
| "webpack-addons-preact" | ||
| ] | ||
| } | ||
| } No newline at end of file |
| inject() {} | ||
| } | ||
|
|
||
| module.exports = WebpackGenerator; |
There was a problem hiding this comment.
Why not export directly in the declaration at L5?
| * @returns { <Function|Error> } initTransform - Initializes the scaffold in yeoman | ||
| */ | ||
|
|
||
| module.exports = function creator(pkgPaths,opts) { |
| //eslint-disable-next-line | ||
| } catch (e) {} | ||
| } | ||
| else if(!options) { |
| } catch (e) {} | ||
| } | ||
| else if(!options) { | ||
| const env = yeoman.createEnv(); |
There was a problem hiding this comment.
Can be extracted from here and L18
|
|
||
| module.exports = function prompt(questions, config) { | ||
| inquirer.prompt(questions).ui.process | ||
| .reduce(function (newOpts, ans) { |
| module.exports = function prompt(questions, config) { | ||
| inquirer.prompt(questions).ui.process | ||
| .reduce(function (newOpts, ans) { | ||
| return attachAnswers(newOpts, ans); |
There was a problem hiding this comment.
Actually, function(newOpts, ans) {...} -> attachAnswers
| describe('validate-options', () => { | ||
| //eslint-disable-next-line | ||
| const {validateOptions} = require('../../__mocks__/parser/validate-options.mock'); | ||
| const {validateOptions} = require('../../__mocks__/creator/validate-options.mock'); |
There was a problem hiding this comment.
Still eslint-disabled. This won't work in Node 4.x
| @@ -17,7 +14,7 @@ const Rx = require('rx'); | |||
|
|
|||
| module.exports = function initializeInquirer(pkg) { | |||
| if(pkg.length == 0) { | |||
There was a problem hiding this comment.
Should we check if pkg is Array? Otherwise this will be a run-time error.
There was a problem hiding this comment.
Is default in yargs, in the future, when we're revamping the ui, perhaps.
| return prompt(Rx.Observable.from(questions), initialConfig); | ||
| return creator(); | ||
| } | ||
| else { |
There was a problem hiding this comment.
No need for this else here.
Removes inquirer, we’re not using it explicitly anymore. Fixed some review mistakes.
|
@okonet I've removed |
Changes the structure to the init feature a bit. We’re now making the parser validate everything, as we can later run the inquirer prompt after running yeoman, reading from a json file. This will allow us to have a more fluid process and removes a lot of «trash» code. Disabled listing for now, as this is work in progress.
This is the groundwork for me to align my work with the AST transformations @pksjce is doing. We're further gonna integrate the prompting from yeoman and we expect to get a config object back from the generator we run.