Skip to content

Commit

Permalink
v0.4 (#123)
Browse files Browse the repository at this point in the history
* feat: initial work on Node to Bun transition (#107)

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: switch to a single-container solution by removing PocketBase (#108)

* feat: create DB connection, draft schemas

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: add initial local storage support, work on DB impl., minor changes

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: rewrite entities fetching, improve DB schema

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: integrate Lucia for auth, update DB schema, work on file server

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: progressing auth flow, update types, DB schema

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: update DB schema, rework DB types, further transition

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: add support for file uploads, update DB schema, improve auth flow

Signed-off-by: Robert Goniszewski <[email protected]>

* chore: remove test PB data

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: various updates of logic

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: update DB schema, improve file upload handling

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: add support for user profile pictures, update DB schema

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: add support for user picture uploads, update DB schema

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(api): migrate category and tag endpoints to use database repositories

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(database): update schema and add cascade delete for user relations

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(deps): update dependencies and refactor database schema

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(metadata): replace metascraper with url-metadata

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: fix file uploads & resolving, types, switching theme etc

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: better typing and serialization

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: switch to unixepoch() for timestamp defaults; additional changes

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(database): update schema and repositories for consistent timestamps

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(bookmarks): improve tag handling and form data processing

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(auth): implement API-based authentication and refactor auth flow

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(bookmarks): improve bookmark creation and update processes; storing files

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor: improve file handling; remove unused imports

Signed-off-by: Robert Goniszewski <[email protected]>

* fix(storage): improve file extension handling for icon and SVG types

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: prevent users from signing up when disabled in config; update README

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(ci): add develop branch and preview releases

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(bookmarks): remove unused import and add Storage import

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(docker): remove PocketBase and fix Docker build issues

Signed-off-by: Robert Goniszewski <[email protected]>

---------

Signed-off-by: Robert Goniszewski <[email protected]>

* chore(release): bump version to 0.4.0

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(ci): add 'v' prefix to preview release tag names; trust 'tree-sitter*' packages

Signed-off-by: Robert Goniszewski <[email protected]>

* Revert "feat(ci): add 'v' prefix to preview release tag names; trust 'tree-sitter*' packages"

This reverts commit 2a5e0f3.

* feat(ci): add 'v' prefix to preview release tag names

Signed-off-by: Robert Goniszewski <[email protected]>

* build(docker): optimize Dockerfile and update Bun installation

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(docker): optimize Dockerfile and update dependencies

Signed-off-by: Robert Goniszewski <[email protected]>

* ci: update GitHub release workflow and versioning

Signed-off-by: Robert Goniszewski <[email protected]>

* fix(config): set default value for PUBLIC_HTTPS_ONLY in .env.example

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(ci): adjust Docker image tagging and GitHub release configuration; update compose file

Signed-off-by: Robert Goniszewski <[email protected]>

* chore(ci): update read-package-version-action to v2.1

Signed-off-by: Robert Goniszewski <[email protected]>

* style(about): improve layout and add new technology credits

Signed-off-by: Robert Goniszewski <[email protected]>

* chore(ci): update GitHub release workflow and package version

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(settings): improve user settings management and UI

Signed-off-by: Robert Goniszewski <[email protected]>

* chore(deps): update development and production dependencies

Signed-off-by: Robert Goniszewski <[email protected]>

* chore(version): bump to 0.4.0-pre.2; update dependencies

Signed-off-by: Robert Goniszewski <[email protected]>

* chore(prettier): update Svelte-specific formatting options

Signed-off-by: Robert Goniszewski <[email protected]>

* feat: fix user settings not being saved, invalidate data on bookmark update

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(bookmarks): improve bookmark deletion and settings management

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(about): add dynamic contributor list and improve UI

Signed-off-by: Robert Goniszewski <[email protected]>

* fix(ci): DB is not properly initiated during ima build; simplify compose file

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(metadata): improve urlMetadataScraper function and error han… (#120)

* refactor(metadata): improve urlMetadataScraper function and error handling; fix error on missing

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(metadata): improve icon URL validation and error handling

Signed-off-by: Robert Goniszewski <[email protected]>

* fix(auth): improve login error handling and messages

Signed-off-by: Robert Goniszewski <[email protected]>

---------

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(login): simplify login form and server-side validation

Signed-off-by: Robert Goniszewski <[email protected]>

* fix(login): wrong input name

Signed-off-by: Robert Goniszewski <[email protected]>

* fix(ci): use proper app path inside Docker image

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(auth): implement environment-based configuration options

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(ui): enhance user profile and bookmark management

Signed-off-by: Robert Goniszewski <[email protected]>

* chore: release v0.4.0-pre.3

* feat(ci): update GitHub Actions workflow for release management

Signed-off-by: Robert Goniszewski <[email protected]>

* fix(bookmark): update category field to categoryId in bookmark data

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(layout): improve tag display and add availability check

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(ui): improve BookmarkCard component and homepage layout

Signed-off-by: Robert Goniszewski <[email protected]>

* PB data migration (#116)

* feat(data-migration): start working on PB data migration

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(metadata): enhance performance logging and URL display

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor(utils): enhance performance logging format

Signed-off-by: Robert Goniszewski <[email protected]>

* chore(deps): update development and production dependencies

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(migration): implement data migration UI and functionality

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(database): update foreign key constraints for cascading deletes

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(bookmark): optimize image storage and improve first-time user experience

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(various): finish migration tool preview, improve file handling

Signed-off-by: Robert Goniszewski <[email protected]>

* feat(setup): simplify installation process and update dependencies

Signed-off-by: Robert Goniszewski <[email protected]>

* chore: release v0.4.0-pre.4

---------

Signed-off-by: Robert Goniszewski <[email protected]>

* refactor: update UI and remove unused dependency

Signed-off-by: Robert Goniszewski <[email protected]>

* chore: release v0.4.0

---------

Signed-off-by: Robert Goniszewski <[email protected]>
  • Loading branch information
goniszewski authored Sep 18, 2024
1 parent d8aa510 commit d1c552d
Show file tree
Hide file tree
Showing 125 changed files with 5,974 additions and 14,132 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ coverage
CONTRIBUTING.md
run-dev.sh
build.sh
data/*
9 changes: 1 addition & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
# Set it if you're using external PocketBase installation (default: http://pocketbase)
# Example: PUBLIC_POCKETBASE_URL=https://grimoire.mydomain.com:8090
PUBLIC_POCKETBASE_URL=
# RECOMMENDED: Change this to your email
ROOT_ADMIN_EMAIL=[email protected]
# RECOMMENDED: Use a secure password. Can be later changed in PocketBase's admin panel
ROOT_ADMIN_PASSWORD=changeme
# Set this to your domain name (default: http://localhost:5173)
# Example: PUBLIC_ORIGIN=grimoire.mydomain.com
PUBLIC_ORIGIN=http://localhost:5173
# Set this to true if you're using HTTPS (default: false)
# Example: PUBLIC_HTTPS_ONLY=true
PUBLIC_HTTPS_ONLY=
PUBLIC_HTTPS_ONLY=false
# Change to the port you want the app to listen on (default: 5173)
# Example: PORT=80
PORT=5173
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'plugin:drizzle/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'perfectionist'],
plugins: ['@typescript-eslint', 'perfectionist', 'drizzle'],
rules: {
'perfectionist/sort-objects': [
'error',
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ on:
push:
branches:
- 'main'
tags:
- 'v*.*.*'
- 'develop'
paths:
- 'src/**'
- 'static/**'
Expand All @@ -21,6 +20,8 @@ on:
- 'tailwind.config.cjs'
- 'tsconfig.json'
- 'vite.config.cjs'
release:
types: [published]

jobs:
docker:
Expand All @@ -38,6 +39,7 @@ jobs:
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=pre-release,enable=${{ github.event_name == 'release' && github.event.release.prerelease }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
pb_data
coverage
coverage
data/db*
data/user-uploads/*
data/temp/*
!data/user-uploads/.gitkeep
3 changes: 0 additions & 3 deletions .npmrc

This file was deleted.

7 changes: 6 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
"svelteSortOrder": "options-styles-scripts-markup",
"svelteStrictMode": false,
"svelteBracketNewLine": false,
"svelteAllowShorthand": false,
"svelteIndentScriptAndStyle": false
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"editor.formatOnSave": true,
"importSorter.generalConfiguration.sortOnBeforeSave": true,
"svelte.plugin.svelte.format.enable": true,
"[svelte]": { "editor.defaultFormatter": "svelte.svelte-vscode" }
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"npm.packageManager": "bun"
}
46 changes: 22 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN apt-get update && apt-get install -y python3 python3-pip wget && rm -rf /var/lib/apt/lists/*
COPY . /app
FROM oven/bun AS base
RUN apt-get update && apt-get install -y python3 python3-pip wget build-essential && rm -rf /var/lib/apt/lists/*
RUN bun i -g svelte-kit@latest
WORKDIR /app

FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM base AS install
WORKDIR /temp/dev
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
ENV NODE_OPTIONS=--max_old_space_size=4096
RUN pnpm run build
WORKDIR /temp/prod
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile --production

FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

FROM base
ARG PUBLIC_POCKETBASE_URL
ARG ROOT_ADMIN_EMAIL
ARG ROOT_ADMIN_PASSWORD
ARG PUBLIC_ORIGIN="http://localhost:5173"
ARG PORT=5173
ARG PUBLIC_HTTPS_ONLY="false"
ARG PUBLIC_SIGNUP_DISABLED="false"
ARG BODY_SIZE_LIMIT="5000000"
ENV NODE_ENV=production
ENV NODE_OPTIONS=--max-old-space-size=8192
RUN bun --bun run build

ENV PUBLIC_POCKETBASE_URL=$PUBLIC_POCKETBASE_URL
ENV ROOT_ADMIN_EMAIL=$ROOT_ADMIN_EMAIL
ENV ROOT_ADMIN_PASSWORD=$ROOT_ADMIN_PASSWORD
ENV PUBLIC_ORIGIN=$PUBLIC_ORIGIN
ENV ORIGIN=$PUBLIC_ORIGIN
ENV PORT=$PORT
ENV PUBLIC_HTTPS_ONLY=$PUBLIC_HTTPS_ONLY
ENV PUBLIC_SIGNUP_DISABLED=$PUBLIC_SIGNUP_DISABLED
ENV BODY_SIZE_LIMIT=$BODY_SIZE_LIMIT

COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/build /app/build
COPY --from=build /app/package.json /app/package.json
COPY --from=base /app/pb_migrations /app/pb_migrations
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /app .
RUN bun --bun run run-migrations
ENV NODE_ENV=production
EXPOSE $PORT
ENTRYPOINT [ "node", "-r", "dotenv/config", "src/server.js" ]
ENTRYPOINT [ "bun","./build/index.js" ]
98 changes: 40 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
<br>

> [!IMPORTANT]
> This application is undergoing a comprehensive overhaul to simplify its architecture, deliver an enhanced user experience, and have a more efficient development cycle.
>
> Read the [Refactoring and streamlining effort](https://github.com/users/goniszewski/projects/1/views/1?pane=issue&itemId=65225221) for more information.
> Version `0.4` introduces a new approach for data storage and user authorization. If you are upgrading from version `0.3.X` you may want to utilize the built-in [**migration tool** (read more)]().
Glimpse into the magical book of _your_ forbidden knowledge - **Grimoire!** 📖💫

Expand Down Expand Up @@ -58,27 +55,44 @@ More screenshots can be found in the [screenshots directory](screenshots).

### Steps

```bash
# Clone the repository
git clone https://github.com/goniszewski/grimoire

# Rename the `.env.example` file to `.env`
# "mv .env.example .env" on Linux/MacOS, "ren .env.example .env" on Windows

# [RECOMMENDED] Update the `.env` to set the initial admin user credentials
# (admins are separate from regular users)

# Build and run the containers
docker compose up
1. Create a `docker-compose.yml` file with the following content:

```yml
services:
grimoire:
image: goniszewski/grimoire:develop
container_name: grimoire
restart: unless-stopped
environment:
- PORT=5173
- PUBLIC_HTTPS_ONLY=false
- PUBLIC_SIGNUP_DISABLED=false
volumes:
- grimoire_data:/app/data/
build:
context: .
dockerfile: Dockerfile
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:$PORT/api/health || exit 1
interval: 30s
timeout: 10s
retries: 3
ports:
- '${PORT:-5173}:${PORT:-5173}'
volumes:
grimoire_data:
```
2. [Optional] Update the environment variables to match your needs.
3. Run the app using `docker compose up -d` command.

</details>

> [!NOTE]
> For the recommended setup, only the `docker-compose.yml`, `.env.example` files and the `pb_migrations/` directory (containing the migration files) are needed.
> For the recommended setup, only the `docker-compose.yml` file is required.

<details>
<summary><strong>Run app using Node + Pocketbase using Docker Compose</strong></summary>
<summary><strong>Run app using Node</strong></summary>

### Prerequisites

Expand All @@ -96,53 +110,15 @@ git clone https://github.com/goniszewski/grimoire
# Rename the `.env.example` file to `.env`
# "mv .env.example .env" on Linux/MacOS, "ren .env.example .env" on Windows

# [RECOMMENDED] Update the `.env` to set the initial admin user credentials
# (admins are separate from regular users)

# Install the dependencies
pnpm i

# Run the Pocketbase container using Docker Compose and start the app
# Run the app
chmod +x ./run-dev.sh && ./run-dev.sh
```

</details>

<details>
<summary><strong>Run app using Node + standalone Pocketbase</strong></summary>

### Prerequisites

- [Node.js](https://nodejs.org/en/download/)
- [PNPM](https://pnpm.io/installation)
- [Pocketbase](https://github.com/pocketbase/pocketbase?tab=readme-ov-file#use-as-standalone-app)

### Steps

```bash
# Clone the repository
git clone https://github.com/goniszewski/grimoire

# Rename the `.env.example` file to `.env`
# "mv .env.example .env" on Linux/MacOS, "ren .env.example .env" on Windows

# [RECOMMENDED] Update the `.env` to set the initial admin user credentials
# (admins are separate from regular users)

# Move the pocketbase executable to the project root directory and run it
./pocketbase serve

# Install the dependencies
pnpm i

# Build and start the app
pnpm build && node -r dotenv/config build

# To start the app again, just run `node -r dotenv/config build`
```

</details>

> [!TIP]
> Although the above setups are intended for development, they are also suitable for daily use. For a better experience, it is recommended to use a Node.js process manager, such as [PM2](https://github.com/Unitech/pm2).
Expand Down Expand Up @@ -175,12 +151,18 @@ This project is licensed under the [MIT License](LICENSE).
## Credits

Special thanks to: [@extractus/article-extractor](https://github.com/extractus/article-extractor),
[Bun](https://github.com/oven-sh/bun),
[DaisyUI](https://github.com/saadeghi/daisyui),
[Drizzle](https://github.com/drizzle-team/drizzle-orm),
[Fuse.js](https://github.com/krisk/fuse),
[Lucia](https://github.com/pilcrowOnPaper/lucia),
[MetaScraper](https://github.com/microlinkhq/metascraper),
[PocketBase](https://github.com/pocketbase/pocketbase),
[sanitize-html](https://github.com/apostrophecms/sanitize-html),
[SvelteKit](https://github.com/sveltejs/kit),
[Svelte Select](https://github.com/rob-balfre/svelte-select),
[Svelte French Toast](https://github.com/kbrgl/svelte-french-toast),
[Tailwind CSS](https://tailwindcss.com)
[Swagger UI](https://github.com/swagger-api/swagger-ui),
[Tabler Icons](https://github.com/tabler/tabler-icons),
[Tailwind CSS](https://tailwindcss.com),
[url-metadata](https://github.com/laurengarcia/url-metadata)
Binary file added bun.lockb
Binary file not shown.
Empty file added data/.gitkeep
Empty file.
Empty file added data/user-uploads/.gitkeep
Empty file.
38 changes: 11 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
version: '3.7'
services:
pocketbase:
image: spectado/pocketbase:0.22.10
container_name: grimoire-pocketbase
restart: unless-stopped
ports:
- '8090:80'
volumes:
- pb_data:/pb_data
- pb_migrations:/pb_migrations/
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:80/api/health || exit 1
interval: 5s
timeout: 5s
retries: 5
env_file: .env
depends_on:
- grimoire
grimoire:
image: goniszewski/grimoire:latest
image: goniszewski/grimoire:develop
container_name: grimoire
restart: unless-stopped
env_file: .env
environment:
- PORT=5173
- PUBLIC_HTTPS_ONLY=false
- PUBLIC_SIGNUP_DISABLED=false
volumes:
- pb_migrations:/app/pb_migrations/
- grimoire_data:/app/data/
build:
context: .
dockerfile: Dockerfile
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:$PORT/api/health || exit 1
interval: 5s
timeout: 5s
retries: 5
interval: 30s
timeout: 10s
retries: 3
ports:
- '$PORT:$PORT'
- '${PORT:-5173}:${PORT:-5173}'
volumes:
pb_data:
pb_migrations:
grimoire_data:
10 changes: 10 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
dialect: 'sqlite',
schema: './src/lib/database/schema.ts',
out: './migrations',
dbCredentials: {
url: './data/db.sqlite'
}
});
Loading

0 comments on commit d1c552d

Please sign in to comment.