tws-first-package
v1.0.4
Published
A new npm package: tws-first-package
Downloads
8
Readme
tws-first-package
A TypeScript utility package with math functions, built with modern tooling and automated publishing.
Installation
npm install tws-first-packageUsage
import { add } from 'tws-first-package';
const result = add(2, 3); // 5Available Functions
add(a: number, b: number)- Adds two numberssubtract(a: number, b: number)- Subtracts two numbersmultiply(a: number, b: number)- Multiplies two numbers
Development
Setup
npm installAvailable Scripts
npm run dev- Run tests in watch mode during developmentnpm run test- Run all tests oncenpm run build- Compile TypeScript todist/npm run format- Auto-format code with Prettiernpm run check-format- Check code formattingnpm run ci- Run full CI checks (build + format + tests)npm run changeset- Create a changeset to document changesnpm run release- Version and publish package
Workflow for Adding New Features
Write your code
# Add new functions to src/utils.ts # Write tests in src/utils.test.ts # Export new functions in src/index.tsTest during development
npm run dev # Watch mode for testsDocument your changes
npm run changesetThis will prompt you to:
- Select the type of change (patch/minor/major)
- Write a description of what changed
Run quality checks
npm run ci # Runs build + format check + testsRelease (maintainers only)
npm run releaseThis will:
- Update version numbers based on changesets
- Generate/update CHANGELOG.md
- Publish to npm
Automated Publishing
The package is automatically published when changes are pushed to the main branch via GitHub Actions. The workflow:
CI Pipeline (
.github/workflows/ci.yml)- Runs on PRs and pushes to main
- Executes
npm run cito validate code
Publish Pipeline (
.github/workflows/publish.yml)- Runs on pushes to main
- Builds and publishes to npm using
NPM_TOKENsecret
Project Structure
src/
├── index.ts # Main exports
├── utils.ts # Utility functions
└── utils.test.ts # Tests using VitestTooling
- TypeScript - Type safety and compilation
- Vitest - Fast unit testing
- Prettier - Code formatting
- Changesets - Version management and changelog generation
- GitHub Actions - Automated CI/CD
Contributing
- Fork the repository
- Create a feature branch
- Make your changes following the development workflow above
- Create a changeset:
npm run changeset - Submit a pull request
License
MIT
Lar-lar-lar-lar
