A comprehensive, production-ready TypeScript npm package template with automated publishing, testing, and modern tooling.
β‘ Quick Start: Click "Use this template" above to create your own npm package in seconds!
- TypeScript Support: Full TypeScript setup with declaration files
- Modern Build System: Rollup for optimized bundling (ESM + CJS)
- Automated Testing: Jest with coverage reporting
- Code Quality: ESLint with TypeScript support
- Automated Publishing: GitHub Actions for NPM and GitHub Packages
- Cross-Platform Scripts: PowerShell and Node.js scripts
- Security: Security policy and vulnerability reporting
- Documentation: Comprehensive docs and examples
- Dual Registry Support: Publish to both NPM and GitHub Packages
- Click "Use this template" button on GitHub
- Create your new repository
- Clone and customize
git clone https://github.com/xarlizard/npm-package-template.git my-package
cd my-package
npm install
npm install @xarlizard/npm-package-template --save-dev
βΉοΈ Missing files: By donwloading it directly as an npm-package, you will miss out on a lot of files, be sure to check the official github URL to see all available ones!
This section explains the purpose of every file and folder in this repository, so you know exactly what each part does.
βββ .github/workflows/ # GitHub Actions
βββ dist/ # Built files (generated)
βββ docs/ # Documentation files
βββ examples/ # Usage examples
βββ scripts/ # Build and release scripts
β βββ dev.ps1 # Development tasks (PowerShell)
β βββ release.ps1 # Release script (PowerShell)
β βββ release.js # Release script (Node.js)
βββ src/ # Source code
β βββ __tests__/ # Test files
β βββ index.ts # Main entry point
β βββ types.ts # Type definitions
β βββ utils.ts # Utility functions
βββ templates/ # Template files with blank fields
βββ .eslintrc.json # ESLint configuration.
βββ .gitignore # Git ignore patterns.
βββ .npmignore # Files to exclude from NPM package.
βββ .npmrc # NPM and GitHub Packages registry configuration.
βββ .prettierignore # Prettier ignore patterns.
βββ .prettierrc.json # Prettier configuration.
βββ CHANGELOG.md # Project change history.
βββ CODE_OF_CONDUCT.md # Contributor Covenant code of conduct.
βββ CONTRIBUTING.md # Contribution guidelines.
βββ jest.config.json # Jest testing configuration.
βββ LICENSE # MIT License.
βββ package.json # NPM package configuration.
βββ README.md: # Main project overview and file reference.
βββ rollup.config.js # Rollup build configuration.
βββ SECURITY.md # Security policy and vulnerability reporting.
βββ tsconfig.json # TypeScript configuration.
- DEPENDABOT.md: Automated dependency updates via
.github/dependabot.yml
. - ISSUE_TEMPLATES.md: Issue templates in
.github/ISSUE_TEMPLATE/
. - PULL_REQUEST_TEMPLATE.md: Pull request template in
.github/pull_request_template.md
. - TEMPLATE_SETUP.md: Step-by-step guide for customizing this template.
- WORKFLOWS.md: Details all GitHub Actions workflows in
.github/workflows/
.
- index.ts: Main entry point for the package.
- types.ts: TypeScript types and interfaces.
- utils.ts: Utility functions.
- **tests/**: Unit tests for main functions and utilities.
- README.md: Usage examples overview.
- basic-usage.js: Node.js usage example.
- typescript-usage.ts: TypeScript usage example.
- dev.ps1: PowerShell script for development tasks.
- release.js: Node.js script for automated release.
- release.ps1: PowerShell script for publishing releases.
- setup.js: Node.js script for initial setup and validation.
- dependabot.yml: Dependabot configuration.
- pull_request_template.md: Pull request template.
- ISSUE_TEMPLATE/: Issue templates for bug reports, documentation, and features.
- workflows/: GitHub Actions workflows for CI, publishing, and security.
See docs/TEMPLATE_SETUP.md
for a step-by-step guide to customizing this template for your
own package, including updating package.json
, configuring secrets, and setting up your code.
# Install dependencies
npm install
# Development with all checks
npm run dev
# Individual tasks
npm run dev:build # Build only
npm run dev:test # Test only
npm run dev:lint # Lint only
npm run dev:typecheck # Type check only
# Testing
npm run test
npm run test:watch
npm run test:coverage
# Building
npm run build
# Releasing
npm run release # Patch version
npm run release:minor # Minor version
npm run release:major # Major version
Script | Description |
---|---|
npm run build |
Build the package |
npm run test |
Run tests |
npm run test:watch |
Run tests in watch mode |
npm run test:coverage |
Run tests with coverage |
npm run lint |
Lint code |
npm run lint:fix |
Fix linting issues |
npm run typecheck |
Type check code |
npm run dev |
Run all development tasks |
npm run release |
Release patch version |
npm run release:minor |
Release minor version |
npm run release:major |
Release major version |
- Create a GitHub release
- GitHub Actions will automatically:
- Run tests
- Build the package
- Publish to NPM
- Publish to GitHub Packages
# Publish to NPM
npm publish
# Publish to GitHub Packages
npm config set @YOUR_USERNAME:registry https://npm.pkg.github.com
npm publish
We welcome contributions! See CONTRIBUTING.md
for guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This template is licensed under the MIT License - see the LICENSE
file for details.
Includes best practices from:
- TypeScript team recommendations
- NPM packaging guidelines
- GitHub Actions community
- Open source community standards
Happy packaging! π¦β¨
Made with β€οΈ by Xarlizard