ts-package-starter - v1.1.0
    Preparing search index...

    ts-package-starter - v1.1.0

    TypeScript Package Starter

    A modern, well-configured starter template for creating TypeScript npm packages. This template provides a solid foundation with best practices and essential tooling for TypeScript package development.

    CI License: MIT

    • ๐Ÿ“ฆ Modern build setup with tsup
    • ๐Ÿ”ฅ ESM and CommonJS support
    • ๐Ÿ“˜ TypeScript with strict mode
    • ๐Ÿงช Testing with Jest
    • ๐Ÿ“Š Code coverage reporting
    • ๐Ÿ“ API documentation with TypeDoc
    • โœจ Code formatting with Prettier
    • ๐Ÿšจ Linting with ESLint
    • ๐Ÿ”„ Continuous Integration with GitHub Actions
    • ๐Ÿ“‹ Conventional commits with commitlint
    • ๐Ÿช Git hooks with husky
    • ๐ŸŒฒ Tree-shakeable exports
    • ๐Ÿ“ฆ Optimized npm package exports
    • ๐Ÿค– Automated dependency updates with Renovate
    • Node.js >= 20.0.0
    • npm >= 10.0.0
    1. Use this template by clicking the "Use this template" button on GitHub or clone it directly:
    git clone https://github.com/imgarylai/ts-package-starter.git my-package
    cd my-package
    1. Update the package information:

      • Modify package.json with your package name, description, author, etc.
      • Update this README.md with your package's information
      • Update the LICENSE file if needed
    2. Install dependencies:

    npm install
    
    1. Start developing:
    npm run dev
    

    This is an example of how your package could be used once you publish it. Update this section with your own package's usage:

    // This is just a placeholder example - replace with your own package's usage
    import { YourFunction } from "your-package-name";

    // Use your package
    const result = YourFunction();
    1. Clone the repository:
    git clone https://github.com/imgarylai/ts-package-starter.git
    cd ts-package-starter
    1. Install dependencies:
    npm install
    
    1. Start developing:
    npm run dev
    
    • npm run build - Build the package with tsup
    • npm run dev - Watch mode for development
    • npm test - Run tests
    • npm run test:coverage - Run tests with coverage
    • npm run lint - Lint the code
    • npm run type-check - Check types
    • npm run docs - Generate documentation
    • npm run docs:watch - Generate documentation in watch mode
    • npm run clean - Clean build outputs
    • npm run prepare - Install git hooks
    .
    โ”œโ”€โ”€ src/ # Source code
    โ”‚ โ”œโ”€โ”€ index.ts # Main entry point
    โ”‚ โ””โ”€โ”€ index.test.ts # Tests
    โ”œโ”€โ”€ .github/ # GitHub configuration
    โ”œโ”€โ”€ .husky/ # Git hooks
    โ”œโ”€โ”€ dist/ # Built files (generated)
    โ”œโ”€โ”€ docs/ # Generated documentation
    โ”œโ”€โ”€ coverage/ # Test coverage reports
    โ””โ”€โ”€ node_modules/ # Dependencies
    1. Write your code in the src directory
    2. Write tests in *.test.ts files
    3. Run tests with npm test
    4. Build your package with npm run build

    This package uses semantic-release for automated publishing based on conventional commit messages. The process is fully automated and will:

    • Determine the next version number based on commit messages
    • Generate release notes
    • Update the CHANGELOG.md
    • Create a GitHub release
    • Publish to npm

    The release process is triggered by commits to the main branch. The version bump is determined by your commit messages:

    • fix: ... - Patch release (1.0.0 โ†’ 1.0.1)
    • feat: ... - Minor release (1.0.0 โ†’ 1.1.0)
    • BREAKING CHANGE: ... in commit body - Major release (1.0.0 โ†’ 2.0.0)
    • feat!: ... - Major release with breaking change (1.0.0 โ†’ 2.0.0)

    Examples:

    # Patch release
    git commit -m "fix: correct network timeout issue"

    # Minor release
    git commit -m "feat: add new API endpoint"

    # Major release
    git commit -m "feat!: redesign public API
    BREAKING CHANGE: The entire public API has been redesigned"

    To enable automated publishing, you need to:

    1. Create an npm account if you don't have one

    2. Create an npm access token:

      • Go to npmjs.com and log in
      • Click on your profile picture โ†’ "Access Tokens"
      • Click "Generate New Token" (select "Automation" type)
      • Copy the token
    3. Add the npm token to your GitHub repository:

      • Go to your GitHub repository settings
      • Click on "Secrets and variables" โ†’ "Actions"
      • Click "New repository secret"
      • Name: NPM_TOKEN
      • Value: Your npm access token
      • Click "Add secret"
    1. Write your code and commit using conventional commit messages
    2. Push to the main branch
    3. semantic-release will automatically:
      • Analyze commit messages
      • Bump version
      • Generate changelog
      • Create GitHub release
      • Publish to npm

    Note: Only commits to the main branch trigger releases. When working on features, use feature branches and pull requests.

    1. Fork the repository
    2. Create your feature branch (git checkout -b feature/amazing-feature)
    3. Commit your changes using conventional commits (git commit -m 'feat: add amazing feature')
    4. Push to the branch (git push origin feature/amazing-feature)
    5. Open a Pull Request

    This project uses Conventional Commits. Examples:

    • feat: add new feature
    • fix: resolve bug issue
    • docs: update README
    • chore: update dependencies

    The project uses tsup for building, which provides:

    • Multiple format outputs (ESM, CommonJS)
    • TypeScript declaration files
    • Source maps
    • Tree shaking
    • Minification

    This project uses TypeDoc for generating API documentation. The documentation is automatically built and deployed to GitHub Pages on every push to the main branch.

    To generate documentation locally:

    # Generate documentation
    npm run docs

    # Watch mode for documentation
    npm run docs:watch

    The documentation will be generated in the docs directory.

    The documentation is automatically deployed to GitHub Pages at: https://imgarylai.github.io/ts-package-starter

    Features of the documentation:

    • Full API reference
    • Type information
    • Search functionality
    • Version information
    • Integration with README
    • Examples and usage

    To set up GitHub Pages for your documentation:

    1. Go to your GitHub repository settings
    2. Navigate to "Pages" under "Code and automation"
    3. Under "Build and deployment":
      • Source: Select "GitHub Actions"
      • Branch: Leave as default (gh-pages will be created automatically)

    The documentation will be automatically built and deployed when:

    • You push to the main branch
    • The GitHub Actions workflow completes successfully

    You can also manually trigger the documentation build:

    1. Go to the "Actions" tab in your repository
    2. Select the "Documentation" workflow
    3. Click "Run workflow"

    The documentation is configured in typedoc.json. Key features:

    • Excludes private and protected members
    • Includes version information
    • Validates links and exports
    • Uses the default theme
    • Integrates with the README

    This project uses Renovate for automated dependency updates. The configuration includes:

    • Automatic merging of minor and patch updates
    • Dependencies are updated every weekend
    • Updates are automatically rebased
    • Non-major dependencies are grouped together
    • Node.js version updates are disabled (managed manually)

    The Renovate bot will automatically create pull requests for dependency updates according to this schedule and configuration. This helps keep your dependencies up-to-date while minimizing maintenance overhead.

    This project is licensed under the MIT License - see the LICENSE file for details.

    Gary Lai - @imgarylai