Skip to content

Commit ea615a4

Browse files
committed
Added lerna support
1 parent a720b63 commit ea615a4

File tree

14 files changed

+48
-19
lines changed

14 files changed

+48
-19
lines changed

.github/workflows/glhf-ecs.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ on:
99
pull_request:
1010
branches: [ "main" ]
1111

12-
defaults:
13-
run:
14-
working-directory: ./packages/glhf-ecs
15-
1612
jobs:
1713
build:
1814
runs-on: ubuntu-latest
@@ -29,7 +25,6 @@ jobs:
2925
with:
3026
node-version: ${{ matrix.node-version }}
3127
cache: 'npm'
32-
cache-dependency-path: ./packages/glhf-ecs/package-lock.json
3328
- run: npm ci
3429
#- run: npm run build --if-present
35-
- run: npm test
30+
- run: lerna run test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.idea
22
.tmp
33
node_modules
4+
.nx/cache
45
packages/glhf-demo/assets/*
56
/packages/glhf-demo/build
67
/packages/glhf-demo/src/assets/sprites/kil.png

lerna.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3+
"version": "0.0.0"
4+
}

nx.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"targetDefaults": {},
3+
"namedInputs": {
4+
"default": [
5+
"{projectRoot}/**/*",
6+
"sharedGlobals"
7+
],
8+
"sharedGlobals": [],
9+
"production": [
10+
"default"
11+
]
12+
}
13+
}

package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "glhf",
3+
"private": true,
4+
"workspaces": [
5+
"packages/*"
6+
],
7+
"dependencies": {},
8+
"devDependencies": {
9+
"lerna": "^8.1.2"
10+
}
11+
}

packages/glhf-assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"Error: no test specified for glhf-assets yet.\""
88
},
99
"author": "",
1010
"license": "ISC"

packages/glhf-component/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "glhf-entity",
2+
"name": "glhf-component",
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"Error: no test specified for glhf-component yet.\""
88
},
99
"author": "Serban Ghita",
1010
"license": "MIT"

packages/glhf-demo/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "",
55
"scripts": {
66
"build": "webpack --mode development",
7-
"dev": "webpack serve --mode development"
7+
"dev": "webpack serve --mode development",
8+
"test": "echo \"Error: no test specified for glhf-demo yet.\""
89
},
910
"author": "Serban Ghita",
1011
"license": "ISC",

packages/glhf-ecs/src/Entity.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import Component from "./Component";
2-
import {addBit, hasBit, removeBit} from "../../glhf-bitmask/src/bitmask";
2+
import {addBit, hasBit, removeBit} from "@glhf/bitmask/bitmask";
33
import World from "./World";
4-
import StateManager from "../../glhf-fsm/src/StateManager";
54

65
export default class Entity {
6+
// Bitmask for storing Entity's components.
77
public componentsBitmask = 0n;
88
// Cache of Component instances.
99
public components = new Map<string, Component>();
1010

11-
constructor(public world: World, public fsm: StateManager, public id: string) {}
11+
constructor(public world: World, public id: string) {}
1212

1313
public addComponent<T extends typeof Component>(declaration: T, properties: Record<string, any> = {}): Entity
1414
{

packages/glhf-ecs/src/World.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import Entity from "./Entity";
22
import System from "./System";
33
import Query, {IQueryFilters} from "./Query";
44
import Component from "./Component";
5-
import { hasBit } from "../../glhf-bitmask/src/bitmask";
6-
import StateManager from "../../glhf-fsm/src/StateManager";
5+
import { hasBit } from "@glhf/bitmask/bitmask";
76
import ComponentRegistry from "./ComponentRegistry";
87

98
export default class World {
@@ -48,7 +47,7 @@ export default class World {
4847
throw new Error(`Entity with the id "${id}" already exists.`);
4948
}
5049

51-
const entity = new Entity(this, new StateManager(), id);
50+
const entity = new Entity(this, id);
5251

5352
this.entities.set(entity.id, entity);
5453
this.notifyQueriesOfEntityCandidacy(entity);

packages/glhf-fsm/src/StateManager.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('StateManager', () => {
128128
sm.unregisterStateWithName('idle');
129129

130130
expect(() => sm.getState('idle')).toThrowError('Requested state idle is not registered.');
131-
expect(() => sm.getDefaultState()).toThrowError('No "default" state has been set.');
131+
expect(() => sm.getDefaultState()).toThrowError('No "default" state has been set.');
132132
expect(() => sm.getCurrentState()).toThrowError('No "current" state has been set yet.');
133133
});
134134

packages/glhf-fsm/src/StateManager.ts

+5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export default class StateManager {
4949
}
5050

5151
public unregisterStateWithName(stateName: string) {
52+
const state = this.states.get(stateName);
53+
if (!state) { return; }
5254
this.states.delete(stateName);
55+
if (this.defaultState?.id === state.id) {
56+
this.defaultState = undefined;
57+
}
5358
}
5459

5560
public queueState(id: string, ...args: any[]): StateManager {

packages/glhf-input/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"Error: no test specified for glhf-input yet.\""
88
},
99
"dependencies": {
1010
"@typescript-eslint/eslint-plugin": "^5.33.1",

packages/glhf-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"tsc": "tsc",
66
"build": "webpack --mode development",
77
"dev": "webpack --mode development --watch",
8-
"test": "jest"
8+
"test": "echo \"Error: no test specified for glhf-renderer yet.\""
99
},
1010
"author": "Serban Ghita",
1111
"license": "MIT",

0 commit comments

Comments
 (0)