Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Bug Report
description: Something isn't working as expected
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report a bug. Please fill out the form below.
- type: textarea
id: description
attributes:
label: What happened?
description: A clear description of the bug.
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Minimal reproduction
description: Code snippet that demonstrates the issue.
render: javascript
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: What did you expect to happen?
validations:
required: true
- type: input
id: version
attributes:
label: Package version
placeholder: "e.g. 2.0.0"
validations:
required: true
- type: input
id: node
attributes:
label: Node.js version
placeholder: "e.g. 22.0.0"
validations:
required: true
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Feature Request
description: Suggest a new feature or improvement
labels: ["enhancement"]
body:
- type: textarea
id: problem
attributes:
label: Problem statement
description: What problem does this feature solve?
validations:
required: true
- type: textarea
id: solution
attributes:
label: Proposed solution
description: Describe the solution you'd like to see.
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives considered
description: Any alternative solutions or features you've considered?
22 changes: 22 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Summary

<!-- What does this PR do? -->

## Type of change

- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that causes existing functionality to change)
- [ ] Documentation update

## Checklist

- [ ] My code passes `npm run lint`
- [ ] I have added tests that cover my changes
- [ ] All existing tests pass (`npm test`)
- [ ] I have updated the README if needed
- [ ] I have updated CHANGELOG.md

## Related issues

<!-- Closes #... -->
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 5
labels:
- "dependencies"
commit-message:
prefix: "chore(deps)"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
labels:
- "dependencies"
- "github-actions"
commit-message:
prefix: "ci"
42 changes: 42 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Java CI

on:
push:
branches: [ master, test, prod-ready-riced-x100 ]
pull_request:
branches: [ master, test ]

defaults:
run:
working-directory: packages/java

jobs:
test:
name: JDK ${{ matrix.java-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
java-version: [ '25' ]

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

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
run: gradle build --no-daemon

- name: Test
run: gradle test --no-daemon
env:
CI: true
48 changes: 30 additions & 18 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master,test ]
branches: [ master, test ]
pull_request:
branches: [ master,test ]
branches: [ master, test ]

jobs:
build:
defaults:
run:
working-directory: packages/js

jobs:
test:
name: Node ${{ matrix.node-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x, 20.x, 22.x, 24.x]
node-version: [18.x, 20.x, 22.x, 24.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
env:
CI: true
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: packages/js/package-lock.json

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Test
run: npm test
env:
CI: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ vendor
temp
tmp
TODO.md
dist/
*.tsbuildinfo
reports/
bun.lock
bun.lockb
66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Changelog

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.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- **Monorepo restructure**: project is now a polyglot monorepo with two
language packages under `packages/`. The npm package source moved to
`packages/js/` (entry now resolves via `packages/js/package.json`,
unchanged for consumers).
- **Java module (`packages/java/`)** — full Java port with 100% feature
parity against the JavaScript module. Targets JDK 25, built with
Gradle Kotlin DSL, tested with JUnit 5 + AssertJ (66 tests).
- Core: `ConditionallyExecute`, `Context`, `Branch`, `Handler`,
`Middleware`, `Next`, `ConditionallyExecuteError`, `AggregateException`
- Plugins: `TimeoutPlugin`, `RetryPlugin`, `AuditLogPlugin`,
`CollectErrorsPlugin`, `DryRunPlugin`, `MultiThreadedPlugin`
(virtual-thread quorum), `GrpcConsensusPlugin` + `GrpcNodeServer`
- Async model: `CompletableFuture<Void>` everywhere; sync escape hatch
via `executeSync()`.
- **Shared gRPC schema** (`proto/conditionally_execute.proto`) — single
source of truth used by both the JS and Java `GrpcConsensusPlugin`,
enabling cross-runtime quorum (Java coordinator → JS nodes, etc.).
- **Java CI workflow** (`.github/workflows/java.yml`) running Gradle
build + tests on Temurin JDK 25.
- **Root README** redesigned as a monorepo overview pointing at per-language docs.
- `ConditionallyExecuteOptions` interface with `initialCondition` and `collectErrors` options (JS)
- `collectErrors` mode: collects all handler errors into an `AggregateError` instead of short-circuiting (JS)
- Full JSDoc documentation on all public members (JS)
- `.prettierrc` code style configuration
- `.editorconfig` for consistent editor settings
- GitHub issue templates (bug report, feature request)
- GitHub PR template
- `dependabot.yml` for automated dependency updates
- `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `SECURITY.md`
- `bench.js` — performance benchmark vs native `if`

### Changed
- **Breaking**: `execute()` is now `async` and returns `Promise<void>`
(previously synchronous — any code that did not `await` execute() was already
silently ignoring async handlers)
- Condition logic: `this.True` (public, boolean-typed `true` literal) replaced
with `this._condition` (private boolean). Last `.condition()` call wins.
- `onTrue()` and `onFalse()` now throw `TypeError` immediately for non-function arguments
- CI updated: `actions/checkout@v2` → `v4`, `setup-node@v1` → `v4` (with npm cache)
- CI: removed no-op `npm run build --if-present`, added lint and typecheck steps
- Node.js CI workflow now runs from `packages/js/` working directory (monorepo restructure)
- README: fixed typo in install command (`conditionaly-execute` → `conditionally-execute`)
- README: added full API reference, async examples, default condition documentation
- Node.js support floor raised from 16 (EOL) to 18 (LTS)

### Fixed
- Multi-condition bug: calling `.condition(false).condition(true)` previously
ignored the second call; it now correctly uses the last-provided value
- Promise-returning handlers were silently dropped; all handlers now properly awaited

## [1.0.0] — Initial release

- `ConditionallyExecute` class with `.condition()`, `.onTrue()`, `.onFalse()`, `.execute()`
- Fluent builder API with arbitrary method ordering
- Basic Mocha test suite
- GitHub Actions CI (Node 16–24)
32 changes: 32 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Code of Conduct

## Our Pledge

We pledge to make participation in this project a harassment-free experience
for everyone, regardless of age, body size, disability, ethnicity, sex
characteristics, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to a positive environment:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy toward other community members
- Not making fun of people for using `if` statements

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the project maintainer. All complaints will be reviewed and
investigated and will result in a response that is deemed necessary and
appropriate to the circumstances.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
version 2.1.
Loading