Skip to content

Commit f698970

Browse files
committed
refactor: 🎨 Move Lysand-FE into its own repository
0 parents  commit f698970

26 files changed

+1226
-0
lines changed

.dockerignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
node_modules
2+
Dockerfile*
3+
docker-compose*
4+
.dockerignore
5+
.git
6+
.gitignore
7+
README.md
8+
LICENSE
9+
.vscode
10+
Makefile
11+
helm-charts
12+
.env
13+
.editorconfig
14+
.idea
15+
coverage*
16+
uploads
17+
.output
18+
.nuxt
19+
logs
20+
dist
21+
pages/dist

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/codeql.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: ["main"]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: ["main"]
20+
21+
jobs:
22+
analyze:
23+
name: Analyze
24+
# Runner size impacts CodeQL analysis time. To learn more, please see:
25+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
26+
# - https://gh.io/supported-runners-and-hardware-resources
27+
# - https://gh.io/using-larger-runners
28+
# Consider using larger runners for possible analysis time improvements.
29+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
30+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
31+
permissions:
32+
actions: read
33+
contents: read
34+
security-events: write
35+
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
language: ["javascript"]
40+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
41+
# Use only 'java' to analyze code written in Java, Kotlin or both
42+
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
43+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
49+
# Initializes the CodeQL tools for scanning.
50+
- name: Initialize CodeQL
51+
uses: github/codeql-action/init@v2
52+
with:
53+
languages: ${{ matrix.language }}
54+
# If you wish to specify custom queries, you can do so here or in a config file.
55+
# By default, queries listed here will override any specified in a config file.
56+
# Prefix the list here with "+" to use these queries and those in the config file.
57+
58+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
59+
# queries: security-extended,security-and-quality
60+
61+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
62+
# If this step fails, then you should remove it and run the build manually (see below)
63+
- name: Autobuild
64+
uses: github/codeql-action/autobuild@v2
65+
66+
# ℹ️ Command-line programs to run using the OS shell.
67+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
68+
69+
# If the Autobuild fails above, remove it and uncomment the following three lines.
70+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
71+
72+
# - run: |
73+
# echo "Run, Build Application using script"
74+
# ./location_of_script_within_repo/buildscript.sh
75+
76+
- name: Perform CodeQL Analysis
77+
uses: github/codeql-action/analyze@v2
78+
with:
79+
category: "/language:${{matrix.language}}"

