From 66b429d580fdb9e01ea076165b644c756db3f440 Mon Sep 17 00:00:00 2001 From: Vladimir Drayling Date: Fri, 23 Sep 2022 16:13:03 +0200 Subject: [PATCH] feat(lib): shared domain --- libs/shared/domain/.eslintrc.json | 36 +++++++++++++++++++++++++++ libs/shared/domain/README.md | 7 ++++++ libs/shared/domain/jest.config.ts | 22 ++++++++++++++++ libs/shared/domain/project.json | 26 +++++++++++++++++++ libs/shared/domain/src/index.ts | 0 libs/shared/domain/src/test-setup.ts | 1 + libs/shared/domain/tsconfig.json | 28 +++++++++++++++++++++ libs/shared/domain/tsconfig.lib.json | 17 +++++++++++++ libs/shared/domain/tsconfig.spec.json | 10 ++++++++ nx.json | 18 +++++++------- tsconfig.base.json | 3 ++- workspace.json | 3 ++- 12 files changed, 160 insertions(+), 11 deletions(-) create mode 100644 libs/shared/domain/.eslintrc.json create mode 100644 libs/shared/domain/README.md create mode 100644 libs/shared/domain/jest.config.ts create mode 100644 libs/shared/domain/project.json create mode 100644 libs/shared/domain/src/index.ts create mode 100644 libs/shared/domain/src/test-setup.ts create mode 100644 libs/shared/domain/tsconfig.json create mode 100644 libs/shared/domain/tsconfig.lib.json create mode 100644 libs/shared/domain/tsconfig.spec.json diff --git a/libs/shared/domain/.eslintrc.json b/libs/shared/domain/.eslintrc.json new file mode 100644 index 0000000..0221f67 --- /dev/null +++ b/libs/shared/domain/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "extends": [ + "plugin:@nrwl/nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "im", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "im", + "style": "kebab-case" + } + ] + } + }, + { + "files": ["*.html"], + "extends": ["plugin:@nrwl/nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/shared/domain/README.md b/libs/shared/domain/README.md new file mode 100644 index 0000000..84bc48c --- /dev/null +++ b/libs/shared/domain/README.md @@ -0,0 +1,7 @@ +# shared-domain + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test shared-domain` to execute the unit tests. diff --git a/libs/shared/domain/jest.config.ts b/libs/shared/domain/jest.config.ts new file mode 100644 index 0000000..5665b16 --- /dev/null +++ b/libs/shared/domain/jest.config.ts @@ -0,0 +1,22 @@ +/* eslint-disable */ +export default { + displayName: 'shared-domain', + preset: '../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + }, + }, + coverageDirectory: '../../../coverage/libs/shared/domain', + transform: { + '^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular', + }, + transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment', + ], +}; diff --git a/libs/shared/domain/project.json b/libs/shared/domain/project.json new file mode 100644 index 0000000..43df162 --- /dev/null +++ b/libs/shared/domain/project.json @@ -0,0 +1,26 @@ +{ + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "libs/shared/domain/src", + "prefix": "im", + "targets": { + "test": { + "executor": "@nrwl/jest:jest", + "outputs": ["coverage/libs/shared/domain"], + "options": { + "jestConfig": "libs/shared/domain/jest.config.ts", + "passWithNoTests": true + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": [ + "libs/shared/domain/**/*.ts", + "libs/shared/domain/**/*.html" + ] + } + } + }, + "tags": ["scope:shared type:domain"] +} diff --git a/libs/shared/domain/src/index.ts b/libs/shared/domain/src/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/libs/shared/domain/src/test-setup.ts b/libs/shared/domain/src/test-setup.ts new file mode 100644 index 0000000..1100b3e --- /dev/null +++ b/libs/shared/domain/src/test-setup.ts @@ -0,0 +1 @@ +import 'jest-preset-angular/setup-jest'; diff --git a/libs/shared/domain/tsconfig.json b/libs/shared/domain/tsconfig.json new file mode 100644 index 0000000..7504c34 --- /dev/null +++ b/libs/shared/domain/tsconfig.json @@ -0,0 +1,28 @@ +{ + "extends": "../../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "target": "es2020", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +} diff --git a/libs/shared/domain/tsconfig.lib.json b/libs/shared/domain/tsconfig.lib.json new file mode 100644 index 0000000..dd189dc --- /dev/null +++ b/libs/shared/domain/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [] + }, + "exclude": [ + "src/test-setup.ts", + "**/*.spec.ts", + "jest.config.ts", + "**/*.test.ts" + ], + "include": ["**/*.ts"] +} diff --git a/libs/shared/domain/tsconfig.spec.json b/libs/shared/domain/tsconfig.spec.json new file mode 100644 index 0000000..7aa46d8 --- /dev/null +++ b/libs/shared/domain/tsconfig.spec.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "files": ["src/test-setup.ts"], + "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] +} diff --git a/nx.json b/nx.json index 0b6b44e..4366bc1 100644 --- a/nx.json +++ b/nx.json @@ -25,30 +25,30 @@ }, "generators": { "@nrwl/angular:application": { - "e2eTestRunner": "cypress", - "linter": "eslint", - "prefix": "im", "style": "scss", - "unitTestRunner": "jest" + "linter": "eslint", + "unitTestRunner": "jest", + "e2eTestRunner": "cypress", + "prefix": "im" }, "@nrwl/angular:component": { + "style": "scss", "changeDetection": "OnPush", "inlineStyle": true, - "standalone": true, - "style": "scss" + "standalone": true }, "@nrwl/angular:library": { + "linter": "eslint", + "unitTestRunner": "jest", "changeDetection": "OnPush", "inlineStyle": true, - "linter": "eslint", "prefix": "im", "skipModule": true, "skipSelector": true, "standalone": true, "standaloneConfig": true, "style": "scss", - "tags": "scope:,type:", - "unitTestRunner": "jest" + "tags": "scope:,type:" }, "@nrwl/nest:application": { "standaloneConfig": true, diff --git a/tsconfig.base.json b/tsconfig.base.json index 39f653f..09f6cef 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -19,7 +19,8 @@ "@immomio/appointment/domain": ["libs/appointment/domain/src/index.ts"], "@immomio/appointment/feature": ["libs/appointment/feature/src/index.ts"], "@immomio/appointment/ui": ["libs/appointment/ui/src/index.ts"], - "@immomio/core/domain": ["libs/core/domain/src/index.ts"] + "@immomio/core/domain": ["libs/core/domain/src/index.ts"], + "@immomio/shared/domain": ["libs/shared/domain/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] diff --git a/workspace.json b/workspace.json index aabb759..0c14244 100644 --- a/workspace.json +++ b/workspace.json @@ -9,6 +9,7 @@ "appointment-feature": "libs/appointment/feature", "appointment-ui": "libs/appointment/ui", "core-domain": "libs/core/domain", - "nest-api": "apps/nest-api" + "nest-api": "apps/nest-api", + "shared-domain": "libs/shared/domain" } }