@thiagopi/ts-utils-kit
v1.0.4
Published
TypeScript utility functions
Readme
@thiagopi/ts-utils-kit
TypeScript utility functions published as an npm package.
Install
npm install @thiagopi/ts-utils-kitUsage
import {
generatePassword,
mask,
maskCEP,
maskCNPJ,
maskCPF,
maskDate,
maskPhoneNumber,
} from "@thiagopi/ts-utils-kit";
generatePassword({ total: 20, uppercase: true, numbers: true });
maskCPF("12345678901"); // "123.456.789-01"Development
npm install
npm test
npm run buildReleasing
This repo uses GitHub Actions to publish to npm. Workflows live in .github/workflows/.
Alpha release (pull request)
Open a PR targeting main, then leave a comment with exactly:
release-alphaYou can also use /release-alpha.
Only repository owners, members, and collaborators can trigger the workflow. Fork PRs are not supported.
The Release Alpha workflow will:
- Run tests and build the package from the PR head commit
- Publish to npm with the
alphadist-tag - Post install instructions on the PR and in the Actions job summary
Alpha versions use the format {package.json version}-alpha.pr{PR number}.{run number} (for example, 1.0.0-alpha.pr42.3).
Install an alpha build:
# Specific PR alpha version (shown in the PR comment)
npm install @thiagopi/[email protected]
# Latest alpha tag
npm install @thiagopi/ts-utils-kit@alphaStable release (main)
When changes are merged into main, the Release workflow publishes a stable version automatically.
The workflow will:
- Bump the patch version when the current
package.jsonversion is already on npm (using the latest npm version as the baseline) - Run tests, build, and publish to npm with the
latestdist-tag - Tag the merge commit and create a GitHub release
package.json on main is not updated by the release workflow so it stays compatible with branch protection. To ship a minor or major release, bump the version in a pull request before merging (for example, 1.0.0 → 1.1.0).
Install a stable release:
# Specific version
npm install @thiagopi/[email protected]
# Latest stable tag
npm install @thiagopi/ts-utils-kit@latestGitHub setup
- Add an npm automation token as the repository secret
NPM_TOKEN. - In Settings → Actions → General, set workflow permissions to Read and write permissions so the alpha workflow can comment on PRs.
- Merge the workflow files to
main. Comment-triggered workflows run from the default branch.
Adding a new helper with Cursor
This repo includes a Cursor skill that guides adding and exporting new utilities.
Skill: export-helper
Location: .cursor/skills/export-helper/SKILL.md
How to use it
Open this project in Cursor.
Ask the agent to add a helper and reference the skill. For example:
Add a
maskRGhelper and export it from the package. Use theexport-helperskill.Or:
@export-helper add a currency formatter utility
The agent will follow the skill workflow:
- Create the helper under
src/ - Add tests (
*.test.tsor*.spec.ts) - Export from the group barrel (if applicable) and
src/index.ts - Run
npm run build && npm test
- Create the helper under
What the skill defines
| Topic | Convention |
|-------|------------|
| Standalone helper | src/<name>/index.ts |
| Grouped helpers | src/<group>/<name>/index.ts (e.g. src/mask/) |
| Types | T prefix (TGeneratePassword) |
| Imports in TS | Use .js extensions for ESM |
| Public API | Explicit named exports in src/index.ts |
For copy-paste templates, see .cursor/skills/export-helper/examples.md.
Manual workflow (without Cursor)
If you prefer to add helpers yourself, follow the checklist in the skill:
- Implement the helper under
src/ - Add tests next to it
- Re-export from the group
index.ts(if part of a group likemask) - Add named exports to
src/index.ts - Run
npm run build && npm test
Scripts
| Command | Description |
|---------|-------------|
| npm test | Run tests |
| npm run build | Build dist/ for publishing |
| npm run check | Lint and format with Biome |
License
MIT
