Smart Node.js text-to-image
npm install node-ttiAn opinionated production-ready TypeScript library template with automated builds, testing, and releases.
And believe me. It is good.
> [!IMPORTANT]
> Looking for a monorepo template tailored for multi-library development, with nx and same features as this template?
> Check out good-typescript-libraries-template!
- ๐ฆ Dual Package Support - Outputs CommonJS and ESM builds
- ๐ก๏ธ Type Safety - Extremely strict TypeScript configuration
- ๐ Always up-to-date deps - Renovate bot for CVE-aware automatic dependency updates
- โ
Build Validation - Uses @arethetypeswrong/cli to check package exports
- ๐งช Automated Testing - Vitest with coverage reporting
- ๐จ Code Quality - Biome linting and formatting with pre-commit hooks
- ๐ Automated Releases - Semantic versioning with changelog generation
- โ๏ธ CI/CD Pipeline - GitHub Actions for testing and publishing
- ๐ง One-Click Setup - Automated repository configuration with init.sh script
- ๐๏ธ Repository rulesets - Branch protection with linear history and PR reviews
- ๐ท Feature cleanup - Disable wikis, projects, squash/merge commits
- ๐ Merge restrictions - Rebase-only workflow at repository and ruleset levels
- ๐ Admin bypass - Repository administrators can bypass protection rules
- ๐ Actions verification - Ensure GitHub Actions are enabled
- ๐๏ธ Secrets validation - Check and guide setup of required secrets
- TypeScript - Strict configuration for type safety
- Rollup - Builds both CommonJS and ESM formats
- Biome - Fast linting and formatting
- Vitest - Testing with coverage reports
- Husky - Pre-commit hooks for code quality
- Semantic Release - Automated versioning and releases
- pnpm - Fast package management with Corepack
- GitHub Actions - CI/CD pipeline
Run this in your terminal _GitHub CLI required_
``bash`
gh repo create my-typescript-library --clone --template neg4n/good-typescript-library-template --private && cd my-typescript-library
> [!NOTE]
> Replace my-typescript-library with your new library name, you can also change the visiblity of the newly created repo by passing --public instead of --private! Read more about possible options in GitHub CLI documentation
#### Setup via GitHub web interface
If for some reason you can't run the mentioned commands in your terminal, click the "Use this template โพ" button below (or in the top right corner of the repository page)
Run the initialization script to automatically configure your repository:
`bash`One-command setup
./init.sh
This script will:
- ๐ Create repository rulesets for branch protection (linear history, PR reviews)
- ๐ซ Disable unnecessary features (wikis, projects, squash/merge commits)
- โ๏ธ Configure merge settings (rebase-only workflow at repository and ruleset levels)
- ๐ค Grant admin bypass permissions for repository administrators
- ๐ง Verify GitHub Actions and validate repository configuration
- ๐ Check required secrets and provide setup instructions
The script will guide you to set up these secrets if missing:
NPM_TOKEN (for publishing):
`bashGenerate NPM token with OTP for enhanced security
pnpm token create --otp=
ACTIONS_BRANCH_PROTECTION_BYPASS (for automated releases):
`bash
Create Personal Access Token with 'repo' permissions
Visit: https://github.com/settings/personal-access-tokens/new
Set the PAT as repository secret
gh secret set ACTIONS_BRANCH_PROTECTION_BYPASS --body "your-pat-token-here"
`Scripts
| Command | Description |
|---------|-------------|
|
pnpm dev | Watch mode build |
| pnpm build | Production build |
| pnpm build:check | Build + package validation |
| pnpm test | Run tests |
| pnpm test:watch | Watch mode testing |
| pnpm test:coverage | Generate coverage report |
| pnpm lint | Check linting and formatting |
| pnpm lint:fix | Fix linting and formatting issues |
| pnpm typecheck | TypeScript type checking |
| pnpm release | Create release (CI only) |Renovate
renovate.json5 already turns onboarding off, so Renovate will start opening update PRs as soon as the GitHub App is installed. Enable it like this:1. Visit https://github.com/apps/renovate and click Install.
2. Choose your personal account or organization, then pick All repos or Only select repos (include this one).
3. Approve the requested permissions to finish installation. Renovate will run shortly after and open PRs based on
renovate.json5.Notes:
- Want to stop it? Uninstall the app or set
"enabled": false in renovate.json5.
- Need custom rules (schedules, groups, automerge)? Extend renovate.json5 - no extra onboarding PR is required.FAQ
#### How do I modify the merging methods?
good-typescript-library-template sets rebase-only at both repository and main branch levels. Here's how to modify this:##### Current Setup
- Repository: Rebase merging only (squash/merge disabled)
- Main branch ruleset: Requires rebase merging
##### To Change Merge Methods
For repository-wide changes:
- Settings > General > Pull Requests - toggle merge methods
For branch-specific changes:
- Settings > Rules - edit the main branch ruleset's "Require merge type"
##### Precedence Rules
1. Repository settings define what's available
2. Rulesets add restrictions on top
3. Most restrictive wins - if repository disallows a method but ruleset requires it, merging is blocked
##### Common Modifications
- Allow all methods: Enable squash/merge in repo settings + remove "Require merge type" from ruleset
- Squash-only: Change repo settings to squash-only OR keep current repo settings + change ruleset to require squash
- Different rules per branch: Create additional rulesets for other branch patterns
> [!TIP]
> Since
good-typescript-library-template is rebase-only, you must enable other methods in repository settings before rulesets can use them.#### How to solve pnpm lockfile error on my CI/CD?
If you're seeing this error in your CI/CD (GitHub Actions) pipeline:
`
[...]ERR_PNPM_OUTDATED_LOCKFILE Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with /package.json
[...]
`##### Why This Happens
This template uses
--frozen-lockfile flag to ensure consistent installations in CI/CD. The error occurs when your package.json has been modified but the pnpm-lock.yaml hasn't been updated to match.##### Solution
Run the following command locally:
`bash
pnpm install
`This will:
1. Update your
pnpm-lock.yaml to match your package.json
2. Install any new dependencies
3. Resolve version conflictsThen commit the updated lockfile:
`bash
git add pnpm-lock.yaml
git commit -m "chore: update pnpm lockfile"
`> [!TIP]
> This is expected behavior and ensures your CI/CD uses the exact same dependency versions as your local environment.
#### Why Linear History?
Linear history provides several benefits for library releases:
- Clean commit history - Easy to track changes and debug issues
- Simplified releases - Semantic release works better with linear commits
- Clear changelog - Each commit represents a complete change
- Better debugging -
git bisect` works more effectivelySee CONTRIBUTING.md for development workflow, commit conventions, and contribution guidelines.
The MIT License