CLI
Elf comes with a CLI that enables a fast and easy setup of your store. It offers the following commands:
Install
$ npx @ngneat/elf-cli install
Using the above command, you can choose which packages to install. Your package manager will be detected and used for installation.
Repo
$ npx @ngneat/elf-cli repo
$ npx @ngneat/elf-cli repo --dry-run
Using the above command, you can create a repository
file. All the boilerplate will be created for you based on which features you select.
Config
You can set the configuration by providing the package.json
file:
{
"elf": {
"cli": {
"repoTemplate": "class",
"inlineStoreInClass": true,
"idKey": "_id",
"repoLibrary": "state",
"plugins": []
}
}
}
repoTemplate
By default, the repository
file generates exported functions. If you prefer to use a class, for instance, when working with Angular, you can set this option to class
.
inlineStoreInClass
By default, a store is created outside of the class. If you prefer creating the store inside a class you can set this option to true
or withoutConstructor
. It might be helpful when you create a component store
or you want to set the initial value to the store given via Angular DI (Works only with repoTemplate
set as class
).
idKey
The default idKey
for the package @ngneat/elf-entities
is id
. By setting this option, you can change it globally.
repoLibrary
The repository
file is created by default at the root path you specify (i.e., flat
). If you set this option, you can specify the directory
you want.
plugins
Specify which plugins you want to use.
@ngneat/elf-cli-ng
Install the package, and add the following code:
{
"elf": {
"cli": {
"repoTemplate": "class",
"plugins": ["@ngneat/elf-cli-ng"]
}
}
}
The plugin will add the Injectable
decorator to the repository
class.
fuzzypath
A fuzzy file/directory search and selection prompt. It can be configured as follows:
module.exports = {
cli: {
fuzzypath: {
rootPath: // defaults to process.cwd()
excludePath(path) {
// defaults to path.includes('node_modules')
}
excludeFilter(path) {
// defaults to path.includes('.');
}
}
}
}