Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
5442fb5
chore: Bump version to 1.5.3 in package.json
jordyfontoura Oct 27, 2025
0558ca1
refactor: Update type annotations in unwrap-error tests for improved …
jordyfontoura Oct 27, 2025
a8303e7
chore: Add Playwright browser installation step to CI workflow for en…
jordyfontoura Oct 27, 2025
ab80fe7
chore: Update Playwright browser installation command in CI workflow …
jordyfontoura Oct 27, 2025
55108b9
chore: Reorder test execution in CI workflow for improved clarity and…
jordyfontoura Oct 27, 2025
0c7d936
chore: Enhance CI/CD workflows with validation steps, multi-version t…
jordyfontoura Oct 27, 2025
d73770a
chore: Remove Node.js version 18 from CI workflow matrix for streamli…
jordyfontoura Oct 27, 2025
3182f65
chore: Update keywords in package.json for improved clarity and relev…
jordyfontoura Oct 27, 2025
86e6fb7
chore: Bump version to 1.5.4 and enhance package metadata for improve…
jordyfontoura Oct 27, 2025
1e94241
chore: Bump version to 1.5.5 and migrate documentation examples to us…
jordyfontoura Oct 27, 2025
709f603
chore: Bump version to 1.5.6 and enhance `resultfy()` to support Prom…
jordyfontoura Feb 3, 2026
a89d686
chore: Simplify package.json exports structure for clearer module res…
jordyfontoura Feb 13, 2026
166e0fb
chore: Bump version to 1.5.7 and fix ESM module exports configuration…
jordyfontoura Feb 13, 2026
60164aa
chore: Bump version to 1.5.8 and fix ESM module compatibility by upda…
jordyfontoura Feb 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 102 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,68 @@ on:
- dev

jobs:
# ValidaΓ§Γ΅es rΓ‘pidas primeiro
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.18.3

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run linter
run: pnpm --filter tryless lint

# VerificaΓ§Γ£o de tipos
typecheck:
name: Type Check
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.18.3

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Check types
run: pnpm --filter tryless exec tsc --noEmit

# Build e testes em mΓΊltiplas versΓ΅es do Node
test:
name: Test (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: [lint, typecheck]

strategy:
fail-fast: false
matrix:
node-version: [22]
node-version: [20, 22]

steps:
- name: Checkout repository
Expand All @@ -36,15 +92,54 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run linter
run: pnpm --filter tryless lint
- name: Get Playwright version
id: playwright-version
run: echo "version=$(pnpm --filter tryless list @playwright/test --depth=0 --json | jq -r '.[0].version')" >> $GITHUB_OUTPUT
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playwright cache key uses wrong dependency

Medium Severity

The cache key reads @playwright/test version, but package/package.json depends on playwright instead. This makes steps.playwright-version.outputs.version resolve to null, so the browser cache key is not tied to the actual Playwright runtime version.

Additional Locations (1)

Fix in CursorΒ Fix in Web


- name: Run tests
run: pnpm --filter tryless test
- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}

- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm --filter tryless exec playwright install --with-deps chromium

- name: Install Playwright system dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: pnpm --filter tryless exec playwright install-deps chromium

- name: Build package
run: pnpm --filter tryless build

- name: Check types
run: pnpm --filter tryless exec tsc --noEmit
- name: Run tests
run: pnpm --filter tryless test

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results-node-${{ matrix.node-version }}
path: package/test-results/
retention-days: 7

# Job final que depende de todos os outros
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [lint, typecheck, test]
if: always()

