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

Adapt changes of yeoman generator 1.0.0 #170

Merged
merged 23 commits into from
Dec 9, 2016
Merged

Conversation

mischah
Copy link
Member

@mischah mischah commented Dec 3, 2016

Hej, I need help 😖

I’m stucked with passing the namespace argument when composing with generator:subgenerator.

See: https://github.com/yeoman/generator-generator/compare/yeoman-generator/1.0.0?expand=1#diff-2018087f584c4398b5c3a23fc0e5f9dbL63

I’m confused.

All set and done

🎉

@mischah mischah force-pushed the yeoman-generator/1.0.0 branch from 484b4c6 to 6fdcf4e Compare December 3, 2016 21:00
});

this.composeWith('generator:subgenerator', {
this.composeWith(require.resolve('../subgenerator'), {
arguments: ['app']
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be the name of the argument you want to pass in. It's treated the same as an option now.

{namespace: 'app'}

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Tried that too. Doesn’t work as well :(
Pushed that for you one minute ago.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. Missed one line. It does work.

generators.Base.apply(this, arguments);
module.exports = class extends Generator {
constructor(args, opts) {
super(args, opts);

this.argument('namespace', {
type: String,
required: true,
description: 'Generator namespace'
Copy link
Member

Choose a reason for hiding this comment

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

Old error, but that key as always been desc instead of the full description.

@mischah mischah force-pushed the yeoman-generator/1.0.0 branch from 965bd76 to f66b24b Compare December 3, 2016 22:46
Using `namespace` leads to `this.options.namespace ===  'generator:subgenerator'` instead of `this.options.namespace ===  'app'`
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 97.619% when pulling 02b7f29 on yeoman-generator/1.0.0 into e40c828 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.368% when pulling 02b7f29 on yeoman-generator/1.0.0 into e40c828 on master.

@mischah
Copy link
Member Author

mischah commented Dec 3, 2016

Passing the arguments works now. Thanks @SBoudrias

But I had to rename the argument.
Using namespace leads to this.options.namespace === 'generator:subgenerator' instead of this.options.namespace === 'app'

I guess because of the parameter of composeWith named namespace ?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.368% when pulling cba5e01 on yeoman-generator/1.0.0 into e40c828 on master.

@mischah mischah changed the title [WIP] Adapt changes of yeoman generator 1.0.0 Adapt changes of yeoman generator 1.0.0 Dec 3, 2016
@@ -1,6 +1,7 @@
sudo: false
language: node_js
node_js:
- stable
- 7
Copy link
Member

Choose a reason for hiding this comment

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

node is the name for the latest stable version. I think I prefer this to 7 given it won't go into LTS.


this.argument('namespace', {
this.option('name', {
Copy link
Member

Choose a reason for hiding this comment

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

This can stay an argument. The issue is that namespace was a "reserved" name for yeoman-environment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mhm. Using this.argument('name', { leads to failing test.

Tests are failing with:

  1) generator:app defaults "before all" hook:
     Error: Did not provide required argument name!
      at .<anonymous> (node_modules/yeoman-generator/lib/index.js:335:33)
      at Array.forEach (native)
      at Base.checkRequiredArgs (node_modules/yeoman-generator/lib/index.js:331:19)
      at Base.parseOptions (node_modules/yeoman-generator/lib/index.js:316:8)
      at argument (node_modules/yeoman-generator/lib/index.js:246:8)
      at new <anonymous> (subgenerator/index.js:9:447)
      at Environment.instantiate (node_modules/yeoman-environment/lib/environment.js:336:10)
      at composeWith (node_modules/yeoman-generator/lib/index.js:485:26)
      at default (app/index.js:9:2522)
      at Object.<anonymous> (node_modules/yeoman-generator/lib/index.js:387:23)

  2) generator:subgenerator "before all" hook:
     Uncaught Error: Did not provide required argument name!
      at .<anonymous> (node_modules/yeoman-generator/lib/index.js:335:33)
      at Array.forEach (native)
      at Base.checkRequiredArgs (node_modules/yeoman-generator/lib/index.js:331:19)
      at Base.parseOptions (node_modules/yeoman-generator/lib/index.js:316:8)
      at argument (node_modules/yeoman-generator/lib/index.js:246:8)
      at new <anonymous> (subgenerator/index.js:9:447)
      at Environment.instantiate (node_modules/yeoman-environment/lib/environment.js:336:10)
      at Environment.create (node_modules/yeoman-environment/lib/environment.js:313:15)
      at RunContext._run (node_modules/yeoman-test/lib/run-context.js:90:29)
      at RunContext.<anonymous> (node_modules/yeoman-test/lib/run-context.js:58:10)

Copy link
Member

Choose a reason for hiding this comment

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

That could be a bug. I'll investigate!

Copy link
Member

Choose a reason for hiding this comment

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

Actually that's pretty simple. It's breaking because generator-node is pre 1.0, so it doesn't recognize the arguments being passed as part of the options.

We should fix that in yeoman-generator so we keep compatibility with older generators too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have to change something over here?

@mischah
Copy link
Member Author

mischah commented Dec 4, 2016

Guess I’m ready to review now.

About failing tests:
They are green locally.

On travis it says:

1) generator:app defaults "before all" hook:
     Uncaught Error: No ESLint configuration found.

I guess that is because the latest version of generator-node/generators/eslint stores the ESLint settings in the package.json?

@SBoudrias
Copy link
Member

Also, could we copy the packages version from our own package.json? I think that'd simplify version bumping as we'd always match generator-generator version with the version it generates.

@mischah
Copy link
Member Author

mischah commented Dec 4, 2016

How can we get the content of the package.json of generator-generator?

I only have nasty ideas like regexing this.resolved which is in my case:

'/Users/mkuehnel/Documents/Projects/generator-generator/app/index.js'

from the package.json of generator-generator
'yeoman-generator': '^0.23.0',
chalk: '^1.0.0',
yosay: '^1.0.0'
'yeoman-generator': 'yeoman/generator#bump-version-for-updating-generator-generator',
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to change this when v1.0.0 is released.

Copy link
Member

Choose a reason for hiding this comment

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

We should update the tests to also read from package.json like the generator

"yeoman-generator": "^0.23.3",
"yosay": "^1.0.2"
"superb": "^1.3.0",
"yeoman-generator": "yeoman/generator#bump-version-for-updating-generator-generator",
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to change this when v1.0.0 is released.

@mischah mischah force-pushed the yeoman-generator/1.0.0 branch from 4a76c5a to 3071aa1 Compare December 4, 2016 18:42
@mischah
Copy link
Member Author

mischah commented Dec 4, 2016

The failing tests are caused by a bug of gulp-eslint adametry/gulp-eslint#186 😖

@mischah mischah force-pushed the yeoman-generator/1.0.0 branch from e47decc to 249963f Compare December 4, 2016 19:59
@shinnn
Copy link

shinnn commented Dec 4, 2016

bug of gulp-eslint

No. (edit) Maybe, no.

@@ -62,15 +62,17 @@ module.exports = class extends Generator {

writing() {
var pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
var generatorGeneratorPkg = this.fs.readJSON(path.normalize(this.resolved.replace(/app\/index.js/, 'package.json')));
Copy link
Member

Choose a reason for hiding this comment

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

you can just use require('../package.json')

Copy link
Member Author

Choose a reason for hiding this comment

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

🙈 Thanks and done.

@@ -2,5 +2,6 @@ sudo: false
language: node_js
node_js:
- stable
- 6
- 5
Copy link
Member

Choose a reason for hiding this comment

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

Let's drop 5 and replace stable by node.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@mischah
Copy link
Member Author

mischah commented Dec 4, 2016

One last to do on my site:
ES6ify generator-generator

@mischah
Copy link
Member Author

mischah commented Dec 4, 2016

Question:
What do do think about dropping the validation: https://github.com/yeoman/generator-generator/pull/170/files#diff-2018087f584c4398b5c3a23fc0e5f9dbL26

validate: function (str) {
  return str.length > 'generator-'.length;
}

It’s dead code because of:

function makeGeneratorName(name) {
  name = _.kebabCase(name);
  name = name.indexOf('generator-') === 0 ? name : 'generator-' + name;
  return name;
}

The generated generator isn’t ES6ified for now.
@mischah mischah force-pushed the yeoman-generator/1.0.0 branch from 6a8469e to e7abcd8 Compare December 4, 2016 22:03
@mischah
Copy link
Member Author

mischah commented Dec 4, 2016

generator-generator is successfully ES6ified 🎉

The generated generator is still using ES5 syntax.
And I don’t want to change this for now because of weird Linting errors on Travis CI 😕

@mischah
Copy link
Member Author

mischah commented Dec 4, 2016

Please remember to squash that mess when merging 🙈

@SBoudrias
Copy link
Member

Hey, you can use 1.0.0-rc1 and move back to using arguments.

Until generator-node goes to 1.0, you'll need pass the arguments as before with {arguments: ['foo']}

@mischah
Copy link
Member Author

mischah commented Dec 8, 2016

Hey, you can use 1.0.0-rc1 and move back to using arguments.

Done

Until generator-node goes to 1.0, you'll need pass the arguments as before with {arguments: ['foo']}

Done. That’s slightly confusing 😆

@mischah mischah force-pushed the yeoman-generator/1.0.0 branch from ab06347 to 2ff0754 Compare December 8, 2016 23:24
@SBoudrias
Copy link
Member

@mischah code looks good! How do you feel about the API changes overall?

@mischah
Copy link
Member Author

mischah commented Dec 9, 2016

@SBoudrias I like them a lot. Especially the new composeWith signature is much more readable and easier to understand 💖

@SBoudrias SBoudrias merged commit 640bdc5 into master Dec 9, 2016
@SBoudrias SBoudrias deleted the yeoman-generator/1.0.0 branch December 9, 2016 19:07
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.

4 participants