feat: frontend demo subproject added (#1)

Co-authored-by: Richard Attermeyer <richard.attermeyer@opitz-consulting.com>
Reviewed-on: https://git.192.168.1.133.nip.io:8543/fjadmin/ci-demo-2/pulls/1
pull/1/head
fjadmin 2023-11-05 20:03:32 +00:00
parent ac28abc12e
commit 08675ee26e
19 changed files with 9195 additions and 35 deletions

View File

@ -18,9 +18,6 @@ repos:
stages: [commit]
- id: check-xml
stages: [commit]
- id: check-added-large-files
args: ["--maxkb=128"]
stages: [commit]
- id: check-byte-order-marker
stages: [commit]
- id: check-case-conflict
@ -40,18 +37,9 @@ repos:
stages: [commit]
- id: detect-private-key
stages: [commit]
- id: mixed-line-ending
args: ["--fix=lf"]
stages: [commit]
- id: trailing-whitespace
exclude: \.preseed$
# DISC: ShellScripts
#
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck
# DISC: Yaml Files
#
- repo: https://github.com/adrienverge/yamllint
@ -61,9 +49,4 @@ repos:
files: \.(yaml|yml)$
stages: [commit]
- repo: https://github.com/igorshubovych/markdownlint-cli.git
rev: v0.37.0
hooks:
- id: markdownlint
...

26
.woodpecker/.backend.yml Normal file
View File

@ -0,0 +1,26 @@
---
when:
path: "app/**"
clone:
git:
image: woodpeckerci/plugin-git
settings:
skip_verify: true
steps:
"lint:style":
group: lint
image: gradle:8.4.0-jdk17
commands:
- gradle spotlessCheck --no-daemon
"lint:hadolint":
group: lint
image: ghcr.io/hadolint/hadolint:latest-debian
commands:
- hadolint --version
"build:java":
group: build
image: gradle:8.4.0-jdk17
commands:
- ./gradlew build
depends_on:
- "lint_general"

28
.woodpecker/.frontend.yml Normal file
View File

@ -0,0 +1,28 @@
---
when:
path: "frontend/**"
variables:
- &frontend_image "cl00e9ment/node.js-builder:git"
clone:
git:
image: woodpeckerci/plugin-git
settings:
skip_verify: true
steps:
"prepare":
image: *frontend_image
commands:
- cd frontend
- pnpm install
"lint:style":
image: *frontend_image
commands:
- cd frontend
- pnpm run prettier
"lint:analyze":
image: *frontend_image
commands:
- cd frontend
- pnpm run lint
depends_on:
- "lint_general"

View File

@ -7,15 +7,11 @@ clone:
steps:
"lint:precommit":
group: lint
image: dchevallier/pre-commit:latest
image: python:3.11.6-bullseye
commands:
- pip install pre-commit
- pre-commit install
- pre-commit run --all-files
"lint:style":
group: lint
image: gradle:8.4.0-jdk17
commands:
- gradle spotlessCheck --no-daemon
"lint:credentials":
group: lint
image: ghcr.io/gitleaks/gitleaks:latest
@ -30,15 +26,4 @@ steps:
- echo "$CI_COMMIT_MESSAGE"x | npx commitlint
when:
- branch: [main, dev]
- event: push
"lint:hadolint":
group: lint
image: ghcr.io/hadolint/hadolint:latest-debian
commands:
- hadolint --version
- hadolint Dockerfile
"build:java":
group: build
image: gradle:8.4.0-jdk17
commands:
- ./gradlew build
event: push

5
frontend/.eslintrc.cjs Normal file
View File

@ -0,0 +1,5 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
ignorePatterns: ["public/build/**", "build/**"],
};

6
frontend/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
node_modules
/.cache
/build
/public/build
.env

3
frontend/.prettierignore Normal file
View File

@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage

1
frontend/.prettierrc Normal file
View File

@ -0,0 +1 @@
{}

38
frontend/README.md Normal file
View File

