diff --git a/package.json b/package.json index a7973b9..3d943d0 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,11 @@ "tsx", "js" ], + "moduleNameMapper": { + "^@rimo/(.*)": [ + "/src/$1" + ] + }, "coveragePathIgnorePatterns": [ "rimo.ts", "/node_modules/", @@ -73,7 +78,7 @@ } }, "collectCoverageFrom": [ - "src/*.{js,ts}" + "src/**/*.{js,ts}" ] }, "prettier": { @@ -102,6 +107,7 @@ "jest": "^25.3.0", "jest-config": "^25.3.0", "lint-staged": "^10.1.3", + "lodash": "^4.17.15", "lodash.camelcase": "^4.3.0", "prettier": "^2.0.4", "prompt": "^1.0.0", @@ -112,9 +118,11 @@ "rollup-plugin-json": "^4.0.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-sourcemaps": "^0.5.0", + "rollup-plugin-ts-paths": "^1.0.5", "rollup-plugin-typescript2": "^0.27.0", "semantic-release": "^17.0.4", "shelljs": "^0.8.3", + "shortid": "^2.2.15", "travis-deploy-once": "^5.0.11", "ts-jest": "^25.3.1", "ts-node": "^8.8.2", @@ -124,8 +132,5 @@ "typedoc": "^0.17.4", "typescript": "^3.8.3" }, - "dependencies": { - "lodash": "^4.17.15", - "shortid": "^2.2.15" - } + "dependencies": {} } diff --git a/rollup.config.ts b/rollup.config.ts index 0008d34..e90aa7b 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -3,6 +3,7 @@ import commonjs from 'rollup-plugin-commonjs' import sourceMaps from 'rollup-plugin-sourcemaps' import camelCase from 'lodash.camelcase' import typescript from 'rollup-plugin-typescript2' +import tsConfigPaths from 'rollup-plugin-ts-paths' import json from 'rollup-plugin-json' const pkg = require('./package.json') @@ -24,6 +25,7 @@ export default { // Allow json resolution json(), // Compile TypeScript files + tsConfigPaths(), typescript({ useTsconfigDeclarationDir: true }), // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) commonjs({ diff --git a/src/AggregateRoot.ts b/src/core/AggregateRoot.ts similarity index 100% rename from src/AggregateRoot.ts rename to src/core/AggregateRoot.ts diff --git a/src/DomainEvent.ts b/src/core/DomainEvent.ts similarity index 100% rename from src/DomainEvent.ts rename to src/core/DomainEvent.ts diff --git a/src/DomainEventHandler.ts b/src/core/DomainEventHandler.ts similarity index 100% rename from src/DomainEventHandler.ts rename to src/core/DomainEventHandler.ts diff --git a/src/DomainEvents.ts b/src/core/DomainEvents.ts similarity index 100% rename from src/DomainEvents.ts rename to src/core/DomainEvents.ts diff --git a/src/Entity.ts b/src/core/Entity.ts similarity index 100% rename from src/Entity.ts rename to src/core/Entity.ts diff --git a/src/EntityId.ts b/src/core/EntityId.ts similarity index 100% rename from src/EntityId.ts rename to src/core/EntityId.ts diff --git a/src/Identifier.ts b/src/core/Identifier.ts similarity index 100% rename from src/Identifier.ts rename to src/core/Identifier.ts diff --git a/src/Object.ts b/src/core/Object.ts similarity index 100% rename from src/Object.ts rename to src/core/Object.ts diff --git a/src/ValueObject.ts b/src/core/ValueObject.ts similarity index 100% rename from src/ValueObject.ts rename to src/core/ValueObject.ts diff --git a/src/core/index.ts b/src/core/index.ts new file mode 100644 index 0000000..98daccf --- /dev/null +++ b/src/core/index.ts @@ -0,0 +1,9 @@ +export * from './AggregateRoot' +export * from './DomainEvent' +export * from './DomainEventHandler' +export * from './DomainEvents' +export * from './Entity' +export * from './EntityId' +export * from './Identifier' +export * from './Object' +export * from './ValueObject' diff --git a/src/rimo.ts b/src/rimo.ts index 98daccf..46d458a 100644 --- a/src/rimo.ts +++ b/src/rimo.ts @@ -1,9 +1 @@ -export * from './AggregateRoot' -export * from './DomainEvent' -export * from './DomainEventHandler' -export * from './DomainEvents' -export * from './Entity' -export * from './EntityId' -export * from './Identifier' -export * from './Object' -export * from './ValueObject' +export * from './core' diff --git a/test/AggregateRoot.test.ts b/test/core/AggregateRoot.test.ts similarity index 91% rename from test/AggregateRoot.test.ts rename to test/core/AggregateRoot.test.ts index 16c8707..cb71b74 100644 --- a/test/AggregateRoot.test.ts +++ b/test/core/AggregateRoot.test.ts @@ -1,8 +1,4 @@ -import { AggregateRoot } from '../src/AggregateRoot' -import { DomainEvent } from '../src/DomainEvent' -import { EntityId } from '../src/EntityId' -import { DomainEventHandler } from '../src/DomainEventHandler' -import { DomainEvents } from '../src/DomainEvents' +import { AggregateRoot, DomainEvent, EntityId, DomainEventHandler, DomainEvents } from '@rimo/core' class PostFollowed implements DomainEvent { public static type: string = 'PostFollowed' diff --git a/test/Entity.test.ts b/test/core/Entity.test.ts similarity index 90% rename from test/Entity.test.ts rename to test/core/Entity.test.ts index 87d0276..4baeb9d 100644 --- a/test/Entity.test.ts +++ b/test/core/Entity.test.ts @@ -1,5 +1,4 @@ -import { Entity } from '../src/Entity' -import { EntityId } from '../src/EntityId' +import { Entity, EntityId } from '@rimo/core' /** * Entity test diff --git a/test/EntityId.test.ts b/test/core/EntityId.test.ts similarity index 88% rename from test/EntityId.test.ts rename to test/core/EntityId.test.ts index 726cd26..abf0f18 100644 --- a/test/EntityId.test.ts +++ b/test/core/EntityId.test.ts @@ -1,4 +1,4 @@ -import { EntityId } from '../src/EntityId' +import { EntityId } from '@rimo/core' /** * EntityId test diff --git a/test/Identifier.test.ts b/test/core/Identifier.test.ts similarity index 92% rename from test/Identifier.test.ts rename to test/core/Identifier.test.ts index 31e7b70..f7415b7 100644 --- a/test/Identifier.test.ts +++ b/test/core/Identifier.test.ts @@ -1,4 +1,4 @@ -import { Identifier } from '../src/Identifier' +import { Identifier } from '@rimo/core' /** * Identifier test diff --git a/test/ValueObject.test.ts b/test/core/ValueObject.test.ts similarity index 93% rename from test/ValueObject.test.ts rename to test/core/ValueObject.test.ts index cc316c7..d05ebe7 100644 --- a/test/ValueObject.test.ts +++ b/test/core/ValueObject.test.ts @@ -1,4 +1,4 @@ -import { ValueObject } from '../src/ValueObject' +import { ValueObject } from '@rimo/core' /** * ValueObject test diff --git a/tsconfig.json b/tsconfig.json index 9d0f422..402754e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,12 @@ "emitDecoratorMetadata": true, "declarationDir": "dist/types", "outDir": "dist/lib", - "typeRoots": ["node_modules/@types"] + "typeRoots": ["node_modules/@types"], + "baseUrl": ".", + "paths": { + "@rimo/*": ["src/*"] + } }, - "include": ["src"] + "include": ["src", "test"], + "exclude": ["node_modules"] } diff --git a/yarn.lock b/yarn.lock index 9c88465..39ff39c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7682,6 +7682,14 @@ rollup-plugin-sourcemaps@^0.5.0: "@rollup/pluginutils" "^3.0.1" source-map-resolve "^0.5.3" +rollup-plugin-ts-paths@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/rollup-plugin-ts-paths/-/rollup-plugin-ts-paths-1.0.5.tgz#bc43245b400d5a87df90191ac74ef184a45ae9be" + integrity sha512-Ca2FK0SEb6SicXQAAyI6Lfibyd7BNuTUERnMS8Dl28sYDS2vu/i8L012FMRjNcuHFzQTlU3QUpb+t4wP/Qb7Kw== + dependencies: + strip-bom "^4.0.0" + strip-json-comments "^3.0.1" + rollup-plugin-typescript2@^0.27.0: version "0.27.0" resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.27.0.tgz#95ff96f9e07d5000a9d2df4d76b548f9a1f83511" @@ -8390,6 +8398,11 @@ strip-json-comments@3.0.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7" integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw== +strip-json-comments@^3.0.1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.0.tgz#7638d31422129ecf4457440009fba03f9f9ac180" + integrity sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w== + strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"