Helps with preparing built Nest.js libraries for publishing, very simple stuff.
The CLI is a simple wrapper around Nest's build command, performing some common additional post-build steps.
Exported components might help you with building your own Nest CLIs.
npm i -D @jchpro/nest-librarian
I'm not a fan of installing too many CLIs globally, so in this document I'll be showing example commands run using npx
, assuming that the package is installed locally in your project.
Put this in your library root if you want to build the library using the CLI. The schema is the one of package.json
, the name is changed in order to not confuse your IDE.
The file will serve as the base for creating output package.json
. Whatever you put there will be present in the output file, with some caveats which will be described below.
npx nestlib build <libraryProject> <options...>
Running npx nestlib help build
will give you more information about the options, here's what the command does:
- Builds the library using nest CLI;
- Copies assets to the output library;
- Merges paths from the root
package.json
to the output one; - Creates output
package.json
, reads dependency versions from the root one if that's what you want (described below); - Deletes the
tsbuildinfo
file.
If you'd like the dependency versions to be read from the root package.json
, just set them to 0.0.0
in the package.lib.json
:
{
"dependencies": {
"lodash": "0.0.0",
"commander": "^11.1.0"
}
}
In this example lodash
will use the version from root, and commander
will have ^11.1.0
.
Please refer to the code comments for additional information.
Represents the library defined in the nest-cli.json
file. Contains paths to significant files and some parsed configuration.
Wrapper around nest-cli.json
file, focusing on the libraries defined in the file. Contains instances of Library
for each library in your workspace.
There are few filesystem and other utilities available, once again - please refer to the code :)