commit 32a0ec3e77c1a45a18c890cdc79c237866d4d62c Author: nomadics9 Date: Thu Jun 13 00:30:13 2024 +0300 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc46dc3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example +vite.config.js.timestamp-* +vite.config.ts.timestamp-* +pb_data +pb_migrations +.vscode 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..cc41cea --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +# Ignore files for PNPM, NPM and YARN +pnpm-lock.yaml +package-lock.json +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 new file mode 100644 index 0000000..5568c33 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# Spock - Svelte + Pocketbase +My boilerplate for + + + + 1. Sveltekit + Pocketbase DB + 2. Tailwindcss + 3. SkeletonUI + +# Auth Ready +### Snippet from login.svelete component - populating name and avatar from Google provider +```typescript + +``` + +### currentUser as a store to use example ``` $currentUser.avatar ``` +```ts +import { env } from '$env/dynamic/public' +import PocketBase from 'pocketbase' +import { writable } from 'svelte/store' + +export const pb = new PocketBase(env.PUBLIC_DB_URL) + +export const currentUser = writable(pb.authStore.model) + +pb.authStore.onChange((auth) => { + //console.log('auth changed ', auth) + currentUser.set(pb.authStore.model) +}) +``` +### use .env for pocketbase URL +```sh +PUBLIC_DB_URL=http://localhost:8090 +``` \ No newline at end of file diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..6486427 Binary files /dev/null and b/bun.lockb differ diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..a351fa9 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,33 @@ +import js from '@eslint/js'; +import ts from 'typescript-eslint'; +import svelte from 'eslint-plugin-svelte'; +import prettier from 'eslint-config-prettier'; +import globals from 'globals'; + +/** @type {import('eslint').Linter.FlatConfig[]} */ +export default [ + js.configs.recommended, + ...ts.configs.recommended, + ...svelte.configs['flat/recommended'], + prettier, + ...svelte.configs['flat/prettier'], + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node + } + } + }, + { + files: ['**/*.svelte'], + languageOptions: { + parserOptions: { + parser: ts.parser + } + } + }, + { + ignores: ['build/', '.svelte-kit/', 'dist/'] + } +]; diff --git a/git_assets/spock.jpg b/git_assets/spock.jpg new file mode 100644 index 0000000..e9bb874 Binary files /dev/null and b/git_assets/spock.jpg differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..a20a6c4 --- /dev/null +++ b/package.json @@ -0,0 +1,47 @@ +{ + "name": "pocketbaseapp", + "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": "^8.56.7", + "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": "^3.6.0", + "tslib": "^2.4.1", + "typescript": "^5.0.0", + "typescript-eslint": "^8.0.0-alpha.20", + "vite": "^5.0.3", + "postcss": "8.4.38", + "autoprefixer": "10.4.19", + "tailwindcss": "3.4.4", + "@skeletonlabs/skeleton": "2.10.0", + "@skeletonlabs/tw-plugin": "0.4.0", + "vite-plugin-tailwind-purgecss": "0.3.3", + "@tailwindcss/typography": "0.5.13", + "@tailwindcss/forms": "0.5.7", + "@types/node": "20.14.2" + }, + "type": "module", + "dependencies": { + "@floating-ui/dom": "1.6.5", + "highlight.js": "11.9.0", + "pocketbase": "^0.21.3" + } +} \ No newline at end of file diff --git a/postcss.config.cjs b/postcss.config.cjs new file mode 100644 index 0000000..16dce0b --- /dev/null +++ b/postcss.config.cjs @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} \ No newline at end of file diff --git a/src/app.d.ts b/src/app.d.ts new file mode 100644 index 0000000..8f4d638 --- /dev/null +++ b/src/app.d.ts @@ -0,0 +1,9 @@ +// See https://kit.svelte.dev/docs/types#app +// for information about these interfaces +// and what to do when importing types +declare namespace App { + // interface Locals {} + // interface PageData {} + // interface Error {} + // interface Platform {} +} diff --git a/src/app.html b/src/app.html new file mode 100644 index 0000000..8365edf --- /dev/null +++ b/src/app.html @@ -0,0 +1,12 @@ + + + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/src/app.postcss b/src/app.postcss new file mode 100644 index 0000000..dfbd3a3 --- /dev/null +++ b/src/app.postcss @@ -0,0 +1,11 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; +@tailwind variants; + +/* gold-nouveau theme */ +@font-face { + font-family: 'Quicksand'; + src: url('/fonts/Quicksand.ttf'); + font-display: swap; +} \ No newline at end of file diff --git a/src/lib/index.ts b/src/lib/index.ts new file mode 100644 index 0000000..856f2b6 --- /dev/null +++ b/src/lib/index.ts @@ -0,0 +1 @@ +// place files you want to import through the `$lib` alias in this folder. diff --git a/src/lib/login.svelte b/src/lib/login.svelte new file mode 100644 index 0000000..6ee1ab4 --- /dev/null +++ b/src/lib/login.svelte @@ -0,0 +1,42 @@ + + +{#if $currentUser} +

