Using Generators
By running this command, SAO will install a generator which in this case is sao-nm from npm, and use it to generate files into my-project directory.
If you want it to generate into current directoy, just omit the second argument like this: sao nm.
A generator could be one of:
- Local directory, e.g.
sao ./path/to/my-generator - An npm package, e.g.
sao reactwill be packagesao-react.- To use an npm package that does not follow the
sao-*naming convention, just prefix the name like this:sao npm:foo, then this will use thefoopackage instead ofsao-foo.
- To use an npm package that does not follow the
- A git repository, e.g.
sao egoist/sao-nmwill usegithub.com/egoist/sao-nm, you can use following prefixes for other git providers:gitlab:For GitLab. e.g.sao gitlab:user/my-generatorbitbucket:For BitBucket. e.g.sao bitbucket:user/my-generatordirect:For a git repository anywhere elsesao direct:git@yourowngitrepo.com:user/my-generator.git
Versioning#
For npm package, you can use a specific verison of the generator:
The syntax here is the same as npm install.
For git repository, you can use a specific tag, commit or branch of the generator:
Sub-generators#
A generator might have sub-generators, you can run them like this:
The part after : is a sub-generator called donate, by running this command SAO will run the sub-generator which will add a postinstall script in package.json to show donation URL.
caution
Sub-generators are supposed to be run in an existing project, which means the output directory is always current working directory.
Update Cached Generator#
Once you've run a generator, it will be cached locally in ~/.sao directory. To run the same generator with an up-to-date version, you can add the --update or -u flag.