This repository uses pnpm workspaces and Nx to manage a monorepo with multiple projects and packages.
git clone <repo-url>
cd <repo-directory>
pnpm install
pnpm build
npx nx <run_command_for_the_package_or_app> <package_or_app_name>
;For example, to run the Switchboard application in
/apps/switchboard/
, usenpx nx start @powerhousedao/switchboard
.
To link a dependency into a project, add it to your package.json and point the dependency version to workspace:*
package.json
{
"name": "my-new-package",
"version": "0.0.0",
"scripts": {
...
},
"dependencies": {
...
"@pgph/pkg-a": "workspace:*", // Link to a local dependency
"@pgph/pkg-b": "workspace:*",
"@pgph/pkg-c": "workspace:*"
}
}
Add your package/app into the respective folder (packages/*
or apps/*
).
Install the dependencies: pnpm install
Ensure that your package.json points to version 0.0.0
Commit your changes: git commit -m "feat(<your_new_package_name>)!: initial package setup"
If pushing a new package to be deployed to npm, build the package first: npx nx <build_command> <your_new_package_name>
Perform an initial test release in your local environment: npx nx release --first-release --projects=<your_new_package_name> --dry-run
Perform the initial release in your local environment: (This step is required, otherwise releases from CI are not going to work): npx nx release --first-release --projects=<your_new_package_name>
Add your package/app to the release GitHub Action workflow: If adding a new package to be released to npm, update the .github/worflows/release-package.yml
:
---
name: Release Package
on:
workflow_dispatch:
inputs:
package:
description: 'Choose a package'
required: true
default: 'packages/*'
type: choice
options:
- '@pgph/pkg-a'
- '@pgph/pkg-b'
- '@pgph/pkg-c'
- <add_your_new_package_name_here>
- 'packages/*'
If adding a new app or a package requiring a special workflow, set up a new release configuration:
name: Your Custom Release
on:
workflow_dispatch:
jobs:
build:
name: ...
runs-on: ...
permissions:
contents: write
id-token: write
steps:
...
- name: git config
shell: bash
run: |
git config user.name "Github Actions Bot"
git config user.email "-"
- name: Update pkg version
run: npx nx release --projects=<your_new_package/app_name> --skip-publish
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
...
Trigger future releases directly from GitHub Actions.
Currently, only the main
branch is enabled in this project, which means all packages are deployed to NPM from the main
branch. To contribute to a package, please follow these steps:
Create a feature branch from the main
branch:
git pull origin main
git checkout main
git checkout -b feature/my-branch
Make your changes in the feature branch.
Once your changes are ready, commit them following the conventional commits standard:
git commit -m "feat(document-model): my commit message"
Push your branch to GitHub and open a pull request (PR) against the main
branch.
Once your PR is approved, merge it.
A GitHub Action will be triggered automatically after you merge your PR. This action will handle versioning and release the new version of the affected packages to NPM. Optionally, you can trigger the deployment of your package manually