From d9f1323c5c9a2bb1defcdf1d3d739b6e9d86c190 Mon Sep 17 00:00:00 2001 From: mmattbtw Date: Sun, 19 Feb 2023 18:31:33 -0600 Subject: [PATCH] feat: start landing page Closes #35 fix: switch to scss feat: finish up layout chore: switch to mask + small other fixes Switched to mask as our task runner from Just. Mask seems to provide a much nicer cli than just and also is much easier to write than the just files, since its markdown. Ideally they should add support for submoudles and some things to help with code duplication. Like global variables, global scripts, cascading flags, catch all extra arguments, ect... However these are not big enough issues for us to not use it since just/make is very unmaintainable and very messy when we have a lot of tasks. I made an issue on their repo for the submodule idea. https://github.com/jacobdeichert/mask/issues/96 Some small fixes: - .gitignores on mac - prettier not formatting all files feat: start landing page Closes #35 fix: switch to scss fix: remove unused file feat: fix magic text positioning chore: format fix: capitalization chore: add code coverage Add code coverage with Codecov. closes #50 feat: add blurred circles to background chore: format fix: remove unused + + diff --git a/frontend/website/src/routes/+page.svelte b/frontend/website/src/routes/+page.svelte index 16af9e524..c070b475a 100644 --- a/frontend/website/src/routes/+page.svelte +++ b/frontend/website/src/routes/+page.svelte @@ -1,12 +1,334 @@ - - -

Welcome to SvelteKit

-

Visit kit.svelte.dev to read the documentation

+ +
+
+
+ +

Scuffle.tv

+

+ We’re building a streaming platform. +
+ A community driven streaming platform, that is. +

+
+
+ +

For Fun™

+

+ Have you ever thought of making your own streaming platform? No? +
+ Well... We are making a streaming platform. An open-source + streaming platform. +
+ You can join us on our journey of world conquer... It will be fun... Probably. +

+
+
+

So... how do we conquer the world?

+
+
+

90% Rust

+

10% Magic

+
+
+
+

+ With the power of Rust.. and + Magic, of course. +

+
+
+

Rust? Like the game?

+

+ No. Not the game, we’re talking ‘bout the programming language. +
+ If you’re a programmer you must have heard of it before. +
+ Fast and safe. That’s all you need to know about Rust. +
+ Did we mention it’s fast? Blazingly Fast™. +

+
+
+ +

So... What makes it community driven?

+

+ Open source. Made by a community of people who actually care about their work. +
+ We plan on having everything be as transparent as possible. +
+ Transparent moderation, development. +
+ That’s what it’s all about. +

+
+
+

Aren’t streaming platforms super expensive?

+

+ Yes, they are... +
+ Our biggest goal and challenge is making everything cost effective and self sustainable. +

+
+
+ + +

Alright, you convinced me. Where can I join in on the fun?

+

You can join our Discord, and check out the source code on GitHub.

