๐ฆ TypeScript Application Template
๐ Summary โ
Professional Template with CI/CD-enabled, versioning with Semantic Release and Typedoc+VitePress documentation.
๐งฉ What's Included โ
Core Infrastructure
- โ๏ธ Node.js + TypeScript
- โ๏ธ Vitest (Unit Testing)
- โ๏ธ Semantic Release
- โ๏ธ GitHub Actions CI/CD
- โ๏ธ GitHub Actions GitHub Pages
Quality Assurance
- โ๏ธ BiomeJS (Linting/Formatting)
- โ๏ธ Husky + Lint Staged
- โ๏ธ Commitlint + Conventional Commits
- โ๏ธ CodeQL Scanning
Project Scaffolding
- โ๏ธ Docs: Contribution Guide & Code of Conduct
- โ๏ธ Husky Git Hooks
- โ๏ธ Automated CHANGELOG.md with Semantic Release
- โ๏ธ TypeDoc + Vitepress for Documentation Site
โ When to Use This Template โ
Perfect for developers who need:
- Zero-config TypeScript library setup
- Automated docs with TypeDoc
- CI/CD pipeline with GitHub Actions
- Semantic versioning right out of the box
๐ก Ideal for: โ
- Building npm packages
- Open source projects
- Enterprise-grade libraries
๐ค Automation Workflows โ
Workflow | Description | Trigger |
---|---|---|
0.test.yml | Runs unit tests | Push/PR to main or develop |
1.create-pr.yml | Creates or updates a pull request from develop to main | Push to develop |
2.deploy-docs.yml | Deploys documentation and coverage badge | After a successful release |
3.release.yml | Generates changelog, tags, and releases | Push to main |
4.publish-npm.yml | Publishes package to npm | After a successful release |
๐ Quick Start โ
npx degit heliomarpm/tslib-template your-lib
cd your-lib
npm install
๐ ๏ธ Initial Setup โ
Replace template info:
- Update
name
anddescription
inpackage.json
- Set version to
0.0.0
inpackage.json
- Replace all references to
tslib-template
andheliomarpm
inpackage.json
andREADME.md
- Delete
CHANGELOG.md
- Update
Configure GitHub repository:
- Enable GitHub Actions (Settings โ Actions โ General)
- Set up branch protection rules (optional)
- Configure GitHub Pages for documentation
- Remove
if false
frompublish-npm.yml
- Generate npm authentication token and copy it.
- [Navigate to your GitHub repository page, click Settings and then Secrets. Click on New repository secret, fill in
NPM_TOKEN
as the Name, paste the npm token created on the previous step inside the Value field and hit Add secret.
๐ Semantic Versioning โ
This template uses semantic-release for automated version management and package publishing. Version numbers are determined automatically based on commit messages:
Commit Message | Release Type | Example Version |
---|---|---|
revert(scope): message | Patch | 1.0.1 |
fix(scope): message | Patch | 1.0.1 |
feat(scope): message | Minor | 1.1.0 |
BREAKING CHANGE: message | Major | 2.0.0 |
๐ Commit Message Format โ
<type>(<scope>): <short summary>
โ โ โ
โ โ โโโซธ Summary in present tense. Not capitalized. No period at the end.
โ โ
โ โโโซธ Commit Scope: core|docs|config|cli|etc.
โ
โโโซธ Commit Type: fix|feat|build|chore|ci|docs|style|refactor|perf|test
When a commit is pushed to main
branch:
- semantic-release analyzes commit messages
- Determines the next version number
- Generates changelog
- Creates a git tag
- Publishes the release to GitHub
Note: To trigger a release, commits must follow the Conventional Commits specification.
๐ฆ Project Scripts โ
npm run lint
โ run linter and fixernpm run format
โ run formatternpm run test
โ run unit testsnpm run test:c
โ run unit tests with coveragenpm run commit
- run conventional commits checknpm run release:test
โ dry run semantic releasenpm run docs:dev
โ run documentation locallynpm run docs
โ build documentation and deploy
Generate Documentation Page โ
- First time:
npx vitepress init
- Documentation code base:
npm run docs
ornpm run docs:dev
โ๏ธ Configuration Guide โ
๐ Workflow permissions โ
For GitHub Actions workflows to create, edit, and manage Pull Requests via API (GitHub CLI or REST) and perform operations like push, release, and deploy, you need to configure the appropriate repository permissions.
- Go to your repository's
Settings
โActions
โGeneral
- Go to section
Workflow permissions
- Set the permission level to
Read and write permissions
- Check on
Allow GitHub Actions to create and approve pull requests
- Click on "Save changes"
By default, the GITHUB_TOKEN token used in actions has read-only permissions. Enabling Read and write permissions allows you to create PRs, edit PRs, commit changes, and create tags/releases programmatically.
๐ Configuration alternatives
Replace the GITHUB_TOKEN
with:
๐ Option 1 โ Classic Personal Access Token (PAT)
โ Required permissions:
repo
(for read and write access to repositories)workflow
(for interacting with GitHub Actions)
โ Features:
- A single token can be used in any repository of the same user or organization
- Cannot restrict granular access to specific repositories or permissions (full access within the configured scope)
โ How to use:
Create a Classic PAT in:
GitHub Settings โ Developer Settings โ Personal access tokens โ Tokens (classic)
Enable the scopes:
repo
workflow
Save the token as a secret in the repository:
Settings โ Secrets and variables โ Actions
- Suggested name:
PAT_TOKEN
Reference in workflow:
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
๐ Option 2 โ Fine-grained Personal Access Token (PAT)
โ Required permissions:
Contents: Read and write
Actions: Read and write
Metadata: Read-only
- (Optional)
Bypass branch protections
if you want to allow direct push even on protected branches
โ Features:
- Allows you to restrict access to specific repositories at the time of creation
- Controls permissions with more granularity and security
- Needs to explicitly mark which repositories it will have access to
- Can be used in multiple repositories if configured to allow access to those repositories during token creation (either by selecting "All repositories" or manually selecting multiple)
โ How to use:
Create a Fine-grained PAT in:
GitHub Settings โ Developer Settings โ Personal access tokens โ Fine-grained tokens
Set:
- Repositories: select all required or check "All repositories"
- Permissions:
Contents: Read and write
Actions: Read and write
Metadata: Read-only
- (Optional)
Bypass branch protections
Save the token as a secret in the repository:
Settings โ Secrets and variables โ Actions
- Suggested name:
PAT_TOKEN
Reference in workflow:
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
๐ Recommended Permissions Summary โ
Operation | GITHUB_TOKEN (read/write) | Classic PAT | Fine-grained PAT |
---|---|---|---|
Create/Edit Pull Request | โ | โ | โ
(Contents: RW ) |
Commit files to repository | โ (if no branch protection) | โ | โ |
Create releases and tags via API | โ | โ | โ |
Bypass branch protection | โ | โ | โ (if enabled) |
โ ๏ธ Note:
The built-inGITHUB_TOKEN
in Actions respects all b>ranch protection rules, which prevents direct pushes to main if branch protection is configured.Using a PAT or adjusting branch protection are the recommended solutions when automations require higher permissions.
For security, it is best to use Fine-grained PATs whenever possible, with specific permissions for the repositories and actions required.
๐ฆ Dependencies โ
โ
Zero runtime dependencies
๐ All devDependencies are pinned to latest stable versions
๐ค Contributing โ
We welcome contributions! Please read:
Thank you to everyone who has already contributed to the project!
Made with contrib.nn. โ
โค๏ธ Support this project โ
If this project helped you in any way, there are several ways to contribute.
Help us maintain and improve this template:
โญ Starring the repository
๐ Reporting bugs
๐ก Suggest features
๐งพ Improving the documentation
๐ข Share with others
๐ต Supporting via GitHub Sponsors, Ko-fi, Paypal or Liberapay, you decide. ๐
๐ License โ
MIT ยฉ Heliomar P. Marques ๐