# {{ PROJECT_NAME }}

[English](./README.md) | [简体中文](./README.zh-CN.md)

A robust boilerplate for developing npm packages using TypeScript and Rollup.

## Features

- **TypeScript** - Strongly typed, based on `tsc` and `@rollup/plugin-typescript`.
- **Rollup** - Blazing fast bundler for multiple module formats.
- **Multiple Output Formats** - Supports ESM, CJS, and UMD formats.
- **Jest** - Fully configured testing framework with `jsdom` testing capabilities.
- **Babel** - Integration for down-compiling and better browser support.
- **PostCSS & Less** - Configured for styling needs within your package.
- **ESLint & Prettier** - Configured for syntax/style checking with Husky and lint-staged pre-commit hooks.
- **Commitlint** - Enforces Conventional Commits standards on commit messages.
- **release-it** - Automated version bumping, git tagging, changelog generation, and npm publishing.

## Getting Started

Make sure to install dependencies first:

```bash
pnpm install
```

## Available Scripts

In the project directory, you can run:

- `pnpm dev`: Starts the local Vite playground for real-time component development and UI testing.
- `pnpm clean`: Cleans the output `lib` directory.
- `pnpm build`: Builds the package for production using Rollup. The outputs are placed in the `lib` directory.
- `pnpm test`: Runs Jest tests.
- `pnpm coveralls`: Runs tests and collects coverage data.
- `pnpm tsc`: Compiles TypeScript without bundling (useful for type checking).
- `pnpm lint`: Lints the codebase with ESLint.
- `pnpm release`: Starts the `release-it` interactive deployment (bumps version, tags, and publishes).

## Development Guidelines

### Commit Convention

This project enforces the [Conventional Commits](https://www.conventionalcommits.org/) specification using `commitlint`.
When you commit your changes, you must format your commit messages with specific prefixes. For example:

- `feat: add a new component` (New feature)
- `fix: resolve a bug` (Bug fix)
- `chore: update dependencies` (Maintenance or config changes)
- `docs: update readme` (Documentation changes)

If you don't follow this format, your commit will be rejected by the Git `commit-msg` hook.

## Usage

1. Write your component code in the `src` directory.
2. Run `pnpm dev` to instantly preview your UI components in the browser via the `playground/` directory.
3. Write component unit tests in the `__tests__/` directory and run them with `pnpm test`.
4. Run `pnpm build` to compile the library.
5. The generated files will be inside the `lib` directory, ready to be published.

## Publishing

This project is configured to publish to the official NPM registry. If you use a domestic mirror (like CNPM or Taobao) locally, you must first log in to the official registry:

```bash
npm login --registry=https://registry.npmjs.org/
pnpm release
```

## License

[MIT](./LICENSE)
