Skip to content

Commit

Permalink
chore: introduce pnpm workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
gtoselli committed Mar 27, 2024
1 parent ec02c0c commit ac935dc
Show file tree
Hide file tree
Showing 29 changed files with 1,011 additions and 1,007 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
on: push

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# compiled output
/dist
/node_modules
dist
node_modules

# Logs
logs
Expand All @@ -15,7 +15,7 @@ lerna-debug.log*
.DS_Store

# Tests
/coverage
coverage
/.nyc_output

# IDEs and editors
Expand Down
60 changes: 5 additions & 55 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,15 @@
"license": "Apache-2.0",
"main": "dist/index",
"scripts": {
"build": "rimraf dist && tsc --project tsconfig.build.json",
"test": "jest",
"test:coverage": "jest --coverage",
"prepublishOnly": "pnpm run build",
"build": "pnpm run -r build",
"test": "pnpm run -r test",
"test:coverage": "pnpm run -r test:coverage",
"prepare": "husky install",
"check": "cspell lint --quiet src/**/*ts"
},
"dependencies": {
"lodash": "^4.17.21",
"uuid": "^9.0.0"
},
"peerDependencies": {
"mongodb": "^4.0.0 || ^5.0.0 || ^6.0.0"
"check": "pnpm run -r check"
},
"devDependencies": {
"@types/jest": "^29.5.2",
"@types/lodash": "^4.14.195",
"@types/node": "^20.3.1",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"cspell": "^8.3.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"husky": "^8.0.0",
"jest": "^29.5.0",
"lint-staged": "^14.0.1",
"mongodb": "^4.17.2",
"mongodb-memory-server": "^8.13.0",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"publishConfig": {
"access": "public"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*spec\\.ts$",
"testPathIgnorePatterns": [
".api-spec.ts$"
],
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
"lint-staged": "^14.0.1"
},
"lint-staged": {
"*.ts": "eslint --fix",
Expand Down
69 changes: 69 additions & 0 deletions packages/ddd-tookit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "@fizzbuds/ddd-toolkit",
"version": "0.0.31",
"description": "",
"author": "Gabriele Toselli, Luca Giovenzana",
"private": false,
"license": "Apache-2.0",
"main": "dist/index",
"types": "dist/index.d.ts",
"scripts": {
"build": "rimraf dist && tsc --project tsconfig.build.json",
"test": "jest",
"test:coverage": "jest --coverage",
"check": "cspell lint --quiet src"
},
"dependencies": {
"lodash": "^4.17.21",
"uuid": "^9.0.0"
},
"peerDependencies": {
"mongodb": "^4.0.0 || ^5.0.0"
},
"devDependencies": {
"@types/jest": "^29.5.2",
"@types/lodash": "^4.14.195",
"@types/node": "^20.3.1",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"cspell": "^8.3.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"husky": "^8.0.0",
"jest": "^29.5.0",
"lint-staged": "^14.0.1",
"mongodb": "^4.17.2",
"mongodb-memory-server": "^8.13.0",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"publishConfig": {
"access": "public"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*spec\\.ts$",
"testPathIgnorePatterns": [
".api-spec.ts$"
],
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions src/generic-id.ts → packages/ddd-tookit/src/generic-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ export abstract class GenericId<T extends string = string> {
if (type && type !== this.typeFromClassNameWithoutId()) throw new Error('Wrong Id type');
}

private typeFromClassNameWithoutId() {
return this.constructor.name.replace(/Id$/, '').trim().toLowerCase();
}

static generate<IdType>(this: { new (_value: string): IdType }): IdType {
return new this(uuid());
}

static fromString<IdType>(this: { new (_value: string, _type: string): IdType }, idString: string): IdType {
const [type, value] = idString.split('_');
if (!value) {
Expand All @@ -36,6 +33,7 @@ export abstract class GenericId<T extends string = string> {
static fromValue<IdType>(this: { new (value: string): IdType }, idValue: string): IdType {
return new this(idValue);
}

equals(other: GenericId<T>): boolean {
if (!(other instanceof GenericId)) {
return false;
Expand All @@ -46,4 +44,8 @@ export abstract class GenericId<T extends string = string> {
toString() {
return `${this.type}_${this.value}`;
}

private typeFromClassNameWithoutId() {
return this.constructor.name.replace(/Id$/, '').trim().toLowerCase();
}
}
1 change: 1 addition & 0 deletions src/index.ts → packages/ddd-tookit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './repo/repo-hooks';
export * from './generic-id';
export * from './errors';
export * from './repo/mongo-query-repo';
export * from './event-bus/event-bus.interface';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions packages/ddd-tookit/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist"
}
}
7 changes: 7 additions & 0 deletions packages/ddd-tookit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist"
}
}
Loading

0 comments on commit ac935dc

Please sign in to comment.