From 567980baa45fd7ad4a25d3e34247d7fc9bc50f37 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 23 Jul 2021 03:08:19 +0300 Subject: [PATCH] add library for common ui --- angular.json | 28 ++++++++++++++++-- jest.config.js | 2 +- libs/common-ui/.eslintrc.json | 33 ++++++++++++++++++++++ libs/common-ui/README.md | 7 +++++ libs/common-ui/jest.config.js | 20 +++++++++++++ libs/common-ui/src/index.ts | 1 + libs/common-ui/src/lib/common-ui.module.ts | 7 +++++ libs/common-ui/src/test-setup.ts | 1 + libs/common-ui/tsconfig.json | 24 ++++++++++++++++ libs/common-ui/tsconfig.lib.json | 14 +++++++++ libs/common-ui/tsconfig.spec.json | 10 +++++++ nx.json | 3 ++ tsconfig.base.json | 3 +- 13 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 libs/common-ui/.eslintrc.json create mode 100644 libs/common-ui/README.md create mode 100644 libs/common-ui/jest.config.js create mode 100644 libs/common-ui/src/index.ts create mode 100644 libs/common-ui/src/lib/common-ui.module.ts create mode 100644 libs/common-ui/src/test-setup.ts create mode 100644 libs/common-ui/tsconfig.json create mode 100644 libs/common-ui/tsconfig.lib.json create mode 100644 libs/common-ui/tsconfig.spec.json diff --git a/angular.json b/angular.json index f3a7abdae..95d3aa1c3 100644 --- a/angular.json +++ b/angular.json @@ -1,5 +1,4 @@ { - "$schema": "node_modules/@angular/cli/lib/config/schema.json", "version": 1, "cli": { "defaultCollection": "@nrwl/angular", @@ -9,12 +8,15 @@ "defaultProject": "red-ui", "schematics": { "@nrwl/angular:application": { + "linter": "eslint", "unitTestRunner": "jest", "e2eTestRunner": "cypress" }, "@nrwl/angular:library": { + "linter": "eslint", "unitTestRunner": "jest" - } + }, + "@nrwl/angular:component": {} }, "projects": { "red-ui": { @@ -186,6 +188,28 @@ "style": "scss" } } + }, + "common-ui": { + "projectType": "library", + "root": "libs/common-ui", + "sourceRoot": "libs/common-ui/src", + "prefix": "redaction", + "architect": { + "test": { + "builder": "@nrwl/jest:jest", + "outputs": ["coverage/libs/common-ui"], + "options": { + "jestConfig": "libs/common-ui/jest.config.js", + "passWithNoTests": true + } + }, + "lint": { + "builder": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": ["libs/common-ui/src/**/*.ts", "libs/common-ui/src/**/*.html"] + } + } + } } } } diff --git a/jest.config.js b/jest.config.js index 1dda619f6..9659a89a6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,3 @@ module.exports = { - projects: ['/apps/red-ui', '/libs/red-ui-http', '/libs/red-cache'] + projects: ['/apps/red-ui', '/libs/red-ui-http', '/libs/red-cache', '/libs/common-ui'] }; diff --git a/libs/common-ui/.eslintrc.json b/libs/common-ui/.eslintrc.json new file mode 100644 index 000000000..ae74dc230 --- /dev/null +++ b/libs/common-ui/.eslintrc.json @@ -0,0 +1,33 @@ +{ + "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": "redaction", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "redaction", + "style": "kebab-case" + } + ] + } + }, + { + "files": ["*.html"], + "extends": ["plugin:@nrwl/nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/common-ui/README.md b/libs/common-ui/README.md new file mode 100644 index 000000000..f2a6bbc60 --- /dev/null +++ b/libs/common-ui/README.md @@ -0,0 +1,7 @@ +# common-ui + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test common-ui` to execute the unit tests. diff --git a/libs/common-ui/jest.config.js b/libs/common-ui/jest.config.js new file mode 100644 index 000000000..f06ef5fa7 --- /dev/null +++ b/libs/common-ui/jest.config.js @@ -0,0 +1,20 @@ +module.exports = { + displayName: 'common-ui', + preset: '../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + astTransformers: { + before: ['jest-preset-angular/build/InlineFilesTransformer', 'jest-preset-angular/build/StripStylesTransformer'] + } + } + }, + coverageDirectory: '../../coverage/libs/common-ui', + 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/common-ui/src/index.ts b/libs/common-ui/src/index.ts new file mode 100644 index 000000000..3b5ad4f19 --- /dev/null +++ b/libs/common-ui/src/index.ts @@ -0,0 +1 @@ +export * from './lib/common-ui.module'; diff --git a/libs/common-ui/src/lib/common-ui.module.ts b/libs/common-ui/src/lib/common-ui.module.ts new file mode 100644 index 000000000..e4e641375 --- /dev/null +++ b/libs/common-ui/src/lib/common-ui.module.ts @@ -0,0 +1,7 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +@NgModule({ + imports: [CommonModule] +}) +export class CommonUiModule {} diff --git a/libs/common-ui/src/test-setup.ts b/libs/common-ui/src/test-setup.ts new file mode 100644 index 000000000..1100b3e8a --- /dev/null +++ b/libs/common-ui/src/test-setup.ts @@ -0,0 +1 @@ +import 'jest-preset-angular/setup-jest'; diff --git a/libs/common-ui/tsconfig.json b/libs/common-ui/tsconfig.json new file mode 100644 index 000000000..d7a0c7629 --- /dev/null +++ b/libs/common-ui/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "angularCompilerOptions": { + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +} diff --git a/libs/common-ui/tsconfig.lib.json b/libs/common-ui/tsconfig.lib.json new file mode 100644 index 000000000..bbcc12b1c --- /dev/null +++ b/libs/common-ui/tsconfig.lib.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "target": "es2015", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [], + "lib": ["dom", "es2018"] + }, + "exclude": ["src/test-setup.ts", "**/*.spec.ts"], + "include": ["**/*.ts"] +} diff --git a/libs/common-ui/tsconfig.spec.json b/libs/common-ui/tsconfig.spec.json new file mode 100644 index 000000000..cfff29a54 --- /dev/null +++ b/libs/common-ui/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": ["**/*.spec.ts", "**/*.d.ts"] +} diff --git a/nx.json b/nx.json index 8b9c0489f..0d03d6b85 100644 --- a/nx.json +++ b/nx.json @@ -30,6 +30,9 @@ }, "red-cache": { "tags": [] + }, + "common-ui": { + "tags": [] } } } diff --git a/tsconfig.base.json b/tsconfig.base.json index e033abefc..3218e8111 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -29,7 +29,8 @@ "@environments/*": ["apps/red-ui/src/environments/*"], "@shared/*": ["apps/red-ui/src/app/modules/shared/*"], "@app-config/*": ["apps/red-ui/src/app/modules/app-config/*"], - "@upload-download/*": ["apps/red-ui/src/app/modules/upload-download/*"] + "@upload-download/*": ["apps/red-ui/src/app/modules/upload-download/*"], + "@devplant/common-ui": ["libs/common-ui/src/index.ts"] } }, "exclude": ["node_modules", "tmp"],