1.7.0 • Published 4 months ago

nanoweb-mono v1.7.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

šŸ“– 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

  1. Node.js runtime environment You must have the node v22+ installed.
  2. 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
  1. 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.

  2. Prepare packages for the usage in the workspace:

    pnpm ws:pull
    pnpm build
  3. 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

  1. Create a new branch:
    git checkout -b feature/my-update
  2. Make changes and commit:
    git commit -m "Add new feature"
  3. Push your branch and open a merge request.

āš™ļø Useful Utility Scripts

CommandDescription
pnpm ws:initInitialize workspace & install packages
pnpm ws:checkValidate package.json & pre-commit hooks
pnpm ws:latestReplace workspace:* with actual versions
pnpm ws:workspaceConvert all versions to workspace:*
pnpm ws:optimizeClean, install, update, lint, build, test
pnpm ws:statusCheck uncommitted changes in all packages
pnpm releaseBuild, test, tag, and publish package
pnpm cloneCloning 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! šŸ›ø

1.7.0

4 months ago

1.6.10

4 months ago

1.6.9

4 months ago

1.6.8

4 months ago

1.6.7

4 months ago

1.6.6

4 months ago

1.6.5

4 months ago

1.6.4

4 months ago

1.6.3

4 months ago

1.6.2

4 months ago

1.6.1

4 months ago

1.6.0

4 months ago