yeoman / yo

CLI tool for running Yeoman generators
http://yeoman.io
BSD 2-Clause "Simplified" License
3.84k stars 398 forks source link

`generator.run is not a function` error after installing 5.0.0 #796

Closed sneridagh closed 10 months ago

sneridagh commented 10 months ago

Type of issue

Bug


My environment

Expected behavior

It does not break after a breaking is released. If a breaking change is issued (thus, the breaking), then provide upgrade notes.

Current behavior

After running my generator command (working on 4.x.x):

yo @plone/volto my-volto-app --description "test volto project" --volto . --skip-install --no-interactive

I got

generator.run is not a function
sneridagh commented 10 months ago

I've been debugging and it seems that the culprit is a call to a subgenerator using this.composeWith in my generator. It seems the subgenerator is never called, it just bails out with the generator is not a function error.

from: https://github.com/plone/volto/blob/main/packages/generator-volto/generators/app/index.js#L262-L268

    this.composeWith(require.resolve('../addon'), {
      addonName: this.opts.defaultAddonName
        ? this.opts.defaultAddonName
        : `volto-${this.globals.projectName}`,
      outputpath: base,
      interactive: false,
    });

The subgenerator works well standalone.

sneridagh commented 10 months ago

@mshima I saw you introduced a bunch of async/await here and there, I bet it's one missing somewhere.

sneridagh commented 10 months ago

Ok, I've found the culprit, the yeoman-generator version in the generator was too old. I've updated to the latest (non ESM) version and it works well there.

However, message to the maintainers: Breaking things without proper release notes is not polite in OSS. A simple table with a version compatibility matrix will suffice, and will serve as documentation for yourself too.