Skip to content


๐Ÿ“ฆ 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:

  1. Zero-config TypeScript library setup
  2. Automated docs with TypeDoc
  3. CI/CD pipeline with GitHub Actions
  4. Semantic versioning right out of the box

๐Ÿ’ก Ideal for: โ€‹

  • Building npm packages
  • Open source projects
  • Enterprise-grade libraries

๐Ÿค– Automation Workflows โ€‹

WorkflowDescriptionTrigger
0.test.ymlRuns unit testsPush/PR to main or develop
1.create-pr.ymlCreates or updates a pull request from develop to mainPush to develop
2.deploy-docs.ymlDeploys documentation and coverage badgeAfter a successful release
3.release.ymlGenerates changelog, tags, and releasesPush to main

๐Ÿš€ Quick Start โ€‹

bash
npx degit heliomarpm/tsapp-template your-app
cd your-app
npm install

๐Ÿ› ๏ธ Initial Setup โ€‹

  1. Replace template info:

    • Update name and description in package.json
    • Set version to 0.0.0 in package.json
    • Replace all references to tsapp-template and heliomarpm in package.json and README.md
    • Delete CHANGELOG.md
  2. Configure GitHub repository:

    • Enable GitHub Actions (Settings โ†’ Actions โ†’ General)
    • Set up branch protection rules (optional)
    • Configure GitHub Pages for documentation

๐Ÿ“ˆ Semantic Versioning โ€‹

This template uses semantic-release for automated version management and package publishing. Version numbers are determined automatically based on commit messages:

Commit MessageRelease TypeExample Version
revert(scope): messagePatch1.0.1
fix(scope): messagePatch1.0.1
feat(scope): messageMinor1.1.0
BREAKING CHANGE: messageMajor2.0.0

๐Ÿ“ Commit Message Format โ€‹

bash
<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:

  1. semantic-release analyzes commit messages
  2. Determines the next version number
  3. Generates changelog
  4. Creates a git tag
  5. 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 fixer
  • npm run format โ€” run formatter
  • npm run test โ€” run unit tests
  • npm run test:c โ€” run unit tests with coverage
  • npm run commit - run conventional commits check
  • npm run release:test โ€” dry run semantic release
  • npm run docs:dev โ€” run documentation locally
  • npm run docs โ€” build documentation and deploy

Generate Documentation Page โ€‹

see TypeDoc Vitepress

  • First time: npx vitepress init
  • Documentation code base: npm run docs or npm 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.

  1. Go to your repository's Settings โ†’ Actions โ†’ General
  2. Go to section Workflow permissions
  3. Set the permission level to Read and write permissions
  4. Check on Allow GitHub Actions to create and approve pull requests
  5. 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:

  1. Create a Classic PAT in: GitHub Settings โ†’ Developer Settings โ†’ Personal access tokens โ†’ Tokens (classic)

  2. Enable the scopes:

    • repo
    • workflow
  3. Save the token as a secret in the repository:

    • Settings โ†’ Secrets and variables โ†’ Actions
    • Suggested name: PAT_TOKEN
  4. Reference in workflow:

yaml
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:

  1. Create a Fine-grained PAT in: GitHub Settings โ†’ Developer Settings โ†’ Personal access tokens โ†’ Fine-grained tokens

  2. 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
  3. Save the token as a secret in the repository:

    • Settings โ†’ Secrets and variables โ†’ Actions
    • Suggested name: PAT_TOKEN
  4. Reference in workflow:

yaml
env:
  GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
OperationGITHUB_TOKEN (read/write)Classic PATFine-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-in GITHUB_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. ๐Ÿ˜‰

PayPalKo-fiLiberapayGitHub Sponsors

๐Ÿ“ License โ€‹

MIT ยฉ Heliomar P. Marques ๐Ÿ”