A mono-repo containing libraries for the CDP (Core Delivery Platform) ecosystem. This mono-repo provides the ability to simply create and manage CDP packages, ensuring consistency and ease of use across different projects.
- Requirements
- Local development
- Creating a new package
- Global tooling
- Testing your changes
- Automatically updating npm dependencies with Dependabot
- Manually updating npm dependencies
- Not releasing
- Releasing
- Changesets
- Release it
To get started with the CDP Libraries mono-repo, you need to have Node.js and npm installed on your machine.
Please install Node.js >= v22 and npm >= v9.
Tip
To install Node.js and npm Use Node Version Manager nvm
To use the correct version of Node.js for this mono-repo, via nvm:
cd cdp-libraries
nvm useInstall all dependencies:
npm install- Copy and rename an existing package in the
packagesdirectory to create a new package - If they exist, remove
coverageandnode_modulesdirectories from the new package - If it exists, remove the CHANGELOG.md
- Empty the
srcfolder in the new package - Update the
README.mdfile in the new package with relevant information about your package - Update the
package.jsonfile in the new package with relevant information:- Update the
namefield to a unique name for your package - Update the
versionfield to0.0.1 - Update the
descriptionfield with a brief description of your package - Update the
mainfield with the path to your entry point - Update the
repositoryfield with the URL of your new package's readme - Update the
release-itobject to include the new package. The config should be ok for you but you will need to use your new package name
- Update the
- Update dependabot by running
node scripts/generate-dependabot.js - Now you have all you need to start developing your new package
The following tools are available for free from the root of cdp-libraries. You do not need to install these in
your package.json file, as they are already included in the root package.json:
vitest- for running testsneostandard- for linting coderelease-it- for managing releasesprettier- for code formattinghusky- for managing git hooks
To test your changes in this repo in a local consuming codebase, npm link is your friend here. Have a read
of https://docs.npmjs.com/cli/v9/commands /npm-link
Dependabot is configured to automatically create pull requests to update npm dependencies in the root package and all packages. These pull requests will be created automatically when new versions of dependencies are released and the specified cooldown period has passed. As a CDP developer you simply need to merge these pull requests when they have been created and have passed all required checks.
Once the dependabot PR's have been merged you will need to release the packages that have had their dependencies
updated. You can do this by creating a new changeset via npm run changeset and merging this PR.
To update npm dependencies in the root package and all packages, you can use the following command from the root of the mono-repo:
npm run update:depsThis will use npm-check-updates to update all dependencies to their latest versions.
You then need to install these updates via:
npm installand commit the changes and release as appropriate.
If you have changes you wish to commit but do not want to release a new version of the package, or tag and release the
package on GitHub. You can simply just make your commits as normal and raise a PR. There is no need to create a
changeset. This is usually documentation or items in the root that do not need to be published.
Tip
For any changes in the packages directory, you should always create a changeset so they are released when your PR is
merged
The GitHub release workflow is intended to authenticate with npm using OIDC Trusted Publishers. For the first release you may need to push the empty project manually using your own npm credentials for the project to be created an then enable OIDC. See the docs for information on how to set this up.
TL;DR: Releasing a new version of a package is as simple as running npm run changeset in root directory and merging a
PR.
- Developer writes changeset
- Chooses correct bump for changes
- CI does everything else. Versions, tags, releases and publishes
Read on for detailed instructions. Releasing to npm and tagging on GitHub is done using
the changeset and release-it
tools, which is configured in the root of the workspace. This is super simple and all you need to do is:
After you have commited your work and are ready to release a new version of your package:
- Run
npm run changesetto create a new changeset - Commit the changeset file that was created in the
.changesetdirectory - Raise a PR with the changes you want to release
- Wait for
status required checksto pass - Get the PR reviewed and approved by at least one other developer
- Get an approval from the
cdp-librariesowners - Merge the PR into
mainbranch - The
cdp-librariesGitHub Action will automatically run thechangesetandrelease-ittool, which will:- Bump the version number in the
package.jsonfile - Create a new tag and release in GitHub with the new version number
- Push the changes to the
mainbranch - Publish the package to npm
- Bump the version number in the
This project uses changeset for managing versioning of packages. This is
already set up to go and works on CI automatically.
This project uses release-it for managing releases. It automates the process of tagging and releasing to GitHub. It is set up to go.