|
| 1 | +# my-typescript-library-starter |
| 2 | + |
| 3 | +A boilerplate (template starter) for starting a TypeScript library with ease; equipped with: |
| 4 | + |
| 5 | + - **ESLint**: auto fix for formatting (no Prettier needed) |
| 6 | + - **Commitizen**: conventional commit interactive-cli helper |
| 7 | + - **Husky**: enforce eslint rules, conventional commit message before each commit |
| 8 | + - **Release-it**: semantic versioning, release management and publishing to npm or github/gitlab with interactive-cli helper |
| 9 | + - **Changelogen**: auto-generated beautiful change-log based on conventional commits |
| 10 | + |
| 11 | +## Usage |
| 12 | +**1) clone:** first clone the repo (our used the github green button `Use this template` on the top-right of this window and change project-related fields in package json. |
| 13 | +> [!IMPORTANT] |
| 14 | +> After cloning the repo, replace `name`, `version`, `description`, `author`, `homepage` and `repository related links` fields in `package.json` to use this template. |
| 15 | +
|
| 16 | +** ** Now enter repo's directory and **install dependency** using 'npm' or 'pnpm': |
| 17 | + |
| 18 | +``` shell |
| 19 | +pnpm i |
| 20 | +``` |
| 21 | + |
| 22 | +**2)** to **build** project: |
| 23 | +``` shell |
| 24 | +pnpm build |
| 25 | +``` |
| 26 | + |
| 27 | +**3)** to **commit** using commitizen-cli, after adding modified files to stage, enter `pnpm commit` instead of `git commit`: |
| 28 | +``` shell |
| 29 | +git add . |
| 30 | +pnpm commit |
| 31 | +``` |
| 32 | + |
| 33 | +**4)** to **release** using release-it cli: |
| 34 | +``` sell |
| 35 | +pnpm release |
| 36 | +``` |
| 37 | +after releasing the `change-log doc` automtically generated to `CHANGELOG.md` file at the root of the project. |
| 38 | + |
| 39 | +## ESLint & ESLint Configuration |
| 40 | +We use @antfu amazing eslint configuration. Js file `eslint.config.js` configures the `eslint`. It extends antfu's configuration but you can customize it. for example if you prefer to use double-quotations for string, change this file as: |
| 41 | + |
| 42 | +``` javascript |
| 43 | +import antfu from '@antfu/eslint-config' |
| 44 | + |
| 45 | +export default antfu({ |
| 46 | + stylistic: { |
| 47 | + quotes: 'double' |
| 48 | + }, |
| 49 | +}) |
| 50 | +``` |
| 51 | +## Conventional Commits & Husky Hooks |
| 52 | +we use `Commitizen` for conventional commits. `husky` is used to enforce conventional commit messages with `commitlint`. |
| 53 | + |
| 54 | +## Test & Test Coverage |
| 55 | +`Vitest` is used for running tests and measure test coverage. |
| 56 | + |
| 57 | +`coverage-v8` is used to obtain coverage metrics. |
| 58 | + |
| 59 | +The test and coverage config file is `vitest.config.ts`. for example to exclude config files in the root of project from coverage analysis, we config `vitest.config.ts` like follow: |
| 60 | + |
| 61 | +```js |
| 62 | +import { configDefaults, defineConfig } from 'vitest/config' |
| 63 | + |
| 64 | +export default defineConfig({ |
| 65 | + test: { |
| 66 | + coverage: { |
| 67 | + exclude: [ |
| 68 | + ...configDefaults.exclude, |
| 69 | + '*.config.js', |
| 70 | + '*.config.ts', |
| 71 | + ], |
| 72 | + }, |
| 73 | + }, |
| 74 | +}) |
| 75 | +``` |
| 76 | + |
| 77 | +## Release-it for Releasing |
| 78 | +We use `release-it` for version management and publish to anywhere (npm or github). We also use its hooks to execute any command we need to test, build, and publish our project. |
| 79 | + |
| 80 | +## Auto Changelog based on Conventional Commits |
| 81 | +We use `changelogen` to generate beautiful changelogs using Conventional Commits. |
| 82 | + |
| 83 | +## License |
| 84 | +[MIT](./LICENSE) License |
0 commit comments