+
+ +
+
+ + + diff --git a/frontend/website/svelte.config.js b/frontend/website/svelte.config.js index 87081a053..1448ea2cb 100644 --- a/frontend/website/svelte.config.js +++ b/frontend/website/svelte.config.js @@ -1,5 +1,5 @@ -import adapter from "svelte-adapter-deno"; import { vitePreprocess } from "@sveltejs/kit/vite"; +import adapter from "svelte-adapter-deno"; /** @type {import('@sveltejs/kit').Config} */ const config = { diff --git a/frontend/website/tests/test.ts b/frontend/website/tests/test.ts index 5076f5217..757c1c7a8 100644 --- a/frontend/website/tests/test.ts +++ b/frontend/website/tests/test.ts @@ -2,5 +2,5 @@ import { expect, test } from "@playwright/test"; test("index page has expected h1", async ({ page }) => { await page.goto("/"); - await expect(page.getByRole("heading", { name: "Welcome to SvelteKit" })).toBeVisible(); + await expect(page.getByRole("heading", { name: "Scuffle.tv" })).toBeVisible(); }); diff --git a/maskfile.md b/maskfile.md new file mode 100644 index 000000000..59f6cb7ae --- /dev/null +++ b/maskfile.md @@ -0,0 +1,615 @@ +# Scuffle Tasks + +## build + +> Build the project + + + +**OPTIONS** + +- container + - flags: --container + - desc: Build the project in a container +- static + - flags: --static + - desc: Compile the project statically + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +static=${static:-false} + +if [ "$container" == "true" ]; then + $MASK env backup + + function cleanup { + $MASK env restore + docker stop $PID >> /dev/null + } + trap cleanup EXIT + + PID=$(docker run -d --stop-signal SIGKILL --rm -v "$(pwd)":/pwd -w /pwd ghcr.io/scuffletv/build:latest mask build) + docker logs -f $PID +else + $MASK build rust --static=$static + $MASK build website +fi +``` + +### rust + +> Build all rust code + +**OPTIONS** + +- container + - flags: --container + - desc: Build the project in a container +- static + - flags: --static + - desc: Compile the project statically + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +static=${static:-false} +target=$(rustup show active-toolchain | cut -d '-' -f2- | cut -d ' ' -f1) + +if [ "$container" == "true" ]; then + $MASK env backup + + function cleanup { + $MASK env restore + docker stop $PID >> /dev/null + } + trap cleanup EXIT + + PID=$(docker run -d --stop-signal SIGKILL --rm -v "$(pwd)":/pwd -w /pwd ghcr.io/scuffletv/build:latest mask build rust --static=$static) + docker logs -f $PID +else + if [ "$static" == "true" ]; then + export RUSTFLAGS="-C target-feature=+crt-static" + fi + + cargo build --release --target=$target +fi +``` + +### website + +> Build the frontend website + +**OPTIONS** + +- container + - flags: --container + - desc: Build the project in a container + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ "$container" == "true" ]; then + $MASK env backup + + function cleanup { + $MASK env restore + docker stop $PID >> /dev/null + } + trap cleanup EXIT + + PID=$(docker run -d --stop-signal SIGKILL --rm -v "$(pwd)":/pwd -w /pwd ghcr.io/scuffletv/build:1.67.1 yarn workspace website build) + docker logs -f $PID +else + yarn workspace website build +fi +``` + +## clean + +> Clean the project + +**OPTIONS** + +- all + + - flags: --all + - desc: Removes everything that isn't tracked by git (use with caution, this is irreversible) + +- node_modules + + - flags: --node-modules + - desc: Removes node_modules + +- env + - flags: --env + - desc: Removes .env + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [[ "$all" == "true" ]]; then + git clean -xfd +fi + +cargo clean +yarn workspace website clean + +if [ "$node_modules" == "true" ]; then + rm -rf node_modules +fi + +if [ "$env" == "true" ]; then + rm -rf .env +fi +``` + +## format + +> Format the project + +**OPTIONS** + +- no_rust + - flags: --no-rust + - type: bool + - desc: Disables Rust formatting +- no_js + - flags: --no-js + - type: bool + - desc: Disables JS formatting + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ "$no_rust" != "true" ]; then + cargo fmt --all + cargo clippy --fix --allow-dirty --allow-staged + cargo clippy --fix --allow-dirty --allow-staged --package player --target wasm32-unknown-unknown +fi + +if [ "$no_js" != "true" ]; then + yarn format + yarn workspace website format +fi +``` + +## lint + +> Lint the project + +**OPTIONS** + +- no_rust + - flags: --no-rust + - type: bool + - desc: Disables Rust linting +- no_js + - flags: --no-js + - type: bool + - desc: Disables JS linting + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ "$no_rust" != "true" ]; then + cargo clippy -- -D warnings + cargo clippy --package player --target wasm32-unknown-unknown -- -D warnings + cargo fmt --all --check + cargo sqlx prepare --check --merged -- --all-targets --all-features +fi + +if [ "$no_js" != "true" ]; then + yarn lint + yarn workspace website lint +fi +``` + +## audit + +> Audit the project + +**OPTIONS** + +- no_rust + - flags: --no-rust + - type: bool + - desc: Disables Rust linting +- no_js + - flags: --no-js + - type: bool + - desc: Disables JS linting + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ "$no_rust" != "true" ]; then + cargo audit +fi + +if [ "$no_js" != "true" ]; then + yarn audit +fi +``` + +## test + +> Test the project + +**OPTIONS** + +- no_rust + - flags: --no-rust + - type: bool + - desc: Disables Rust testing +- no_js + - flags: --no-js + - type: bool + - desc: Disables JS testing + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ "$no_rust" != "true" ]; then + cargo llvm-cov clean --workspace + cargo llvm-cov nextest --lcov --output-path lcov.info --ignore-filename-regex "(main.rs|tests.rs)" +fi + +if [ "$no_js" != "true" ]; then + yarn workspace website test +fi +``` + +## db + +> Database tasks + +### migrate + +> Migrate the database + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +sqlx database create +sqlx migrate run --source ./backend/migrations +``` + +#### create (name) + +> Create a database migration + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +sqlx migrate add "$name" --source ./backend/migrations -r +``` + +### rollback + +> Rollback the database + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +sqlx migrate revert --source ./backend/migrations +``` + +### prepare + +> Prepare the database + +**OPTIONS** + +- no_format + - flags: --no-format + - type: bool + - desc: Disables formatting + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +cargo sqlx prepare --merged -- --all-targets --all-features + +if [ "$no_format" != "true" ]; then + yarn prettier --write sqlx-data.json +fi +``` + +### reset + +> Reset the database + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +sqlx database reset --source ./backend/migrations +``` + +### up + +> Starts the docker compose stack + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +docker compose --file ./dev-stack/db.docker-compose.yml up -d +``` + +### down + +> Stops the docker compose stack + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +docker compose --file ./dev-stack/db.docker-compose.yml down +``` + +### status + +> Gets the status of the docker compose db stack + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +docker compose --file ./dev-stack/db.docker-compose.yml ps -a +``` + +## env + +> Environment tasks + +### generate + +> Generate the environment files + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ ! -f .env ]; then + echo "DATABASE_URL=postgres://postgres:postgres@localhost:5432/scuffle-dev" > .env +fi +``` + +### backup + +> Backup the environment files + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ -f .env ]; then + mv .env .env.bak +fi +``` + +### restore + +> Restore the environment files + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ -f .env.bak ]; then + mv .env.bak .env +fi +``` + +## stack + +> Development stack tasks + +### up + +> Starts the docker compose stack + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +docker compose --file ./dev-stack/docker-compose.yml up -d --build +``` + +### down + +> Stops the docker compose stack + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +docker compose --file ./dev-stack/docker-compose.yml down +``` + +### init + +> Initializes the development stack + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +cp ./dev-stack/example.docker-compose.yml ./dev-stack/docker-compose.yml +``` + +### status + +> Gets the status of the docker compose stack + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +docker compose --file ./dev-stack/docker-compose.yml ps -a +``` + +### logs (service) + +> Prints the logs of the given service +> You can show logs of multiple services by passing a single string with space separated service names + +**OPTIONS** + +- follow + - flags: -f, --follow + - type: bool + - desc: Follow log output + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +follow=${follow:-false} + +docker compose --file ./dev-stack/docker-compose.yml logs --follow=$follow $service +``` + +## bootstrap + +> Bootstrap the project + +**OPTIONS** + +- no_rust + - flags: --no-rust + - type: bool + - desc: Disables Rust bootstrapping +- no_js + - flags: --no-js + - type: bool + - desc: Disables JS bootstrapping +- no_js_tests + - flags: --no-js-tests + - type: bool + - desc: Disables JS tests bootstrapping +- no_env + - flags: --no-env + - type: bool + - desc: Disables environment bootstrapping +- no_docker + - flags: --no-docker + - type: bool + - desc: Disables docker bootstrapping +- no_stack + - flags: --no-stack + - type: bool + - desc: Disables stack bootstrapping +- no_db + - flags: --no-db + - type: bool + - desc: Disables database bootstrapping + +```bash +set -e +if [[ "$verbose" == "true" ]]; then + set -x +fi + +if [ "$no_rust" != "true" ]; then + rustup update + rustup target add wasm32-unknown-unknown + + rustup component add rustfmt clippy llvm-tools-preview + + cargo install cargo-binstall + cargo binstall cargo-watch -y + cargo install sqlx-cli --features rustls,postgres --no-default-features + cargo binstall wasm-pack -y + cargo binstall cargo-llvm-cov -y + cargo binstall cargo-nextest -y + cargo install cargo-audit --features vendored-openssl +fi + +if [ "$no_js" != "true" ]; then + yarn install + + if [ "$no_js_tests" != "true" ]; then + yarn playwright install + fi +fi + +if [ "$no_env" != "true" ]; then + $MASK env generate +fi + +if [ "$no_docker" != "true" ]; then + docker network create scuffle-dev || true + + if [ "$no_stack" != "true" ]; then + $MASK stack init + fi + + if [ "$no_db" != "true" ]; then + $MASK db up + $MASK db migrate + fi +fi +``` diff --git a/package.json b/package.json index 51f1eb705..443f5b644 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ ], "scripts": { "prepare": "husky install", - "lint": "prettier --check .", - "format": "prettier --write ." + "lint": "prettier --check \"**/*\" -u", + "format": "prettier --write \"**/*\" -u" } } diff --git a/sqlx-data.json b/sqlx-data.json index 05d9d6f59..c2110f43d 100644 --- a/sqlx-data.json +++ b/sqlx-data.json @@ -1,3 +1,49 @@ { - "db": "PostgreSQL" + "db": "PostgreSQL", + "165e3eb51d255f5b3013430059b5267269df7285cdb0736efddbf8fca9c32ed2": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [] + } + }, + "query": "INSERT INTO users (id, username, password_hash, email, email_verified, created_at, last_login_at) VALUES\n (1, 'admin', 'abc', 'xyz@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (2, 'user', 'abc2', 'xyz2@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (3, 'user1', 'abc3', 'xyz3@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (4, 'user2', 'abc4', 'xyz4@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (5, 'user3', 'abc5', 'xyz5@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (6, 'user4', 'abc6', 'xyz6@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (7, 'user5', 'abc7', 'xyz7@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (8, 'user6', 'abc8', 'xyz8@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (9, 'user7', 'abc9', 'xyz9@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (10, 'user8', 'abc10', 'xyz10@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00'),\n (11, 'user9', 'abc11', 'xyz11@gmail.com', true, '2021-01-01 00:00:00', '2021-01-01 00:00:00');" + }, + "1c9b66121e84a7657c44ebd2c19957f71c02ef364f4c1727c68d530a3b68c31a": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "username", + "ordinal": 1, + "type_info": "Varchar" + }, + { + "name": "created_at", + "ordinal": 2, + "type_info": "Timestamptz" + } + ], + "nullable": [false, false, false], + "parameters": { + "Left": ["Int8Array"] + } + }, + "query": "\n SELECT id, username, created_at\n FROM users\n WHERE id = ANY($1)\n " + }, + "f4f8f8c2668ec23ba1f4a315d74087521496603e8b1bc10475a864001e795593": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [] + } + }, + "query": "DELETE FROM users" + } } diff --git a/yarn.lock b/yarn.lock index a1dee9f83..5fec2e5a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -316,6 +316,16 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" +"@fontsource/be-vietnam-pro@^4.5.8": + version "4.5.8" + resolved "https://registry.yarnpkg.com/@fontsource/be-vietnam-pro/-/be-vietnam-pro-4.5.8.tgz#fb26070f83ab763df8952a8bb89632b7f1dff7c3" + integrity sha512-02BI3zS+7Rs4vffa2U6AznQEjG2skMn4nswjEzwQc7uzE04n1MLxh9Mhf3KT5GBuP9HuPHJYVgytcGQ1xNLJfw== + +"@fontsource/comfortaa@^4.5.11": + version "4.5.11" + resolved "https://registry.yarnpkg.com/@fontsource/comfortaa/-/comfortaa-4.5.11.tgz#f3dc5e07637fc26b87e80897c611d60229d5e24c" + integrity sha512-KKC2C6KbF9BD6m9+wMf5hK0wFjIi3p3J/6C4JZW6OF9G6K4qZJFp2dBZzsEBepKh4s9/Q5G1SWsUUZY3ZeZNDA== + "@humanwhocodes/config-array@^0.11.8": version "0.11.8" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" @@ -898,7 +908,7 @@ check-error@^1.0.2: resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" integrity sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA== -chokidar@^3.4.1: +"chokidar@>=3.0.0 <4.0.0", chokidar@^3.4.1: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -1687,6 +1697,11 @@ ignore@^5.2.0: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== +immutable@^4.0.0: + version "4.2.4" + resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.2.4.tgz#83260d50889526b4b531a5e293709a77f7c55a2a" + integrity sha512-WDxL3Hheb1JkRN3sQkyujNlL/xRjAo3rJtaU5xeufUauG66JdMr32bLj4gF+vWl84DIA3Zxw7tiAjneYzRRw+w== + import-fresh@^3.0.0, import-fresh@^3.2.1: version "3.3.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" @@ -2601,6 +2616,15 @@ sander@^0.5.0: mkdirp "^0.5.1" rimraf "^2.5.2" +sass@^1.58.3: + version "1.58.3" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.58.3.tgz#2348cc052061ba4f00243a208b09c40e031f270d" + integrity sha512-Q7RaEtYf6BflYrQ+buPudKR26/lH+10EmO9bBqbmPh/KeLqv8bjpTNqxe71ocONqXq+jYiCbpPUmQMS+JJPk4A== + dependencies: + chokidar ">=3.0.0 <4.0.0" + immutable "^4.0.0" + source-map-js ">=0.6.2 <2.0.0" + "semver@2 || 3 || 4 || 5": version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -2690,7 +2714,7 @@ sorcery@^0.11.0: minimist "^1.2.0" sander "^0.5.0" -source-map-js@^1.0.2: +"source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==