Compare commits
8 Commits
fc43f440aa
...
0.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b39e4923e1 | ||
|
|
369feb3cc8 | ||
|
|
51bdb799ae | ||
|
|
1baddad939 | ||
|
|
e701e4dd70 | ||
|
|
e2b0e7d5ee | ||
|
|
635e9c0705 | ||
|
|
582a42e62d |
9
.dockerignore
Normal file
9
.dockerignore
Normal file
@@ -0,0 +1,9 @@
|
||||
node_modules
|
||||
.pnpm-store
|
||||
dist
|
||||
coverage
|
||||
.git
|
||||
.claude
|
||||
.specify
|
||||
specs
|
||||
docs
|
||||
49
.gitea/workflows/ci.yml
Normal file
49
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["*"]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm check
|
||||
|
||||
build-image:
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
needs: check
|
||||
runs-on: host
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Gitea registry
|
||||
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.bahamut.nitrix.one -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
||||
|
||||
- name: Build and push
|
||||
run: |
|
||||
IMAGE=git.bahamut.nitrix.one/dostulata/initiative
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
docker build -t $IMAGE:$TAG -t $IMAGE:latest .
|
||||
docker push $IMAGE:$TAG
|
||||
docker push $IMAGE:latest
|
||||
|
||||
- name: Deploy
|
||||
run: |
|
||||
IMAGE=git.bahamut.nitrix.one/dostulata/initiative
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
docker stop initiative || true
|
||||
docker rm initiative || true
|
||||
docker run -d --name initiative --restart unless-stopped -p 8080:80 $IMAGE:$TAG
|
||||
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM node:22-slim AS build
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable
|
||||
|
||||
WORKDIR /app
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY packages/domain/package.json packages/domain/
|
||||
COPY packages/application/package.json packages/application/
|
||||
COPY apps/web/package.json apps/web/
|
||||
RUN pnpm install --frozen-lockfile --ignore-scripts
|
||||
|
||||
COPY . .
|
||||
RUN pnpm --filter web build
|
||||
|
||||
FROM nginx:alpine
|
||||
COPY --from=build /app/apps/web/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
@@ -226,7 +226,7 @@ export function ActionBar({
|
||||
value={nameInput}
|
||||
onChange={(e) => handleNameChange(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
placeholder="Search creatures to add..."
|
||||
placeholder="+ Add combatants"
|
||||
className="max-w-xs"
|
||||
/>
|
||||
{suggestions.length > 0 && (
|
||||
|
||||
@@ -22,7 +22,6 @@ import type {
|
||||
} from "@initiative/domain";
|
||||
import {
|
||||
combatantId,
|
||||
createEncounter,
|
||||
isDomainError,
|
||||
creatureId as makeCreatureId,
|
||||
resolveCreatureName,
|
||||
@@ -33,24 +32,16 @@ import {
|
||||
saveEncounter,
|
||||
} from "../persistence/encounter-storage.js";
|
||||
|
||||
function createDemoEncounter(): Encounter {
|
||||
const result = createEncounter([
|
||||
{ id: combatantId("1"), name: "Aria" },
|
||||
{ id: combatantId("2"), name: "Brak" },
|
||||
{ id: combatantId("3"), name: "Cael" },
|
||||
]);
|
||||
|
||||
if (isDomainError(result)) {
|
||||
throw new Error(`Failed to create demo encounter: ${result.message}`);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
const EMPTY_ENCOUNTER: Encounter = {
|
||||
combatants: [],
|
||||
activeIndex: 0,
|
||||
roundNumber: 1,
|
||||
};
|
||||
|
||||
function initializeEncounter(): Encounter {
|
||||
const stored = loadEncounter();
|
||||
if (stored !== null) return stored;
|
||||
return createDemoEncounter();
|
||||
return EMPTY_ENCOUNTER;
|
||||
}
|
||||
|
||||
function deriveNextId(encounter: Encounter): number {
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"!.claude/**",
|
||||
"!.specify/**",
|
||||
"!specs/**",
|
||||
"!coverage/**"
|
||||
"!coverage/**",
|
||||
"!.pnpm-store/**"
|
||||
]
|
||||
},
|
||||
"assist": {
|
||||
|
||||
9
nginx.conf
Normal file
9
nginx.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
server {
|
||||
listen 80;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
@@ -169,9 +169,9 @@ describe("advanceTurn", () => {
|
||||
});
|
||||
|
||||
describe("invariants", () => {
|
||||
it("INV-1: createEncounter rejects empty combatant list", () => {
|
||||
it("INV-1: createEncounter accepts empty combatant list", () => {
|
||||
const result = createEncounter([]);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
expect(isDomainError(result)).toBe(false);
|
||||
});
|
||||
|
||||
it("INV-2: activeIndex always in bounds across all scenarios", () => {
|
||||
|
||||
@@ -38,8 +38,8 @@ function domainError(code: string, message: string): DomainError {
|
||||
|
||||
/**
|
||||
* Creates a valid Encounter, enforcing INV-1, INV-2, INV-3.
|
||||
* - INV-1: At least one combatant required.
|
||||
* - INV-2: activeIndex defaults to 0 (always in bounds).
|
||||
* - INV-1: An encounter MAY have zero combatants.
|
||||
* - INV-2: activeIndex defaults to 0 (always in bounds when combatants exist).
|
||||
* - INV-3: roundNumber defaults to 1 (positive integer).
|
||||
*/
|
||||
export function createEncounter(
|
||||
@@ -47,13 +47,10 @@ export function createEncounter(
|
||||
activeIndex = 0,
|
||||
roundNumber = 1,
|
||||
): Encounter | DomainError {
|
||||
if (combatants.length === 0) {
|
||||
return domainError(
|
||||
"invalid-encounter",
|
||||
"An encounter must have at least one combatant",
|
||||
);
|
||||
}
|
||||
if (activeIndex < 0 || activeIndex >= combatants.length) {
|
||||
if (
|
||||
combatants.length > 0 &&
|
||||
(activeIndex < 0 || activeIndex >= combatants.length)
|
||||
) {
|
||||
return domainError(
|
||||
"invalid-encounter",
|
||||
`activeIndex ${activeIndex} out of bounds for ${combatants.length} combatants`,
|
||||
|
||||
Reference in New Issue
Block a user