@ -0,0 +1,38 @@
# Welcome to Remix
- [Remix Docs](https://remix.run/docs)
## Development
From your terminal:
```sh
npm run dev
```
This starts your app in development mode, rebuilding assets on file changes.
## Deployment
First, build your app for production:
```sh
npm run build
```
Then run the app in production mode:
```sh
npm start
```
Now you'll need to pick a host to deploy it to.
### DIY
If you're familiar with deploying node applications, the built-in Remix app server is production-ready.
Make sure to deploy the output of `remix build`
- `build/`
- `public/build/`

View File

@ -0,0 +1,18 @@
/**
* By default, Remix will handle hydrating your app on the client for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal`
* For more information, see https://remix.run/file-conventions/entry.client
*/
import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>,
);
});

View File

@ -0,0 +1,137 @@
/**
* By default, Remix will handle generating the HTTP Response for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal`
* For more information, see https://remix.run/file-conventions/entry.server
*/
import { PassThrough } from "node:stream";
import type { AppLoadContext, EntryContext } from "@remix-run/node";
import { createReadableStreamFromReadable } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { renderToPipeableStream } from "react-dom/server";
const ABORT_DELAY = 5_000;
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
loadContext: AppLoadContext,
) {
return isbot(request.headers.get("user-agent"))
? handleBotRequest(
request,
responseStatusCode,
responseHeaders,
remixContext,
)
: handleBrowserRequest(
request,
responseStatusCode,
responseHeaders,
remixContext,
);
}
function handleBotRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onAllReady() {
shellRendered = true;
const body = new PassThrough();
const stream = createReadableStreamFromReadable(body);
responseHeaders.set("Content-Type", "text/html");
resolve(
new Response(stream, {
headers: responseHeaders,
status: responseStatusCode,
}),
);
pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error);
}
},
},
);
setTimeout(abort, ABORT_DELAY);
});
}
function handleBrowserRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onShellReady() {
shellRendered = true;
const body = new PassThrough();
const stream = createReadableStreamFromReadable(body);
responseHeaders.set("Content-Type", "text/html");
resolve(
new Response(stream, {
headers: responseHeaders,
status: responseStatusCode,
}),
);
pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error);
}
},
},
);
setTimeout(abort, ABORT_DELAY);
});
}

33
frontend/app/root.tsx Normal file
View File

@ -0,0 +1,33 @@
import { cssBundleHref } from "@remix-run/css-bundle";
import type { LinksFunction } from "@remix-run/node";
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";
export const links: LinksFunction = () => [
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
];
export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
}

View File

@ -0,0 +1,41 @@
import type { MetaFunction } from "@remix-run/node";
export const meta: MetaFunction = () => {
return [
{ title: "New Remix App" },
{ name: "description", content: "Welcome to Remix!" },
];
};
export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}>
<h1>Welcome to Remix</h1>
<ul>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/blog"
rel="noreferrer"
>
15m Quickstart Blog Tutorial
</a>
</li>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/jokes"
rel="noreferrer"
>
Deep Dive Jokes App Tutorial
</a>
</li>
<li>
<a target="_blank" href="https://remix.run/docs" rel="noreferrer">
Remix Docs
</a>
</li>
</ul>
</div>
);
}

38
frontend/package.json Normal file
View File

@ -0,0 +1,38 @@
{
"name": "frontend",
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"build": "remix build",
"dev": "remix dev --manual",
"start": "remix-serve ./build/index.js",
"typecheck": "tsc",
"lint": "eslint app",
"lint:fix": "pnpm run lint --fix",
"prettier": "pnpm exec prettier . --check",
"prettier:fix": "pnpm exec prettier . --write"
},
"dependencies": {
"@remix-run/css-bundle": "^2.2.0",
"@remix-run/node": "^2.2.0",
"@remix-run/react": "^2.2.0",
"@remix-run/serve": "^2.2.0",
"isbot": "^3.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.2.0",
"@remix-run/eslint-config": "^2.2.0",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"eslint": "^8.38.0",
"eslint-config-prettier": "9.0.0",
"prettier": "3.0.3",
"typescript": "^5.1.6"
},
"engines": {
"node": ">=18.0.0"
}
}

8786
frontend/pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

BIN
frontend/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

8
frontend/remix.config.js Normal file
View File

@ -0,0 +1,8 @@
/** @type {import('@remix-run/dev').AppConfig} */
export default {
ignoredRouteFiles: ["**/.*"],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// publicPath: "/build/",
// serverBuildPath: "build/index.js",
};

2
frontend/remix.env.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/node" />

22
frontend/tsconfig.json Normal file
View File

@ -0,0 +1,22 @@
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"target": "ES2022",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},
// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}