Skip to content

Commit

Permalink
chore: release v0.4.3 (#149)
Browse files Browse the repository at this point in the history
* chore: release v0.4.1-hotfix.3

* fix(data-migration): early return if no categories have parents (#128)

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

* Closes #130 (#131)

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

* fix(database): use dynamic path for SQLite database file

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

* docs(readme): use single README file for latest/preview version

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

* feat(ci): add manual deployment workflow and adjust tag conditions

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

* refactor(workflow): simplify manual-deploy GitHub Action

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

* fix(metadata): handle multiple image URLs in mainImageUrl field

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

* fix: auth error handling (#144)

* refactor(api): migrate Swagger UI to external documentation and enhance health endpoint

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

* chore: release v0.4.3

---------

Signed-off-by: Robert Goniszewski <[email protected]>
Co-authored-by: Prabhanjan <[email protected]>
  • Loading branch information
goniszewski and Sparkenstein authored Nov 6, 2024
1 parent cc29548 commit a7ccb95
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 85 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name: manual-deploy
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: true
tag:
description: 'Tag to use (latest or preview)'
required: true
Expand All @@ -21,8 +18,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
Expand Down
23 changes: 16 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@

Thank you for considering contributing to this project! All contributors, big or small, are welcomed. To make the contribution process as smooth as possible, please follow the guidelines below.

## Prerequisites

- Bun

## Steps

1. **Fork the repository:** Start by forking the repository to your own GitHub account. This will create a copy of the repository under your username.
2. **Create a new branch:** Clone the forked repository to your local machine and create a new branch for your feature or bug fix.
```bash
git clone https://github.com/your-username/grimoire.git
cd grimoire
git checkout -b your-branch-name
```
3. **Make the changes:** Make the necessary changes to the codebase, ensuring that you follow any coding style guidelines mentioned in the project documentation or README file.
4. **Test your changes:** Thoroughly test your changes to ensure that they do not break existing functionality and introduce new bugs.
5. **Commit your changes:** Once you are satisfied with your modifications, commit them using a descriptive commit message following the rules of [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716).
3. **Install Deps** run `bun install` to install the deps
4. **Start the server:** if you are on \*nix systems run `./run-dev.sh`. Might need to chmod it before. On windows just `bun --bun run dev` should work.
5. **Run migrations:** `bun run-migrations` to run migrations and have base DB setup.
6. **Make the changes:** Make the necessary changes to the codebase, ensuring that you follow any coding style guidelines mentioned in the project documentation or README file.
7. **Test your changes:** Thoroughly test your changes to ensure that they do not break existing functionality and introduce new bugs.
8. **Commit your changes:** Once you are satisfied with your modifications, commit them using a descriptive commit message following the rules of [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716).
```bash
git add .
git commit -m "fix: Your detailed description of your changes."
```
6. **Push to your branch:** Push your changes to your forked repository on GitHub.
9. **Push to your branch:** Push your changes to your forked repository on GitHub.
```bash
git push origin your-branch-name
```
7. **Submit a Pull Request:** Navigate to the GitHub page of the original project and submit a pull request with a clear description of your changes.
8. **Wait for review:** Patiently wait for the maintainers to review your pull request. They might ask for additional information or changes, which you can address by updating your branch and submitting an updated pull request.
9. **Let it spark** ✨ Yay, your contribution has been accepted and merged into the project! Thank you for making this project better 🤝
10. **Submit a Pull Request:** Navigate to the GitHub page of the original project and submit a pull request with a clear description of your changes.
11. **Wait for review:** Patiently wait for the maintainers to review your pull request. They might ask for additional information or changes, which you can address by updating your branch and submitting an updated pull request.
12. **Let it spark** ✨ Yay, your contribution has been accepted and merged into the project! Thank you for making this project better 🤝

Thank you for contributing to this project! We appreciate your efforts in making it even better. If you have any questions or need further clarification, feel free to reach out to us.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grimoire",
"version": "0.4.2",
"version": "0.4.3",
"description": "Bookmark manager for the wizards 🧙",
"author": "Robert Goniszewski <[email protected]>",
"main": "./build/index.js",
Expand Down
28 changes: 13 additions & 15 deletions src/lib/components/ThemeSwitch/ThemeSwitch.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<script lang="ts">
import { enhance } from '$app/forms';
import { themes } from '$lib/enums/themes';
import type { User } from '$lib/types/User.type';
import { IconMoon, IconSunHigh } from '@tabler/icons-svelte';
import { enhance } from '$app/forms';
import { themes } from '$lib/enums/themes';
import type { User } from '$lib/types/User.type';
import { IconMoon, IconSunHigh } from '@tabler/icons-svelte';
export let user: User | null = null;
let themeSwitchForm: HTMLFormElement;
export let user: User | null = null;
let themeSwitchForm: HTMLFormElement;
$: theme = user?.settings?.theme ?? 'light';
$: theme = user?.settings?.theme ?? 'light';
function handleThemeChange(theme: keyof typeof themes) {
document.documentElement.setAttribute('data-theme', themes[theme]);
document.cookie = `theme=${theme}; ${document.cookie}`;
}
function handleThemeChange(theme: keyof typeof themes) {
document.documentElement.setAttribute('data-theme', themes[theme]);
document.cookie = `theme=${theme}; ${document.cookie}; SameSite=Lax`;
}
</script>

<form
Expand All @@ -25,16 +25,14 @@
handleThemeChange(theme);

return async () => {};
}}
>
}}>
<label class="btn btn-circle swap swap-rotate btn-sm">
<input
id="theme"
name="theme"
type="checkbox"
checked={theme === 'dark'}
on:change={() => themeSwitchForm.requestSubmit()}
/>
on:change={() => themeSwitchForm.requestSubmit()} />
<IconSunHigh size={20} class="swap-on" />
<IconMoon size={20} class="swap-off" />
</label>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/utils/get-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ async function urlMetadataScraper(html: string, url: string): Promise<Partial<Me
url,
iconUrls?.[0] || urlMetadataMetadata?.favicons?.[0]?.href || ''
);
const mainImageUrl: string = urlMetadataMetadata?.image || urlMetadataMetadata?.['og:image'];

