From 736bca2b605d611d49a79491bfd20078b36566fc Mon Sep 17 00:00:00 2001 From: whalemare Date: Sun, 22 Jan 2023 16:43:03 +0300 Subject: [PATCH] Run ReactRenderer --- apps/my-app-e2e/.eslintrc.json | 17 + apps/my-app-e2e/cypress.config.ts | 8 + apps/my-app-e2e/project.json | 30 + apps/my-app-e2e/src/e2e/app.cy.ts | 13 + apps/my-app-e2e/src/fixtures/example.json | 4 + apps/my-app-e2e/src/support/app.po.ts | 1 + apps/my-app-e2e/src/support/commands.ts | 33 + apps/my-app-e2e/src/support/e2e.ts | 17 + apps/my-app-e2e/tsconfig.json | 10 + apps/my-app/.eslintrc.json | 18 + apps/my-app/index.html | 15 + apps/my-app/project.json | 123 ++ apps/my-app/public/favicon.ico | Bin 0 -> 15086 bytes apps/my-app/server.ts | 29 + apps/my-app/src/app/app.spec.tsx | 15 + apps/my-app/src/app/app.tsx | 12 + apps/my-app/src/app/nx-welcome.tsx | 809 +++++++ apps/my-app/src/assets/.gitkeep | 0 apps/my-app/src/main.server.tsx | 43 + apps/my-app/src/main.tsx | 11 + apps/my-app/tsconfig.app.json | 22 + apps/my-app/tsconfig.json | 21 + apps/my-app/tsconfig.server.json | 9 + apps/my-app/tsconfig.spec.json | 23 + apps/my-app/vite.config.ts | 36 + apps/node-example/src/app/workflowReactApp.ts | 22 + apps/node-example/src/main.ts | 4 +- libs/core/src/index.ts | 1 + .../renderer/react/ReactAppRender.tsx | 2 +- .../renderer/terminal/TerminalRenderStore.ts | 2 +- .../renderer => shared}/AppRender.ts | 0 libs/core/src/shared/workflow.ts | 9 +- libs/react-renderer/.eslintrc.json | 18 + libs/react-renderer/README.md | 7 + libs/react-renderer/jest.config.ts | 11 + libs/react-renderer/package.json | 12 + libs/react-renderer/project.json | 41 + libs/react-renderer/public/index.html | 15 + libs/react-renderer/src/index.ts | 3 + libs/react-renderer/src/shared/App.tsx | 10 + .../src/shared/ReactRenderer.tsx | 86 + libs/react-renderer/tsconfig.json | 21 + libs/react-renderer/tsconfig.lib.json | 28 + libs/react-renderer/tsconfig.spec.json | 20 + libs/react-renderer/vite.config.ts | 48 + nx.json | 59 +- package.json | 37 +- tsconfig.base.json | 1 + workspace.json | 3 + yarn.lock | 1963 +++++++++++++++-- 50 files changed, 3472 insertions(+), 270 deletions(-) create mode 100644 apps/my-app-e2e/.eslintrc.json create mode 100644 apps/my-app-e2e/cypress.config.ts create mode 100644 apps/my-app-e2e/project.json create mode 100644 apps/my-app-e2e/src/e2e/app.cy.ts create mode 100644 apps/my-app-e2e/src/fixtures/example.json create mode 100644 apps/my-app-e2e/src/support/app.po.ts create mode 100644 apps/my-app-e2e/src/support/commands.ts create mode 100644 apps/my-app-e2e/src/support/e2e.ts create mode 100644 apps/my-app-e2e/tsconfig.json create mode 100644 apps/my-app/.eslintrc.json create mode 100644 apps/my-app/index.html create mode 100644 apps/my-app/project.json create mode 100644 apps/my-app/public/favicon.ico create mode 100644 apps/my-app/server.ts create mode 100644 apps/my-app/src/app/app.spec.tsx create mode 100644 apps/my-app/src/app/app.tsx create mode 100644 apps/my-app/src/app/nx-welcome.tsx create mode 100644 apps/my-app/src/assets/.gitkeep create mode 100644 apps/my-app/src/main.server.tsx create mode 100644 apps/my-app/src/main.tsx create mode 100644 apps/my-app/tsconfig.app.json create mode 100644 apps/my-app/tsconfig.json create mode 100644 apps/my-app/tsconfig.server.json create mode 100644 apps/my-app/tsconfig.spec.json create mode 100644 apps/my-app/vite.config.ts create mode 100644 apps/node-example/src/app/workflowReactApp.ts rename libs/core/src/{internal/renderer => shared}/AppRender.ts (100%) create mode 100644 libs/react-renderer/.eslintrc.json create mode 100644 libs/react-renderer/README.md create mode 100644 libs/react-renderer/jest.config.ts create mode 100644 libs/react-renderer/package.json create mode 100644 libs/react-renderer/project.json create mode 100644 libs/react-renderer/public/index.html create mode 100644 libs/react-renderer/src/index.ts create mode 100644 libs/react-renderer/src/shared/App.tsx create mode 100644 libs/react-renderer/src/shared/ReactRenderer.tsx create mode 100644 libs/react-renderer/tsconfig.json create mode 100644 libs/react-renderer/tsconfig.lib.json create mode 100644 libs/react-renderer/tsconfig.spec.json create mode 100644 libs/react-renderer/vite.config.ts diff --git a/apps/my-app-e2e/.eslintrc.json b/apps/my-app-e2e/.eslintrc.json new file mode 100644 index 0000000..4c5989b --- /dev/null +++ b/apps/my-app-e2e/.eslintrc.json @@ -0,0 +1,17 @@ +{ + "extends": ["plugin:cypress/recommended", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["src/plugins/index.js"], + "rules": { + "@typescript-eslint/no-var-requires": "off", + "no-undef": "off" + } + } + ] +} diff --git a/apps/my-app-e2e/cypress.config.ts b/apps/my-app-e2e/cypress.config.ts new file mode 100644 index 0000000..453ecc2 --- /dev/null +++ b/apps/my-app-e2e/cypress.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'cypress' +import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset' + +export default defineConfig({ + e2e: nxE2EPreset(__dirname, { + bundler: 'vite', + }), +}) diff --git a/apps/my-app-e2e/project.json b/apps/my-app-e2e/project.json new file mode 100644 index 0000000..0093a31 --- /dev/null +++ b/apps/my-app-e2e/project.json @@ -0,0 +1,30 @@ +{ + "name": "my-app-e2e", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "apps/my-app-e2e/src", + "projectType": "application", + "targets": { + "e2e": { + "executor": "@nrwl/cypress:cypress", + "options": { + "cypressConfig": "apps/my-app-e2e/cypress.config.ts", + "devServerTarget": "my-app:serve:development", + "testingType": "e2e" + }, + "configurations": { + "production": { + "devServerTarget": "my-app:serve:production" + } + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/my-app-e2e/**/*.{js,ts}"] + } + } + }, + "tags": [], + "implicitDependencies": ["my-app"] +} diff --git a/apps/my-app-e2e/src/e2e/app.cy.ts b/apps/my-app-e2e/src/e2e/app.cy.ts new file mode 100644 index 0000000..3e60199 --- /dev/null +++ b/apps/my-app-e2e/src/e2e/app.cy.ts @@ -0,0 +1,13 @@ +import { getGreeting } from '../support/app.po' + +describe('my-app', () => { + 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 my-app') + }) +}) diff --git a/apps/my-app-e2e/src/fixtures/example.json b/apps/my-app-e2e/src/fixtures/example.json new file mode 100644 index 0000000..294cbed --- /dev/null +++ b/apps/my-app-e2e/src/fixtures/example.json @@ -0,0 +1,4 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io" +} diff --git a/apps/my-app-e2e/src/support/app.po.ts b/apps/my-app-e2e/src/support/app.po.ts new file mode 100644 index 0000000..00f556e --- /dev/null +++ b/apps/my-app-e2e/src/support/app.po.ts @@ -0,0 +1 @@ +export const getGreeting = () => cy.get('h1') diff --git a/apps/my-app-e2e/src/support/commands.ts b/apps/my-app-e2e/src/support/commands.ts new file mode 100644 index 0000000..270f023 --- /dev/null +++ b/apps/my-app-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/my-app-e2e/src/support/e2e.ts b/apps/my-app-e2e/src/support/e2e.ts new file mode 100644 index 0000000..185d654 --- /dev/null +++ b/apps/my-app-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/my-app-e2e/tsconfig.json b/apps/my-app-e2e/tsconfig.json new file mode 100644 index 0000000..cc509a7 --- /dev/null +++ b/apps/my-app-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/my-app/.eslintrc.json b/apps/my-app/.eslintrc.json new file mode 100644 index 0000000..734ddac --- /dev/null +++ b/apps/my-app/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/apps/my-app/index.html b/apps/my-app/index.html new file mode 100644 index 0000000..9b5c41a --- /dev/null +++ b/apps/my-app/index.html @@ -0,0 +1,15 @@ + + + + + MyApp + + + + + + +
+ + + diff --git a/apps/my-app/project.json b/apps/my-app/project.json new file mode 100644 index 0000000..564540c --- /dev/null +++ b/apps/my-app/project.json @@ -0,0 +1,123 @@ +{ + "name": "my-app", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "apps/my-app/src", + "projectType": "application", + "targets": { + "build": { + "executor": "@nrwl/vite:build", + "outputs": ["{options.outputPath}"], + "defaultConfiguration": "production", + "options": { + "outputPath": "dist/apps/my-app/browser" + }, + "configurations": { + "development": { + "mode": "development" + }, + "production": { + "mode": "production" + } + } + }, + "serve": { + "executor": "@nrwl/webpack:ssr-dev-server", + "defaultConfiguration": "development", + "options": { + "browserTarget": "my-app:build:development", + "serverTarget": "my-app:serve-server:development", + "port": 4200, + "browserTargetOptions": { + "watch": true + } + }, + "configurations": { + "development": {}, + "production": { + "browserTarget": "my-app:build:production", + "serverTarget": "my-app:serve-server:production" + } + } + }, + "test": { + "executor": "@nrwl/vite:test", + "outputs": ["coverage/apps/my-app"], + "options": { + "passWithNoTests": true, + "reportsDirectory": "../../coverage/apps/my-app" + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/my-app/**/*.{ts,tsx,js,jsx}"] + } + }, + "server": { + "dependsOn": ["build"], + "executor": "@nrwl/webpack:webpack", + "outputs": ["{options.outputPath}"], + "defaultConfiguration": "production", + "options": { + "target": "node", + "main": "apps/my-app/server.ts", + "outputPath": "dist/apps/my-app/server", + "tsConfig": "apps/my-app/tsconfig.server.json", + "compiler": "babel", + "externalDependencies": "all", + "outputHashing": "none", + "webpackConfig": "apps/my-app/webpack.config.js" + }, + "configurations": { + "development": { + "optimization": false, + "sourceMap": true + }, + "production": { + "fileReplacements": [ + { + "replace": "apps/my-app/src/environments/environment.ts", + "with": "apps/my-app/src/environments/environment.prod.ts" + } + ], + "sourceMap": false + } + } + }, + "serve-browser": { + "executor": "@nrwl/vite:dev-server", + "defaultConfiguration": "development", + "options": { + "buildTarget": "my-app:build" + }, + "configurations": { + "development": { + "buildTarget": "my-app:build:development", + "hmr": true + }, + "production": { + "buildTarget": "my-app:build:production", + "hmr": false + } + } + }, + "serve-server": { + "executor": "@nrwl/js:node", + "defaultConfiguration": "development", + "options": { + "buildTarget": "my-app:server:development", + "buildTargetOptions": { + "watch": true + } + }, + "configurations": { + "development": {}, + "production": { + "buildTarget": "my-app:server:production" + } + } + } + }, + "tags": [] +} diff --git a/apps/my-app/public/favicon.ico b/apps/my-app/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..317ebcb2336e0833a22dddf0ab287849f26fda57 GIT binary patch literal 15086 zcmeI332;U^%p|z7g|#(P)qFEA@4f!_@qOK2 z_lJl}!lhL!VT_U|uN7%8B2iKH??xhDa;*`g{yjTFWHvXn;2s{4R7kH|pKGdy(7z!K zgftM+Ku7~24TLlh(!g)gz|foI94G^t2^IO$uvX$3(OR0<_5L2sB)lMAMy|+`xodJ{ z_Uh_1m)~h?a;2W{dmhM;u!YGo=)OdmId_B<%^V^{ovI@y`7^g1_V9G}*f# zNzAtvou}I!W1#{M^@ROc(BZ! z+F!!_aR&Px3_reO(EW+TwlW~tv*2zr?iP7(d~a~yA|@*a89IUke+c472NXM0wiX{- zl`UrZC^1XYyf%1u)-Y)jj9;MZ!SLfd2Hl?o|80Su%Z?To_=^g_Jt0oa#CT*tjx>BI z16wec&AOWNK<#i0Qd=1O$fymLRoUR*%;h@*@v7}wApDl^w*h}!sYq%kw+DKDY)@&A z@9$ULEB3qkR#85`lb8#WZw=@})#kQig9oqy^I$dj&k4jU&^2(M3q{n1AKeGUKPFbr z1^<)aH;VsG@J|B&l>UtU#Ejv3GIqERzYgL@UOAWtW<{p#zy`WyJgpCy8$c_e%wYJL zyGHRRx38)HyjU3y{-4z6)pzb>&Q1pR)B&u01F-|&Gx4EZWK$nkUkOI|(D4UHOXg_- zw{OBf!oWQUn)Pe(=f=nt=zkmdjpO^o8ZZ9o_|4tW1ni+Un9iCW47*-ut$KQOww!;u z`0q)$s6IZO!~9$e_P9X!hqLxu`fpcL|2f^I5d4*a@Dq28;@2271v_N+5HqYZ>x;&O z05*7JT)mUe&%S0@UD)@&8S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b/apps/my-app/src/app/app.spec.tsx new file mode 100644 index 0000000..b870b4e --- /dev/null +++ b/apps/my-app/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 my-app/gi)).toBeTruthy() + }) +}) diff --git a/apps/my-app/src/app/app.tsx b/apps/my-app/src/app/app.tsx new file mode 100644 index 0000000..5a86e0a --- /dev/null +++ b/apps/my-app/src/app/app.tsx @@ -0,0 +1,12 @@ +import NxWelcome from './nx-welcome' + +export function App() { + return ( + <> + +
+ + ) +} + +export default App diff --git a/apps/my-app/src/app/nx-welcome.tsx b/apps/my-app/src/app/nx-welcome.tsx new file mode 100644 index 0000000..fdee306 --- /dev/null +++ b/apps/my-app/src/app/nx-welcome.tsx @@ -0,0 +1,809 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + 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 ( + <> +