steps:
- name: Check all jobs
run: |
if [[ "${{ needs.lint.result }}" != "success" ]] || \
[[ "${{ needs.typecheck.result }}" != "success" ]] || \
[[ "${{ needs.test.result }}" != "success" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All jobs passed successfully!"

80 changes: 77 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Validate tag format
id: tag-info
run: |
TAG=${GITHUB_REF#refs/tags/}
echo "tag=$TAG" >> $GITHUB_OUTPUT

# Remove 'v' prefix for version comparison
VERSION=${TAG#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT

# Validate semantic versioning format
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$ ]]; then
echo "Error: Tag must follow semantic versioning (e.g., v1.0.0)"
exit 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semver validation rejects valid prerelease tags

Medium Severity

The tag regex in publish.yml does not allow - inside prerelease or build identifiers, so valid SemVer tags like v1.2.3-beta-1 fail validation. This makes Validate tag format reject legitimate release tags and blocks publishing.

Fix in CursorΒ Fix in Web

fi

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
Expand All @@ -31,18 +47,76 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Verify package.json version matches tag
run: |
PACKAGE_VERSION=$(node -p "require('./package/package.json').version")
TAG_VERSION="${{ steps.tag-info.outputs.version }}"

if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
echo "Error: package.json version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
exit 1
fi
echo "βœ… Version validation passed: $PACKAGE_VERSION"

- name: Verify CHANGELOG entry exists
run: |
TAG_VERSION="${{ steps.tag-info.outputs.version }}"

if ! grep -q "## \[$TAG_VERSION\]" CHANGELOG.md && ! grep -q "## $TAG_VERSION" CHANGELOG.md; then
echo "⚠️ Warning: No CHANGELOG entry found for version $TAG_VERSION"
echo "Please update CHANGELOG.md before publishing"
exit 1
fi
echo "βœ… CHANGELOG entry found for version $TAG_VERSION"

- name: Run linter
run: pnpm --filter tryless lint

- name: Run tests
run: pnpm --filter tryless test
- name: Check types
run: pnpm --filter tryless exec tsc --noEmit

- name: Get Playwright version
id: playwright-version
run: echo "version=$(pnpm --filter tryless list @playwright/test --depth=0 --json | jq -r '.[0].version')" >> $GITHUB_OUTPUT

- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}

- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm --filter tryless exec playwright install --with-deps chromium

- name: Install Playwright system dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: pnpm --filter tryless exec playwright install-deps chromium

- name: Build package
run: pnpm --filter tryless build

- name: Run tests
run: pnpm --filter tryless test

- name: Copy README to package
run: cp README.md package/README.md

- name: Verify package contents
working-directory: ./package
run: |
echo "πŸ“¦ Package contents:"
ls -la
echo ""
echo "πŸ“„ Dist files:"
ls -la dist/
echo ""
if [ ! -f "README.md" ]; then
echo "Error: README.md not found in package directory"
exit 1
fi

- name: Publish to NPM
working-directory: ./package
run: npm publish --provenance --access public
Expand All @@ -61,7 +135,7 @@ jobs:
## πŸ“¦ Installation

```bash
npm install tryless@${{ github.ref_name }}
npm install tryless@${{ steps.tag-info.outputs.version }}
```

## πŸ“š Documentation
Expand Down
88 changes: 83 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,84 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.5.8] - 2025-02-13

### Fixed
- Fixed ESM module compatibility issue with ESM loaders/runtimes like `tsx` by changing ESM output extension from `.js` to `.mjs`
- Updated Rollup config to generate `dist/index.mjs` instead of `dist/index.esm.js` to ensure proper ESM resolution
- Updated `package.json` exports to use `.mjs` extension for ESM imports, resolving "does not provide an export named 'err'" errors
- The `.mjs` extension is always treated as ESM by Node.js regardless of `package.json` `type` field, eliminating ambiguity
- This fix ensures compatibility with tools like `tsx`, `ts-node` with ESM loader, and other ESM loaders without requiring `"type": "module"` in package.json

## [1.5.7] - 2025-02-13

### Fixed
- Fixed ESM module exports configuration in package.json to ensure proper resolution of named exports (`err`, `ok`, `resultfy`, etc.)
- Simplified exports field format for better compatibility with Node.js ESM resolution and tools like `tsx`
- Resolved issue where imports like `import { err } from 'tryless'` would fail with "does not provide an export named 'err'"

## [1.5.6] - 2025-02-13

### Changed
- Enhanced `resultfy()` to support PromiseLike objects (proxy promises) in addition to native Promise instances
- Replaced `instanceof Promise` checks with `isThenable()` type guard following Promise/A+ specification
- `resultfy()` now correctly handles any object that implements the `then` method, including proxy promises and custom promise-like objects