return {
url: urlMetadataMetadata?.url || urlMetadataMetadata?.['og:url'],
title: urlMetadataMetadata?.title || urlMetadataMetadata?.['og:title'],
description: urlMetadataMetadata?.description || urlMetadataMetadata?.['og:description'],
author: urlMetadataMetadata?.author || urlMetadataMetadata?.['twitter:creator'],
mainImageUrl: urlMetadataMetadata?.image || urlMetadataMetadata?.['og:image'],
mainImageUrl: mainImageUrl.includes(',http') ? mainImageUrl.split(',http')[0] : mainImageUrl,
iconUrl
};
} catch (error) {
Expand Down
24 changes: 9 additions & 15 deletions src/routes/api/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
<script lang="ts">
import { onMount } from 'svelte';
import SwaggerUI from 'swagger-ui';
import 'swagger-ui/dist/swagger-ui.css';
import * as spec from './api-schema.json';
onMount(async () => {
SwaggerUI({
spec,
dom_id: '#swagger-ui-container'
});
});
</script>

<svelte:head>
<title>Grimoire - SwaggerUI</title>
</svelte:head>

<div id="swagger-ui-container" class="bg-gray-50 w-full rounded-lg" />
<div class="flex h-full w-full flex-col items-center justify-center">
<a
href="https://grimoire.pro/api"
target="_blank"
rel="noopener noreferrer"
class="text-blue-500 underline hover:text-blue-700">
View Swagger Documentation
</a>
</div>
9 changes: 8 additions & 1 deletion src/routes/api/health/+server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { version } from '$app/environment';
import { getUserCount } from '$lib/database/repositories/User.repository';

import { json } from '@sveltejs/kit';

import type { RequestHandler } from '@sveltejs/kit';

export const GET: RequestHandler = async () => {
const dbConnected = await getUserCount().then((count) => count >= 0);

return json(
{
currentServerTime: new Date().toISOString()
currentServerTime: new Date().toISOString(),
database: dbConnected ? 'CONNECTED' : 'FAILED TO CONNECT',
appVersion: version
},
{
status: 200
Expand Down
17 changes: 6 additions & 11 deletions src/routes/login/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fail, redirect } from '@sveltejs/kit';

import type { Actions } from './$types';

const USER_NOT_FOUND = 'User not found';
const INVALID_USERNAME_OR_PASSWORD = 'Invalid username or password';
export const actions: Actions = {
default: async (event) => {
Expand All @@ -16,17 +17,10 @@ export const actions: Actions = {
const existingUser = await getUserWithoutSerialization(login);

if (!existingUser) {
const randomMs = Math.floor(Math.random() * 1000);

return new Promise((resolve) => {
setTimeout(() => {
resolve(
fail(401, {
login: login,
message: INVALID_USERNAME_OR_PASSWORD
})
);
}, randomMs);
return fail(401, {
login: login,
invalid: true,
message: USER_NOT_FOUND
});
}

Expand All @@ -40,6 +34,7 @@ export const actions: Actions = {
if (!validPassword) {
return fail(401, {
login: login,
invalid: true,
message: INVALID_USERNAME_OR_PASSWORD
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export let form: HTMLFormElement;
{#if form?.invalid}
<div role="alert" class="alert alert-error">
<IconExclamationCircle />
<span> Incorrect credentials. </span>
<span> {form.message} </span>
</div>
{/if}
<div class="mt-24 w-full">
Expand Down
20 changes: 17 additions & 3 deletions src/routes/signup/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import config from '$lib/config';
import { createCategory } from '$lib/database/repositories/Category.repository';
import {
createUser, getUserByUsername, getUserCount
createUser,
getUserByUsername,
getUserCount
} from '$lib/database/repositories/User.repository';
import { lucia } from '$lib/server/auth';
import { createSlug } from '$lib/utils/create-slug';
Expand Down Expand Up @@ -43,7 +45,9 @@ export const actions: Actions = {
username: Joi.string().min(3).max(31),
email: Joi.string().email().optional(),
password: Joi.string().min(6).max(255),
passwordConfirm: Joi.string().valid(Joi.ref('password'))
passwordConfirm: Joi.string().valid(Joi.ref('password')).messages({
'any.only': 'Passwords do not match.'
})
});

const { error, value } = validationSchema.validate({
Expand All @@ -55,8 +59,14 @@ export const actions: Actions = {
});

if (error) {
const fieldName = error.details[0].path[0] as string;

return fail(400, {
message: error!.message
message: error!.message,
invalid: true,
[fieldName]: {
message: error!.message
}
});
}

Expand All @@ -73,6 +83,10 @@ export const actions: Actions = {

if (userExists) {
return fail(400, {
username: {
message: 'User with this username already exists'
},
invalid: true,
message: 'User with this username / email already exists'
});
}
Expand Down
Loading

0 comments on commit a7ccb95

Please sign in to comment.