rblopes / generator-phaser-plus

[🛑 DISCONTINUED] It has been a long journey but development of `generator-phaser-plus` is now over. I recommend you have a look and fork `yandeu/phaser-project-template` instead.
https://github.com/yandeu/phaser-project-template
MIT License
146 stars 13 forks source link

Object generator fails with error #11

Closed budda closed 8 years ago

budda commented 8 years ago

When trying to generate an object i get:

$ yo phaser-plus:object
Object class generator:
? What's the name of the object? Shape
? (Optional) What does this object do? Represents a single shape on the grid.
? From which base class this object extends? Group
? Is that OK to proceed? Yes
events.js:154
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read property 'objects' of undefined
    at module.exports.yeoman.Base.extend.writing (/usr/local/lib/node_modules/generator-phaser-plus/generators/object/index.js:16:38)
    at Object.<anonymous> (/usr/local/lib/node_modules/generator-phaser-plus/node_modules/yeoman-generator/lib/base.js:436:25)
    at /usr/local/lib/node_modules/generator-phaser-plus/node_modules/run-async/index.js:24:25
    at /usr/local/lib/node_modules/generator-phaser-plus/node_modules/yeoman-generator/lib/base.js:448:8
    at processImmediate [as _immediateCallback] (timers.js:383:17)
budda commented 8 years ago

If it is of use:

$ yo --version
1.7.0

Not sure how to tell what version of the Phaser-plus generator i'm using!

rblopes commented 8 years ago

Newer versions of the generator rely on a hidden .yo-rc.json config file. Such file is required by Yeoman to properly determine where the project root is located. At the moment, only info about the source structure is stored there, and these are read by the subgenerators when writing the files to their proper locations.

In your case, the config file of your project is missing, much probably because it was created by the old Slush generator — projects created with this Yeoman generator always have one. The subgenerator should work as expected after you create one. Currently, a .yo-rc.json file looks like in the following sample. Remember to adjust the file paths to match your project. If you have other projects created with slush-phaser-plus, you'll have to make the same adjustments for compatibility with Yeoman.

{
  "generator-phaser-plus": {
    "dirs": {
      "objects": "src/objects",
      "plugins": "src/plugins",
      "states": "src/states"
    },
    "states-module": "src/states.js"
  }
}

The fix is ready but planned for the next release, along several other changes.

budda commented 8 years ago

okay i created the missing file and populated it with paths to match what had previously been created by your generator:

{
  "generator-phaser-plus": {
    "dirs": {
      "objects": "src/scripts/app/objects",
      "plugins": "src/scripts/app/plugins",
      "states": "src/scripts/app/states"
    },
    "states-module": "src/scripts/states.js"
  }
}

Worked fine, thanks for the info!