saojs / sao

⚔ Futuristic scaffolding tool
https://sao.vercel.app
MIT License
1.05k stars 61 forks source link

Question regarding packages as sub-generators #158

Closed ghost closed 3 years ago

ghost commented 3 years ago

The documentation for v1 has a section about sub-generators, explaining their usage, more specifically, in two different manners, being them, as a path to the generator, or a package:

module.exports = {
  subGenerators: [
    {
      name: 'foo',
      // A path to the generator, relative to the saofile
      generator: './generators/foo'
    },
    {
      name: 'bar',
      // Or use a package, like `sao-bar` here
      // It's also resolved relative to the saofile
      generator: 'sao-bar'
    }
  ]
}

From where exactly the package is retrieved? i'm not sure if it's from npm, or from the filesystem, also, does it works with monorepos?

egoist commented 3 years ago

it follows the same rule of the cli pattern, sao ./foo will fetch the generator from the local folder ./foo, sao nm will instead use sao-npm the npm package.

egoist commented 3 years ago

but in this case the npm package is resolved from the file system, relative to the saofile instead of downloading from npm. so it has to be installed in your project, which means it works with monorepo as well.

ghost commented 3 years ago

Got it, thank you for the quick response and the great work you're doing with SAO, just discovered it and it's already my favorite option for project scaffolding :)