fuma 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,17 +1,51 @@
1
1
  # fuma
2
2
 
3
- My fullstake material build with sveltekit, daisyui, zod and more ...
3
+ My fullstack material build with sveltekit, daisyui, zod and more ...
4
4
 
5
5
  ## Fast setup
6
6
 
7
7
  ```sh
8
- export project="myproject"
9
- pn create svelte@latest $project
10
- cd $project
8
+ echo "Enter project's name : " && read project_name
9
+ echo "Enter mysql username : " && read mysql_username
10
+
11
+ pn create svelte@latest $project_name
12
+ cd $project_name
11
13
  pn i fuma
12
- px svelte-add@latest tailwindcss
13
- pn i -D daisyui@latest
14
- sed -i "s/plugins: \[\]/plugins: \[require('daisyui')\],\n\tdaisyui: {\n\t\tlogs: false\n\t}\n/g" tailwind.config.cjs
14
+ px svelte-add@latest tailwindcss --tailwindcss-daisyui
15
+ sed -i "s|\}'\],|\}', './node_modules/**/fuma/dist/**/*.svelte'\],|g" tailwind.config.cjs
16
+ sed -i 's|"singleQuote": true,|"singleQuote": true,\n\t"semi": false,|g' .prettierrc
17
+
18
+ # Prisma
19
+ pn i prisma
20
+ px prisma init --datasource-provider mysql
21
+
22
+ mkdir -p ./src/lib/server
23
+ source="https://raw.githubusercontent.com/peufo/fuma/main"
24
+ wget "$source/prisma/schema.prisma" -O ./prisma/schema.prisma
25
+ wget "$source/src/lib/server/prisma.ts" -O ./src/lib/server/prisma.ts
26
+
27
+ echo "DATABASE_URL=\"mysql://$mysql_username@localhost:3306/$project_name\"" > .env
28
+ cp .env .env.example
29
+ px prisma migrate dev --name init
30
+ node -e "\
31
+ const pkg = require('./package.json'); \
32
+ pkg.scripts.migrate = 'prisma migrate dev'; \
33
+ pkg.scripts.generate = 'prisma generate'; \
34
+ pkg.scripts.studio = 'prisma studio'; \
35
+ pkg.scripts.postinstall = 'prisma migrate deploy && prisma generate'; \
36
+ fs.writeFileSync('./package.json', JSON.stringify(pkg, null, ' ')); \
37
+ "
38
+
39
+ # Authentication
40
+ pn i lucia oslo @lucia-auth/adapter-prisma
41
+ auth="src/routes/auth"
42
+ mkdir -p "./$auth"
43
+ wget "$source/src/app.d.ts" -O ./src/app.d.ts
44
+ wget "$source/src/hooks.server.ts" -O ./src/hooks.server.ts
45
+ wget "$source/src/lib/server/auth.ts" -O ./src/lib/server/auth.ts
46
+ wget "$source/$auth/+page.svelte" -O "./$auth/+page.svelte"
47
+ wget "$source/$auth/+layout.svelte" -O "./$auth/+layout.svelte"
48
+ wget "$source/$auth/+page.server.ts" -O "./$auth/+page.server.ts"
15
49
 
16
50
 
17
51
  git init && git add -A && git commit -m "Initial commit"
@@ -0,0 +1,12 @@
1
+ import { Lucia } from 'lucia';
2
+ export declare const lucia: Lucia<Record<never, never>, {
3
+ username: string;
4
+ }>;
5
+ declare module 'lucia' {
6
+ interface Register {
7
+ Lucia: typeof lucia;
8
+ DatabaseUserAttributes: {
9
+ username: string;
10
+ };
11
+ }
12
+ }
@@ -0,0 +1,15 @@
1
+ import { Lucia } from 'lucia';
2
+ import { dev } from '$app/environment';
3
+ import { PrismaAdapter } from '@lucia-auth/adapter-prisma';
4
+ import { prisma } from './prisma.js';
5
+ const adapter = new PrismaAdapter(prisma.session, prisma.user);
6
+ export const lucia = new Lucia(adapter, {
7
+ sessionCookie: {
8
+ attributes: {
9
+ secure: !dev
10
+ }
11
+ },
12
+ getUserAttributes: (attributes) => ({
13
+ username: attributes.username
14
+ })
15
+ });
@@ -0,0 +1,2 @@
1
+ import { PrismaClient } from '@prisma/client';
2
+ export declare const prisma: PrismaClient<import("@prisma/client").Prisma.PrismaClientOptions, never, import("@prisma/client/runtime/library").DefaultArgs>;
@@ -0,0 +1,2 @@
1
+ import { PrismaClient } from '@prisma/client';
2
+ export const prisma = new PrismaClient();
@@ -0,0 +1,89 @@
1
+ <script>import { slide } from "svelte/transition";
2
+ import { InputText, InputPassword } from "./index.js";
3
+ import { useForm } from "../validation/form.js";
4
+ import { page } from "$app/stores";
5
+ export let onSuccess = void 0;
6
+ const { enhance } = useForm({
7
+ onSuccess,
8
+ successMessage(action) {
9
+ if (action.search === "?/reset_password") {
10
+ recorverDialog.close();
11
+ state = "login";
12
+ return "Un lien de r\xE9cup\xE9ration t'a \xE9t\xE9 envoy\xE9 par email";
13
+ }
14
+ return "Bienvenue";
15
+ },
16
+ onError(err) {
17
+ if (err === "This account already exists") {
18
+ state = "login";
19
+ return;
20
+ }
21
+ if (err === "This account already created from an invitation") {
22
+ recorverDialog.showModal();
23
+ return;
24
+ }
25
+ }
26
+ });
27
+ let state = "login";
28
+ $:
29
+ redirectTo = $page.url.searchParams.get("redirectTo");
30
+ let recorverDialog;
31
+ </script>
32
+
33
+ <div class="grid place-content-center p-10">
34
+ <div style:width="min(24rem, calc(100vw - 1rem))" class="card place-content-center shadow-lg">
35
+ <div class="tabs tabs-lifted w-full">
36
+ <span
37
+ role="button"
38
+ tabindex="0"
39
+ class="tab-lg tab grow rounded-t-2xl"
40
+ class:tab-active={state === 'login'}
41
+ on:click={() => (state = 'login')}
42
+ on:keyup={() => (state = 'login')}
43
+ >
44
+ Connexion
45
+ </span>
46
+ <span
47
+ role="button"
48
+ tabindex="0"
49
+ class="tab-lg tab-lifted tab grow rounded-t-2xl"
50
+ class:tab-active={state === 'register'}
51
+ on:click={() => (state = 'register')}
52
+ on:keyup={() => (state = 'register')}
53
+ >
54
+ Nouveau compte
55
+ </span>
56
+ </div>
57
+
58
+ <form class="card-body border border-t-0 border-base-300 bg-base-100" method="post" use:enhance>
59
+ <InputText key="username" label="Nom d'utilisateur" input={{ autocomplete: 'username' }} />
60
+
61
+ {#if state === 'register'}
62
+ <div transition:slide|local>
63
+ <InputText
64
+ key="email"
65
+ label="Email"
66
+ input={{ autocomplete: 'email', inputmode: 'email' }}
67
+ />
68
+ </div>
69
+ {/if}
70
+
71
+ <InputPassword key="password" label="Mot de passe" />
72
+
73
+ {#if redirectTo}
74
+ <input type="hidden" name="redirectTo" value={redirectTo} />
75
+ {/if}
76
+
77
+ <div class="card-actions flex-row-reverse items-center pt-4">
78
+ <button class="btn" formaction="/auth?/{state}">
79
+ {state === 'login' ? 'Connexion' : 'Valider'}
80
+ </button>
81
+ <div class="grow" />
82
+
83
+ <button class="link-hover link" formaction="/auth?/reset_password">
84
+ Mot de passe oublié
85
+ </button>
86
+ </div>
87
+ </form>
88
+ </div>
89
+ </div>
@@ -0,0 +1,16 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ onSuccess?: ((action: URL, data?: Record<string, unknown> | undefined) => any) | undefined;
5
+ };
6
+ events: {
7
+ [evt: string]: CustomEvent<any>;
8
+ };
9
+ slots: {};
10
+ };
11
+ export type LoginProps = typeof __propDef.props;
12
+ export type LoginEvents = typeof __propDef.events;
13
+ export type LoginSlots = typeof __propDef.slots;
14
+ export default class Login extends SvelteComponent<LoginProps, LoginEvents, LoginSlots> {
15
+ }
16
+ export {};
@@ -12,3 +12,4 @@ export { default as Icon } from './Icon.svelte';
12
12
  export { default as Pagination } from './Pagination.svelte';
13
13
  export { default as Placeholder } from './Placeholder.svelte';
14
14
  export { default as PlaceholderImage } from './PlaceholderImage.svelte';
15
+ export { default as Login } from './Login.svelte';
package/dist/ui/index.js CHANGED
@@ -12,3 +12,4 @@ export { default as Icon } from './Icon.svelte';
12
12
  export { default as Pagination } from './Pagination.svelte';
13
13
  export { default as Placeholder } from './Placeholder.svelte';
14
14
  export { default as PlaceholderImage } from './PlaceholderImage.svelte';
15
+ export { default as Login } from './Login.svelte';
@@ -1,6 +1,5 @@
1
1
  /// <reference types="svelte" />
2
2
  import type { SuggestionOptions } from '@tiptap/suggestion';
3
- import '$lib/ui/menu/dropdown.css';
4
3
  export type SuggestionItem = {
5
4
  id: string;
6
5
  label: string;
@@ -1,7 +1,6 @@
1
1
  import { writable, get } from 'svelte/store';
2
2
  import { tippy } from '../../../utils/tippy.js';
3
3
  import SuggesionList from './SuggesionList.svelte';
4
- import '$lib/ui/menu/dropdown.css';
5
4
  export let suggestionItems = writable([]);
6
5
  export const suggestion = {
7
6
  items: ({ query }) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fuma",
3
- "version": "0.0.3",
4
- "description": "My fullstake material build with sveltekit, daisyui, zod and more",
3
+ "version": "0.1.0",
4
+ "description": "My fullstack material build with sveltekit, daisyui, zod and more",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",
7
7
  "email": "jonas.voisard@gmail.com"
@@ -53,7 +53,9 @@
53
53
  "vitest": "^1.2.0"
54
54
  },
55
55
  "dependencies": {
56
+ "@lucia-auth/adapter-prisma": "^4.0.1",
56
57
  "@mdi/js": "^7.4.47",
58
+ "@prisma/client": "5.12.1",
57
59
  "@tiptap/core": "^2.3.0",
58
60
  "@tiptap/extension-color": "^2.3.0",
59
61
  "@tiptap/extension-highlight": "^2.3.0",
@@ -71,7 +73,10 @@
71
73
  "debounce": "^2.0.0",
72
74
  "devalue": "^4.3.2",
73
75
  "litepicker": "^2.0.12",
76
+ "lucia": "^3.1.1",
74
77
  "mode-watcher": "^0.3.0",
78
+ "oslo": "^1.2.0",
79
+ "prisma": "^5.12.1",
75
80
  "svelte-easy-crop": "^2.0.3",
76
81
  "svelte-sonner": "^0.3.22",
77
82
  "tippy.js": "^6.3.7",
@@ -86,6 +91,10 @@
86
91
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
87
92
  "test": "vitest",
88
93
  "lint": "prettier --check . && eslint .",
89
- "format": "prettier --write ."
94
+ "format": "prettier --write .",
95
+ "migrate": "prisma migrate dev",
96
+ "generate": "prisma generate",
97
+ "studio": "prisma studio",
98
+ "postinstall": "prisma migrate deploy && prisma generate"
90
99
  }
91
100
  }