From 549c5df5d4c6002d065daf573ff34cf3fa8f816c Mon Sep 17 00:00:00 2001 From: Artem-Darius Atlas Date: Mon, 26 Jun 2023 22:40:53 +0300 Subject: [PATCH] Initial commit --- .editorconfig | 13 + .eslintignore | 1 + .eslintrc.json | 42 + .gitignore | 39 + .prettierignore | 3 + .prettierrc | 3 + .vscode/extensions.json | 8 + README.md | 63 + apps/.gitkeep | 0 apps/frontend-e2e/.eslintrc.json | 10 + apps/frontend-e2e/cypress.config.ts | 6 + apps/frontend-e2e/project.json | 33 + apps/frontend-e2e/src/e2e/app.cy.ts | 13 + apps/frontend-e2e/src/fixtures/example.json | 4 + apps/frontend-e2e/src/support/app.po.ts | 1 + apps/frontend-e2e/src/support/commands.ts | 33 + apps/frontend-e2e/src/support/e2e.ts | 17 + apps/frontend-e2e/tsconfig.json | 10 + apps/frontend/.babelrc | 11 + apps/frontend/.eslintrc.json | 18 + apps/frontend/jest.config.ts | 11 + apps/frontend/project.json | 93 + apps/frontend/src/app/app.module.scss | 1 + apps/frontend/src/app/app.spec.tsx | 15 + apps/frontend/src/app/app.tsx | 14 + apps/frontend/src/app/nx-welcome.tsx | 845 + apps/frontend/src/assets/.gitkeep | 0 .../src/environments/environment.prod.ts | 3 + apps/frontend/src/environments/environment.ts | 6 + apps/frontend/src/favicon.ico | Bin 0 -> 15086 bytes apps/frontend/src/index.html | 14 + apps/frontend/src/main.tsx | 13 + apps/frontend/src/styles.scss | 1 + apps/frontend/tsconfig.app.json | 23 + apps/frontend/tsconfig.json | 20 + apps/frontend/tsconfig.spec.json | 24 + apps/frontend/webpack.config.js | 9 + jest.config.ts | 5 + jest.preset.js | 3 + libs/.gitkeep | 0 nx.json | 79 + package-lock.json | 17160 ++++++++++++++++ package.json | 54 + tools/tsconfig.tools.json | 12 + tsconfig.base.json | 20 + 45 files changed, 18753 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc.json create mode 100644 .gitignore create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 .vscode/extensions.json create mode 100644 README.md create mode 100644 apps/.gitkeep create mode 100644 apps/frontend-e2e/.eslintrc.json create mode 100644 apps/frontend-e2e/cypress.config.ts create mode 100644 apps/frontend-e2e/project.json create mode 100644 apps/frontend-e2e/src/e2e/app.cy.ts create mode 100644 apps/frontend-e2e/src/fixtures/example.json create mode 100644 apps/frontend-e2e/src/support/app.po.ts create mode 100644 apps/frontend-e2e/src/support/commands.ts create mode 100644 apps/frontend-e2e/src/support/e2e.ts create mode 100644 apps/frontend-e2e/tsconfig.json create mode 100644 apps/frontend/.babelrc create mode 100644 apps/frontend/.eslintrc.json create mode 100644 apps/frontend/jest.config.ts create mode 100644 apps/frontend/project.json create mode 100644 apps/frontend/src/app/app.module.scss create mode 100644 apps/frontend/src/app/app.spec.tsx create mode 100644 apps/frontend/src/app/app.tsx create mode 100644 apps/frontend/src/app/nx-welcome.tsx create mode 100644 apps/frontend/src/assets/.gitkeep create mode 100644 apps/frontend/src/environments/environment.prod.ts create mode 100644 apps/frontend/src/environments/environment.ts create mode 100644 apps/frontend/src/favicon.ico create mode 100644 apps/frontend/src/index.html create mode 100644 apps/frontend/src/main.tsx create mode 100644 apps/frontend/src/styles.scss create mode 100644 apps/frontend/tsconfig.app.json create mode 100644 apps/frontend/tsconfig.json create mode 100644 apps/frontend/tsconfig.spec.json create mode 100644 apps/frontend/webpack.config.js create mode 100644 jest.config.ts create mode 100644 jest.preset.js create mode 100644 libs/.gitkeep create mode 100644 nx.json create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 tools/tsconfig.tools.json create mode 100644 tsconfig.base.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6e87a00 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +node_modules diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..0be733b --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,42 @@ +{ + "root": true, + "ignorePatterns": ["**/*"], + "plugins": ["@nx"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": { + "@nx/enforce-module-boundaries": [ + "error", + { + "enforceBuildableLibDependency": true, + "allow": [], + "depConstraints": [ + { + "sourceTag": "*", + "onlyDependOnLibsWithTags": ["*"] + } + ] + } + ] + } + }, + { + "files": ["*.ts", "*.tsx"], + "extends": ["plugin:@nx/typescript"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "extends": ["plugin:@nx/javascript"], + "rules": {} + }, + { + "files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"], + "env": { + "jest": true + }, + "rules": {} + } + ] +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..51b9af5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +dist +tmp +/out-tsc + +# dependencies +node_modules + +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +yarn-error.log +testem.log +/typings + +# System Files +.DS_Store +Thumbs.db diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..9481e77 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Add files here to ignore them from prettier formatting +/dist +/coverage \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..544138b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..6a302fe --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "nrwl.angular-console", + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint", + "firsttris.vscode-jest-runner" + ] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..b9be89c --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Platform + + + +✨ **This workspace has been generated by [Nx, a Smart, fast and extensible build system.](https://nx.dev)** ✨ + + +## Start the app + +To start the development server run `nx serve frontend`. Open your browser and navigate to http://localhost:4200/. Happy coding! + + +## Generate code + +If you happen to use Nx plugins, you can leverage code generators that might come with it. + +Run `nx list` to get a list of available plugins and whether they have generators. Then run `nx list ` to see what generators are available. + +Learn more about [Nx generators on the docs](https://nx.dev/plugin-features/use-code-generators). + +## Running tasks + +To execute tasks with Nx use the following syntax: + +``` +nx <...options> +``` + +You can also run multiple targets: + +``` +nx run-many -t +``` + +..or add `-p` to filter specific projects + +``` +nx run-many -t -p +``` + +Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/core-features/run-tasks). + +## Want better Editor Integration? + +Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users. + +## Ready to deploy? + +Just run `nx build demoapp` to build the application. The build artifacts will be stored in the `dist/` directory, ready to be deployed. + +## Set up CI! + +Nx comes with local caching already built-in (check your `nx.json`). On CI you might want to go a step further. + +- [Set up remote caching](https://nx.dev/core-features/share-your-cache) +- [Set up task distribution across multiple machines](https://nx.dev/core-features/distribute-task-execution) +- [Learn more how to setup CI](https://nx.dev/recipes/ci) + +## Connect with us! + +- [Join the community](https://nx.dev/community) +- [Subscribe to the Nx Youtube Channel](https://www.youtube.com/@nxdevtools) +- [Follow us on Twitter](https://twitter.com/nxdevtools) diff --git a/apps/.gitkeep b/apps/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/apps/frontend-e2e/.eslintrc.json b/apps/frontend-e2e/.eslintrc.json new file mode 100644 index 0000000..696cb8b --- /dev/null +++ b/apps/frontend-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/frontend-e2e/cypress.config.ts b/apps/frontend-e2e/cypress.config.ts new file mode 100644 index 0000000..bc91e98 --- /dev/null +++ b/apps/frontend-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/frontend-e2e/project.json b/apps/frontend-e2e/project.json new file mode 100644 index 0000000..eac6b11 --- /dev/null +++ b/apps/frontend-e2e/project.json @@ -0,0 +1,33 @@ +{ + "name": "frontend-e2e", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "apps/frontend-e2e/src", + "projectType": "application", + "targets": { + "e2e": { + "executor": "@nx/cypress:cypress", + "options": { + "cypressConfig": "apps/frontend-e2e/cypress.config.ts", + "devServerTarget": "frontend:serve:development", + "testingType": "e2e" + }, + "configurations": { + "production": { + "devServerTarget": "frontend:serve:production" + }, + "ci": { + "devServerTarget": "frontend:serve-static" + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/frontend-e2e/**/*.{js,ts}"] + } + } + }, + "tags": [], + "implicitDependencies": ["frontend"] +} diff --git a/apps/frontend-e2e/src/e2e/app.cy.ts b/apps/frontend-e2e/src/e2e/app.cy.ts new file mode 100644 index 0000000..c37b7f7 --- /dev/null +++ b/apps/frontend-e2e/src/e2e/app.cy.ts @@ -0,0 +1,13 @@ +import { getGreeting } from '../support/app.po'; + +describe('frontend', () => { + 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 frontend'); + }); +}); diff --git a/apps/frontend-e2e/src/fixtures/example.json b/apps/frontend-e2e/src/fixtures/example.json new file mode 100644 index 0000000..294cbed --- /dev/null +++ b/apps/frontend-e2e/src/fixtures/example.json @@ -0,0 +1,4 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io" +} diff --git a/apps/frontend-e2e/src/support/app.po.ts b/apps/frontend-e2e/src/support/app.po.ts new file mode 100644 index 0000000..3293424 --- /dev/null +++ b/apps/frontend-e2e/src/support/app.po.ts @@ -0,0 +1 @@ +export const getGreeting = () => cy.get('h1'); diff --git a/apps/frontend-e2e/src/support/commands.ts b/apps/frontend-e2e/src/support/commands.ts new file mode 100644 index 0000000..310f1fa --- /dev/null +++ b/apps/frontend-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/frontend-e2e/src/support/e2e.ts b/apps/frontend-e2e/src/support/e2e.ts new file mode 100644 index 0000000..3d469a6 --- /dev/null +++ b/apps/frontend-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/frontend-e2e/tsconfig.json b/apps/frontend-e2e/tsconfig.json new file mode 100644 index 0000000..cc509a7 --- /dev/null +++ b/apps/frontend-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/frontend/.babelrc b/apps/frontend/.babelrc new file mode 100644 index 0000000..88ee27b --- /dev/null +++ b/apps/frontend/.babelrc @@ -0,0 +1,11 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic" + } + ] + ], + "plugins": [] +} diff --git a/apps/frontend/.eslintrc.json b/apps/frontend/.eslintrc.json new file mode 100644 index 0000000..a39ac5d --- /dev/null +++ b/apps/frontend/.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/frontend/jest.config.ts b/apps/frontend/jest.config.ts new file mode 100644 index 0000000..ee504ef --- /dev/null +++ b/apps/frontend/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'frontend', + 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/frontend', +}; diff --git a/apps/frontend/project.json b/apps/frontend/project.json new file mode 100644 index 0000000..3ca4c7b --- /dev/null +++ b/apps/frontend/project.json @@ -0,0 +1,93 @@ +{ + "name": "frontend", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "apps/frontend/src", + "projectType": "application", + "targets": { + "build": { + "executor": "@nx/webpack:webpack", + "outputs": ["{options.outputPath}"], + "defaultConfiguration": "production", + "options": { + "compiler": "babel", + "outputPath": "dist/apps/frontend", + "index": "apps/frontend/src/index.html", + "baseHref": "/", + "main": "apps/frontend/src/main.tsx", + "tsConfig": "apps/frontend/tsconfig.app.json", + "assets": ["apps/frontend/src/favicon.ico", "apps/frontend/src/assets"], + "styles": ["apps/frontend/src/styles.scss"], + "scripts": [], + "isolatedConfig": true, + "webpackConfig": "apps/frontend/webpack.config.js" + }, + "configurations": { + "development": { + "extractLicenses": false, + "optimization": false, + "sourceMap": true, + "vendorChunk": true + }, + "production": { + "fileReplacements": [ + { + "replace": "apps/frontend/src/environments/environment.ts", + "with": "apps/frontend/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": "frontend:build", + "hmr": true + }, + "configurations": { + "development": { + "buildTarget": "frontend:build:development" + }, + "production": { + "buildTarget": "frontend:build:production", + "hmr": false + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/frontend/**/*.{ts,tsx,js,jsx}"] + } + }, + "serve-static": { + "executor": "@nx/web:file-server", + "options": { + "buildTarget": "frontend:build" + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "apps/frontend/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + } + }, + "tags": [] +} diff --git a/apps/frontend/src/app/app.module.scss b/apps/frontend/src/app/app.module.scss new file mode 100644 index 0000000..7b88fba --- /dev/null +++ b/apps/frontend/src/app/app.module.scss @@ -0,0 +1 @@ +/* Your styles goes here. */ diff --git a/apps/frontend/src/app/app.spec.tsx b/apps/frontend/src/app/app.spec.tsx new file mode 100644 index 0000000..95caf44 --- /dev/null +++ b/apps/frontend/src/app/app.spec.tsx @@ -0,0 +1,15 @@ +import { render } from '@testing-library/react'; + +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 frontend/gi)).toBeTruthy(); + }); +}); diff --git a/apps/frontend/src/app/app.tsx b/apps/frontend/src/app/app.tsx new file mode 100644 index 0000000..cd752af --- /dev/null +++ b/apps/frontend/src/app/app.tsx @@ -0,0 +1,14 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import styles from './app.module.scss'; + +import NxWelcome from './nx-welcome'; + +export function App() { + return ( +
+ +
+ ); +} + +export default App; diff --git a/apps/frontend/src/app/nx-welcome.tsx b/apps/frontend/src/app/nx-welcome.tsx new file mode 100644 index 0000000..f0cd657 --- /dev/null +++ b/apps/frontend/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 ( + <> +