Sharing generators cross-projects and cross-teams can be done simply by copying or any custom tooling your teams come up with that perfectly fits your workflow.
hygen-add tool offers a streamlined way to do this by introducing Packages. Packages are a compiled set of generators which are published as a node module that you can install and share with others.
First, you need to install the
hygen-add tool, it's one of the tools in the
$ yarn global add hygen-add
Now pick a published module on
npm and install it. For a module called
hygen-acme-generators, run this, without the prefix
$ hygen-add acme-generators
This installs the
acme-generators package with the embedded
yarn so it's versioned and locked, and adds the generators to your current project. Technically, it will copy the generators to your local
_templates directory, because copying is more resilient and robust rather than referncing something that can change unexpectedly.
Once that's done, you can remove
yarn, or leave it if you'd like to sync your templates once in a while.
hygen-add supports installing from Github, in the same way
yarn supports it because it uses
yarn under the hood. It will try to infer the package name from the Github repo URL.
$ hygen-add https://github.com/acme/acme-generators
Will install the package
acme-generators. The package name
acme-generators was parsed out of the Github URL.
If for some reason your Github URL doesn't reveal anything about the package name, you can manually specify the package name (remember: the package name is the
name property in the package project's
$ hygen-add https://github.com/acme/archive --name acme-generators
If you want to install a
react package from both
awesome, you can prefix one of those, or both, to avoid name clashes:
$ hygen-add acme-react $ hygen-add awesome-react --prefix awsm