Signed in as {$currentUser.name}

+ {$currentUser.name} + + +{:else} +

Please Login

+ +{/if} diff --git a/src/lib/pocketbase.ts b/src/lib/pocketbase.ts new file mode 100644 index 0000000..6a0627c --- /dev/null +++ b/src/lib/pocketbase.ts @@ -0,0 +1,12 @@ +import { env } from '$env/dynamic/public' +import PocketBase from 'pocketbase' +import { writable } from 'svelte/store' + +export const pb = new PocketBase(env.PUBLIC_DB_URL) + +export const currentUser = writable(pb.authStore.model) + +pb.authStore.onChange((auth) => { + //console.log('auth changed ', auth) + currentUser.set(pb.authStore.model) +}) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte new file mode 100644 index 0000000..60b1517 --- /dev/null +++ b/src/routes/+layout.svelte @@ -0,0 +1,28 @@ + +
+
+ +
+
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte new file mode 100644 index 0000000..010f065 --- /dev/null +++ b/src/routes/+page.svelte @@ -0,0 +1,7 @@ + + + diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000..c4e3735 Binary files /dev/null and b/static/favicon.png differ diff --git a/static/fonts/Quicksand.ttf b/static/fonts/Quicksand.ttf new file mode 100644 index 0000000..0ec2219 Binary files /dev/null and b/static/fonts/Quicksand.ttf differ diff --git a/svelte.config.js b/svelte.config.js new file mode 100644 index 0000000..e9c20b3 --- /dev/null +++ b/svelte.config.js @@ -0,0 +1,18 @@ +import adapter from '@sveltejs/adapter-auto'; +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + extensions: ['.svelte'], + // Consult https://kit.svelte.dev/docs/integrations#preprocessors + // for more information about preprocessors + preprocess: [vitePreprocess()], + + kit: { + // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. + // If your environment is not supported or you settled on a specific environment, switch out the adapter. + // See https://kit.svelte.dev/docs/adapters for more information about adapters. + adapter: adapter() + } +}; +export default config; \ No newline at end of file diff --git a/tailwind.config.ts b/tailwind.config.ts new file mode 100644 index 0000000..16898b9 --- /dev/null +++ b/tailwind.config.ts @@ -0,0 +1,35 @@ +import { join } from 'path' +import type { Config } from 'tailwindcss' +import forms from '@tailwindcss/forms'; +import typography from '@tailwindcss/typography'; +import { skeleton } from '@skeletonlabs/tw-plugin' + +export default { + darkMode: 'class', + content: ['./src/**/*.{html,js,svelte,ts}', join(require.resolve('@skeletonlabs/skeleton'), '../**/*.{html,js,svelte,ts}')], + theme: { + extend: {}, + }, + plugins: [ + forms, + typography, + skeleton({ + themes: { + preset: [ + { + name: 'skeleton', + enhancements: true, + }, + { + name: 'wintry', + enhancements: true, + }, + { + name: 'gold-nouveau', + enhancements: true, + }, + ], + }, + }), + ], +} satisfies Config; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..fc93cbd --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler" + } + // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias + // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files + // + // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes + // from the referenced tsconfig.json - TypeScript does not merge them in +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..8e4637e --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,7 @@ +import { purgeCss } from 'vite-plugin-tailwind-purgecss'; +import { sveltekit } from '@sveltejs/kit/vite'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [sveltekit(), purgeCss()] +}); \ No newline at end of file