Skip to content

Commit

Permalink
feat: add tag for Query / Command
Browse files Browse the repository at this point in the history
  • Loading branch information
jbpionnier committed Feb 24, 2024
1 parent 58761d8 commit ce45e97
Show file tree
Hide file tree
Showing 9 changed files with 603 additions and 268 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: ci
on:
workflow_dispatch:
push:
paths-ignore:
- "*.md"
branches:
- master
pull_request:
paths-ignore:
- "*.md"
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ "16", "20" ]
name: Build on Node ${{ matrix.node }}
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run build

lint:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ "16", "20" ]
name: Lint on Node ${{ matrix.node }}
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run lint
39 changes: 39 additions & 0 deletions .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release on npm (canary)
on:
workflow_dispatch:

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16

- name: Install dependencies
run: |
npm install
- name: Build
run: |
npm run clean
npm run build
- name: Set version
run: |
npm --no-git-tag-version version minor
npm --no-git-tag-version version $(npm pkg get version | sed 's/"//g')-canary.$(date +'%Y%m%dT%H%M%S')
- id: publish
name: Publish to NPM
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
dry-run: false
tag: canary
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release on npm
on:
workflow_dispatch:

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16

- name: Install dependencies
run: |
npm install
- name: Build
run: |
npm run clean
npm run build
- id: publish
name: Publish to NPM
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
dry-run: false

- name: Post-publish
if: steps.publish.outputs.type != 'none'
run: |
echo "Published ${{ steps.publish.outputs.type }} version: ${{ steps.publish.outputs.version }}"
- name: Publish skipped
if: steps.publish.outputs.type == 'none'
run: |
echo "Version in package.json has not changed. Skipping."
exit 0
- name: Configure changelog
if: steps.publish.outputs.type != 'none'
run: |
echo '{"categories": [], "template": "## Commits:\n\n${{ '${{UNCATEGORIZED}}' }}", "pr_template": ${{ '"- ${{MERGE_SHA}} ${{TITLE}}"' }} }' > changelog_config.json
cat changelog_config.json
echo "last_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "curr_commit=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Generate changelog
if: steps.publish.outputs.type != 'none'
id: github_release
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
fromTag: "${{ env.last_tag }}"
toTag: ${{ github.ref }}
commitMode: true
configuration: changelog_config.json

- name: Create release
if: steps.publish.outputs.type != 'none'
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.publish.outputs.version }}
release_name: v${{ steps.publish.outputs.version }}
commitish: ${{ github.ref }}
body: ${{steps.github_release.outputs.changelog}}
draft: false
prerelease: false
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,51 @@
# ts-ddd
Domain-Driven Design TypeScript

[![npm version](https://badge.fury.io/js/%40jbpionnier%2Fddd.svg)](https://badge.fury.io/js/%40jbpionnier%2Fddd)
[![Build Status](https://travis-ci.org/jbpionnier/ts-ddd.svg?branch=master)](https://travis-ci.org/jbpionnier/ts-ddd)
[![npm](https://img.shields.io/npm/dm/%40jbpionnier%2Fddd.svg)](https://npm-stat.com/charts.html?package=%40jbpionnier%2Fddd)

Utilities types for Domain-Driven Design in TypeScript

> [!WARNING]
> Work in progress.
## Installation

```bash
npm install @jbpionnier/ddd
```

## Usage

- ICommandBus / Command / CommandHandler
- IQueryBus / Query / QueryHandler
- IEventBus / Event / EventHandler
- AggregateRoot
- DomainEvent / DomainEventStream
- Entity / ValueObject
- Repository
- EventStream / Saga
- EventStore

### ICommandBus / Command / CommandHandler

```typescript
import { ICommandBus, ICommandHandler, Command } from '@jbpionnier/ddd'

class MyCommand implements Command {
constructor(public readonly id: string) {}
}

@CommandHandler(MyCommand)
class MyCommandHandler implements ICommandHandler<ImportMediaCommand> {
handle(command: MyCommand): void {
console.log('Handling command', command)
}
}
// Create the command bus
const commandBus: ICommandBus = new CommandBus()
commandBus.register(new MyCommandHandler())

// Execute the command
commandBus.execute(new MyCommand('123'))
```
Loading

0 comments on commit ce45e97

Please sign in to comment.