Skip to content

Feature/yeoman generators#93

Merged
evenstensberg merged 11 commits into
masterfrom
feature/yeoman-generators
Mar 31, 2017
Merged

Feature/yeoman generators#93
evenstensberg merged 11 commits into
masterfrom
feature/yeoman-generators

Conversation

@evenstensberg

@evenstensberg evenstensberg commented Mar 21, 2017

Copy link
Copy Markdown
Member

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.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for constructor in this case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeoman needs it, and I'm passing something to it later

Comment thread lib/creator/generators/index.js Outdated
@@ -1,4 +1,5 @@
const Generator = require('yeoman-generator');
// eslint-disable-next-line

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you disabled the next line? AFAIK destructuring won't work in Node 4.x

@evenstensberg evenstensberg changed the title [WIP] Feature/yeoman generators Feature/yeoman generators Mar 29, 2017
Comment thread .yo-rc.json
"webpack-addons-preact"
]
}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new line

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is deleted.

Comment thread lib/creator/generators/index.js Outdated
inject() {}
}

module.exports = WebpackGenerator;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not export directly in the declaration at L5?

Comment thread lib/creator/index.js Outdated
* @returns { <Function|Error> } initTransform - Initializes the scaffold in yeoman
*/

module.exports = function creator(pkgPaths,opts) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

White space after ,

Comment thread lib/creator/init-transform.js Outdated
//eslint-disable-next-line
} catch (e) {}
}
else if(!options) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else if isn't needed.

Comment thread lib/creator/init-transform.js Outdated
} catch (e) {}
}
else if(!options) {
const env = yeoman.createEnv();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be extracted from here and L18

Comment thread lib/inquirer-prompt.js Outdated

module.exports = function prompt(questions, config) {
inquirer.prompt(questions).ui.process
.reduce(function (newOpts, ans) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function -> =>

Comment thread lib/inquirer-prompt.js Outdated
module.exports = function prompt(questions, config) {
inquirer.prompt(questions).ui.process
.reduce(function (newOpts, ans) {
return attachAnswers(newOpts, ans);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, function(newOpts, ans) {...} -> attachAnswers

Comment thread lib/creator/validate-options.spec.js Outdated
describe('validate-options', () => {
//eslint-disable-next-line
const {validateOptions} = require('../../__mocks__/parser/validate-options.mock');
const {validateOptions} = require('../../__mocks__/creator/validate-options.mock');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still eslint-disabled. This won't work in Node 4.x

Comment thread lib/initialize.js
@@ -17,7 +14,7 @@ const Rx = require('rx');

module.exports = function initializeInquirer(pkg) {
if(pkg.length == 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check if pkg is Array? Otherwise this will be a run-time error.

@evenstensberg evenstensberg Mar 30, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is default in yargs, in the future, when we're revamping the ui, perhaps.

Comment thread lib/initialize.js Outdated
return prompt(Rx.Observable.from(questions), initialConfig);
return creator();
}
else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this else here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code now

Removes inquirer, we’re not using it explicitly anymore. Fixed some
review mistakes.
@evenstensberg

Copy link
Copy Markdown
Member Author

@okonet I've removed inquirer.prompt, can look on commit history if we need to use it again.

@okonet okonet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@evenstensberg
evenstensberg merged commit 16b80a0 into master Mar 31, 2017
@evenstensberg
evenstensberg deleted the feature/yeoman-generators branch March 31, 2017 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants