From 986b3e1bb6b81c184db463c98ba7b05994bdc139 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 10 Nov 2023 15:27:04 +0100 Subject: [PATCH] feat(project): delete dependancy to primeng --- apps/angular/di/.eslintrc.json | 19 +------- apps/angular/di/project.json | 7 +-- apps/angular/di/src/app/app.component.ts | 15 +++---- apps/angular/di/src/styles.scss | 22 +++++++++- libs/angular/di/.eslintrc.json | 26 +++++++++++ libs/angular/di/README.md | 7 +++ libs/angular/di/jest.config.ts | 22 ++++++++++ libs/angular/di/ng-package.json | 7 +++ libs/angular/di/package.json | 12 +++++ libs/angular/di/project.json | 51 ++++++++++++++++++++++ libs/angular/di/src/index.ts | 1 + libs/angular/di/src/lib/table.component.ts | 29 ++++++++++++ libs/angular/di/src/test-setup.ts | 8 ++++ libs/angular/di/tsconfig.json | 29 ++++++++++++ libs/angular/di/tsconfig.lib.json | 17 ++++++++ libs/angular/di/tsconfig.lib.prod.json | 7 +++ libs/angular/di/tsconfig.spec.json | 16 +++++++ package-lock.json | 23 ---------- package.json | 6 +-- tsconfig.base.json | 3 +- 20 files changed, 266 insertions(+), 61 deletions(-) create mode 100644 libs/angular/di/.eslintrc.json create mode 100644 libs/angular/di/README.md create mode 100644 libs/angular/di/jest.config.ts create mode 100644 libs/angular/di/ng-package.json create mode 100644 libs/angular/di/package.json create mode 100644 libs/angular/di/project.json create mode 100644 libs/angular/di/src/index.ts create mode 100644 libs/angular/di/src/lib/table.component.ts create mode 100644 libs/angular/di/src/test-setup.ts create mode 100644 libs/angular/di/tsconfig.json create mode 100644 libs/angular/di/tsconfig.lib.json create mode 100644 libs/angular/di/tsconfig.lib.prod.json create mode 100644 libs/angular/di/tsconfig.spec.json diff --git a/apps/angular/di/.eslintrc.json b/apps/angular/di/.eslintrc.json index bf8df14..bd48864 100644 --- a/apps/angular/di/.eslintrc.json +++ b/apps/angular/di/.eslintrc.json @@ -4,24 +4,7 @@ "overrides": [ { "files": ["*.ts"], - "rules": { - "@angular-eslint/directive-selector": [ - "error", - { - "type": "attribute", - "prefix": "app", - "style": "camelCase" - } - ], - "@angular-eslint/component-selector": [ - "error", - { - "type": "element", - "prefix": "app", - "style": "kebab-case" - } - ] - }, + "rules": {}, "extends": [ "plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates" diff --git a/apps/angular/di/project.json b/apps/angular/di/project.json index fa475c1..23f373c 100644 --- a/apps/angular/di/project.json +++ b/apps/angular/di/project.json @@ -19,12 +19,7 @@ "apps/angular/di/src/favicon.ico", "apps/angular/di/src/assets" ], - "styles": [ - "apps/angular/di/src/styles.scss", - "node_modules/primeicons/primeicons.css", - "node_modules/primeng/resources/themes/lara-light-blue/theme.css", - "node_modules/primeng/resources/primeng.min.css" - ], + "styles": ["apps/angular/di/src/styles.scss"], "scripts": [] }, "configurations": { diff --git a/apps/angular/di/src/app/app.component.ts b/apps/angular/di/src/app/app.component.ts index ff525ec..bacff72 100644 --- a/apps/angular/di/src/app/app.component.ts +++ b/apps/angular/di/src/app/app.component.ts @@ -1,7 +1,6 @@ -/* eslint-disable @angular-eslint/directive-selector */ +import { TableComponent } from '@angular-challenges/angular/di'; import { AsyncPipe, NgFor } from '@angular/common'; import { Component, Directive } from '@angular/core'; -import { TableModule } from 'primeng/table'; import { CurrencyPipe } from './currency.pipe'; import { CurrencyService } from './currency.service'; import { Product, products } from './product.model'; @@ -11,7 +10,7 @@ interface ProductContext { } @Directive({ - selector: 'ng-template[pTemplate="body"]', + selector: 'ng-template[product]', standalone: true, }) export class ProductDirective { @@ -25,19 +24,19 @@ export class ProductDirective { @Component({ standalone: true, - imports: [TableModule, CurrencyPipe, AsyncPipe, NgFor, ProductDirective], + imports: [TableComponent, CurrencyPipe, AsyncPipe, NgFor, ProductDirective], providers: [CurrencyService], selector: 'app-root', template: ` - - + + - + @@ -45,7 +44,7 @@ export class ProductDirective { - +
{{ col }}
{{ product.name }} {{ product.priceA | currency | async }}{{ product.priceC | currency | async }}
`, }) export class AppComponent { diff --git a/apps/angular/di/src/styles.scss b/apps/angular/di/src/styles.scss index 90d4ee0..bb86669 100644 --- a/apps/angular/di/src/styles.scss +++ b/apps/angular/di/src/styles.scss @@ -1 +1,21 @@ -/* You can add global styles to this file, and also import other style files */ +table { + width: 100%; +} + +table thead > tr > th { + text-align: left; + padding: 1rem 1rem; + border: 1px solid #dee2e6; + border-width: 0 0 1px 0; + font-weight: 700; + color: #343a40; + background: #f8f9fa; + transition: box-shadow 0.2s; +} + +table tbody > tr > td { + text-align: left; + border: 1px solid #dee2e6; + border-width: 0 0 1px 0; + padding: 1rem 1rem; +} diff --git a/libs/angular/di/.eslintrc.json b/libs/angular/di/.eslintrc.json new file mode 100644 index 0000000..f776d76 --- /dev/null +++ b/libs/angular/di/.eslintrc.json @@ -0,0 +1,26 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ], + "rules": {} + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/libs/angular/di/README.md b/libs/angular/di/README.md new file mode 100644 index 0000000..824450f --- /dev/null +++ b/libs/angular/di/README.md @@ -0,0 +1,7 @@ +# angular/di + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test angular/di` to execute the unit tests. diff --git a/libs/angular/di/jest.config.ts b/libs/angular/di/jest.config.ts new file mode 100644 index 0000000..79303be --- /dev/null +++ b/libs/angular/di/jest.config.ts @@ -0,0 +1,22 @@ +/* eslint-disable */ +export default { + displayName: 'angular/di', + preset: '../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: '../../../coverage/libs/angular/di', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + }, + ], + }, + 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/angular/di/ng-package.json b/libs/angular/di/ng-package.json new file mode 100644 index 0000000..312bafb --- /dev/null +++ b/libs/angular/di/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../../dist/libs/angular/di", + "lib": { + "entryFile": "src/index.ts" + } +} diff --git a/libs/angular/di/package.json b/libs/angular/di/package.json new file mode 100644 index 0000000..cc70af2 --- /dev/null +++ b/libs/angular/di/package.json @@ -0,0 +1,12 @@ +{ + "name": "angular/di", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^16.2.0", + "@angular/core": "^16.2.0" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "sideEffects": false +} diff --git a/libs/angular/di/project.json b/libs/angular/di/project.json new file mode 100644 index 0000000..cf326c3 --- /dev/null +++ b/libs/angular/di/project.json @@ -0,0 +1,51 @@ +{ + "name": "angular/di", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/angular/di/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/angular:ng-packagr-lite", + "outputs": ["{workspaceRoot}/dist/{projectRoot}"], + "options": { + "project": "libs/angular/di/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "libs/angular/di/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "libs/angular/di/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/angular/di/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/angular/di/**/*.ts", + "libs/angular/di/**/*.html", + "libs/angular/di/package.json" + ] + } + } + } +} diff --git a/libs/angular/di/src/index.ts b/libs/angular/di/src/index.ts new file mode 100644 index 0000000..017d633 --- /dev/null +++ b/libs/angular/di/src/index.ts @@ -0,0 +1 @@ +export { TableComponent } from './lib/table.component'; diff --git a/libs/angular/di/src/lib/table.component.ts b/libs/angular/di/src/lib/table.component.ts new file mode 100644 index 0000000..162c8cd --- /dev/null +++ b/libs/angular/di/src/lib/table.component.ts @@ -0,0 +1,29 @@ +import { NgFor, NgTemplateOutlet } from '@angular/common'; +import { Component, ContentChild, Input, TemplateRef } from '@angular/core'; + +@Component({ + selector: 'table', + standalone: true, + imports: [NgTemplateOutlet, NgFor], + template: ` + + + + + + + `, +}) +export class TableComponent { + @Input() items!: T[]; + + @ContentChild('header', { read: TemplateRef }) + headerTemplate!: TemplateRef; + + @ContentChild('body', { read: TemplateRef }) + bodyTemplate!: TemplateRef<{ $implicit: T }>; +} diff --git a/libs/angular/di/src/test-setup.ts b/libs/angular/di/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/angular/di/src/test-setup.ts @@ -0,0 +1,8 @@ +// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment +globalThis.ngJest = { + testEnvironmentOptions: { + errorOnUnknownElements: true, + errorOnUnknownProperties: true, + }, +}; +import 'jest-preset-angular/setup-jest'; diff --git a/libs/angular/di/tsconfig.json b/libs/angular/di/tsconfig.json new file mode 100644 index 0000000..5cf0a16 --- /dev/null +++ b/libs/angular/di/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "extends": "../../../tsconfig.base.json", + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +} diff --git a/libs/angular/di/tsconfig.lib.json b/libs/angular/di/tsconfig.lib.json new file mode 100644 index 0000000..9b49be7 --- /dev/null +++ b/libs/angular/di/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [] + }, + "exclude": [ + "src/**/*.spec.ts", + "src/test-setup.ts", + "jest.config.ts", + "src/**/*.test.ts" + ], + "include": ["src/**/*.ts"] +} diff --git a/libs/angular/di/tsconfig.lib.prod.json b/libs/angular/di/tsconfig.lib.prod.json new file mode 100644 index 0000000..61b5237 --- /dev/null +++ b/libs/angular/di/tsconfig.lib.prod.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": {} +} diff --git a/libs/angular/di/tsconfig.spec.json b/libs/angular/di/tsconfig.spec.json new file mode 100644 index 0000000..f858ef7 --- /dev/null +++ b/libs/angular/di/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "module": "commonjs", + "target": "es2016", + "types": ["jest", "node"] + }, + "files": ["src/test-setup.ts"], + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/package-lock.json b/package-lock.json index 1ce548d..0ad9e82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,6 @@ "": { "name": "angular-challenges", "version": "0.0.0", - "hasInstallScript": true, "license": "MIT", "dependencies": { "@angular/animations": "~16.2.0", @@ -32,8 +31,6 @@ "@rx-angular/state": "^1.7.0", "@rx-angular/template": "^1.0.0-rc.5", "@swc/helpers": "0.5.3", - "primeicons": "6.0.1", - "primeng": "16.0.2", "rxjs": "7.8.1", "tailwindcss": "^3.2.1", "tslib": "^2.3.0", @@ -24564,26 +24561,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/primeicons": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/primeicons/-/primeicons-6.0.1.tgz", - "integrity": "sha512-KDeO94CbWI4pKsPnYpA1FPjo79EsY9I+M8ywoPBSf9XMXoe/0crjbUK7jcQEDHuc0ZMRIZsxH3TYLv4TUtHmAA==" - }, - "node_modules/primeng": { - "version": "16.0.2", - "resolved": "https://registry.npmjs.org/primeng/-/primeng-16.0.2.tgz", - "integrity": "sha512-gLFUSQ0fV5948yM1fMCv9oGaJ54AS8+HHSMOeR2lHWFiZzomxjXR0MST9yyAQ0NjrOlhke3BBpl+zYjISBeEJg==", - "dependencies": { - "tslib": "^2.3.0" - }, - "peerDependencies": { - "@angular/common": "^16.0.0", - "@angular/core": "^16.0.0", - "@angular/forms": "^16.0.0", - "rxjs": "^6.0.0 || ^7.8.1", - "zone.js": "~0.13.0" - } - }, "node_modules/proc-log": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-3.0.0.tgz", diff --git a/package.json b/package.json index b15b119..7d498c0 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,6 @@ "@rx-angular/state": "^1.7.0", "@rx-angular/template": "^1.0.0-rc.5", "@swc/helpers": "0.5.3", - "primeicons": "6.0.1", - "primeng": "16.0.2", "rxjs": "7.8.1", "tailwindcss": "^3.2.1", "tslib": "^2.3.0", @@ -58,6 +56,7 @@ "@ngrx/schematics": "16.0.0", "@nx/cypress": "17.0.1", "@nx/devkit": "17.0.1", + "@nx/eslint": "17.0.1", "@nx/eslint-plugin": "17.0.1", "@nx/jest": "17.0.1", "@nx/js": "17.0.1", @@ -97,8 +96,7 @@ "testing-library-selector": "^0.2.1", "ts-jest": "29.1.0", "ts-node": "10.9.1", - "typescript": "5.1.6", - "@nx/eslint": "17.0.1" + "typescript": "5.1.6" }, "lint-staged": { "*.{ts,json,md}": [ diff --git a/tsconfig.base.json b/tsconfig.base.json index 0d18e9a..59047cb 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -75,7 +75,8 @@ ], "@tomalaforge/ngrx-callstate-store": [ "libs/shared/ngrx-callstate-store/src/index.ts" - ] + ], + "@angular-challenges/angular/di": ["libs/angular/di/src/index.ts"] } }, "exclude": ["node_modules", "tmp"]