Create a New Package¶
This guide details the steps to create and configure a new package within the Hyperledger Cacti monorepo.
Prerequisites¶
- A working Cacti development environment (see the Build Instructions).
- Familiarity with TypeScript and the project's monorepo structure.
Steps¶
- Create the package directory
Create a new subfolder under the
/packagesfolder. - Name the package
Name the folder according to the convention:
cacti-$PLUGIN_TYPE-$PLUGIN_FLAVOR. For example:cacti-plugin-satp-hermes.Note: Legacy packages may use the
cactus-prefix, but all new packages should usecacti-. - Set up the directory structure
Inside the new package folder, follow the base directory structure of current packages. The
distandnode_modulesfolders are generated automatically, so you do not need to create them.
Base structure:
- CHANGELOG.md
- CONTRIBUTING.md (optional, for package-specific guidelines)
- README.md
- package.json
- src/
- main/
- typescript/
- test/
- typescript/
- unit/
- integration/
- tsconfig.json
Example for cacti-plugin-satp-hermes:
- CHANGELOG.md
- README.md
- package.json
- src/
- main/
- typescript/
- solidity/ (for smart contracts)
- yml/ (for OpenAPI specs)
- test/
- typescript/
- unit/
- integration/
- solidity/ (for contract tests)
- cucumber/ (for BDD tests)
- tsconfig.json
- jest.config-unit.ts
- jest.config-integration.ts
- Configure
package.jsonIn thepackage.jsonfile, change the name to@hyperledger-cacti/<your-package-name>. Example:@hyperledger-cacti/cacti-plugin-satp-hermes. - Configure
tsconfig.jsonEnsure it extends the Hyperledger Cacti basetsconfig.jsonfile. Follow this example: -
Add to the root
Note: Sequence order matters. The packages are built sequentially, which can raise issues if there are dependencies between packages. More specialized packages (i.e. those with more dependencies) should be inserted lower in the list.tsconfig.jsonAdd your new package to the references array in Hyperledger Cacti's basetsconfig.jsonfile located at the root. -
Configure the monorepo At the root of the Hyperledger Cacti project, run:
If it runs successfully, your new package has been properly added to the workspace. -
Create a separate test package (Optional but recommended) When testing, ensure you have a separate test package that can depend on the
api-serverpackage without causing circular dependencies. The recommended naming convention iscacti-test-$PLUGIN_TYPE-$PLUGIN_FLAVOR. Example:cacti-test-plugin-satp-hermes.
Expected Outcome¶
A correctly structured new package is created, integrated into the monorepo's build configuration, and ready for development.