Codux Librarian
codux-librarian
is a CLI tool for packaging libraries of third-party boards and components templates
into a format that can be consumed by Codux.
This tool creates an NPM package containing the library's boards. Once this package is added as a dev dependency in a user's project, the boards will appear in the "libraries" section of the Add Panel when the project is opened in Codux and in the new component dialog to allow install/inline component templates.
Building an Asset Library
To package your boards into a library, follow these steps:
- Add
@wixc3/codux-librarian
as a dev dependency to the project you want to use for providing boards to other projects:
npm install --save-dev @wixc3/codux-librarian
-
Create a codux-librarian.config.json
file in the root directory of the project. Configure it based on the format described in the LibrarianConfig interface.
-
Build the library using the CLI:
npx codux-librarian build
Build Options
The build command supports the following option:
--config
: Specify a custom path to a configuration file. Defaults to ./codux-librarian.config.json
.
-
A new directory containing the packaged library will be generated. Publish this package to NPM:
Build Process Details and Requirements
Board Templates
Any board file located in the configured boardsPath
will be copied to the package.
Component Templates
Folders containing a *.component.json
file under the configured componentsPath
will be copied to the package. Required dependencies for components are automatically determined by inspecting JavaScript imports in the component template modules.
Dependency Management:
- Dependencies required by components must be explicitly set as
peerDependencies
in the library package with the acceptable version range. - To prevent automatic installation by consuming projects, the dependency's
optional
flag should be set in the usedPeerDependenciesMeta
.
Ignored Directories
The metadata directory
is excluded from the package during the build process.
Consuming an Asset library
To use a packaged library in a project:
-
Add the packaged library as a development dependency:
npm install --save-dev library-package
-
Update the codux.config.json
file of the consuming project to include the library:
{
"addPanel": {
"assets": ["library-package"]
}
}
Limitations
- Boards in the
boardsPath
that import components using relative paths are not supported. Components must be imported from external packages. - Boards containing multiple return statements are not supported.
- Board cover images must be imported using a relative path to the image file, including the file extension.