my-typescript-library-starter
Advanced tools
Comparing version
{ | ||
"name": "my-typescript-library-starter", | ||
"type": "module", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"packageManager": "pnpm@8.15.3", | ||
@@ -62,23 +62,24 @@ "description": "A boilerplate for starting a TypeScript library, equipped with Vitest + ESLint + Commitizen + Husky + Release-it and generating beautiful change-log with Changelogen", | ||
"devDependencies": { | ||
"@antfu/eslint-config": "^2.6.4", | ||
"@antfu/eslint-config": "^2.15.0", | ||
"@antfu/ni": "^0.21.12", | ||
"@antfu/utils": "^0.7.7", | ||
"@commitlint/cli": "^18.6.0", | ||
"@commitlint/config-conventional": "^18.6.0", | ||
"@types/node": "^20.11.19", | ||
"@vitest/coverage-v8": "^1.3.1", | ||
"bumpp": "^9.3.0", | ||
"@commitlint/cli": "^18.6.1", | ||
"@commitlint/config-conventional": "^18.6.3", | ||
"@types/node": "^20.12.7", | ||
"@vitest/coverage-v8": "^1.5.0", | ||
"changelogen": "^0.5.5", | ||
"commitizen": "^4.3.0", | ||
"cspell": "^8.7.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^8.56.0", | ||
"eslint": "^8.57.0", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.2.2", | ||
"pnpm": "^8.15.3", | ||
"release-it": "^17.1.1", | ||
"pnpm": "^8.15.7", | ||
"release-it": "^17.2.0", | ||
"release-it-beautiful-changelog": "^0.1.1", | ||
"rimraf": "^5.0.5", | ||
"typescript": "^5.3.3", | ||
"typescript": "^5.4.5", | ||
"unbuild": "^2.0.0", | ||
"vite": "^5.1.4", | ||
"vitest": "^1.3.1" | ||
"vite": "^5.2.10", | ||
"vitest": "^1.5.0" | ||
}, | ||
@@ -85,0 +86,0 @@ "lint-staged": { |
# my-typescript-library-starter | ||
A boilerplate for starting a TypeScript library with ease, equipped with: | ||
- ESLint | ||
- Commitizen | ||
- Husky | ||
- Release-it | ||
- Changelogen | ||
> **Note**: | ||
A boilerplate (template starter) for starting a TypeScript library with ease; equipped with: | ||
- **ESLint**: auto fix for formatting (no Prettier needed) | ||
- **Commitizen**: conventional commit interactive-cli helper | ||
- **Husky**: enforce eslint rules, conventional commit message before each commit | ||
- **Release-it**: semantic versioning, release management and publishing to npm or github/gitlab with interactive-cli helper | ||
- **Changelogen**: auto-generated beautiful change-log based on conventional commits | ||
## Usage | ||
**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. | ||
> [!IMPORTANT] | ||
> After cloning the repo, replace `name`, `version`, `description`, `author`, `homepage` and `repository related links` fields in `package.json` to use this template. | ||
** ** Now enter repo's directory and **install dependency** using 'npm' or 'pnpm': | ||
``` shell | ||
pnpm i | ||
``` | ||
**2)** to **build** project: | ||
``` shell | ||
pnpm build | ||
``` | ||
**3)** to **commit** using commitizen-cli, after adding modified files to stage, enter `pnpm commit` instead of `git commit`: | ||
``` shell | ||
git add . | ||
pnpm commit | ||
``` | ||
**4)** to **release** using release-it cli: | ||
``` sell | ||
pnpm release | ||
``` | ||
after releasing the `change-log doc` automatically generated to `CHANGELOG.md` file at the root of the project. | ||
## ESLint & ESLint Configuration | ||
@@ -25,3 +52,3 @@ 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: | ||
## Conventional Commits & Husky Hooks | ||
we use `Commitizen` for conventinal commits. `husky` is used to enforce conventional commit messages with `commitlint`. | ||
we use `Commitizen` for conventional commits. `husky` is used to enforce conventional commit messages with `commitlint`. | ||
@@ -31,2 +58,22 @@ ## Test & Test Coverage | ||
`coverage-v8` is used to obtain coverage metrics. | ||
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: | ||
```js | ||
import { configDefaults, defineConfig } from 'vitest/config' | ||
export default defineConfig({ | ||
test: { | ||
coverage: { | ||
exclude: [ | ||
...configDefaults.exclude, | ||
'*.config.js', | ||
'*.config.ts', | ||
], | ||
}, | ||
}, | ||
}) | ||
``` | ||
## Release-it for Releasing | ||
@@ -38,3 +85,14 @@ 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. | ||
## CSpell | ||
`CSpell` used to automatically check for spelling errors when committing files and writing commit messages. | ||
If there are spelling errors in the staged files for commit, `husky` will prevent you from committing. | ||
Also, if the commit message text has spelling errors, `husky` will still prevent the commit. | ||
Additional Notes: | ||
- You can configure CSpell in `cspell.json` file in your project directory. | ||
- You can list words that you want `CSpell` to ignore in `/project-words.txt` file. | ||
## License | ||
[MIT](./LICENSE) License |
7478
39.1%96
152.63%22
4.76%