nanoweb-mono v1.7.0
š Monorepo Usage Guide
This guide covers how to set up, manage, and maintain the nanoweb monorepo, including package dependencies, scripts, and automated workflows.
š Project Structure
The monorepo follows a pnpm workspace setup with multiple packages:
root/
āāā apps/ # Your apps
āāā bin/ # Utility scripts
ā āāā clean.js
ā āāā create-app.js
ā āāā create-package.js
ā āāā lint.js
ā āāā llm.js
ā āāā optimize.js
ā āāā release.js
ā āāā workspace.js
ā āāā write-docs.js
āāā packages/ # All packages in the workspace
ā āāā nano-db-fs
ā āāā nano-db-fetch
ā āāā nano-format
ā āāā nanoweb-cli
ā āāā nanoweb-fs
ā āāā nanoweb-llm
ā āāā nanoweb-react
ā āāā nanoweb-sync
ā āāā nanoweb-sync-ftp
ā āāā nanoweb-sync-php
ā āāā nanoweb-theme
āāā pnpm-workspace.yaml # Defines workspace packages
āāā package.json # Root package.json (manages workspace commands)
āāā eslint.config.js # ESLint configuration
š Requirements
- Node.js runtime environment You must have the node v22+ installed.
- The pnpm package manager You must have the pnpm package manager installed.
š§ Setting Up the Monorepo
š¢ Work within the monorepo.
1. Clone the repository:
git clone https://gitlab.com/nan.web/monorepo.git nanoweb && cd nanoweb
Initialize workspace and install dependencies:
pnpm install pnpm ws:clone # runs the ws:optimize within the ws:init pnpm ws:init
This command clones all missing package repositories, ensures correct dependencies, and installs them.
Prepare packages for the usage in the workspace:
pnpm ws:pull pnpm build
Run optimization (optional, recommended after setup, if did not run within the ws:init):
pnpm ws:optimize
This command:
- Cleans unnecessary cache and dependencies
- Updates dependencies to their latest versions
- Runs linter and tests
š Running the Development Environment
1ļøā£ Work only within the specific project.
Change the directory to the specific package, for instance: cd packages/nano-format
.
Start the development server:
pnpm dev
Run tests across all packages:
pnpm test:all
Run nanoweb-mono tests:
pnpm test
Build all packages:
pnpm build:all
Lint all packages:
pnpm lint:all
š Managing Dependencies & Versions
Updating Dependencies
1ļøā£š¢ Work within the specific package and within the monorepo.
Before committing, ensure all workspace: dependencies are replaced with their actual versions:
pnpm ws:latest
If you plan to work on multiple interdependent packages, switch all dependencies to workspace:*
:
pnpm ws:workspace
Checking for Issues Before Commit
Run the following to check for uncommitted workspace dependencies and pre-commit hooks:
pnpm ws:check
Checking Git Status Across All Packages
pnpm ws:status
š Releasing Packages
1ļøā£ Work within the specific package.
Change the directory to the specific package, for instance: cd packages/nano-format
.
1. Ensure all changes are committed and pushed.
2. Run the release script inside the package:
pnpm release
This will:
- Run all tests and linting
- Build the package
- Tag the new version in Git
- Publish to npm
- Push all commits and tags
šø Contributing
- Create a new branch:
git checkout -b feature/my-update
- Make changes and commit:
git commit -m "Add new feature"
- Push your branch and open a merge request.
āļø Useful Utility Scripts
Command | Description |
---|---|
pnpm ws:init | Initialize workspace & install packages |
pnpm ws:check | Validate package.json & pre-commit hooks |
pnpm ws:latest | Replace workspace:* with actual versions |
pnpm ws:workspace | Convert all versions to workspace:* |
pnpm ws:optimize | Clean, install, update, lint, build, test |
pnpm ws:status | Check uncommitted changes in all packages |
pnpm release | Build, test, tag, and publish package |
pnpm clone | Cloning missing packages into the monorepo |
š ļø Troubleshooting
- Dependency Issues: Run
pnpm ws:optimize
to clean and reinstall. - Build Errors: Ensure all dependencies are up to date with
pnpm ws:latest
. - Linting Issues: Run
pnpm lint
and fix reported errors. - Pre-commit Hook Failures: Check
.husky/pre-commit
and ensure it includes workspace checks.
With these steps, you can efficiently manage and maintain the nanoweb monorepo! šø