.github/workflows/docker-publish.yml

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags: ["v*.*.*"]
7+
pull_request:
8+
branches: ["*"]
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: "Tag"
13+
required: false
14+
default: "v0.0.0"
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
19+
jobs:
20+
build:
21+
name: Build for ${{ matrix.platform }}
22+
runs-on: ${{ matrix.os }}
23+
environment:
24+
name: Production
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
- os: ubuntu-latest
30+
platform: linux/arm64
31+
- os: ubuntu-latest
32+
platform: linux/amd64
33+
permissions:
34+
contents: read
35+
packages: write
36+
id-token: write
37+
38+
steps:
39+
- name: Prepare
40+
run: |
41+
platform=${{ matrix.platform }}
42+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
43+
echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV
44+
45+
- name: Checkout repository
46+
uses: actions/checkout@v4
47+
48+
- name: Set up QEMU
49+
uses: docker/setup-qemu-action@v3
50+
51+
- name: Setup Docker buildx
52+
uses: docker/setup-buildx-action@v3
53+
54+
- name: Log into registry ${{ env.REGISTRY }}
55+
if: github.event_name != 'pull_request'
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ${{ env.REGISTRY }}
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Extract Docker metadata
63+
id: meta
64+
uses: docker/metadata-action@v5
65+
with:
66+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
67+
68+
- name: Build and push Docker image
69+
id: build
70+
uses: docker/build-push-action@v5
71+
with:
72+
context: .
73+
file: Dockerfile
74+
labels: ${{ steps.meta.outputs.labels }}
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
platforms: ${{ matrix.platform }}
78+
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
79+
80+
- name: Export digest
81+
run: |
82+
mkdir -p /tmp/digests
83+
digest="${{ steps.build.outputs.digest }}"
84+
touch "/tmp/digests/${digest#sha256:}"
85+
- name: Upload digest
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: digests-${{ env.PLATFORM_PAIR }}
89+
path: /tmp/digests/*
90+
if-no-files-found: error
91+
retention-days: 1
92+
93+
merge:
94+
name: Merge digests
95+
runs-on: ubuntu-latest
96+
environment:
97+
name: Production
98+
needs:
99+
- build
100+
steps:
101+
- name: Prepare
102+
run: |
103+
echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV
104+
105+
- name: Download digests
106+
uses: actions/download-artifact@v4
107+
with:
108+
path: /tmp/digests
109+
pattern: digests-*
110+
merge-multiple: true
111+
112+
- name: Set up Docker Buildx
113+
uses: docker/setup-buildx-action@v3
114+
115+
- name: Docker meta
116+
id: meta
117+
uses: docker/metadata-action@v5
118+
with:
119+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
120+
121+
- name: Login to Docker Hub
122+
uses: docker/login-action@v3
123+
with:
124+
registry: ${{ env.REGISTRY }}
125+
username: ${{ github.actor }}
126+
password: ${{ secrets.GITHUB_TOKEN }}
127+
128+
- name: Create manifest list and push
129+
working-directory: /tmp/digests
130+
run: |
131+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
132+
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
133+
134+
- name: Inspect image
135+
run: |
136+
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM oven/bun:1.1.3 AS base
2+
# Temporarily switch back to the non-alpine version of Bun because of Bun's issues with musl
3+
4+
# Install dependencies into temp directory
5+
# This will cache them and speed up future builds
6+
FROM base AS install
7+
RUN mkdir -p /temp/dev
8+
COPY package.json bun.lockb /temp/dev/
9+
RUN cd /temp/dev && bun install --frozen-lockfile
10+
11+
FROM base AS builder
12+
COPY . /app
13+
14+
COPY --from=install /temp/dev/node_modules /app/node_modules
15+
RUN cd /app && bun run build
16+
17+
FROM base as final
18+
19+
COPY --from=builder /app/.output/ /app
20+
21+
LABEL org.opencontainers.image.authors "Gaspard Wierzbinski (https://cpluspatch.com)"
22+
LABEL org.opencontainers.image.source "https://github.com/lysand-org/lysand-fe"
23+
LABEL org.opencontainers.image.vendor "Lysand Org"
24+
LABEL org.opencontainers.image.licenses "AGPL-3.0"
25+
LABEL org.opencontainers.image.title "Lysand-FE"
26+
LABEL org.opencontainers.image.description "Frontend for the Lysand Project"
27+
28+
WORKDIR /app/server
29+
CMD ["bun", "index.mjs"]

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# FE

app.vue

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<NuxtPage>
3+
<slot />
4+
</NuxtPage>
5+
</template>
6+
7+
<script setup lang="ts">
8+
useServerSeoMeta({
9+
titleTemplate: (titleChunk) => {
10+
return titleChunk ? `${titleChunk} · Lysand` : "Lysand";
11+
},
12+
});
13+
</script>

biome.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
3+
"organizeImports": {
4+
"enabled": true,
5+
"ignore": ["node_modules/**/*", "dist/**/*", ".output", ".nuxt"]
6+
},
7+
"linter": {
8+
"enabled": true,
9+
"rules": {
10+
"recommended": true
11+
},
12+
"ignore": ["node_modules/**/*", "dist/**/*", ".output", ".nuxt"]
13+
},
14+
"formatter": {
15+
"enabled": true,
16+
"indentStyle": "space",
17+
"indentWidth": 4,
18+
"ignore": ["node_modules/**/*", "dist/**/*", ".output", ".nuxt"]
19+
}
20+
}

bun.lockb

470 KB
Binary file not shown.

components/LoginInput.vue

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<div class="flex items-center justify-between">
3+
<label for="password" class="block text-sm font-medium leading-6 text-gray-900">{{ label }}</label>
4+
</div>
5+
<div class="mt-2">
6+
<input v-bind="$attrs" @input="checkValid" :class="['block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6',
7+
(isInvalid || error) && 'invalid:!ring-red-600 invalid:ring-2']">
8+
<span v-if="isInvalid || error" class="mt-1 text-xs text-red-600">{{ error ? error : `${label} is invalid` }}</span>
9+
</div>
10+
</template>
11+
12+
<script setup lang="ts">
13+
import { ref } from "vue";
14+
15+
const props = defineProps<{
16+
label: string;
17+
error?: string;
18+
}>();
19+
20+
const isInvalid = ref(false);
21+
22+
const checkValid = (e: Event) => {
23+
const target = e.target as HTMLInputElement;
24+
if (target.checkValidity()) {
25+
isInvalid.value = false;
26+
} else {
27+
isInvalid.value = true;
28+
}
29+
};
30+
</script>

composables/useConfig.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export const useConfig = async () => {
2+
let host = useRequestHeader("X-Forwarded-Host") ?? useRuntimeConfig().public.apiHost;
3+
4+
if (!host?.includes("http")) {
5+
// On server, this will be some kind of localhost
6+
host = `http://${host}`;
7+
}
8+
9+
if (!host) {
10+
throw createError({
11+
statusCode: 500,
12+
statusMessage: "No X-Forwarded-Host header found",
13+
});
14+
}
15+
16+
return await fetch(new URL("/api/_fe/config", host)).then((res) =>
17+
res.json(),
18+
);
19+
};

0 commit comments

Comments
 (0)