diff --git a/.gitignore b/.gitignore index 925c749..79518f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,21 @@ -/.env -__pycache__/ \ No newline at end of file +node_modules + +# Output +.output +.vercel +/.svelte-kit +/build + +# OS +.DS_Store +Thumbs.db + +# Env +.env +.env.* +!.env.example +!.env.test + +# Vite +vite.config.js.timestamp-* +vite.config.ts.timestamp-* diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..b6f27f1 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..ab78a95 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +# Package Managers +package-lock.json +pnpm-lock.yaml +yarn.lock diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..9573023 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "useTabs": true, + "singleQuote": true, + "trailingComma": "none", + "printWidth": 100, + "plugins": ["prettier-plugin-svelte"], + "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] +} diff --git a/README.md b/README.md index b1a605d..5ce6766 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,38 @@ -# Zauberkiste +# create-svelte -A selfhosted wishlist manager. +Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte). + +## Creating a project + +If you're seeing this, you've probably already done this step. Congrats! + +```bash +# create a new project in the current directory +npm create svelte@latest + +# create a new project in my-app +npm create svelte@latest my-app +``` + +## Developing + +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: + +```bash +npm run dev + +# or start the server and open the app in a new browser tab +npm run dev -- --open +``` + +## Building + +To create a production version of your app: + +```bash +npm run build +``` + +You can preview the production build with `npm run preview`. + +> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f966a42 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3' + +services: + zauberkiste: + build: + context: . + target: dev # Build the development target + ports: + - "5173:5173" + - "24678:24678" + volumes: + - .:/app + - /app/node_modules + - ./data:/app/data + container_name: svelte-app-dev + environment: + NODE_ENV: development diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..df6967e --- /dev/null +++ b/dockerfile @@ -0,0 +1,51 @@ +# Stage 1: Base stage +FROM node:18 AS base + +# Set the working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the application files +COPY . . + +# Define build arguments +ARG NODE_ENV +ENV NODE_ENV=$NODE_ENV + +# Stage 2: Development stage +FROM base AS dev + +# Expose ports needed for the development server and hot module reloading +EXPOSE 5173 24678 + +# In development mode, run the dev server +CMD ["npm", "run", "dev", "--", "--host"] + +# Stage 3: Build for production +FROM base AS build + +# Build the Svelte app in production mode +RUN npm run build + +# Stage 4: Production stage +FROM node:18-alpine AS prod + +# Install a lightweight server to serve the production build +RUN npm install -g serve + +# Set the working directory +WORKDIR /app + +# Copy the built files from the build stage +COPY --from=build /app/build /app/build + +# Expose port 5000 for serving the production app +EXPOSE 5000 + +# Serve the production build +CMD ["serve", "-s", "build", "-l", "5000"] diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..39ea393 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,32 @@ +import eslint from '@eslint/js'; +import prettier from 'eslint-config-prettier'; +import svelte from 'eslint-plugin-svelte'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.recommended, + ...svelte.configs['flat/recommended'], + prettier, + ...svelte.configs['flat/prettier'], + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node + } + } + }, + { + files: ['**/*.svelte'], + languageOptions: { + parserOptions: { + parser: tseslint.parser + } + } + }, + { + ignores: ['build/', '.svelte-kit/', 'dist/'] + } +); diff --git a/package.json b/package.json new file mode 100644 index 0000000..dff1c99 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "zauberkiste", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "lint": "prettier --check . && eslint .", + "format": "prettier --write ." + }, + "devDependencies": { + "@sveltejs/adapter-auto": "^3.0.0", + "@sveltejs/kit": "^2.0.0", + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "@types/eslint": "^9.6.0", + "eslint": "^9.0.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-svelte": "^2.36.0", + "globals": "^15.0.0", + "prettier": "^3.1.1", + "prettier-plugin-svelte": "^3.1.2", + "svelte": "^4.2.7", + "svelte-check": "^4.0.0", + "typescript": "^5.0.0", + "typescript-eslint": "^8.0.0", + "vite": "^5.0.3" + }, + "type": "module" +} diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index fe22a16..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -Django>=4.2.7 -mysqlclient \ No newline at end of file diff --git a/src/app.d.ts b/src/app.d.ts new file mode 100644 index 0000000..743f07b --- /dev/null +++ b/src/app.d.ts @@ -0,0 +1,13 @@ +// See https://kit.svelte.dev/docs/types#app +// for information about these interfaces +declare global { + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface PageState {} + // interface Platform {} + } +} + +export {}; diff --git a/src/app.html b/src/app.html new file mode 100644 index 0000000..77a5ff5 --- /dev/null +++ b/src/app.html @@ -0,0 +1,12 @@ + + +
+ + + + %sveltekit.head% + + +Visit kit.svelte.dev to read the documentation
diff --git a/src/wishlists/__init__.py b/src/wishlists/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/wishlists/admin.py b/src/wishlists/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/src/wishlists/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/src/wishlists/apps.py b/src/wishlists/apps.py deleted file mode 100644 index 0d5575f..0000000 --- a/src/wishlists/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class WishlistsConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'wishlists' diff --git a/src/wishlists/handler/__init__.py b/src/wishlists/handler/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/wishlists/handler/wishlist/__init__.py b/src/wishlists/handler/wishlist/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/wishlists/handler/wishlist/get_wishlist_handler.py b/src/wishlists/handler/wishlist/get_wishlist_handler.py deleted file mode 100644 index a9d477e..0000000 --- a/src/wishlists/handler/wishlist/get_wishlist_handler.py +++ /dev/null @@ -1,16 +0,0 @@ -from uuid import UUID - -from django.http import Http404 - -from wishlists.models import Wishlist - - -def get_wishlist_by_uuid(uuid: UUID) -> Wishlist: - return Wishlist.objects.get(id=uuid) - - -def get_wishlist_or_404_by_uuid(uuid: UUID) -> Wishlist: - try: - return get_wishlist_by_uuid(uuid) - except Wishlist.DoesNotExist: - raise Http404("This wishlist does not exist.") diff --git a/src/wishlists/migrations/0001_initial.py b/src/wishlists/migrations/0001_initial.py deleted file mode 100644 index 9241fec..0000000 --- a/src/wishlists/migrations/0001_initial.py +++ /dev/null @@ -1,40 +0,0 @@ -# Generated by Django 4.2.7 on 2023-11-27 22:52 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Wishlist', - fields=[ - ('id', models.UUIDField(primary_key=True, serialize=False)), - ('name', models.CharField(max_length=200)), - ('description', models.CharField(max_length=2000)), - ('created_at', models.DateTimeField(auto_now_add=True)), - ('updated_at', models.DateTimeField(auto_now=True)), - ], - ), - migrations.CreateModel( - name='WishlistItem', - fields=[ - ('id', models.UUIDField(primary_key=True, serialize=False)), - ('name', models.CharField(max_length=200)), - ('description', models.CharField(max_length=2000)), - ('url', models.CharField(max_length=2000)), - ('price', models.FloatField()), - ('image', models.CharField(blank=True, max_length=2000, null=True)), - ('gifted', models.BooleanField(default=False)), - ('created_at', models.DateTimeField(auto_now_add=True)), - ('updated_at', models.DateTimeField(auto_now=True)), - ('wishlist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wishlists.wishlist')), - ], - ), - ] diff --git a/src/wishlists/migrations/0002_alter_wishlist_description_and_more.py b/src/wishlists/migrations/0002_alter_wishlist_description_and_more.py deleted file mode 100644 index dbb0abe..0000000 --- a/src/wishlists/migrations/0002_alter_wishlist_description_and_more.py +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Django 4.2.7 on 2023-11-27 23:02 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('wishlists', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='wishlist', - name='description', - field=models.CharField(max_length=2000, null=True), - ), - migrations.AlterField( - model_name='wishlistitem', - name='description', - field=models.CharField(max_length=2000, null=True), - ), - migrations.AlterField( - model_name='wishlistitem', - name='price', - field=models.FloatField(null=True), - ), - migrations.AlterField( - model_name='wishlistitem', - name='url', - field=models.CharField(max_length=2000, null=True), - ), - ] diff --git a/src/wishlists/migrations/__init__.py b/src/wishlists/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/wishlists/models.py b/src/wishlists/models.py deleted file mode 100644 index 8728651..0000000 --- a/src/wishlists/models.py +++ /dev/null @@ -1,30 +0,0 @@ -from django.db import models - - -class Wishlist(models.Model): - id = models.UUIDField(primary_key=True) - name = models.CharField(max_length=200) - description = models.CharField(max_length=2000, null=True) - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - - def __str__(self): - return f"{self.name} ({self.id})" - - -class WishlistItem(models.Model): - id = models.UUIDField(primary_key=True) - wishlist = models.ForeignKey(Wishlist, on_delete=models.CASCADE) - name = models.CharField(max_length=200) - description = models.CharField(max_length=2000, null=True) - order = models.IntegerField(null=True) - url = models.CharField(max_length=2000, null=True) - price = models.FloatField(null=True) - image = models.CharField(max_length=2000, blank=True, null=True) - gifted = models.BooleanField(default=False) - reveal_date = models.DateTimeField(null=True) - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - - def __str__(self): - return f"{self.name} ({self.id})" diff --git a/src/wishlists/templates/owner/index.html b/src/wishlists/templates/owner/index.html deleted file mode 100644 index 1d602cf..0000000 --- a/src/wishlists/templates/owner/index.html +++ /dev/null @@ -1,9 +0,0 @@ -{% if wishlist %} -{{ wishlist.description }}
- {% endif %} -{% else %} -Wishlist not found.
-{% endif %} \ No newline at end of file diff --git a/src/wishlists/templates/public/index.html b/src/wishlists/templates/public/index.html deleted file mode 100644 index 16790fe..0000000 --- a/src/wishlists/templates/public/index.html +++ /dev/null @@ -1,37 +0,0 @@ -{% if wishlist %} -{{ wishlist.description }}
- {% endif %} - - Public link - -Item | -Price | -Link | -Priority | -Actions | -
---|---|---|---|---|
{{ item.name }} | -{{ item.price }} | -{{ item.link }} | -{{ item.priority }} | -- Edit - Delete - | -
Wishlist not found.
-{% endif %} \ No newline at end of file diff --git a/src/wishlists/tests.py b/src/wishlists/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/src/wishlists/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/src/wishlists/urls.py b/src/wishlists/urls.py deleted file mode 100644 index be37554..0000000 --- a/src/wishlists/urls.py +++ /dev/null @@ -1,9 +0,0 @@ -from django.urls import path - -from . import views - -urlpatterns = [ - path("public/