## [1.5.5] - 2025-10-27

### Changed
- Migrated documentation examples from `.then(ok, errReject())` pattern to `resultfy()` for improved readability

### Documentation
- Refactored all promise handling examples to use `resultfy()` as the recommended approach
- Added comparison highlighting benefits of `resultfy()` over `.then(ok, errReject())`
- Enhanced `resultfy` section with best practices and clearer examples
- Maintained `errReject` documentation for complex promise chain scenarios
- Updated JSDoc docstrings in source code:
- `resultfy`: Marked as "Recommended approach" with improved examples showing custom error messages
- `errReject`: Added note to prefer `resultfy()` for simple cases, with comparison examples
- `IResult` type: Updated example to use `resultfy()` instead of try-catch pattern

## [1.5.4] - 2025-10-27

### Changed
- Enhanced NPM keywords for better package discoverability and SEO optimization
- Added strategic keywords: `result-type`, `type-safe`, `functional-programming`, `railway-oriented`, `async-error-handling`, `promise`, `no-throw`, `either`, `option`, `monad`, `error-management`, `exception-handling`, `fp`, `functional`, `nodejs`, `zero-dependencies`
- Updated package description from generic to more compelling: "Type-safe error handling for TypeScript without try-catch hell"

### Documentation
- Improved package metadata to increase visibility in NPM search results

## [1.5.3] - 2025-10-27

### Added
- Comprehensive documentation in README
- GitHub Actions workflows for CI/CD
- Publishing guide for contributors
- `IResult` type for type-safe result handling with success and error types
- Runtime module for Node.js environment detection
- Custom inspect function for `UnwrapError` with Node.js support
- Tests for `IUnknownError`, `IUnknownOk`, `IUnknownErr`, and `IUnknownOkErr` type utilities
- TypeScript configuration for test types with type-checking capabilities
- Comprehensive test script in package.json covering unit, integration, and type tests
- Version validation in publish workflow (ensures package.json matches git tag)
- CHANGELOG entry verification before publishing
- Type checking step in publish workflow
- Automated test results upload on failure for easier debugging
- CI success job for better branch protection integration
- Playwright browser caching in both CI and publish workflows
- Playwright browser installation step in CI workflow

### Changed
- Migrated testing framework from Jest to Vitest for better performance and DX
- Optimized CI workflow with parallel job execution (lint, typecheck, and tests run simultaneously)
- Added multi-version Node.js testing (Node 18, 20, and 22) to ensure compatibility across LTS versions
- Implemented intelligent Playwright browser cache to reduce CI execution time
- Enhanced publish workflow with comprehensive validation steps
- Reordered test execution in CI workflow for improved clarity and consistency
- Updated Playwright browser installation to use pnpm filter for better dependency management
- Configured Turbo for test dependencies

### Fixed
- Updated Vitest configuration to include specific test directories for better test organization
- Improved type annotations in unwrap-error tests for enhanced type safety

## [1.4.3] - 2024-XX-XX

Expand All @@ -32,6 +104,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Examples for common use cases
- Integration examples with Zod validation

[Unreleased]: https://github.com/jordyfontoura/tryless/compare/v1.4.3...HEAD
[Unreleased]: https://github.com/jordyfontoura/tryless/compare/v1.5.8...HEAD
[1.5.8]: https://github.com/jordyfontoura/tryless/compare/v1.5.7...v1.5.8
[1.5.7]: https://github.com/jordyfontoura/tryless/compare/v1.5.6...v1.5.7
[1.5.6]: https://github.com/jordyfontoura/tryless/compare/v1.5.5...v1.5.6
[1.5.5]: https://github.com/jordyfontoura/tryless/compare/v1.5.4...v1.5.5
[1.5.4]: https://github.com/jordyfontoura/tryless/compare/v1.5.3...v1.5.4
[1.5.3]: https://github.com/jordyfontoura/tryless/compare/v1.4.3...v1.5.3
[1.4.3]: https://github.com/jordyfontoura/tryless/releases/tag/v1.4.3

Loading