From 3b78ac765977f8963ad6ebcc95667dc111b2fa3f Mon Sep 17 00:00:00 2001 From: Vygandas Pliasas Date: Wed, 25 Oct 2023 18:35:11 +0300 Subject: [PATCH] repaired issues with makefile+docker user and group being root instead of proper current user; added couple libs - dtos and interfaces --- Makefile | 15 +- apps/platform-e2e/.eslintrc.json | 10 + apps/platform-e2e/cypress.config.ts | 6 + apps/platform-e2e/project.json | 33 + apps/platform-e2e/src/e2e/app.cy.ts | 13 + apps/platform-e2e/src/fixtures/example.json | 4 + apps/platform-e2e/src/support/app.po.ts | 1 + apps/platform-e2e/src/support/commands.ts | 33 + apps/platform-e2e/src/support/e2e.ts | 17 + apps/platform-e2e/tsconfig.json | 10 + apps/platform/.babelrc | 11 + apps/platform/.eslintrc.json | 18 + apps/platform/jest.config.ts | 11 + apps/platform/project.json | 93 + apps/platform/src/app/app.module.scss | 1 + apps/platform/src/app/app.spec.tsx | 25 + apps/platform/src/app/app.tsx | 53 + apps/platform/src/app/nx-welcome.tsx | 845 ++ apps/platform/src/assets/.gitkeep | 0 .../src/environments/environment.prod.ts | 3 + apps/platform/src/environments/environment.ts | 6 + apps/platform/src/favicon.ico | Bin 0 -> 15086 bytes apps/platform/src/index.html | 14 + apps/platform/src/main.tsx | 16 + apps/platform/src/styles.scss | 1 + apps/platform/tsconfig.app.json | 24 + apps/platform/tsconfig.json | 20 + apps/platform/tsconfig.spec.json | 21 + apps/platform/webpack.config.js | 9 + docker/utility/node.dockerfile | 6 +- docs/uml/Level 0 Engineer Use Case Diagram | 16 + docs/uml/Level 0 Use Case Diagram.drawio | 80 + dtos/.eslintrc.json | 18 + dtos/README.md | 7 + dtos/jest.config.ts | 11 + dtos/project.json | 30 + dtos/src/index.ts | 1 + dtos/src/lib/dtos.spec.ts | 7 + dtos/src/lib/dtos.ts | 3 + dtos/tsconfig.json | 16 + dtos/tsconfig.lib.json | 11 + dtos/tsconfig.spec.json | 14 + interfaces/.eslintrc.json | 18 + interfaces/README.md | 7 + interfaces/jest.config.ts | 11 + interfaces/project.json | 30 + interfaces/src/index.ts | 1 + interfaces/src/lib/interfaces.spec.ts | 7 + interfaces/src/lib/interfaces.ts | 3 + interfaces/tsconfig.json | 16 + interfaces/tsconfig.lib.json | 11 + interfaces/tsconfig.spec.json | 14 + nx.json | 40 +- package.json | 30 +- tsconfig.base.json | 5 +- yarn.lock | 10230 ++++++++++++++++ 56 files changed, 11927 insertions(+), 29 deletions(-) create mode 100644 apps/platform-e2e/.eslintrc.json create mode 100644 apps/platform-e2e/cypress.config.ts create mode 100644 apps/platform-e2e/project.json create mode 100644 apps/platform-e2e/src/e2e/app.cy.ts create mode 100644 apps/platform-e2e/src/fixtures/example.json create mode 100644 apps/platform-e2e/src/support/app.po.ts create mode 100644 apps/platform-e2e/src/support/commands.ts create mode 100644 apps/platform-e2e/src/support/e2e.ts create mode 100644 apps/platform-e2e/tsconfig.json create mode 100644 apps/platform/.babelrc create mode 100644 apps/platform/.eslintrc.json create mode 100644 apps/platform/jest.config.ts create mode 100644 apps/platform/project.json create mode 100644 apps/platform/src/app/app.module.scss create mode 100644 apps/platform/src/app/app.spec.tsx create mode 100644 apps/platform/src/app/app.tsx create mode 100644 apps/platform/src/app/nx-welcome.tsx create mode 100644 apps/platform/src/assets/.gitkeep create mode 100644 apps/platform/src/environments/environment.prod.ts create mode 100644 apps/platform/src/environments/environment.ts create mode 100644 apps/platform/src/favicon.ico create mode 100644 apps/platform/src/index.html create mode 100644 apps/platform/src/main.tsx create mode 100644 apps/platform/src/styles.scss create mode 100644 apps/platform/tsconfig.app.json create mode 100644 apps/platform/tsconfig.json create mode 100644 apps/platform/tsconfig.spec.json create mode 100644 apps/platform/webpack.config.js create mode 100644 docs/uml/Level 0 Engineer Use Case Diagram create mode 100644 docs/uml/Level 0 Use Case Diagram.drawio create mode 100644 dtos/.eslintrc.json create mode 100644 dtos/README.md create mode 100644 dtos/jest.config.ts create mode 100644 dtos/project.json create mode 100644 dtos/src/index.ts create mode 100644 dtos/src/lib/dtos.spec.ts create mode 100644 dtos/src/lib/dtos.ts create mode 100644 dtos/tsconfig.json create mode 100644 dtos/tsconfig.lib.json create mode 100644 dtos/tsconfig.spec.json create mode 100644 interfaces/.eslintrc.json create mode 100644 interfaces/README.md create mode 100644 interfaces/jest.config.ts create mode 100644 interfaces/project.json create mode 100644 interfaces/src/index.ts create mode 100644 interfaces/src/lib/interfaces.spec.ts create mode 100644 interfaces/src/lib/interfaces.ts create mode 100644 interfaces/tsconfig.json create mode 100644 interfaces/tsconfig.lib.json create mode 100644 interfaces/tsconfig.spec.json create mode 100644 yarn.lock diff --git a/Makefile b/Makefile index 730149a..74790a0 100644 --- a/Makefile +++ b/Makefile @@ -8,21 +8,24 @@ devinit: # --- Commands --- npm: - docker run -it --rm -u $(id -u):$(id -g) -v ./:/app --workdir="/app" --entrypoint="npm" node-dev-env:latest $(call args,defaultstring) + docker run -it --rm -u $(shell id -u):$(shell id -g) -v ./:/app --workdir="/app" --entrypoint="npm" node-dev-env:latest $(call args,defaultstring) yarn: - docker run -it --rm -u $(id -u):$(id -g) -v ./:/app --workdir="/app" --entrypoint="yarn" node-dev-env:latest $(call args,defaultstring) + docker run -it --rm -u $(shell id -u):$(shell id -g) -v ./:/app --workdir="/app" --entrypoint="yarn" node-dev-env:latest $(call args,defaultstring) npx: - docker run -it --rm -u $(id -u):$(id -g) -v ./:/app --workdir="/app" --entrypoint="npx" node-dev-env:latest $(call args,defaultstring) + docker run -it --rm -u $(shell id -u):$(shell id -g) -v ./:/app --workdir="/app" --entrypoint="npx" node-dev-env:latest $(call args,defaultstring) nx: - docker run -it --rm -u $(id -u):$(id -g) -v ./:/app --workdir="/app" --entrypoint="nx" node-dev-env:latest $(call args,defaultstring) + docker run -it --rm -u $(shell id -u):$(shell id -g) -v ./:/app --workdir="/app" --entrypoint="nx" node-dev-env:latest $(call args,defaultstring) node: - docker run -it --rm -u $(id -u):$(id -g) -v ./:/app --workdir="/app" --entrypoint="node" node-dev-env:latest $(call args,defaultstring) + docker run -it --rm -u $(shell id -u):$(shell id -g) -v ./:/app --workdir="/app" --entrypoint="node" node-dev-env:latest $(call args,defaultstring) # --- Server stuff --- serve-api: - docker run -it --rm -u $(id -u):$(id -g) -p '8080:3000' -v ./:/app --workdir="/app" --entrypoint="nx" node-dev-env:latest serve api \ No newline at end of file + docker run -it --rm -u $(shell id -u):$(shell id -g) --network="host" -v ./:/app --workdir="/app" --entrypoint="nx" node-dev-env:latest serve api + +serve-platform: + docker run -it --rm -u $(shell id -u):$(shell id -g) --network="host" -v ./:/app --workdir="/app" --entrypoint="nx" node-dev-env:latest serve platform --verbose diff --git a/apps/platform-e2e/.eslintrc.json b/apps/platform-e2e/.eslintrc.json new file mode 100644 index 0000000..696cb8b --- /dev/null +++ b/apps/platform-e2e/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "extends": ["plugin:cypress/recommended", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/apps/platform-e2e/cypress.config.ts b/apps/platform-e2e/cypress.config.ts new file mode 100644 index 0000000..bc91e98 --- /dev/null +++ b/apps/platform-e2e/cypress.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from 'cypress'; +import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'; + +export default defineConfig({ + e2e: nxE2EPreset(__dirname), +}); diff --git a/apps/platform-e2e/project.json b/apps/platform-e2e/project.json new file mode 100644 index 0000000..55ca75b --- /dev/null +++ b/apps/platform-e2e/project.json @@ -0,0 +1,33 @@ +{ + "name": "platform-e2e", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "apps/platform-e2e/src", + "projectType": "application", + "targets": { + "e2e": { + "executor": "@nx/cypress:cypress", + "options": { + "cypressConfig": "apps/platform-e2e/cypress.config.ts", + "devServerTarget": "platform:serve:development", + "testingType": "e2e" + }, + "configurations": { + "production": { + "devServerTarget": "platform:serve:production" + }, + "ci": { + "devServerTarget": "platform:serve-static" + } + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/platform-e2e/**/*.{js,ts}"] + } + } + }, + "tags": [], + "implicitDependencies": ["platform"] +} diff --git a/apps/platform-e2e/src/e2e/app.cy.ts b/apps/platform-e2e/src/e2e/app.cy.ts new file mode 100644 index 0000000..3438355 --- /dev/null +++ b/apps/platform-e2e/src/e2e/app.cy.ts @@ -0,0 +1,13 @@ +import { getGreeting } from '../support/app.po'; + +describe('platform', () => { + beforeEach(() => cy.visit('/')); + + it('should display welcome message', () => { + // Custom command example, see `../support/commands.ts` file + cy.login('my-email@something.com', 'myPassword'); + + // Function helper example, see `../support/app.po.ts` file + getGreeting().contains('Welcome platform'); + }); +}); diff --git a/apps/platform-e2e/src/fixtures/example.json b/apps/platform-e2e/src/fixtures/example.json new file mode 100644 index 0000000..294cbed --- /dev/null +++ b/apps/platform-e2e/src/fixtures/example.json @@ -0,0 +1,4 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io" +} diff --git a/apps/platform-e2e/src/support/app.po.ts b/apps/platform-e2e/src/support/app.po.ts new file mode 100644 index 0000000..3293424 --- /dev/null +++ b/apps/platform-e2e/src/support/app.po.ts @@ -0,0 +1 @@ +export const getGreeting = () => cy.get('h1'); diff --git a/apps/platform-e2e/src/support/commands.ts b/apps/platform-e2e/src/support/commands.ts new file mode 100644 index 0000000..310f1fa --- /dev/null +++ b/apps/platform-e2e/src/support/commands.ts @@ -0,0 +1,33 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** + +// eslint-disable-next-line @typescript-eslint/no-namespace +declare namespace Cypress { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + interface Chainable { + login(email: string, password: string): void; + } +} +// +// -- This is a parent command -- +Cypress.Commands.add('login', (email, password) => { + console.log('Custom command example: Login', email, password); +}); +// +// -- This is a child command -- +// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This will overwrite an existing command -- +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/apps/platform-e2e/src/support/e2e.ts b/apps/platform-e2e/src/support/e2e.ts new file mode 100644 index 0000000..3d469a6 --- /dev/null +++ b/apps/platform-e2e/src/support/e2e.ts @@ -0,0 +1,17 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands'; diff --git a/apps/platform-e2e/tsconfig.json b/apps/platform-e2e/tsconfig.json new file mode 100644 index 0000000..cc509a7 --- /dev/null +++ b/apps/platform-e2e/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "sourceMap": false, + "outDir": "../../dist/out-tsc", + "allowJs": true, + "types": ["cypress", "node"] + }, + "include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"] +} diff --git a/apps/platform/.babelrc b/apps/platform/.babelrc new file mode 100644 index 0000000..88ee27b --- /dev/null +++ b/apps/platform/.babelrc @@ -0,0 +1,11 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic" + } + ] + ], + "plugins": [] +} diff --git a/apps/platform/.eslintrc.json b/apps/platform/.eslintrc.json new file mode 100644 index 0000000..a39ac5d --- /dev/null +++ b/apps/platform/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/apps/platform/jest.config.ts b/apps/platform/jest.config.ts new file mode 100644 index 0000000..cdc4dd9 --- /dev/null +++ b/apps/platform/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'platform', + preset: '../../jest.preset.js', + transform: { + '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', + '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }], + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../coverage/apps/platform', +}; diff --git a/apps/platform/project.json b/apps/platform/project.json new file mode 100644 index 0000000..55ae40e --- /dev/null +++ b/apps/platform/project.json @@ -0,0 +1,93 @@ +{ + "name": "platform", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "apps/platform/src", + "projectType": "application", + "targets": { + "build": { + "executor": "@nx/webpack:webpack", + "outputs": ["{options.outputPath}"], + "defaultConfiguration": "production", + "options": { + "compiler": "babel", + "outputPath": "dist/apps/platform", + "index": "apps/platform/src/index.html", + "baseHref": "/", + "main": "apps/platform/src/main.tsx", + "tsConfig": "apps/platform/tsconfig.app.json", + "assets": ["apps/platform/src/favicon.ico", "apps/platform/src/assets"], + "styles": ["apps/platform/src/styles.scss"], + "scripts": [], + "isolatedConfig": true, + "webpackConfig": "apps/platform/webpack.config.js" + }, + "configurations": { + "development": { + "extractLicenses": false, + "optimization": false, + "sourceMap": true, + "vendorChunk": true + }, + "production": { + "fileReplacements": [ + { + "replace": "apps/platform/src/environments/environment.ts", + "with": "apps/platform/src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false + } + } + }, + "serve": { + "executor": "@nx/webpack:dev-server", + "defaultConfiguration": "development", + "options": { + "buildTarget": "platform:build", + "hmr": true + }, + "configurations": { + "development": { + "buildTarget": "platform:build:development" + }, + "production": { + "buildTarget": "platform:build:production", + "hmr": false + } + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/platform/**/*.{ts,tsx,js,jsx}"] + } + }, + "serve-static": { + "executor": "@nx/web:file-server", + "options": { + "buildTarget": "platform:build" + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "apps/platform/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + } + }, + "tags": [] +} diff --git a/apps/platform/src/app/app.module.scss b/apps/platform/src/app/app.module.scss new file mode 100644 index 0000000..7b88fba --- /dev/null +++ b/apps/platform/src/app/app.module.scss @@ -0,0 +1 @@ +/* Your styles goes here. */ diff --git a/apps/platform/src/app/app.spec.tsx b/apps/platform/src/app/app.spec.tsx new file mode 100644 index 0000000..08028eb --- /dev/null +++ b/apps/platform/src/app/app.spec.tsx @@ -0,0 +1,25 @@ +import { render } from '@testing-library/react'; + +import { BrowserRouter } from 'react-router-dom'; + +import App from './app'; + +describe('App', () => { + it('should render successfully', () => { + const { baseElement } = render( + + + + ); + expect(baseElement).toBeTruthy(); + }); + + it('should have a greeting as the title', () => { + const { getByText } = render( + + + + ); + expect(getByText(/Welcome platform/gi)).toBeTruthy(); + }); +}); diff --git a/apps/platform/src/app/app.tsx b/apps/platform/src/app/app.tsx new file mode 100644 index 0000000..c92ac04 --- /dev/null +++ b/apps/platform/src/app/app.tsx @@ -0,0 +1,53 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import styles from './app.module.scss'; + +import NxWelcome from './nx-welcome'; + +import { Route, Routes, Link } from 'react-router-dom'; + +export function App() { + return ( +
+ + + {/* START: routes */} + {/* These routes and navigation have been generated for you */} + {/* Feel free to move and update them to fit your needs */} +
+
+
+
+
    +
  • + Home +
  • +
  • + Page 2 +
  • +
+
+ + + This is the generated root route.{' '} + Click here for page 2. +
+ } + /> + + Click here to go back to root page. + + } + /> + + {/* END: routes */} + + ); +} + +export default App; diff --git a/apps/platform/src/app/nx-welcome.tsx b/apps/platform/src/app/nx-welcome.tsx new file mode 100644 index 0000000..f0cd657 --- /dev/null +++ b/apps/platform/src/app/nx-welcome.tsx @@ -0,0 +1,845 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + This is a starter component and can be deleted. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + Delete this file and get started with your project! + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + */ +export function NxWelcome({ title }: { title: string }) { + return ( + <> +