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

Feature/yeoman generators #93

Merged
merged 11 commits into from
Mar 31, 2017
Merged

Feature/yeoman generators #93

merged 11 commits into from
Mar 31, 2017

Conversation

evenstensberg
Copy link
Member

@evenstensberg evenstensberg commented Mar 21, 2017

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

@@ -1,4 +1,5 @@
const Generator = require('yeoman-generator');
// eslint-disable-next-line
Copy link
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
"webpack-addons-preact"
]
}
}
Copy link
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
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.

inject() {}
}

module.exports = WebpackGenerator;
Copy link
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?

* @returns { <Function|Error> } initTransform - Initializes the scaffold in yeoman
*/

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

Choose a reason for hiding this comment

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

White space after ,

//eslint-disable-next-line
} catch (e) {}
}
else if(!options) {
Copy link
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.

} catch (e) {}
}
else if(!options) {
const env = yeoman.createEnv();
Copy link
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

@@ -9,20 +9,20 @@ const chalk = require('chalk');
* @param { Object } questions - questions to be prompted in RxJS format
* @param { Object } config - Configuration passed from an addon to be included in
* answers, later sent down to the parser
* @returns { Function } Parser function that validates the answers, later transforming
* @returns { Function } Creator function that validates the answers, later transforming
* the answers to an webpack configuration
*/

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

Choose a reason for hiding this comment

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

function -> =>

@@ -9,20 +9,20 @@ const chalk = require('chalk');
* @param { Object } questions - questions to be prompted in RxJS format
* @param { Object } config - Configuration passed from an addon to be included in
* answers, later sent down to the parser
* @returns { Function } Parser function that validates the answers, later transforming
* @returns { Function } Creator function that validates the answers, later transforming
* the answers to an webpack configuration
*/

module.exports = function prompt(questions, config) {
inquirer.prompt(questions).ui.process
.reduce(function (newOpts, ans) {
return attachAnswers(newOpts, ans);
Copy link
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

@@ -2,7 +2,7 @@

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

@@ -17,7 +14,7 @@ const Rx = require('rx');

module.exports = function initializeInquirer(pkg) {
if(pkg.length == 0) {
Copy link
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.

Copy link
Member Author

@evenstensberg evenstensberg Mar 30, 2017

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.

@@ -17,7 +14,7 @@ const Rx = require('rx');

module.exports = function initializeInquirer(pkg) {
if(pkg.length == 0) {
return prompt(Rx.Observable.from(questions), initialConfig);
return creator();
}
else {
Copy link
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
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
Member Author

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

Copy link
Contributor

@okonet okonet left a comment

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